ipfix.h (13470B)
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_IPFIX_H__ 14 #define __BCM_IPFIX_H__ 15 16 #include <bcm/types.h> 17 18 #define BCM_IPFIX_DSCP_MASK_COUNT 64 19 20 typedef enum bcm_ipfix_stage_e { 21 BCM_IPFIX_STAGE_INGRESS = 0, 22 BCM_IPFIX_STAGE_EGRESS = 1 23 } bcm_ipfix_stage_t; 24 25 /* Flags for bcm_ipfix_data_t.flags. */ 26 #define BCM_IPFIX_DATA_VLAN_TAGGED 0x0001 27 #define BCM_IPFIX_DATA_TYPE_L2 0x0002 28 #define BCM_IPFIX_DATA_TYPE_IP4 0x0004 29 #define BCM_IPFIX_DATA_TYPE_IP6 0x0008 30 #define BCM_IPFIX_DATA_REASON_FLOW_TIMEOUT 0x0010 31 #define BCM_IPFIX_DATA_REASON_FLOW_END 0x0020 32 #define BCM_IPFIX_DATA_REASON_FLOW 0x0040 33 #define BCM_IPFIX_DATA_REASON_COUNT 0x0080 34 #define BCM_IPFIX_DATA_REASON_TIMESTAMP 0x0100 35 #define BCM_IPFIX_DATA_RATE_VIOLATION 0x0200 36 #define BCM_IPFIX_DATA_NON_FRAGMENT_PKT_DETECTED 0x0400 37 #define BCM_IPFIX_DATA_FRAGMENT_PKT_DETECTED 0x0800 38 #define BCM_IPFIX_DATA_TTL_CHANGED_DETECTED 0x1000 39 #define BCM_IPFIX_DATA_DROP_DETECTED 0x2000 40 #define BCM_IPFIX_DATA_TYPE_MASK 0x000e 41 #define BCM_IPFIX_DATA_REASON_MASK 0x01f0 42 43 /* Export data structure */ 44 typedef struct bcm_ipfix_data_s { 45 bcm_ipfix_stage_t stage; /* Ingress or egress. */ 46 uint32 flags; /* Type and reason. */ 47 bcm_port_t port; /* port. */ 48 bcm_vlan_t vlan; /* L2: VLAN identifier. */ 49 uint16 vlan_prio; /* L2: VLAN priority. */ 50 uint16 ether_type; /* L2: type in ethernet II frame or 802.1Q 51 tag. */ 52 bcm_mac_t src_mac_addr; /* L2: source MAC address. */ 53 bcm_mac_t dst_mac_addr; /* L2: destination MAC address. */ 54 bcm_ip_t src_ip4_addr; /* IPv4: source IP address. */ 55 bcm_ip_t dst_ip4_addr; /* IPv4: destination IP address. */ 56 bcm_ip6_t src_ip6_addr; /* IPv6: source IP address. */ 57 bcm_ip6_t dst_ip6_addr; /* IPv6: destination IP address. */ 58 uint16 ip_protocol; /* IPv4: protocol; IPv6: next header. */ 59 uint16 tos; /* IPv4: type of service; IPv6: traffic 60 class. */ 61 uint32 ip6_flow_label; /* IPv6: flow label. */ 62 uint16 l4_src_port; /* First 16 bits of L4 header such as TCP 63 source port or ICMP type and code. */ 64 uint16 l4_dst_port; /* Second 16 bits of L4 header such as TCP 65 destination port. */ 66 bcm_gport_t source_port; /* Source port. */ 67 uint32 start_timestamp; /* Session information. */ 68 uint32 last_timestamp; /* Session information. */ 69 uint32 byte_count; /* Session information. */ 70 uint32 pkt_count; /* Session information. */ 71 uint32 ttl; /* TTL value of the first packet. */ 72 uint32 tcp_flags; /* TCP flags. */ 73 bcm_gport_t dest_port; /* Destination. */ 74 bcm_vlan_t egress_vlan; /* Egress VLAN. */ 75 bcm_multicast_t dest_multicast; /* Destination multicast group. */ 76 } bcm_ipfix_data_t; 77 78 /* Flags for bcm_ipfix_config_t.flags. */ 79 #define BCM_IPFIX_CONFIG_ENABLE_NON_IP 0x00000001 80 #define BCM_IPFIX_CONFIG_ENABLE_IP4 0x00000002 81 #define BCM_IPFIX_CONFIG_ENABLE_IP6 0x00000004 82 #define BCM_IPFIX_CONFIG_TCP_END_DETECT 0x00000008 83 #define BCM_IPFIX_CONFIG_RECORD_NON_DISCARD_PKT 0x00000010 84 #define BCM_IPFIX_CONFIG_RECORD_DISCARD_PKT 0x00000020 85 #define BCM_IPFIX_CONFIG_KEY_IP4_USE_L2 0x00000040 86 #define BCM_IPFIX_CONFIG_KEY_IP6_USE_L2 0x00000080 87 #define BCM_IPFIX_CONFIG_KEY_SRC_IP 0x00000100 88 #define BCM_IPFIX_CONFIG_KEY_DST_IP 0x00000200 89 #define BCM_IPFIX_CONFIG_KEY_IP_PROT 0x00000400 90 #define BCM_IPFIX_CONFIG_KEY_IP_DSCP 0x00000800 91 #define BCM_IPFIX_CONFIG_KEY_IP_ECN 0x00001000 92 #define BCM_IPFIX_CONFIG_KEY_L4_SRC_PORT 0x00002000 93 #define BCM_IPFIX_CONFIG_KEY_L4_DST_PORT 0x00004000 94 #define BCM_IPFIX_CONFIG_KEY_IP6_FLOW 0x00008000 95 #define BCM_IPFIX_CONFIG_KEY_ICMP_TYPE 0x00010000 96 #define BCM_IPFIX_CONFIG_KEY_ICMP_CODE 0x00020000 97 #define BCM_IPFIX_CONFIG_KEY_MACDA 0x00040000 98 #define BCM_IPFIX_CONFIG_KEY_MACSA 0x00080000 99 #define BCM_IPFIX_CONFIG_KEY_VLAN_ID 0x00100000 100 #define BCM_IPFIX_CONFIG_KEY_VLAN_PRI 0x00200000 101 #define BCM_IPFIX_CONFIG_KEY_ETHER_TYPE 0x00400000 102 #define BCM_IPFIX_CONFIG_KEY_VLAN_TAGGED 0x00800000 103 #define BCM_IPFIX_CONFIG_TCP_FLAGS_LAST 0x01000000 104 #define BCM_IPFIX_CONFIG_KEY_SOURCE_PORT_OR_INTERFACE 0x02000000 105 #define BCM_IPFIX_CONFIG_ENABLE_MASK 0x00000007 106 #define BCM_IPFIX_CONFIG_KEY_MASK 0x02ffffc0 107 108 /* IPFIX port configuration structure */ 109 typedef struct bcm_ipfix_config_s { 110 uint32 flags; /* Fields select and other flags. */ 111 uint8 dscp_mask[BCM_IPFIX_DSCP_MASK_COUNT]; /* DSCP value translation mapping. */ 112 bcm_ip_t src_ip4_mask; /* Mask to map IPv4 address to key 113 value. */ 114 bcm_ip_t dst_ip4_mask; /* Mask to map IPv4 address to key 115 value. */ 116 bcm_ip_t tunnel_src_ip4_mask; /* Mask to map IPv4 address to key 117 value. */ 118 bcm_ip_t tunnel_dst_ip4_mask; /* Mask to map IPv4 address to key 119 value. */ 120 bcm_ip6_t src_ip6_mask; /* Mask to map IPv6 address to key 121 value. */ 122 bcm_ip6_t dst_ip6_mask; /* Mask to map IPv6 address to key 123 value. */ 124 bcm_ip6_t tunnel_src_ip6_mask; /* Mask to map IPv6 address to key 125 value. */ 126 bcm_ip6_t tunnel_dst_ip6_mask; /* Mask to map IPv6 address to key 127 value. */ 128 uint32 entry_limit; /* Maximum number of flow entry 129 collected for the port. */ 130 uint32 min_time; /* The flow will not be exported unless 131 the flow has been established for 132 more than min_time (unit is 10 ms). */ 133 uint32 max_time; /* The flow will not be exported unless 134 the flow has been established for 135 less than max_time (unit is 10 ms). */ 136 uint32 max_idle_time; /* The flow will be exported and 137 terminated if idle for more than 138 max_idle_time (unit is 10 ms). */ 139 uint32 sample_rate; /* Collect one packet info for every 140 sample_rate packets. */ 141 } bcm_ipfix_config_t; 142 143 /* bcm_ipfix_callback_t */ 144 typedef void (*bcm_ipfix_callback_t)( 145 int unit, 146 bcm_ipfix_data_t *info, 147 void *userdata); 148 149 /* Flags for bcm_ipfix_rate_t.flags */ 150 #define BCM_IPFIX_RATE_VIOLATION_WITH_ID 0x00000001 151 #define BCM_IPFIX_RATE_VIOLATION_REPLACE 0x00000002 152 #define BCM_IPFIX_RATE_VIOLATION_DROP 0x00000004 153 #define BCM_IPFIX_RATE_VIOLATION_COPY_TO_CPU 0x00000008 154 #define BCM_IPFIX_RATE_VIOLATION_DSCP_SET 0x00000010 155 #define BCM_IPFIX_RATE_VIOLATION_COLOR_SET 0x00000020 156 #define BCM_IPFIX_RATE_VIOLATION_PKT_PRI_SET 0x00000040 157 #define BCM_IPFIX_RATE_VIOLATION_INT_PRI_SET 0x00000080 158 159 /* Flow rate meter entry */ 160 typedef struct bcm_ipfix_rate_s { 161 bcm_ipfix_rate_id_t rate_id; /* Flow rate meter id. */ 162 uint32 flags; /* Configuration flags. */ 163 uint32 count; /* Flow count (for get only). */ 164 uint32 limit; /* Max number of good flows to allow. */ 165 uint32 rate; /* Number of good flows per second. */ 166 uint8 dscp; /* New DSCP value. */ 167 bcm_color_t color; /* New color value. */ 168 int pkt_pri; /* New packet priority. */ 169 int int_pri; /* New internal priority. */ 170 } bcm_ipfix_rate_t; 171 172 /* Flags for bcm_ipfix_mirror_config_t.flags. */ 173 #define BCM_IPFIX_MIRROR_CONFIG_TTL_OFFSET_MAX 0x0001 174 #define BCM_IPFIX_MIRROR_CONFIG_FRAGMENT 0x0002 175 #define BCM_IPFIX_MIRROR_CONFIG_NON_FRAGMENT 0x0004 176 177 /* IPFIX port mirror configuration */ 178 typedef struct bcm_ipfix_mirror_config_s { 179 uint32 flags; /* Configuration flags. */ 180 uint32 pkt_count; /* Number of packets to be mirrored. */ 181 uint8 tcp_flags_mask; /* TCP flags mask to determine if the packet will be 182 mirrored. */ 183 uint8 ttl_offset_max; /* Max TTL offset allowance to be mirrored. */ 184 } bcm_ipfix_mirror_config_t; 185 186 /* bcm_ipfix_config_t_init */ 187 extern void bcm_ipfix_config_t_init( 188 bcm_ipfix_config_t *config); 189 190 /* bcm_ipfix_rate_t_init */ 191 extern void bcm_ipfix_rate_t_init( 192 bcm_ipfix_rate_t *rate); 193 194 /* bcm_ipfix_mirror_config_t_init */ 195 extern void bcm_ipfix_mirror_config_t_init( 196 bcm_ipfix_mirror_config_t *config); 197 198 #ifndef BCM_HIDE_DISPATCHABLE 199 200 /* bcm_ipfix_register */ 201 extern int bcm_ipfix_register( 202 int unit, 203 bcm_ipfix_callback_t callback, 204 void *userdata); 205 206 /* bcm_ipfix_unregister */ 207 extern int bcm_ipfix_unregister( 208 int unit, 209 bcm_ipfix_callback_t callback, 210 void *userdata); 211 212 /* bcm_ipfix_config_set */ 213 extern int bcm_ipfix_config_set( 214 int unit, 215 bcm_ipfix_stage_t stage, 216 bcm_port_t port, 217 bcm_ipfix_config_t *config); 218 219 /* bcm_ipfix_config_get */ 220 extern int bcm_ipfix_config_get( 221 int unit, 222 bcm_ipfix_stage_t stage, 223 bcm_port_t port, 224 bcm_ipfix_config_t *config); 225 226 /* Add an IPFIX flow rate meter entry */ 227 extern int bcm_ipfix_rate_create( 228 int unit, 229 bcm_ipfix_rate_t *rate_info); 230 231 /* Delete an IPFIX flow rate meter entry */ 232 extern int bcm_ipfix_rate_destroy( 233 int unit, 234 bcm_ipfix_rate_id_t rate_id); 235 236 /* Get IPFIX flow rate meter entry for the specified id */ 237 extern int bcm_ipfix_rate_get( 238 int unit, 239 bcm_ipfix_rate_t *rate_info); 240 241 #endif /* BCM_HIDE_DISPATCHABLE */ 242 243 /* IPFIX flow rate meter entry traverse callback function */ 244 typedef int (*bcm_ipfix_rate_traverse_cb)( 245 int unit, 246 bcm_ipfix_rate_t *rate_info, 247 void *userdata); 248 249 #ifndef BCM_HIDE_DISPATCHABLE 250 251 /* Traverse through IPFIX flow rate meter entries */ 252 extern int bcm_ipfix_rate_traverse( 253 int unit, 254 bcm_ipfix_rate_traverse_cb cb, 255 void *userdata); 256 257 /* Delete all IPFIX flow rate meter entries */ 258 extern int bcm_ipfix_rate_destroy_all( 259 int unit); 260 261 /* Add a mirror destination to the IPFIX flow rate meter entry */ 262 extern int bcm_ipfix_rate_mirror_add( 263 int unit, 264 bcm_ipfix_rate_id_t rate_id, 265 bcm_gport_t mirror_dest_id); 266 267 /* Delete a mirror destination from the IPFIX flow rate meter entry */ 268 extern int bcm_ipfix_rate_mirror_delete( 269 int unit, 270 bcm_ipfix_rate_id_t rate_id, 271 bcm_gport_t mirror_dest_id); 272 273 /* 274 * Delete all mirror destination associated to the IPFIX flow rate meter 275 * entry 276 */ 277 extern int bcm_ipfix_rate_mirror_delete_all( 278 int unit, 279 bcm_ipfix_rate_id_t rate_id); 280 281 /* Get all mirror destination from the IPFIX flow rate meter entry */ 282 extern int bcm_ipfix_rate_mirror_get( 283 int unit, 284 bcm_ipfix_rate_id_t rate_id, 285 int mirror_dest_size, 286 bcm_gport_t *mirror_dest_id, 287 int *mirror_dest_count); 288 289 /* Set IPFIX mirror control configuration of the specified port */ 290 extern int bcm_ipfix_mirror_config_set( 291 int unit, 292 bcm_ipfix_stage_t stage, 293 bcm_gport_t port, 294 bcm_ipfix_mirror_config_t *config); 295 296 /* Get all IPFIX mirror control configuration of the specified port */ 297 extern int bcm_ipfix_mirror_config_get( 298 int unit, 299 bcm_ipfix_stage_t stage, 300 bcm_gport_t port, 301 bcm_ipfix_mirror_config_t *config); 302 303 /* Add an IPFIX mirror destination to the specified port */ 304 extern int bcm_ipfix_mirror_port_dest_add( 305 int unit, 306 bcm_ipfix_stage_t stage, 307 bcm_gport_t port, 308 bcm_gport_t mirror_dest_id); 309 310 /* Delete an IPFIX mirror destination from the specified port */ 311 extern int bcm_ipfix_mirror_port_dest_delete( 312 int unit, 313 bcm_ipfix_stage_t stage, 314 bcm_gport_t port, 315 bcm_gport_t mirror_dest_id); 316 317 /* Delete all IPFIX mirror destination from the specified port */ 318 extern int bcm_ipfix_mirror_port_dest_delete_all( 319 int unit, 320 bcm_ipfix_stage_t stage, 321 bcm_gport_t port); 322 323 /* Get IPFIX mirror destination of the specified port */ 324 extern int bcm_ipfix_mirror_port_dest_get( 325 int unit, 326 bcm_ipfix_stage_t stage, 327 bcm_gport_t port, 328 int mirror_dest_size, 329 bcm_gport_t *mirror_dest_id, 330 int *mirror_dest_count); 331 332 #endif /* BCM_HIDE_DISPATCHABLE */ 333 334 #endif /* __BCM_IPFIX_H__ */