flowtracker.h (76211B)
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_FLOWTRACKER_H__ 14 #define __BCM_FLOWTRACKER_H__ 15 16 #include <bcm/port.h> 17 #include <bcm/collector.h> 18 #include <bcm/pkt.h> 19 20 /* Flowtracker IPFIX observation domain. */ 21 typedef uint32 bcm_flowtracker_ipfix_observation_domain_t; 22 23 /* Flowtracker export trigger types */ 24 typedef enum bcm_flowtracker_export_trigger_e { 25 bcmFlowtrackerExportTriggerNone = 0, /* No export trigger. */ 26 bcmFlowtrackerExportTriggerTimer = 1, /* Flow data will be exported to 27 collector every 28 bcm_flowtracker_export_trigger_info_t.interval_usecs. */ 29 bcmFlowtrackerExportTriggerNewLearn = 2, /* Flow data will be exported to 30 collector everytime a new flow is 31 learnt in the group. */ 32 bcmFlowtrackerExportTriggerAgeOut = 3, /* Flow data will be exported to 33 collector everytime a flow ages out 34 in the group. */ 35 bcmFlowtrackerExportTriggerDrop = 4, /* Drop reason on a flow has changed. */ 36 bcmFlowtrackerExportTriggerCount = 5 /* Last Value. Not Usable. */ 37 } bcm_flowtracker_export_trigger_t; 38 39 /* Flowtracker export trigger information. */ 40 typedef struct bcm_flowtracker_export_trigger_info_s { 41 SHR_BITDCL trigger_bmp[_SHR_BITDCLSIZE(bcmFlowtrackerExportTriggerCount)]; /* The bitmap of export triggers which 42 will result in the export of the 43 IPFIX packets. */ 44 uint32 interval_usecs; /* If one of the export triggers is 45 bcmFlowtrackerExportTriggerTimer, 46 this provides the interval for the 47 timer. */ 48 } bcm_flowtracker_export_trigger_info_t; 49 50 /* Manipulate the export trigger bitmap. */ 51 #define BCM_FLOWTRACKER_TRIGGER_SET(_export_info, _trigger) SHR_BITSET(((_export_info).trigger_bmp), (_trigger)) 52 #define BCM_FLOWTRACKER_TRIGGER_GET(_export_info, _trigger) SHR_BITGET(((_export_info).trigger_bmp), (_trigger)) 53 #define BCM_FLOWTRACKER_TRIGGER_CLEAR(_export_info, _trigger) SHR_BITCLR(((_export_info).trigger_bmp), (_trigger)) 54 #define BCM_FLOWTRACKER_TRIGGER_CLEAR_ALL(_export_info) SHR_BITCLR_RANGE(((_export_info).trigger_bmp), 0, bcmFlowtrackerExportTriggerCount) 55 56 /* 57 * Macros for bcm_flowtracker_collector_eth_header_t.vlan_tag_structure 58 * to indicate the tag structure of vlans. 59 */ 60 #define BCM_FLOWTRACKER_COLLECTOR_ETH_HDR_UNTAGGED 0x1 61 #define BCM_FLOWTRACKER_COLLECTOR_ETH_HDR_SINGLE_TAGGED 0x2 62 #define BCM_FLOWTRACKER_COLLECTOR_ETH_HDR_DOUBLE_TAGGED 0x3 63 64 /* 65 * Ethernet header in the encap used to send the IPFIX packet to the 66 * collector. 67 */ 68 typedef struct bcm_flowtracker_collector_eth_header_s { 69 bcm_mac_t dst_mac; 70 bcm_mac_t src_mac; 71 uint8 vlan_tag_structure; 72 uint16 outer_tpid; 73 uint16 inner_tpid; 74 bcm_vlan_tag_t outer_vlan_tag; 75 bcm_vlan_tag_t inner_vlan_tag; 76 } bcm_flowtracker_collector_eth_header_t; 77 78 /* 79 * IPv4 header in the encap used to send the IPFIX packet to the 80 * collector. 81 */ 82 typedef struct bcm_flowtracker_collector_ipv4_header_s { 83 bcm_ip_t src_ip; 84 bcm_ip_t dst_ip; 85 uint8 dscp; 86 uint8 ttl; 87 } bcm_flowtracker_collector_ipv4_header_t; 88 89 /* 90 * IPv6 header in the encap used to send the IPFIX packet to the 91 * collector. 92 */ 93 typedef struct bcm_flowtracker_collector_ipv6_header_s { 94 bcm_ip6_t src_ip; 95 bcm_ip6_t dst_ip; 96 uint8 traffic_class; 97 uint32 flow_label; 98 uint8 hop_limit; 99 } bcm_flowtracker_collector_ipv6_header_t; 100 101 /* 102 * UDP header in the encap used to send the IPFIX packet to the 103 * collector. 104 */ 105 typedef struct bcm_flowtracker_collector_udp_header_s { 106 bcm_l4_port_t src_port; 107 bcm_l4_port_t dst_port; 108 } bcm_flowtracker_collector_udp_header_t; 109 110 /* Software ID given for a Flowtracker collector configuration. */ 111 typedef int bcm_flowtracker_collector_t; 112 113 /* 114 * Transport types that are supported for exporting flow data to the 115 * collector 116 */ 117 typedef enum bcm_flowtracker_collector_transport_type_e { 118 bcmFlowtrackerCollectorTransportTypeIpfixIpv4Udp = 0, /* The encap will be of the format UDP 119 over IPv4. */ 120 bcmFlowtrackerCollectorTransportTypeIpfixIpv6Udp = 1, /* The encap will be of the format UDP 121 over IPv6. */ 122 bcmFlowtrackerCollectorTransportTypeRaw = 2, /* Indicates no encap. This will be 123 useful when the raw IPFIX PDUs need 124 to be transported to the local CPU. */ 125 bcmFlowtrackerCollectorTransportTypeCount = 3 /* Last Value. Not Usable. */ 126 } bcm_flowtracker_collector_transport_type_t; 127 128 /* Flowtracker Collector types. */ 129 typedef enum bcm_flowtracker_collector_type_e { 130 bcmFlowtrackerCollectorRemote = 0, /* The collector is a remote machine 131 expecting flow information records 132 using encap scheme defined through 133 TransportTypeXxx. */ 134 bcmFlowtrackerCollectorLocal = 1, /* The collector is local CPU receiving 135 flow information records usually 136 without any encap. TransportTypeRaw. */ 137 bcmFlowtrackerCollectorCount = 2 /* Last Value. Not Usable. */ 138 } bcm_flowtracker_collector_type_t; 139 140 /* Flowtracker collector information. */ 141 typedef struct bcm_flowtracker_collector_info_s { 142 bcm_flowtracker_collector_type_t collector_type; /* Flowtracker Collector type. Remote vs 143 Local */ 144 bcm_flowtracker_collector_transport_type_t transport_type; /* Transport type used for exporting 145 flow data to the collector. This 146 identifies the usable fields within 147 the encap structure member defined 148 below. */ 149 bcm_flowtracker_collector_eth_header_t eth; /* Ethernet encapsulation of the packet 150 sent to collector. */ 151 bcm_flowtracker_collector_ipv4_header_t ipv4; /* IPv4 encapsulation of the packet sent 152 to collector. */ 153 bcm_flowtracker_collector_ipv6_header_t ipv6; /* IPv6 encapsulation of the packet sent 154 to collector. */ 155 bcm_flowtracker_collector_udp_header_t udp; /* UDP encapsulation of the packet sent 156 to collector. */ 157 uint16 max_packet_length; /* The maximum packet length of an 158 export packet that can be sent to 159 this collector. */ 160 } bcm_flowtracker_collector_info_t; 161 162 /* Software ID given for a Flowtracker flow group configuration. */ 163 typedef int bcm_flowtracker_group_t; 164 165 /* Flow check object. */ 166 typedef uint32 bcm_flowtracker_check_t; 167 168 /* 169 * Flags (bcm_flowtracker_group_info_t.flags) to be used with group 170 * during group create. 171 */ 172 #define BCM_FLOWTRACKER_GROUP_USER_ENTRIES_ONLY (1 << 0) /* Group supports user 173 added flow entries 174 only. */ 175 176 /* Default Group. */ 177 #define BCM_FLOWTRACKER_GROUP_DEFAULT (1 << 1) /* Indicates that this is a 178 default group. */ 179 180 /* Custom key length. */ 181 #define BCM_FLOWTRACKER_CUSTOM_KEY_MAX_LENGTH 16 /* Maximum length of 182 custom key */ 183 184 /* Flowtracker flow group information. */ 185 typedef struct bcm_flowtracker_group_info_s { 186 bcm_flowtracker_ipfix_observation_domain_t observation_domain_id; /* IPFIX observation domain to which 187 this flow group belongs to. */ 188 int group_class; /* Flowtracker flow group Class id. */ 189 uint32 group_flags; /* Flowtracker flow group flags. See 190 BCM_FLOWTRACKER_GROUP_XXX. */ 191 bcm_field_group_t field_group[BCM_PIPES_MAX]; /* Field group corresponding to the flow 192 group. */ 193 } bcm_flowtracker_group_info_t; 194 195 /* 196 * Five tuple can be outer/inner SRC IP, DST IP, L4 SRC PORT, L4 DST PORT 197 * and IP PROTOCOL that constitutes a flow. 198 */ 199 typedef struct bcm_flowtracker_flow_key_s { 200 bcm_ip_addr_t src_ip; 201 bcm_ip_addr_t dst_ip; 202 bcm_l4_port_t l4_src_port; 203 bcm_l4_port_t l4_dst_port; 204 uint8 ip_protocol; 205 bcm_ip_addr_t inner_src_ip; 206 bcm_ip_addr_t inner_dst_ip; 207 bcm_l4_port_t inner_l4_src_port; 208 bcm_l4_port_t inner_l4_dst_port; 209 uint8 inner_ip_protocol; 210 uint32 vxlan_network_id; 211 uint8 custom[BCM_FLOWTRACKER_CUSTOM_KEY_MAX_LENGTH]; 212 bcm_port_t in_port; 213 } bcm_flowtracker_flow_key_t; 214 215 /* Flowtracker flow group flow level data. */ 216 typedef struct bcm_flowtracker_flow_data_s { 217 uint64 packet_count; 218 uint64 byte_count; 219 uint64 flow_start_timestamp_msecs; 220 uint64 observation_timestamp_msecs; 221 bcm_rx_reasons_t pkt_drop_reasons; 222 } bcm_flowtracker_flow_data_t; 223 224 /* Software ID given for a Flowtracker export template configuration. */ 225 typedef int bcm_flowtracker_export_template_t; 226 227 /* Flowtracker export element flags. */ 228 #define BCM_FLOWTRACKER_EXPORT_ELEMENT_FLAGS_ENTERPRISE (1 << 0) /* Indicates that the 229 element is an 230 enterprise specific 231 element */ 232 233 /* The different export element types that constitute an template. */ 234 typedef enum bcm_flowtracker_export_element_type_e { 235 bcmFlowtrackerExportElementTypeSrcIPv4 = 0, 236 bcmFlowtrackerExportElementTypeDstIPv4 = 1, 237 bcmFlowtrackerExportElementTypeSrcIPv6 = 2, 238 bcmFlowtrackerExportElementTypeDstIPv6 = 3, 239 bcmFlowtrackerExportElementTypeL4SrcPort = 4, 240 bcmFlowtrackerExportElementTypeL4DstPort = 5, 241 bcmFlowtrackerExportElementTypeIPProtocol = 6, 242 bcmFlowtrackerExportElementTypePktCount = 7, 243 bcmFlowtrackerExportElementTypeByteCount = 8, 244 bcmFlowtrackerExportElementTypePktDeltaCount = 9, 245 bcmFlowtrackerExportElementTypeByteDeltaCount = 10, 246 bcmFlowtrackerExportElementTypeVRF = 11, 247 bcmFlowtrackerExportElementTypeObservationTimeMsecs = 12, 248 bcmFlowtrackerExportElementTypeFlowStartTimeMsecs = 13, 249 bcmFlowtrackerExportElementTypeFlowtrackerGroup = 14, 250 bcmFlowtrackerExportElementTypeReserved = 15, 251 bcmFlowtrackerExportElementTypeTTL = 16, 252 bcmFlowtrackerExportElementTypeIPLength = 17, 253 bcmFlowtrackerExportElementTypeTcpWindowSize = 18, 254 bcmFlowtrackerExportElementTypeDosAttack = 19, 255 bcmFlowtrackerExportElementTypeVxlanNetworkId = 20, 256 bcmFlowtrackerExportElementTypeNextHeader = 21, 257 bcmFlowtrackerExportElementTypeHopLimit = 22, 258 bcmFlowtrackerExportElementTypeInnerSrcIPv4 = 23, 259 bcmFlowtrackerExportElementTypeInnerDstIPv4 = 24, 260 bcmFlowtrackerExportElementTypeInnerSrcIPv6 = 25, 261 bcmFlowtrackerExportElementTypeInnerDstIPv6 = 26, 262 bcmFlowtrackerExportElementTypeInnerIPProtocol = 27, 263 bcmFlowtrackerExportElementTypeInnerTTL = 28, 264 bcmFlowtrackerExportElementTypeInnerNextHeader = 29, 265 bcmFlowtrackerExportElementTypeInnerHopLimit = 30, 266 bcmFlowtrackerExportElementTypeInnerL4SrcPort = 31, 267 bcmFlowtrackerExportElementTypeInnerL4DstPort = 32, 268 bcmFlowtrackerExportElementTypeExportReasons = 33, 269 bcmFlowtrackerExportElementTypeExportFlags = 34, 270 bcmFlowtrackerExportElementTypeTcpFlags = 35, 271 bcmFlowtrackerExportElementTypeOuterVlanTag = 36, 272 bcmFlowtrackerExportElementTypeIP6Length = 37, 273 bcmFlowtrackerExportElementTypeInnerIPLength = 38, 274 bcmFlowtrackerExportElementTypeInnerIP6Length = 39, 275 bcmFlowtrackerExportElementTypeTimestampNewLearn = 40, 276 bcmFlowtrackerExportElementTypeTimestampFlowStart = 41, 277 bcmFlowtrackerExportElementTypeTimestampFlowEnd = 42, 278 bcmFlowtrackerExportElementTypeTimestampCheckEvent1 = 43, 279 bcmFlowtrackerExportElementTypeTimestampCheckEvent2 = 44, 280 bcmFlowtrackerExportElementTypeInnerDosAttack = 45, 281 bcmFlowtrackerExportElementTypeTunnelClass = 46, 282 bcmFlowtrackerExportElementTypeFlowtrackerCheck = 47, 283 bcmFlowtrackerExportElementTypeCustom = 48, 284 bcmFlowtrackerExportElementTypeCount = 49 285 } bcm_flowtracker_export_element_type_t; 286 287 /* The different tracking parameters that can be tracked in flowtracker. */ 288 typedef enum bcm_flowtracker_tracking_param_type_e { 289 bcmFlowtrackerTrackingParamTypeNone = 0, 290 bcmFlowtrackerTrackingParamTypeSrcIPv4 = 1, 291 bcmFlowtrackerTrackingParamTypeDstIPv4 = 2, 292 bcmFlowtrackerTrackingParamTypeSrcIPv6 = 3, 293 bcmFlowtrackerTrackingParamTypeDstIPv6 = 4, 294 bcmFlowtrackerTrackingParamTypeL4SrcPort = 5, 295 bcmFlowtrackerTrackingParamTypeL4DstPort = 6, 296 bcmFlowtrackerTrackingParamTypeIPProtocol = 7, 297 bcmFlowtrackerTrackingParamTypePktCount = 8, 298 bcmFlowtrackerTrackingParamTypeByteCount = 9, 299 bcmFlowtrackerTrackingParamTypeVRF = 10, 300 bcmFlowtrackerTrackingParamTypeTTL = 11, 301 bcmFlowtrackerTrackingParamTypeIPLength = 12, 302 bcmFlowtrackerTrackingParamTypeTcpWindowSize = 13, 303 bcmFlowtrackerTrackingParamTypeDosAttack = 14, 304 bcmFlowtrackerTrackingParamTypeVxlanNetworkId = 15, 305 bcmFlowtrackerTrackingParamTypeNextHeader = 16, 306 bcmFlowtrackerTrackingParamTypeHopLimit = 17, 307 bcmFlowtrackerTrackingParamTypeInnerSrcIPv4 = 18, 308 bcmFlowtrackerTrackingParamTypeInnerDstIPv4 = 19, 309 bcmFlowtrackerTrackingParamTypeInnerSrcIPv6 = 20, 310 bcmFlowtrackerTrackingParamTypeInnerDstIPv6 = 21, 311 bcmFlowtrackerTrackingParamTypeInnerIPProtocol = 22, 312 bcmFlowtrackerTrackingParamTypeInnerTTL = 23, 313 bcmFlowtrackerTrackingParamTypeInnerNextHeader = 24, 314 bcmFlowtrackerTrackingParamTypeInnerHopLimit = 25, 315 bcmFlowtrackerTrackingParamTypeInnerL4SrcPort = 26, 316 bcmFlowtrackerTrackingParamTypeInnerL4DstPort = 27, 317 bcmFlowtrackerTrackingParamTypeTcpFlags = 28, 318 bcmFlowtrackerTrackingParamTypeOuterVlanTag = 29, 319 bcmFlowtrackerTrackingParamTypeIP6Length = 30, 320 bcmFlowtrackerTrackingParamTypeInnerIPLength = 31, 321 bcmFlowtrackerTrackingParamTypeInnerIP6Length = 32, 322 bcmFlowtrackerTrackingParamTypeTimestampNewLearn = 33, 323 bcmFlowtrackerTrackingParamTypeTimestampFlowStart = 34, 324 bcmFlowtrackerTrackingParamTypeTimestampFlowEnd = 35, 325 bcmFlowtrackerTrackingParamTypeTimestampCheckEvent1 = 36, 326 bcmFlowtrackerTrackingParamTypeTimestampCheckEvent2 = 37, 327 bcmFlowtrackerTrackingParamTypeInnerDosAttack = 38, 328 bcmFlowtrackerTrackingParamTypeTunnelClass = 39, 329 bcmFlowtrackerTrackingParamTypeFlowtrackerCheck = 40, 330 bcmFlowtrackerTrackingParamTypeCustom = 41, 331 bcmFlowtrackerTrackingParamTypeInPort = 42, 332 bcmFlowtrackerTrackingParamTypeCount = 43 333 } bcm_flowtracker_tracking_param_type_t; 334 335 #define BCM_FT_TRACKING_PARAM_STRINGS \ 336 { \ 337 "None", \ 338 "SrcIPv4", \ 339 "DstIPv4", \ 340 "SrcIPv6", \ 341 "DstIPv6", \ 342 "L4SrcPort", \ 343 "L4DstPort", \ 344 "IPProtocol", \ 345 "PktCount", \ 346 "ByteCount", \ 347 "VRF", \ 348 "TTL", \ 349 "IPLength", \ 350 "TcpWindowSize", \ 351 "DosAttack", \ 352 "VxlanNetworkId", \ 353 "NextHeader", \ 354 "HopLimit", \ 355 "InnerSrcIPv4", \ 356 "InnerDstIPv4", \ 357 "InnerSrcIPv6", \ 358 "InnerDstIPv6", \ 359 "InnerIPProtocol", \ 360 "InnerTTL", \ 361 "InnerNextHeader", \ 362 "InnerHopLimit", \ 363 "InnerL4SrcPort", \ 364 "InnerL4DstPort", \ 365 "TcpFlags", \ 366 "OuterVlanTag", \ 367 "IP6Length", \ 368 "InnerIPLength", \ 369 "InnerIP6Length", \ 370 "TimestampNewLearn", \ 371 "TimestampFlowStart", \ 372 "TimestampFlowEnd", \ 373 "TimestampCheckEvent1", \ 374 "TimestampCheckEvent2", \ 375 "InnerDosAttack", \ 376 "TunnelClass", \ 377 "FlowtrackerCheck", \ 378 "Custom", \ 379 "InPort", \ 380 "Count" \ 381 } 382 383 /* Flowtracker export template elements information. */ 384 typedef struct bcm_flowtracker_export_element_info_s { 385 uint32 flags; /* See 386 BCM_FLOWTRACKER_EXPORT_ELEMENT_FLAGS_XXX. */ 387 bcm_flowtracker_export_element_type_t element; /* Type of export element. */ 388 uint32 data_size; /* Size of information element in the 389 export record in bytes. If the 390 data_size is given as 0, then the 391 default RFC size is used. */ 392 uint16 info_elem_id; /* Information element to be used, when 393 the template set is exported. */ 394 bcm_flowtracker_check_t check_id; /* Flowtracker Check Id for exporting 395 check data. */ 396 } bcm_flowtracker_export_element_info_t; 397 398 /* Flowtracker template set transmit configuration. */ 399 typedef struct bcm_flowtracker_template_transmit_config_s { 400 int retransmit_interval_secs; /* Interval in seconds at which the template 401 set has to be transmitted. */ 402 int initial_burst; /* Number of times the template set needs to 403 be sent before settling to a periodic 404 export. */ 405 } bcm_flowtracker_template_transmit_config_t; 406 407 #ifndef BCM_HIDE_DISPATCHABLE 408 409 /* Initialize the Flowtracker subsystem. */ 410 extern int bcm_flowtracker_init( 411 int unit); 412 413 /* Shut down the Flowtracker subsystem. */ 414 extern int bcm_flowtracker_detach( 415 int unit); 416 417 #endif /* BCM_HIDE_DISPATCHABLE */ 418 419 /* 420 * Options that can be passed via options parameter during export 421 * template creation. 422 */ 423 #define BCM_FLOWTRACKER_EXPORT_TEMPLATE_WITH_ID (1 << 0) /* Create an export 424 template with ID. */ 425 426 #ifndef BCM_HIDE_DISPATCHABLE 427 428 /* Validate the template and return the list supported by the device. */ 429 extern int bcm_flowtracker_export_template_validate( 430 int unit, 431 bcm_flowtracker_group_t flow_group_id, 432 int max_in_export_elements, 433 bcm_flowtracker_export_element_info_t *in_export_elements, 434 int max_out_export_elements, 435 bcm_flowtracker_export_element_info_t *out_export_elements, 436 int *actual_out_export_elements); 437 438 /* Create a flowtracker export template. */ 439 extern int bcm_flowtracker_export_template_create( 440 int unit, 441 uint32 options, 442 bcm_flowtracker_export_template_t *id, 443 uint16 set_id, 444 int num_export_elements, 445 bcm_flowtracker_export_element_info_t *list_of_export_elements); 446 447 /* Get a flowtracker export template with ID. */ 448 extern int bcm_flowtracker_export_template_get( 449 int unit, 450 bcm_flowtracker_export_template_t id, 451 uint16 *set_id, 452 int max_size, 453 bcm_flowtracker_export_element_info_t *list_of_export_elements, 454 int *list_size); 455 456 #endif /* BCM_HIDE_DISPATCHABLE */ 457 458 /* Initialize flowtracker template transmit configuration. */ 459 extern void bcm_flowtracker_template_transmit_config_t_init( 460 bcm_flowtracker_template_transmit_config_t *config); 461 462 #ifndef BCM_HIDE_DISPATCHABLE 463 464 /* Destroy a flowtracker export template with ID. */ 465 extern int bcm_flowtracker_export_template_destroy( 466 int unit, 467 bcm_flowtracker_export_template_t id); 468 469 /* Set the template transmit configuration. */ 470 extern int bcm_flowtracker_template_transmit_config_set( 471 int unit, 472 bcm_flowtracker_export_template_t template_id, 473 bcm_collector_t collector_id, 474 bcm_flowtracker_template_transmit_config_t *config); 475 476 /* Get the template transmit configuration. */ 477 extern int bcm_flowtracker_template_transmit_config_get( 478 int unit, 479 bcm_flowtracker_export_template_t template_id, 480 bcm_collector_t collector_id, 481 bcm_flowtracker_template_transmit_config_t *config); 482 483 #endif /* BCM_HIDE_DISPATCHABLE */ 484 485 /* Initialize a flowtracker collector information structure. */ 486 extern void bcm_flowtracker_collector_info_t_init( 487 bcm_flowtracker_collector_info_t *collector_info); 488 489 /* 490 * Options that can be passed via options parameter during collector 491 * creation. 492 */ 493 #define BCM_FLOWTRACKER_COLLECTOR_WITH_ID (1 << 0) /* Create a collector 494 with ID. */ 495 #define BCM_FLOWTRACKER_COLLECTOR_REPLACE (1 << 1) /* Replace a collector 496 with ID. */ 497 498 #ifndef BCM_HIDE_DISPATCHABLE 499 500 /* Create a flowtracker collector with given collector info. */ 501 extern int bcm_flowtracker_collector_create( 502 int unit, 503 uint32 options, 504 bcm_flowtracker_collector_t *collector_id, 505 bcm_flowtracker_collector_info_t *collector_info); 506 507 /* Get flowtracker collector information with ID. */ 508 extern int bcm_flowtracker_collector_get( 509 int unit, 510 bcm_flowtracker_collector_t id, 511 bcm_flowtracker_collector_info_t *collector_info); 512 513 /* Get the list of all flowtracker collectors configured. */ 514 extern int bcm_flowtracker_collector_get_all( 515 int unit, 516 int max_size, 517 bcm_flowtracker_collector_t *collector_list, 518 int *list_size); 519 520 /* Destroy a flowtracker collector with ID. */ 521 extern int bcm_flowtracker_collector_destroy( 522 int unit, 523 bcm_flowtracker_collector_t id); 524 525 #endif /* BCM_HIDE_DISPATCHABLE */ 526 527 /* Initialize a flowtracker flow group information structure. */ 528 extern void bcm_flowtracker_group_info_t_init( 529 bcm_flowtracker_group_info_t *flow_group_info); 530 531 /* 532 * Options that can be passed via options parameter during flow group 533 * creation. 534 */ 535 #define BCM_FLOWTRACKER_GROUP_WITH_ID (1 << 0) /* Create a flow group with 536 ID. */ 537 #define BCM_FLOWTRACKER_GROUP_REPLACE (1 << 1) /* Replace a flow group with 538 ID. */ 539 540 #ifndef BCM_HIDE_DISPATCHABLE 541 542 /* Create a flowtracker flow group with given flow group info. */ 543 extern int bcm_flowtracker_group_create( 544 int unit, 545 uint32 options, 546 bcm_flowtracker_group_t *flow_group_id, 547 bcm_flowtracker_group_info_t *flow_group_info); 548 549 /* Get flowtracker flow group information with ID. */ 550 extern int bcm_flowtracker_group_get( 551 int unit, 552 bcm_flowtracker_group_t id, 553 bcm_flowtracker_group_info_t *flow_group_info); 554 555 /* Get the list of all flowtracker flow groups configured. */ 556 extern int bcm_flowtracker_group_get_all( 557 int unit, 558 int max_size, 559 bcm_flowtracker_group_t *flow_group_list, 560 int *list_size); 561 562 /* Set flow limit on the flow group with ID. */ 563 extern int bcm_flowtracker_group_flow_limit_set( 564 int unit, 565 bcm_flowtracker_group_t id, 566 uint32 flow_limit); 567 568 /* Get flow limit of the flow group with ID. */ 569 extern int bcm_flowtracker_group_flow_limit_get( 570 int unit, 571 bcm_flowtracker_group_t id, 572 uint32 *flow_limit); 573 574 /* Set stat modeid on the flow group with ID. */ 575 extern int bcm_flowtracker_group_stat_modeid_set( 576 int unit, 577 bcm_flowtracker_group_t id, 578 uint32 stat_modeid); 579 580 /* Get flow limit of the flow group with ID. */ 581 extern int bcm_flowtracker_group_stat_modeid_get( 582 int unit, 583 bcm_flowtracker_group_t id, 584 uint32 *stat_modeid); 585 586 /* 587 * Set aging timer interval in ms on the flow group with ID. The minimum 588 * is 100ms. And the value is expected to be multiples of 100ms. Default 589 * would be 1 minute 590 */ 591 extern int bcm_flowtracker_group_age_timer_set( 592 int unit, 593 bcm_flowtracker_group_t id, 594 uint32 aging_interval_ms); 595 596 /* Get aging timer interval in ms of the flow group with ID. */ 597 extern int bcm_flowtracker_group_age_timer_get( 598 int unit, 599 bcm_flowtracker_group_t id, 600 uint32 *aging_interval_ms); 601 602 /* Set export trigger information of the flow group with ID. */ 603 extern int bcm_flowtracker_group_export_trigger_set( 604 int unit, 605 bcm_flowtracker_group_t id, 606 bcm_flowtracker_export_trigger_info_t *export_trigger_info); 607 608 /* Get export trigger information of the flow group with ID. */ 609 extern int bcm_flowtracker_group_export_trigger_get( 610 int unit, 611 bcm_flowtracker_group_t id, 612 bcm_flowtracker_export_trigger_info_t *export_trigger_info); 613 614 /* Get the number of flows learnt in the flow group with ID. */ 615 extern int bcm_flowtracker_group_flow_count_get( 616 int unit, 617 bcm_flowtracker_group_t id, 618 uint32 *flow_count); 619 620 /* Destroy a flowtracker flow group with ID. */ 621 extern int bcm_flowtracker_group_destroy( 622 int unit, 623 bcm_flowtracker_group_t id); 624 625 #endif /* BCM_HIDE_DISPATCHABLE */ 626 627 /* 628 * Flags that can be passed via flags parameter during flow group clear 629 * operation. 630 */ 631 #define BCM_FLOWTRACKER_GROUP_CLEAR_ALL (1 << 0) /* Clear entire flow 632 group flow entries(key 633 and data). */ 634 #define BCM_FLOWTRACKER_GROUP_CLEAR_FLOW_DATA_ONLY (1 << 1) /* Clear only data of the 635 flow group flow 636 entries. */ 637 638 #ifndef BCM_HIDE_DISPATCHABLE 639 640 /* Clear a flow group's flow entries. */ 641 extern int bcm_flowtracker_group_clear( 642 int unit, 643 bcm_flowtracker_group_t id, 644 uint32 flags); 645 646 /* Associate flow group to a collector with an export template. */ 647 extern int bcm_flowtracker_group_collector_add( 648 int unit, 649 bcm_flowtracker_group_t flow_group_id, 650 bcm_flowtracker_collector_t collector_id, 651 bcm_flowtracker_export_template_t template_id); 652 653 /* Dis-associate flow group from a collector with an export template. */ 654 extern int bcm_flowtracker_group_collector_delete( 655 int unit, 656 bcm_flowtracker_group_t flow_group_id, 657 bcm_flowtracker_collector_t collector_id, 658 bcm_flowtracker_export_template_t template_id); 659 660 /* 661 * Get the list of collectors and templates associated with the flow 662 * group. 663 */ 664 extern int bcm_flowtracker_group_collector_get_all( 665 int unit, 666 bcm_flowtracker_group_t flow_group_id, 667 int max_list_size, 668 bcm_flowtracker_collector_t *list_of_collectors, 669 bcm_flowtracker_export_template_t *list_of_templates, 670 int *list_size); 671 672 /* Associate flow group to a collector with an export template. */ 673 extern int bcm_flowtracker_group_collector_attach( 674 int unit, 675 bcm_flowtracker_group_t flow_group_id, 676 bcm_collector_t collector_id, 677 int export_profile_id, 678 bcm_flowtracker_export_template_t template_id); 679 680 /* Dis-associate flow group from a collector with an export template. */ 681 extern int bcm_flowtracker_group_collector_detach( 682 int unit, 683 bcm_flowtracker_group_t flow_group_id, 684 bcm_collector_t collector_id, 685 int export_profile_id, 686 bcm_flowtracker_export_template_t template_id); 687 688 /* 689 * Get the list of collectors and templates associated with the flow 690 * group. 691 */ 692 extern int bcm_flowtracker_group_collector_attach_get_all( 693 int unit, 694 bcm_flowtracker_group_t flow_group_id, 695 int max_list_size, 696 bcm_collector_t *list_of_collectors, 697 bcm_flowtracker_export_template_t *list_of_templates, 698 int *export_profile_id_list, 699 int *list_size); 700 701 #endif /* BCM_HIDE_DISPATCHABLE */ 702 703 /* Initialize flow key. */ 704 extern void bcm_flowtracker_flow_key_t_init( 705 bcm_flowtracker_flow_key_t *flow_key); 706 707 #ifndef BCM_HIDE_DISPATCHABLE 708 709 /* Get flow data for a given flow key within the given flow group. */ 710 extern int bcm_flowtracker_group_data_get( 711 int unit, 712 bcm_flowtracker_group_t flow_group_id, 713 bcm_flowtracker_flow_key_t *flow_key, 714 bcm_flowtracker_flow_data_t *flow_data); 715 716 #endif /* BCM_HIDE_DISPATCHABLE */ 717 718 /* Flow check operation types */ 719 typedef enum bcm_flowtracker_check_operation_e { 720 bcmFlowtrackerCheckOpNone = 0, /* No operation for check. */ 721 bcmFlowtrackerCheckOpEqual = 1, /* The packet attribute value should be 722 equal to minimum value. */ 723 bcmFlowtrackerCheckOpNotEqual = 2, /* The packet attribute value should not 724 be equal to minimum value. */ 725 bcmFlowtrackerCheckOpSmaller = 3, /* The packet attribute value should be 726 smaller than the maximum value. */ 727 bcmFlowtrackerCheckOpSmallerEqual = 4, /* The packet attribute value should be 728 smaller or equal to the maximum 729 value. */ 730 bcmFlowtrackerCheckOpGreater = 5, /* The packet attribute value should be 731 greater than minimum value. */ 732 bcmFlowtrackerCheckOpGreaterEqual = 6, /* The packet attribute value should be 733 Greater than or equal to minimum 734 value. */ 735 bcmFlowtrackerCheckOpPass = 7, /* The check will always pass. */ 736 bcmFlowtrackerCheckOpFail = 8, /* The Check will always fail. */ 737 bcmFlowtrackerCheckOpInRange = 9, /* The packet attribute value should be 738 in Range of minimum and maximum 739 values. Both values are inclusive */ 740 bcmFlowtrackerCheckOpOutofRange = 10, /* The packet attribute value should be 741 out of Range of minimum and maximum 742 values. Both values are inclusive */ 743 bcmFlowtrackerCheckOpCount = 13 /* Last Value. Total number of all 744 operations. */ 745 } bcm_flowtracker_check_operation_t; 746 747 #define BCM_FT_CHECK_OPERATION_STRINGS \ 748 { \ 749 "None", \ 750 "Equal", \ 751 "NotEqual", \ 752 "Smaller", \ 753 "SmallerEqual", \ 754 "Greater", \ 755 "GreaterEqual", \ 756 "Pass", \ 757 "Fail", \ 758 "InRange", \ 759 "OutofRange", \ 760 "Count" \ 761 } 762 763 /* Flags for flowtracker check creation. */ 764 #define BCM_FLOWTRACKER_CHECK_TIMESTAMP_CHECK_EVENT1 (1 << 0) /* Enable trigger for 765 check's first event. */ 766 #define BCM_FLOWTRACKER_CHECK_TIMESTAMP_CHECK_EVENT2 (1 << 1) /* Enable trigger for 767 check's second event. */ 768 #define BCM_FLOWTRACKER_CHECK_DATA_CLEAR_ON_EXPORT (1 << 2) /* Clear data associated 769 with this check during 770 export. */ 771 #define BCM_FLOWTRACKER_CHECK_EXPORT_MODE_THRESHOLD (1 << 3) /* if set, compare if 772 check's updated data 773 is greater-equal to 774 threshold and old data 775 is less than threshold 776 for export check else 777 compare ALU new data 778 to old session data 779 and perform export 780 check. */ 781 782 /* Flowtracker check information. */ 783 typedef struct bcm_flowtracker_check_info_s { 784 uint32 flags; /* Configuration flags for Check 785 Creation. */ 786 bcm_flowtracker_tracking_param_type_t param; /* The attribute of flow on which the 787 check is performed. */ 788 uint32 min_value; /* Element value to do greater than or 789 equal checks. Minimum value to do 790 range checks. */ 791 uint32 max_value; /* Element value to do smaller than 792 checks. Maximum element value to do 793 Range checks. */ 794 bcm_flowtracker_check_operation_t operation; /* Operation to be performed for this 795 check. */ 796 bcm_flowtracker_check_t primary_check_id; /* primary check id to associate second 797 check for aggregated checks on same 798 flow. */ 799 } bcm_flowtracker_check_info_t; 800 801 /* Flow check Action types */ 802 typedef enum bcm_flowtracker_check_action_e { 803 bcmFlowtrackerCheckActionNone = 0, /* No action. */ 804 bcmFlowtrackerCheckActionCounterIncr = 1, /* Increment the Counter stored in 805 tracking data table by 1. */ 806 bcmFlowtrackerCheckActionCounterIncrByValue = 2, /* Increment the attribute value stored 807 in tracking data with the packet's 808 attribute value. */ 809 bcmFlowtrackerCheckActionUpdateLowerValue = 3, /* Compare packet's attribute value with 810 tracking data value and if lower, 811 replace tracking data value with 812 packets attribute value. */ 813 bcmFlowtrackerCheckActionUpdateHigherValue = 4, /* Compare packet's attribute value with 814 tracking data value and if higher, 815 replace tracking data value with 816 packets attribute value. */ 817 bcmFlowtrackerCheckActionUpdateValue = 5, /* Replace packet's attribute value with 818 the tracking data value. */ 819 bcmFlowtrackerCheckActionUpdateAverageValue = 6, /* Update tracking data with the 820 Avergare of packet's attribute value 821 and tracking data value */ 822 bcmFlowtrackerCheckActionCounterIncrByPktBytes = 7, /* Increment the Counter attached to 823 this tracking data by number of bytes 824 in the packet. */ 825 bcmFlowtrackerCheckActionCount = 8 /* Last Value. Count of Flow check 826 Actions */ 827 } bcm_flowtracker_check_action_t; 828 829 #define BCM_FT_CHECK_ACTION_STRINGS \ 830 { \ 831 "None", \ 832 "CounterIncr", \ 833 "CounterIncrByValue", \ 834 "UpdateLowerValue", \ 835 "UpdateHigherValue", \ 836 "UpdateValue", \ 837 "UpdateAverageValue", \ 838 "CounterIncrByPktBytes", \ 839 "Count" \ 840 } 841 842 /* Initialize a Flow check structure. */ 843 extern void bcm_flowtracker_check_info_t_init( 844 bcm_flowtracker_check_info_t *check_info); 845 846 /* 847 * Options that can be passed via options parameter during flow check 848 * creation. 849 */ 850 #define BCM_FLOWTRACKER_CHECK_WITH_ID (1 << 0) /* Create a flow check with 851 ID. */ 852 #define BCM_FLOWTRACKER_CHECK_SECOND (1 << 1) /* Create a secondary check 853 on existing check. */ 854 855 #ifndef BCM_HIDE_DISPATCHABLE 856 857 /* Create Flow check and return software ID. */ 858 extern int bcm_flowtracker_check_create( 859 int unit, 860 uint32 options, 861 bcm_flowtracker_check_info_t check_info, 862 bcm_flowtracker_check_t *check_id); 863 864 /* Destroy flow check corresponding to this software ID. */ 865 extern int bcm_flowtracker_check_destroy( 866 int unit, 867 bcm_flowtracker_check_t check_id); 868 869 /* Get information of flow check. */ 870 extern int bcm_flowtracker_check_get( 871 int unit, 872 bcm_flowtracker_check_t check_id, 873 bcm_flowtracker_check_info_t *check_info); 874 875 /* Destroy all the flow checks. */ 876 extern int bcm_flowtracker_check_destroy_all( 877 int unit); 878 879 #endif /* BCM_HIDE_DISPATCHABLE */ 880 881 /* User callback for flow check traverse routine. */ 882 typedef int(*bcm_flowtracker_check_traverse_cb)( 883 int unit, 884 bcm_flowtracker_check_t check_id, 885 bcm_flowtracker_check_info_t *check_info, 886 void *user_data); 887 888 #ifndef BCM_HIDE_DISPATCHABLE 889 890 /* Traverse through the flow checks and run callback at each valid entry. */ 891 extern int bcm_flowtracker_check_traverse( 892 int unit, 893 bcm_flowtracker_check_traverse_cb cb, 894 void *user_data); 895 896 #endif /* BCM_HIDE_DISPATCHABLE */ 897 898 /* Actions related information for Flow check. */ 899 typedef struct bcm_flowtracker_check_action_info_s { 900 uint32 flags; /* Action flags. */ 901 bcm_flowtracker_tracking_param_type_t param; /* The attribute of flow on which the 902 check is performed. */ 903 bcm_flowtracker_check_action_t action; /* Action to be performed if check 904 passes. */ 905 } bcm_flowtracker_check_action_info_t; 906 907 /* Initialize a flow check action information structure. */ 908 extern void bcm_flowtracker_check_action_info_t_init( 909 bcm_flowtracker_check_action_info_t *info); 910 911 #ifndef BCM_HIDE_DISPATCHABLE 912 913 /* Set action information of flow check. */ 914 extern int bcm_flowtracker_check_action_info_set( 915 int unit, 916 bcm_flowtracker_check_t check_id, 917 bcm_flowtracker_check_action_info_t info); 918 919 /* Get action information of flow check. */ 920 extern int bcm_flowtracker_check_action_info_get( 921 int unit, 922 bcm_flowtracker_check_t check_id, 923 bcm_flowtracker_check_action_info_t *info); 924 925 #endif /* BCM_HIDE_DISPATCHABLE */ 926 927 /* Flow check action flags. */ 928 #define BCM_FLOWTRACKER_FLOWCHECKER_ACTION_IFP 0x00000001 929 930 /* Export related information for Flow check. */ 931 typedef struct bcm_flowtracker_check_export_info_s { 932 uint32 export_check_threshold; /* Threshold at which the export should 933 be triggered for this check. At each 934 incoming matching flow's packet the 935 tracking data is updated and that 936 value is checked with threshold 937 value. If the check mentioned by 938 operation passes between two values 939 then export is triggered. */ 940 bcm_flowtracker_check_operation_t operation; /* Operation to be checked with 941 threshold value for export check. */ 942 } bcm_flowtracker_check_export_info_t; 943 944 /* Initialize a flow check export information structure. */ 945 extern void bcm_flowtracker_check_export_info_t_init( 946 bcm_flowtracker_check_export_info_t *info); 947 948 #ifndef BCM_HIDE_DISPATCHABLE 949 950 /* Set export information of flow check. */ 951 extern int bcm_flowtracker_check_export_info_set( 952 int unit, 953 bcm_flowtracker_check_t check_id, 954 bcm_flowtracker_check_export_info_t info); 955 956 /* Get export information of flow check. */ 957 extern int bcm_flowtracker_check_export_info_get( 958 int unit, 959 bcm_flowtracker_check_t check_id, 960 bcm_flowtracker_check_export_info_t *info); 961 962 /* Add flow check to this flowtracker group */ 963 extern int bcm_flowtracker_group_check_add( 964 int unit, 965 bcm_flowtracker_group_t group_id, 966 bcm_flowtracker_check_t check_id); 967 968 /* Delete flow check from this flowtracker group. */ 969 extern int bcm_flowtracker_group_check_delete( 970 int unit, 971 bcm_flowtracker_group_t group_id, 972 bcm_flowtracker_check_t check_id); 973 974 /* Get all the checks associated with the group. */ 975 extern int bcm_flowtracker_group_check_get_all( 976 int unit, 977 bcm_flowtracker_group_t group_id, 978 int max_checks, 979 bcm_flowtracker_check_t *list_of_check_ids, 980 int *num_checks); 981 982 #endif /* BCM_HIDE_DISPATCHABLE */ 983 984 /* Collector Copy Flags. */ 985 #define BCM_FLOWTRACKER_COLLECTOR_COPY_SAMPLE_RANDOM 0x00000001 /* This flag is used to 986 select the random 987 number out of 988 num_pkts_skip_for_next_sample 989 for random sampling of 990 packet. If this flag 991 is not used then 992 num_pkts_skip_for_next_sample 993 is used as sampling 994 interval. */ 995 996 /* Flowtracker Collector copy info. */ 997 typedef struct bcm_flowtracker_collector_copy_info_s { 998 uint32 flags; /* Flags for Collector copy information */ 999 uint32 num_pkts_initial_samples; /* Number of initial sample copies to 1000 be sent to collector */ 1001 uint32 num_pkts_skip_for_next_sample; /* Number of packets to skip to send 1002 next sample copy to collector. */ 1003 } bcm_flowtracker_collector_copy_info_t; 1004 1005 /* Initialize a flowtracker collector copy information structure. */ 1006 extern void bcm_flowtracker_collector_copy_info_t_init( 1007 bcm_flowtracker_collector_copy_info_t *info); 1008 1009 #ifndef BCM_HIDE_DISPATCHABLE 1010 1011 /* Set collector copy information to the flowtracker group. */ 1012 extern int bcm_flowtracker_group_collector_copy_info_set( 1013 int unit, 1014 bcm_flowtracker_group_t group_id, 1015 bcm_flowtracker_collector_copy_info_t info); 1016 1017 /* Get collector copy information of this flowtracker group. */ 1018 extern int bcm_flowtracker_group_collector_copy_info_get( 1019 int unit, 1020 bcm_flowtracker_group_t group_id, 1021 bcm_flowtracker_collector_copy_info_t *info); 1022 1023 #endif /* BCM_HIDE_DISPATCHABLE */ 1024 1025 /* Configuration flags for flowtracker groups's meter. */ 1026 #define BCM_FLOWTRACKER_METER_MODE_PACKET (1 << 0) /* Group metering mode is 1027 per packet. */ 1028 1029 /* Flowtracker meter info. */ 1030 typedef struct bcm_flowtracker_meter_info_s { 1031 uint32 flags; /* Flags for meter information */ 1032 uint32 ckbits_sec; /* Committed rate (kbits per sec). */ 1033 uint32 ckbits_burst; /* Committed burst size (kbits). */ 1034 uint32 actual_ckbits_sec; /* Granularity adjusted Committed rate (kbits 1035 per sec). */ 1036 uint32 actual_ckbits_burst; /* Granularity adjusted Committed burst size 1037 (kbits). */ 1038 } bcm_flowtracker_meter_info_t; 1039 1040 /* Initialize a flowtracker meter information structure. */ 1041 extern void bcm_flowtracker_meter_info_t_init( 1042 bcm_flowtracker_meter_info_t *meter_info); 1043 1044 #ifndef BCM_HIDE_DISPATCHABLE 1045 1046 /* Set meter information of this flowtracker group. */ 1047 extern int bcm_flowtracker_group_meter_info_set( 1048 int unit, 1049 bcm_flowtracker_group_t group_id, 1050 bcm_flowtracker_meter_info_t info); 1051 1052 /* Get meter information of this flowtracker group. */ 1053 extern int bcm_flowtracker_group_meter_info_get( 1054 int unit, 1055 bcm_flowtracker_group_t group_id, 1056 bcm_flowtracker_meter_info_t *info); 1057 1058 #endif /* BCM_HIDE_DISPATCHABLE */ 1059 1060 /* Flowtracker Tracking param defines. */ 1061 #define BCM_FLOWTRACKER_TRACKING_PARAM_MASK_LEN 16 /* Mask Length for 1062 highest bit length 1063 tracking parameter. */ 1064 1065 /* bcm_flowtracker_tracking_param_mask_t */ 1066 typedef uint8 bcm_flowtracker_tracking_param_mask_t[BCM_FLOWTRACKER_TRACKING_PARAM_MASK_LEN]; 1067 1068 /* bcm_flowtracker_param_user_entry_param_data_t */ 1069 typedef uint8 bcm_flowtracker_tracking_param_user_data_t[BCM_FLOWTRACKER_TRACKING_PARAM_MASK_LEN]; 1070 1071 /* 1072 * Options that can be passed via options parameter during export 1073 * template creation. 1074 */ 1075 #define BCM_FLOWTRACKER_TRACKING_PARAM_TYPE_KEY (1 << 0) /* Tracking parameter is 1076 a key. */ 1077 1078 /* Flowtracker tracking parameter information. */ 1079 typedef struct bcm_flowtracker_tracking_param_info_s { 1080 uint32 flags; /* Flags for tracking parameters. */ 1081 bcm_flowtracker_tracking_param_type_t param; /* Type of tracking parameter. */ 1082 bcm_flowtracker_tracking_param_user_data_t tracking_data; /* Element data for the tracking param 1083 to be used to add a flow. */ 1084 bcm_flowtracker_tracking_param_mask_t mask; /* Mask to select granular information 1085 from tracking parameter. By default, 1086 mask is set to all enabled. */ 1087 bcm_flowtracker_check_t check_id; /* Flowtracker Check to be used to 1088 tracking flow check data. */ 1089 bcm_udf_id_t udf_id; /* UDF Id associated with the tracking 1090 param. */ 1091 } bcm_flowtracker_tracking_param_info_t; 1092 1093 /* Initialize flowtracker's tracking parameters information structure. */ 1094 extern void bcm_flowtracker_tracking_param_info_t_init( 1095 bcm_flowtracker_tracking_param_info_t *info); 1096 1097 #ifndef BCM_HIDE_DISPATCHABLE 1098 1099 /* Set tracking parameter for this flowtracker group. */ 1100 extern int bcm_flowtracker_group_tracking_params_set( 1101 int unit, 1102 bcm_flowtracker_group_t id, 1103 int num_tracking_params, 1104 bcm_flowtracker_tracking_param_info_t *list_of_tracking_params); 1105 1106 /* Get flowtracker tracking parameters for this group. */ 1107 extern int bcm_flowtracker_group_tracking_params_get( 1108 int unit, 1109 bcm_flowtracker_group_t id, 1110 int max_size, 1111 bcm_flowtracker_tracking_param_info_t *list_of_tracking_params, 1112 int *list_size); 1113 1114 /* Clear all the groups mentioned in group list. */ 1115 extern int bcm_flowtracker_group_multi_clear( 1116 int unit, 1117 uint32 flags, 1118 int num_groups, 1119 bcm_flowtracker_group_t *list_of_group_ids); 1120 1121 #endif /* BCM_HIDE_DISPATCHABLE */ 1122 1123 /* Flowtracker Flow direction Types. */ 1124 typedef enum bcm_flowtracker_direction_e { 1125 bcmFlowtrackerFlowDirectionNone = 0, /* No Direction. */ 1126 bcmFlowtrackerFlowDirectionForward = 1, /* The flow is tracked in forward 1127 direction only. Flow direciton is 1128 forward from server to client flow. */ 1129 bcmFlowtrackerFlowDirectionReverse = 2, /* The flow is tracked in reverse 1130 direction only. Flow direciton is 1131 reverse from client to server flow. */ 1132 bcmFlowtrackerFlowDirectionBidirectional = 3, /* The flow is tracked in both the 1133 forward and reverse directions. */ 1134 bcmFlowtrackerFlowDirectionCount = 4 /* Last Value. Not Usable. */ 1135 } bcm_flowtracker_direction_t; 1136 1137 /* Flowtracker Group Control types */ 1138 typedef enum bcm_flowtracker_group_control_type_e { 1139 bcmFlowtrackerGroupControlNone = 0, /* No Group Control. */ 1140 bcmFlowtrackerGroupControlNewLearnEnable = 1, /* Control to Enable/disable New flow 1141 learn on this group. */ 1142 bcmFlowtrackerGroupControlFlowtrackerEnable = 2, /* Control to Enable/disable flow 1143 tracking on this group */ 1144 bcmFlowtrackerGroupControlFlowDirection = 3, /* Control to set flow direction for 1145 tracking forward/reverse flow. */ 1146 bcmFlowtrackerGroupControlCount = 4 /* Total Count of Group controls. */ 1147 } bcm_flowtracker_group_control_type_t; 1148 1149 #ifndef BCM_HIDE_DISPATCHABLE 1150 1151 /* Set flowtracker group control. */ 1152 extern int bcm_flowtracker_group_control_set( 1153 int unit, 1154 bcm_flowtracker_group_t group_id, 1155 bcm_flowtracker_group_control_type_t type, 1156 int arg); 1157 1158 /* Get flowtracker group control. */ 1159 extern int bcm_flowtracker_group_control_get( 1160 int unit, 1161 bcm_flowtracker_group_t group_id, 1162 bcm_flowtracker_group_control_type_t type, 1163 int *arg); 1164 1165 #endif /* BCM_HIDE_DISPATCHABLE */ 1166 1167 /* Flowtracker Tracking param defines. */ 1168 #define BCM_FLOWTRACKER_TRACKING_USER_ENTRY_WIDTH 48 /* Max width of 1169 flowtracker user entry 1170 key. */ 1171 1172 /* Flowtracker user entry handle information. */ 1173 typedef struct bcm_flowtracker_user_entry_handle_s { 1174 bcm_flowtracker_group_t flow_group_id; /* Flowtracker group Id. */ 1175 int flow_index; /* Flow index. */ 1176 int flow_key_mode; /* Flow Key mode. */ 1177 int flow_key_type; /* Flow Key type. */ 1178 uint8 key_data[BCM_FLOWTRACKER_TRACKING_USER_ENTRY_WIDTH]; /* Flow user entry Key. */ 1179 } bcm_flowtracker_user_entry_handle_t; 1180 1181 /* Initialize flowtracker user entry handle information structure. */ 1182 extern void bcm_flowtracker_user_entry_handle_t_init( 1183 bcm_flowtracker_user_entry_handle_t *user_entry_handle); 1184 1185 #ifndef BCM_HIDE_DISPATCHABLE 1186 1187 /* 1188 * Add a user flow entry basis user input key elements. API expects that 1189 * all tracking parametrs of type = 'KEY' in the group are specified. 1190 */ 1191 extern int bcm_flowtracker_user_entry_add( 1192 int unit, 1193 bcm_flowtracker_group_t flow_group_id, 1194 uint32 options, 1195 int num_user_entry_params, 1196 bcm_flowtracker_tracking_param_info_t *user_entry_param_list, 1197 bcm_flowtracker_user_entry_handle_t *entry_handle); 1198 1199 /* Fetch user entry info given the entry handle. */ 1200 extern int bcm_flowtracker_user_entry_get( 1201 int unit, 1202 bcm_flowtracker_user_entry_handle_t *entry_handle, 1203 int num_user_entry_params, 1204 bcm_flowtracker_tracking_param_info_t *user_entry_param_list, 1205 int *actual_user_entry_params); 1206 1207 /* Fetch all user entries added in a against a given flow group. */ 1208 extern int bcm_flowtracker_user_entry_get_all( 1209 int unit, 1210 bcm_flowtracker_group_t flow_group_id, 1211 int num_user_entry_handles, 1212 bcm_flowtracker_user_entry_handle_t *user_entry_handle_list, 1213 int *actual_user_entry_handles); 1214 1215 /* Delete user flow entry that is added earlier. */ 1216 extern int bcm_flowtracker_user_entry_delete( 1217 int unit, 1218 bcm_flowtracker_group_t flow_group_id, 1219 bcm_flowtracker_user_entry_handle_t *entry_handle); 1220 1221 /* Delete user flow entry that is added earlier. */ 1222 extern int bcm_flowtracker_user_entry_delete_all( 1223 int unit, 1224 bcm_flowtracker_group_t flow_group_id); 1225 1226 #endif /* BCM_HIDE_DISPATCHABLE */ 1227 1228 /* Stats of the Flows on the group. */ 1229 typedef struct bcm_flowtracker_group_stat_s { 1230 uint64 flow_exceeded_count; /* Count of flows not tracked in this 1231 group after maximum number of flows 1232 configured for this group are already 1233 learnt. */ 1234 uint64 flow_missed_count; /* Count of Aged out flows in the group. */ 1235 uint64 flow_aged_out_count; /* Count of flows which are Aged out in 1236 the group. */ 1237 uint64 flow_learnt_count; /* Count of flows learnt on the group. */ 1238 uint64 flow_meter_exceeded_count; /* Count of flows which exceeded the 1239 metering limits in the group. */ 1240 } bcm_flowtracker_group_stat_t; 1241 1242 /* Initialize a flowtracker group statistics structure. */ 1243 extern void bcm_flowtracker_group_stat_t_init( 1244 bcm_flowtracker_group_stat_t *group_stats); 1245 1246 #ifndef BCM_HIDE_DISPATCHABLE 1247 1248 /* Get flowtracker group statistics. */ 1249 extern int bcm_flowtracker_group_stat_get( 1250 int unit, 1251 bcm_flowtracker_group_t group_id, 1252 bcm_flowtracker_group_stat_t *group_stats); 1253 1254 /* Set flowtracker group statistics. */ 1255 extern int bcm_flowtracker_group_stat_set( 1256 int unit, 1257 bcm_flowtracker_group_t group_id, 1258 bcm_flowtracker_group_stat_t *group_stats); 1259 1260 #endif /* BCM_HIDE_DISPATCHABLE */ 1261 1262 /* Flowtracker CPU Notification types */ 1263 typedef enum bcm_flowtracker_cpu_notification_e { 1264 bcmFlowtrackerCpuNotificationNone = 0, /* No CPU Notification. Initial Value. */ 1265 bcmFlowtrackerCpuNotificationFlowExceeded = 1, /* Notification will be sent to CPU when 1266 number of flows per group is exceeded 1267 from configured Max Limit. */ 1268 bcmbcmFlowtrackerCpuNotificationTableFull = 2, /* Notification will be sent to CPU when 1269 Table is full and no new flow can be 1270 learnt. */ 1271 bcmFlowtrackerCpuNotificationCount = 3 /* Last Value. Count of all CPU 1272 notifications. */ 1273 } bcm_flowtracker_cpu_notification_t; 1274 1275 /* Flowtracker CPU notification information. */ 1276 typedef struct bcm_flowtracker_cpu_notification_info_s { 1277 SHR_BITDCL notification_bmp[_SHR_BITDCLSIZE(bcmFlowtrackerCpuNotificationCount)]; /* The bitmap of CPU notifications which 1278 will notify CPU on corresponding 1279 activity. */ 1280 } bcm_flowtracker_cpu_notification_info_t; 1281 1282 /* Initialize a flowtracker CPU notification information structure. */ 1283 extern void bcm_flowtracker_cpu_notification_info_t_init( 1284 bcm_flowtracker_cpu_notification_info_t *info); 1285 1286 #define BCM_FLOWTRACKER_CPU_NOTIFICATION_SET(_info, _notification) SHR_BITSET(((_info).notification_bmp), (_notification)) 1287 1288 #define BCM_FLOWTRACKER_CPU_NOTIFICATION_GET(_info, _notification) SHR_BITGET(((_info).notification_bmp), (_notification)) 1289 1290 #define BCM_FLOWTRACKER_CPU_NOTIFICATION_CLEAR(_info, _notification) SHR_BITCLR(((_info).notification_bmp), (_notification)) 1291 1292 #define BCM_FLOWTRACKER_CPU_NOTIFICATION_CLEAR_ALL(_info) SHR_BITCLR_RANGE(((_info).notification_bmp), 0, bcmFlowtrackerCpuNotificationCount) 1293 1294 #ifndef BCM_HIDE_DISPATCHABLE 1295 1296 /* Set CPU notification on the flowtracker group. */ 1297 extern int bcm_flowtracker_group_cpu_notification_set( 1298 int unit, 1299 bcm_flowtracker_group_t id, 1300 bcm_flowtracker_cpu_notification_info_t *info); 1301 1302 /* Get CPU notification of the flowtracker group. */ 1303 extern int bcm_flowtracker_group_cpu_notification_get( 1304 int unit, 1305 bcm_flowtracker_group_t id, 1306 bcm_flowtracker_cpu_notification_info_t *info); 1307 1308 #endif /* BCM_HIDE_DISPATCHABLE */ 1309 1310 /* 1311 * Max size of the data record received at the CPU through the FIFO DMA 1312 * reception. 1313 */ 1314 #define BCM_FLOWTRACKER_EXPORT_RECORD_LENGTH BITS2BYTES(1024) /* Maximum length of a 1315 data record. 1024 1316 bits. */ 1317 1318 /* 1319 * Flowtracker Export record structure. Data record info passed to 1320 * application software by SDK Software. The unprocessed data record will 1321 * be presented in network byte order. 1322 */ 1323 typedef struct bcm_flowtracker_export_record_s { 1324 int size; /* Number of valid octets in the 1325 data_record array for the device. */ 1326 uint8 data_record[BCM_FLOWTRACKER_EXPORT_RECORD_LENGTH]; /* Raw data record in network byte 1327 order. */ 1328 } bcm_flowtracker_export_record_t; 1329 1330 /* bcm_flowtracker_export_record_t_init */ 1331 extern void bcm_flowtracker_export_record_t_init( 1332 bcm_flowtracker_export_record_t *record); 1333 1334 /* 1335 * Defines for priorities of registered handlers for Flowtracker export 1336 * records. Callback handlers are always called from highest priority to 1337 * lowest priority until one of the handlers returns record_handled or 1338 * record_handled_owned. 1339 * 1340 * 1341 * When callback handling proecedure starts, a default callback handler 1342 * is installed at BCM_FLOWTRACKER_EXPORT_CB_PRIO_MIN priority that 1343 * simply discards the record. 1344 */ 1345 #define BCM_FLOWTRACKER_EXPORT_CB_PRIO_MIN ((uint8)0) 1346 #define BCM_FLOWTRACKER_EXPORT_CB_PRIO_MAX ((uint8)255) 1347 1348 /* Flowtracker Export callback options */ 1349 typedef struct bcm_flowtracker_collector_callback_options_s { 1350 int callback_prio; /* Priority of the callback function in the list. */ 1351 } bcm_flowtracker_collector_callback_options_t; 1352 1353 /* bcm_flowtracker_collector_callback_options_t_init */ 1354 extern void bcm_flowtracker_collector_callback_options_t_init( 1355 bcm_flowtracker_collector_callback_options_t *callback_options); 1356 1357 /* Return values from Flowtracker export record callout routines. */ 1358 typedef enum bcm_flowtracker_export_record_handle_e { 1359 BCM_FLOWTRACKER_EXPORT_RECORD_INVALID = 0, /* Invalid return value. */ 1360 BCM_FLOWTRACKER_EXPORT_RECORD_NOT_HANDLED = 1, /* Export record not processed. */ 1361 BCM_FLOWTRACKER_EXPORT_RECORD_HANDLED = 2, /* Export record handled, not owned. */ 1362 BCM_FLOWTRACKER_EXPORT_RECORD_HANDLED_OWNED = 3 /* Export record handled and owned. */ 1363 } bcm_flowtracker_export_record_handle_t; 1364 1365 /* Callback routine for flowtracker record exported to local collector. */ 1366 typedef bcm_flowtracker_export_record_handle_t (*bcm_flowtracker_export_record_cb_f)( 1367 int unit, 1368 bcm_flowtracker_collector_t collector_id, 1369 bcm_flowtracker_export_record_t *record, 1370 void *userdata); 1371 1372 #ifndef BCM_HIDE_DISPATCHABLE 1373 1374 /* 1375 * Register callback routine for Local collector Flowtracker record 1376 * export. 1377 */ 1378 extern int bcm_flowtracker_export_record_register( 1379 int unit, 1380 bcm_flowtracker_collector_t collector_id, 1381 bcm_flowtracker_collector_callback_options_t callback_options, 1382 bcm_flowtracker_export_record_cb_f callback_fn, 1383 void *userdata); 1384 1385 /* 1386 * Unregister callback routine for Local collector Flowtracker record 1387 * export. 1388 */ 1389 extern int bcm_flowtracker_export_record_unregister( 1390 int unit, 1391 bcm_flowtracker_collector_t collector_id, 1392 bcm_flowtracker_collector_callback_options_t callback_options, 1393 bcm_flowtracker_export_record_cb_f callback_fn); 1394 1395 #endif /* BCM_HIDE_DISPATCHABLE */ 1396 1397 /* Group actions set flags. */ 1398 #define BCM_FLOWTRACKER_GROUP_ACTIONS_SET_FLAGS_ELEPHANT_FLOWS (1 << 0) /* Actions apply to only 1399 elephant flows in the 1400 group. */ 1401 1402 /* 1403 * Packet Color, need to be specified in param0 when using 1404 * bcmFlowtrackerGroupActionXXDropPrecedence. 1405 */ 1406 #define BCM_FLOWTRACKER_GROUP_ACTION_PKT_COLOR_GREEN 1 1407 #define BCM_FLOWTRACKER_GROUP_ACTION_PKT_COLOR_YELLOW 2 1408 #define BCM_FLOWTRACKER_GROUP_ACTION_PKT_COLOR_RED 3 1409 1410 /* Flowtracker Group action types */ 1411 typedef enum bcm_flowtracker_group_action_e { 1412 bcmFlowtrackerGroupActionRpDropPrecedence = 0, /* Set Red Priority Drop Precedence; 1413 param0: 1414 BCM_FLOWTRACKER_GROUP_ACTION_PKT_COLOR_XXX.. */ 1415 bcmFlowtrackerGroupActionYpDropPrecedence = 1, /* Set Yellow Priority Drop Precedence; 1416 param0: 1417 BCM_FLOWTRACKER_GROUP_ACTION_PKT_COLOR_XXX.. */ 1418 bcmFlowtrackerGroupActionGpDropPrecedence = 2, /* Set Green Priority Drop Precedence; 1419 param0: 1420 BCM_FLOWTRACKER_GROUP_ACTION_PKT_COLOR_XXX.. */ 1421 bcmFlowtrackerGroupActionUcastCosQNew = 3, /* Change CoS Queue for unicast packets; 1422 param0: New CoS Queue. */ 1423 bcmFlowtrackerGroupActionMcastCosQNew = 4, /* Change CoS Queue for multicast 1424 packets; param0: New CoS Queue. */ 1425 bcmFlowtrackerGroupActionPrioIntNew = 5, /* Change internal priority; param0: New 1426 internal priority */ 1427 bcmFlowtrackerGroupActionFspReinject = 6, /* Re-inject the First Seen Packet to 1428 the specified CosQ */ 1429 bcmFlowtrackerGroupActionDropMonitor = 7, /* Monitor Dropped flows */ 1430 bcmFlowtrackerGroupActionCount = 8 /* Always Last. Not a usable value. */ 1431 } bcm_flowtracker_group_action_t; 1432 1433 /* Flowtracker Group action params */ 1434 typedef struct bcm_flowtracker_group_action_param_s { 1435 uint32 param0; 1436 uint32 param1; 1437 } bcm_flowtracker_group_action_param_t; 1438 1439 /* Flowtracker Group action info */ 1440 typedef struct bcm_flowtracker_group_action_info_s { 1441 bcm_flowtracker_group_action_t action; /* Action */ 1442 bcm_flowtracker_group_action_param_t params; /* Action param */ 1443 } bcm_flowtracker_group_action_info_t; 1444 1445 /* Initialize a flowtracker group action info structure. */ 1446 extern void bcm_flowtracker_group_action_info_t_init( 1447 bcm_flowtracker_group_action_info_t *action_info); 1448 1449 #ifndef BCM_HIDE_DISPATCHABLE 1450 1451 /* Set list of actions on a flow group. */ 1452 extern int bcm_flowtracker_group_actions_set( 1453 int unit, 1454 bcm_flowtracker_group_t flow_group_id, 1455 uint32 flags, 1456 int num_actions, 1457 bcm_flowtracker_group_action_info_t *action_list); 1458 1459 /* Get list of actions applied on a flow group. */ 1460 extern int bcm_flowtracker_group_actions_get( 1461 int unit, 1462 bcm_flowtracker_group_t flow_group_id, 1463 uint32 flags, 1464 int max_actions, 1465 bcm_flowtracker_group_action_info_t *action_list, 1466 int *num_actions); 1467 1468 #endif /* BCM_HIDE_DISPATCHABLE */ 1469 1470 /* Miscellaneous Flowtracker Elephant defines. */ 1471 #define BCM_FLOWTRACKER_ELEPHANT_MAX_PROMOTION_FILTERS 2 /* Maximum number of 1472 promotion filters in 1473 an elephant profile. */ 1474 1475 /* Elephant filter flags. */ 1476 #define BCM_FLOWTRACKER_ELEPHANT_FILTER_FLAGS_INCREASING_RATE (1 << 0) /* Rate must increase on 1477 every scan */ 1478 1479 /* 1480 * Options that can be passed via options parameter during elephant 1481 * profile creation. 1482 */ 1483 #define BCM_FLOWTRACKER_ELEPHANT_PROFILE_WITH_ID (1 << 0) /* Create an elephant 1484 profile with ID. */ 1485 1486 /* Mirror on Drop class ID flag. */ 1487 #define BCM_FLOWTRACKER_EXACT_MATCH_CLASS_ID_FLOW_DROP 1 /* Exact Match flow drop 1488 indicator class ID */ 1489 1490 /* Flowtracker Elephant profile Id. */ 1491 typedef int bcm_flowtracker_elephant_profile_t; 1492 1493 /* Flowtracker Elephant filter config */ 1494 typedef struct bcm_flowtracker_elephant_filter_s { 1495 uint32 flags; /* See 1496 BCM_FLOWTRACKER_ELEPHANT_FILTER_FLAGS_XXX 1497 definitions */ 1498 uint32 monitor_interval_usecs; /* How long should the flow be monitored */ 1499 uint32 rate_low_threshold_kbits_sec; /* Minimum rate the flow must have to 1500 continue monitoring (kbits_sec = 1000 1501 bits/sec) */ 1502 uint32 rate_high_threshold_kbits_sec; /* Rate that must be observed at least 1503 once during monitoring interval for a 1504 flow to pass the monitoring criteria 1505 (kbits_sec = 1000 bits/sec) */ 1506 uint64 size_threshold_bytes; /* Total size in bytes that must be 1507 observed after the monitoring 1508 interval for a flow to pass the 1509 monitoring criteria */ 1510 } bcm_flowtracker_elephant_filter_t; 1511 1512 /* Flowtracker Elephant profile info */ 1513 typedef struct bcm_flowtracker_elephant_profile_info_s { 1514 uint8 num_promotion_filters; /* Number of promotion filters */ 1515 bcm_flowtracker_elephant_filter_t promotion_filters[BCM_FLOWTRACKER_ELEPHANT_MAX_PROMOTION_FILTERS]; /* Promotion filters */ 1516 bcm_flowtracker_elephant_filter_t demotion_filter; /* Demotion filter */ 1517 } bcm_flowtracker_elephant_profile_info_t; 1518 1519 /* Initialize a flowtracker elephant profile info structure. */ 1520 extern void bcm_flowtracker_elephant_profile_info_t_init( 1521 bcm_flowtracker_elephant_profile_info_t *profile); 1522 1523 #ifndef BCM_HIDE_DISPATCHABLE 1524 1525 /* Create flowtracker elephant profile. */ 1526 extern int bcm_flowtracker_elephant_profile_create( 1527 int unit, 1528 uint32 options, 1529 bcm_flowtracker_elephant_profile_info_t *profile, 1530 bcm_flowtracker_elephant_profile_t *profile_id); 1531 1532 /* Destroy a flowtracker elephant profile. */ 1533 extern int bcm_flowtracker_elephant_profile_destroy( 1534 int unit, 1535 bcm_flowtracker_elephant_profile_t profile_id); 1536 1537 /* Get flowtracker elephant profile information. */ 1538 extern int bcm_flowtracker_elephant_profile_get( 1539 int unit, 1540 bcm_flowtracker_elephant_profile_t profile_id, 1541 bcm_flowtracker_elephant_profile_info_t *profile); 1542 1543 /* Get the list of all flowtracker elephant profiles configured. */ 1544 extern int bcm_flowtracker_elephant_profile_get_all( 1545 int unit, 1546 int max, 1547 bcm_flowtracker_elephant_profile_t *profile_list, 1548 int *count); 1549 1550 /* Attach a flow group with an elephant profile. */ 1551 extern int bcm_flowtracker_group_elephant_profile_attach( 1552 int unit, 1553 bcm_flowtracker_group_t flow_group_id, 1554 bcm_flowtracker_elephant_profile_t profile_id); 1555 1556 /* Get the elephant profile Id attached to a flow group. */ 1557 extern int bcm_flowtracker_group_elephant_profile_attach_get( 1558 int unit, 1559 bcm_flowtracker_group_t flow_group_id, 1560 bcm_flowtracker_elephant_profile_t *profile_id); 1561 1562 /* Detach a flow group from an elephant profile. */ 1563 extern int bcm_flowtracker_group_elephant_profile_detach( 1564 int unit, 1565 bcm_flowtracker_group_t flow_group_id); 1566 1567 #endif /* BCM_HIDE_DISPATCHABLE */ 1568 1569 /* Elephant match types */ 1570 #define BCM_FLOWTRACKER_ELEPHANT_MATCH_TYPE_PKT_TYPE_BMP (1 << 0) /* Packet type bitmap. */ 1571 #define BCM_FLOWTRACKER_ELEPHANT_MATCH_TYPE_INT_PRI_BMP (1 << 1) /* Internal priority 1572 bitmap. */ 1573 #define BCM_FLOWTRACKER_ELEPHANT_MATCH_TYPE_INGRESS_PBMP (1 << 2) /* Ingress port bitmap. */ 1574 #define BCM_FLOWTRACKER_ELEPHANT_MATCH_TYPE_EGRESS_PBMP (1 << 3) /* Egress port bitmap. */ 1575 1576 /* Elephant flow packet types */ 1577 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_IPV4_TCP (1 << 0) /* IPv4 TCP packets. */ 1578 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_IPV4_UDP (1 << 1) /* IPv4 UDP packets. */ 1579 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_IPV4_OTHER (1 << 2) /* IPv4 non TCP, UDP 1580 packets. */ 1581 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_IPV6_TCP (1 << 3) /* IPv6 TCP packets. */ 1582 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_IPV6_UDP (1 << 4) /* IPv6 UDP packets. */ 1583 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_IPV6_OTHER (1 << 5) /* IPv6 non TCP, UDP 1584 packets. */ 1585 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_MPLS (1 << 6) /* MPLS packets. */ 1586 #define BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_OTHER (1 << 7) /* Non IPv4, IPv6, MPLS 1587 packets. */ 1588 1589 /* Elephant match data. */ 1590 typedef struct bcm_flowtracker_elephant_match_data_s { 1591 bcm_pbmp_t ingress_pbmp; /* Ingress port bitmap */ 1592 bcm_pbmp_t egress_pbmp; /* Egress port bitmap */ 1593 uint32 pkt_type_bmp; /* pkt type bitmap, See 1594 BCM_FLOWTRACKER_ELEPHANT_PKT_TYPE_XXX */ 1595 uint32 int_pri_bmp; /* Internal priority bitmap */ 1596 } bcm_flowtracker_elephant_match_data_t; 1597 1598 /* Initialize elephant match data. */ 1599 extern void bcm_flowtracker_elephant_match_data_t_init( 1600 bcm_flowtracker_elephant_match_data_t *match_data); 1601 1602 typedef enum bcm_flowtracker_elephant_match_action_e { 1603 bcmFlowtrackerElephantMatchActionLookup = 0, /* Enable elephant lookup */ 1604 bcmFlowtrackerElephantMatchActionQueue = 1, /* Enable queue actions */ 1605 bcmFlowtrackerElephantMatchActionColor = 2, /* Enable color actions */ 1606 bcmFlowtrackerElephantMatchActionCount = 3 /* Always Last. Not a usable value. */ 1607 } bcm_flowtracker_elephant_match_action_t; 1608 1609 #ifndef BCM_HIDE_DISPATCHABLE 1610 1611 /* Set the match criteria for an elephant action. */ 1612 extern int bcm_flowtracker_elephant_action_match_set( 1613 int unit, 1614 bcm_flowtracker_elephant_match_action_t action, 1615 uint32 match_types, 1616 bcm_flowtracker_elephant_match_data_t *match_data); 1617 1618 /* Get the match criteria for an elephant action. */ 1619 extern int bcm_flowtracker_elephant_action_match_get( 1620 int unit, 1621 bcm_flowtracker_elephant_match_action_t action, 1622 uint32 *match_types, 1623 bcm_flowtracker_elephant_match_data_t *match_data); 1624 1625 /* Set the internal priority remap for elephant flows. */ 1626 extern int bcm_flowtracker_elephant_int_pri_remap_set( 1627 int unit, 1628 bcm_cos_t int_pri, 1629 bcm_cos_t new_int_pri); 1630 1631 /* Get the internal priority remap for elephant flows. */ 1632 extern int bcm_flowtracker_elephant_int_pri_remap_get( 1633 int unit, 1634 bcm_cos_t int_pri, 1635 bcm_cos_t *new_int_pri); 1636 1637 #endif /* BCM_HIDE_DISPATCHABLE */ 1638 1639 /* Elephant controls */ 1640 typedef enum bcm_flowtracker_elephant_control_e { 1641 bcmFlowtrackerElephantControlMonitorIntervalUsecs = 0, /* Elephant monitor interval in 1642 microseconds */ 1643 bcmFlowtrackerElephantControlBloomFilterByteThreshold = 1, /* Bloom filter promotion threshold in 1644 bytes */ 1645 bcmFlowtrackerElephantControlElephantThresholdBytes = 2, /* Elephant promotion threshold in bytes */ 1646 bcmFlowtrackerElephantControlDemotionThresholdBytes = 3, /* Elephant demotion threshold in bytes */ 1647 bcmFlowtrackerElephantControlYellowThreshold = 4, /* Threshold in bytes to mark an 1648 elephant flow as yellow */ 1649 bcmFlowtrackerElephantControlRedThreshold = 5, /* Threshold in bytes to mark an 1650 elephant flow as red */ 1651 bcmFlowtrackerElephantControlPacketRemarkEnable = 6, /* Enable packet remarking */ 1652 bcmFlowtrackerElephantControlSampleRate = 7, /* Set elephant flow sample rate (Every 1653 1 in 'arg' number of packets will be 1654 sampled) */ 1655 bcmFlowtrackerElephantControlSampleSeed = 8, /* Set seed for the random number 1656 generator used for sampling */ 1657 bcmFlowtrackerElephantControlSampleCopyToCpu = 9, /* Copy to Cpu sampled packets */ 1658 bcmFlowtrackerElephantControlCount = 10 /* Last Value. Not Usable. */ 1659 } bcm_flowtracker_elephant_control_t; 1660 1661 #ifndef BCM_HIDE_DISPATCHABLE 1662 1663 /* Set elephant controls. */ 1664 extern int bcm_flowtracker_elephant_control_set( 1665 int unit, 1666 bcm_flowtracker_elephant_control_t type, 1667 int arg); 1668 1669 /* Get elephant controls. */ 1670 extern int bcm_flowtracker_elephant_control_get( 1671 int unit, 1672 bcm_flowtracker_elephant_control_t type, 1673 int *arg); 1674 1675 #endif /* BCM_HIDE_DISPATCHABLE */ 1676 1677 /* Elephant hash tables */ 1678 typedef enum bcm_flowtracker_elephant_hash_table_e { 1679 bcmFlowtrackerElephantHashTableBloomFilter = 0, /* Bloom filter hash table. */ 1680 bcmFlowtrackerElephantHashTableFlowTable = 1, /* Elephant flow table. */ 1681 bcmFlowtrackerElephantHashTableCount = 2 /* Last Value. Not Usable. */ 1682 } bcm_flowtracker_elephant_hash_table_t; 1683 1684 /* Elephant hash types */ 1685 typedef enum bcm_flowtracker_elephant_hash_type_e { 1686 bcmFlowtrackerElephantHashTypeField0Function0 = 0, /* Hash field 0, mode 0 configured using 1687 bcmSwitchHashField0Config */ 1688 bcmFlowtrackerElephantHashTypeField0Function1 = 1, /* Hash field 0, mode 1 configured using 1689 bcmSwitchHashField0Config1. */ 1690 bcmFlowtrackerElephantHashTypeField1Function0 = 2, /* Hash field 1, mode 0 configured using 1691 bcmSwitchHashField1Config. */ 1692 bcmFlowtrackerElephantHashTypeField1Function1 = 3, /* Hash field 1, mode 1 configured using 1693 bcmSwitchHashField1Config1. */ 1694 bcmbcmFlowtrackerElephantHashTypeCount = 4 /* Last Value. Not Usable. */ 1695 } bcm_flowtracker_elephant_hash_type_t; 1696 1697 #ifndef BCM_HIDE_DISPATCHABLE 1698 1699 /* Set the hashing configuration */ 1700 extern int bcm_flowtracker_elephant_hash_config_set( 1701 int unit, 1702 bcm_flowtracker_elephant_hash_table_t hash_table, 1703 int instance_num, 1704 int bank_num, 1705 bcm_flowtracker_elephant_hash_type_t hash_type, 1706 int right_rotate_bits); 1707 1708 /* Get the hashing configuration */ 1709 extern int bcm_flowtracker_elephant_hash_config_get( 1710 int unit, 1711 bcm_flowtracker_elephant_hash_table_t hash_table, 1712 int instance_num, 1713 int bank_num, 1714 bcm_flowtracker_elephant_hash_type_t *hash_type, 1715 int *right_rotate_bits); 1716 1717 #endif /* BCM_HIDE_DISPATCHABLE */ 1718 1719 /* Elephant statistics */ 1720 typedef struct bcm_flowtracker_elephant_stats_s { 1721 uint64 num_candidates_detected; /* Total number of candidate flows that 1722 were detected */ 1723 uint64 num_flow_table_insert_failures; /* Total number of elephant flow table 1724 insertion failures */ 1725 uint64 num_flow_table_insert_success; /* Total number of elephant flow table 1726 insertion success */ 1727 uint64 num_elephants_detected; /* Total number of elephants that were 1728 detected */ 1729 } bcm_flowtracker_elephant_stats_t; 1730 1731 /* Initialize elephant statistics structure. */ 1732 extern void bcm_flowtracker_elephant_stats_t_init( 1733 bcm_flowtracker_elephant_stats_t *stats); 1734 1735 #ifndef BCM_HIDE_DISPATCHABLE 1736 1737 /* Set the elephant statistics */ 1738 extern int bcm_flowtracker_elephant_stats_set( 1739 int unit, 1740 bcm_flowtracker_elephant_stats_t *stats); 1741 1742 /* Get the elephant statistics */ 1743 extern int bcm_flowtracker_elephant_stats_get( 1744 int unit, 1745 bcm_flowtracker_elephant_stats_t *stats); 1746 1747 /* Get the instantaneous elephant statistics */ 1748 extern int bcm_flowtracker_elephant_stats_sync_get( 1749 int unit, 1750 bcm_flowtracker_elephant_stats_t *stats); 1751 1752 #endif /* BCM_HIDE_DISPATCHABLE */ 1753 1754 /* Flowtracker Chip Debug configuration. */ 1755 typedef struct bcm_flowtracker_chip_debug_info_s { 1756 bcm_flowtracker_tracking_param_type_t param; /* The attribute of flow on which 1757 debugging is enabled. */ 1758 uint32 count; /* Count of the pass events happened for 1759 a particular check. */ 1760 } bcm_flowtracker_chip_debug_info_t; 1761 1762 /* Initialize flowtracker Chip Debug information. */ 1763 extern void bcm_flowtracker_chip_debug_info_t_init( 1764 bcm_flowtracker_chip_debug_info_t *info); 1765 1766 #ifndef BCM_HIDE_DISPATCHABLE 1767 1768 /* Set tracking parameters debug information. */ 1769 extern int bcm_flowtracker_chip_debug_info_set( 1770 int unit, 1771 int num_debug_info, 1772 bcm_flowtracker_chip_debug_info_t *list_of_debug_info); 1773 1774 /* Get flowtracker tracking parameters debug information. */ 1775 extern int bcm_flowtracker_chip_debug_info_get( 1776 int unit, 1777 int max_debug_info_size, 1778 bcm_flowtracker_chip_debug_info_t *list_of_debug_info, 1779 int *actual_debug_info_size); 1780 1781 #endif /* BCM_HIDE_DISPATCHABLE */ 1782 1783 #endif /* __BCM_FLOWTRACKER_H__ */