openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

ifa.h (17226B)


      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_IFA_H__
     11 #define __BCM_IFA_H__
     12 
     13 #include <bcm/types.h>
     14 #include <bcm/collector.h>
     15 
     16 /* IFA configuration information data. */
     17 typedef struct bcm_ifa_config_info_s {
     18     uint32 probemarker_1;               /* INT header ProbeMarker1 Value. */
     19     uint32 probemarker_2;               /* INT header ProbeMarker2 Value. */
     20     uint32 device_id;                   /* Meta Data header Device ID. */
     21     uint16 max_payload_length;          /* INT header Maximum payload. */
     22     uint16 module_id;                   /* Meta Data header Module Id used to
     23                                            identify loopback source port
     24                                            information. */
     25     uint8 hop_limit;                    /* INT header Hop Limit condition. */
     26     uint16 rx_packet_payload_length;    /* Recieved packet payload length that
     27                                            can be sent to collector. */
     28     uint16 lb_port_1;                   /* Loopback port for IFA E_APP. */
     29     uint16 lb_port_2;                   /* Loopback port for IFA E_APP. */
     30     uint8 optional_headers;             /* Option to send with recieved packet
     31                                            headers. */
     32     uint8 true_hop_count;               /* Number of hops in the topology is
     33                                            greater than Hop limit,  IFA MD stack
     34                                            contains Hop limit number of MDs in
     35                                            MD stack. */
     36     uint8 template_id;                  /* Template id for IFA probe header */
     37     uint16 senders_handle;              /* Sender's Handle for Probe Header */
     38     uint16 rx_packet_export_max_length; /* Maximum length of the Rx pkt that
     39                                            needs to be exported to collector. */
     40 } bcm_ifa_config_info_t;
     41 
     42 /* IFA statistics information data. */
     43 typedef struct bcm_ifa_stat_info_s {
     44     uint32 rx_pkt_cnt;                  /* Number of packet recieved in FW. */
     45     uint32 tx_pkt_cnt;                  /* Number of packet transmitted from FW. */
     46     uint32 ifa_no_config_drop;          /* Number of pkt dropped due to missing
     47                                            configuration. */
     48     uint32 ifa_collector_not_present_drop; /* Number of pkt dropped due to missing
     49                                            collector configuration. */
     50     uint32 ifa_hop_cnt_invalid_drop;    /* Number of pkt dropped due to Hop
     51                                            count and Hop limit are out of order. */
     52     uint32 ifa_int_hdr_len_invalid_drop; /* Number of pkt dropped due to maximum
     53                                            length and current length are out of
     54                                            order. */
     55     uint32 ifa_pkt_size_invalid_drop;   /* Number of pkt dropped due to invalid
     56                                            packet size. */
     57     uint32 rx_pkt_length_exceed_max_drop_count; /* Number of Rx packets dropped due to
     58                                            its length exceeding the max length
     59                                            configured using the config property
     60                                            ifa_rx_pkt_max_length. */
     61     uint32 rx_pkt_parse_error_drop_count; /* Number of Rx packets dropped due to
     62                                            errors in parsing. */
     63     uint32 rx_pkt_unknown_namespace_drop_count; /* Number of Rx packets dropped as the
     64                                            namespace is unknown. */
     65     uint32 rx_pkt_excess_rate_drop_count; /* Number of Rx packets dropped as the
     66                                            incoming rate is too high to process. */
     67     uint32 tx_record_count;             /* Number of IFA records exported to
     68                                            collector. */
     69     uint32 tx_pkt_failure_count;        /* Number of Tx packets that could not
     70                                            be exported due to some failure. */
     71     uint32 ifa_template_not_present_drop; /* Number of packets dropped due to
     72                                            missing Template configuration. */
     73     uint32 ifa_incomplete_metadata_drop_count; /* Number of Rx packets dropped due to
     74                                            incomplete metadata stack. */
     75 } bcm_ifa_stat_info_t;
     76 
     77 /* 
     78  * Macros for bcm_ifa_collector_eth_header_t.vlan_tag_structure to
     79  * indicate the tag structure of vlans.
     80  */
     81 #define BCM_IFA_COLLECTOR_ETH_HDR_UNTAGGED  0x1        
     82 #define BCM_IFA_COLLECTOR_ETH_HDR_SINGLE_TAGGED 0x2        
     83 #define BCM_IFA_COLLECTOR_ETH_HDR_DOUBLE_TAGGED 0x3        
     84 
     85 /* 
     86  * Ethernet header in the encap used to send the IFA packet to the
     87  * collector.
     88  */
     89 typedef struct bcm_ifa_collector_eth_header_s {
     90     bcm_mac_t dst_mac; 
     91     bcm_mac_t src_mac; 
     92     uint8 vlan_tag_structure; 
     93     uint16 outer_tpid; 
     94     uint16 inner_tpid; 
     95     bcm_vlan_tag_t outer_vlan_tag; 
     96     bcm_vlan_tag_t inner_vlan_tag; 
     97 } bcm_ifa_collector_eth_header_t;
     98 
     99 /* IPv4 header in the encap used to send the IFA packet to the collector. */
    100 typedef struct bcm_ifa_collector_ipv4_header_s {
    101     bcm_ip_t src_ip; 
    102     bcm_ip_t dst_ip; 
    103     uint8 dscp; 
    104     uint8 ttl; 
    105 } bcm_ifa_collector_ipv4_header_t;
    106 
    107 /* IPv6 header in the encap used to send the IFA packet to the collector. */
    108 typedef struct bcm_ifa_collector_ipv6_header_s {
    109     bcm_ip6_t src_ip; 
    110     bcm_ip6_t dst_ip; 
    111     uint8 traffic_class; 
    112     uint32 flow_label; 
    113     uint8 hop_limit; 
    114 } bcm_ifa_collector_ipv6_header_t;
    115 
    116 /* UDP header in the encap used to send the IFA packet to the collector. */
    117 typedef struct bcm_ifa_collector_udp_header_s {
    118     bcm_l4_port_t src_port; 
    119     bcm_l4_port_t dst_port; 
    120 } bcm_ifa_collector_udp_header_t;
    121 
    122 /* Transport types that are supported for the collector */
    123 typedef enum bcm_ifa_collector_transport_type_e {
    124     bcmIfaCollectorTransportTypeIpv4Udp = 0, /* The encap will be of the format UDP
    125                                            over IPv4. */
    126     bcmIfaCollectorTransportTypeIpv6Udp = 1 /* The encap will be of the format UDP
    127                                            over IPv6. */
    128 } bcm_ifa_collector_transport_type_t;
    129 
    130 /* In-band flow analyzer collector information. */
    131 typedef struct bcm_ifa_collector_info_s {
    132     bcm_ifa_collector_transport_type_t transport_type; /* Transport type used for sending data
    133                                            to the collector. */
    134     bcm_ifa_collector_eth_header_t eth; /* Ethernet encapsulation of the packet
    135                                            sent to collector. */
    136     bcm_ifa_collector_ipv4_header_t ipv4; /* IPv4 encapsulation of the packet sent
    137                                            to collector. */
    138     bcm_ifa_collector_ipv6_header_t ipv6; /* IPv6 encapsulation of the packet sent
    139                                            to collector. */
    140     bcm_ifa_collector_udp_header_t udp; /* UDP encapsulation of the packet sent
    141                                            to collector. */
    142     uint16 mtu;                         /* The maximum packet length transmitted
    143                                            by collector. */
    144 } bcm_ifa_collector_info_t;
    145 
    146 #ifndef BCM_HIDE_DISPATCHABLE
    147 
    148 /* Initializes ifa subsystem. */
    149 extern int bcm_ifa_init(
    150     int unit);
    151 
    152 /* Detaches ifa subsystem. */
    153 extern int bcm_ifa_detach(
    154     int unit);
    155 
    156 #endif /* BCM_HIDE_DISPATCHABLE */
    157 
    158 /* 
    159  * Options that can be passed via options parameter during configuration
    160  * set.
    161  */
    162 #define BCM_IFA_CONFIG_ADD      (1 << 0)   /* Add configuration to transfer ifa
    163                                               information. */
    164 #define BCM_IFA_CONFIG_MODIFY   (1 << 1)   /* Update a configuration
    165                                               information. */
    166 #define BCM_IFA_CONFIG_CLEAR    (1 << 2)   /* Clear configuration information. */
    167 
    168 /* Options that can be passed via options parameter during collector set. */
    169 #define BCM_IFA_COLLECTOR_ADD       (1 << 0)   /* Add collector to transfer ifa
    170                                                   information. */
    171 #define BCM_IFA_COLLECTOR_MODIFY    (1 << 1)   /* Update a collector
    172                                                   information. */
    173 #define BCM_IFA_COLLECTOR_DETACH    (1 << 2)   /* Detach collector. */
    174 
    175 /* Software ID given for a IFA export template configuration. */
    176 typedef int bcm_ifa_export_template_t;
    177 
    178 #ifndef BCM_HIDE_DISPATCHABLE
    179 
    180 /* Create a In-band Flow Analyzer collector. */
    181 extern int bcm_ifa_collector_set(
    182     int unit, 
    183     uint32 options, 
    184     bcm_ifa_collector_info_t *collector_info);
    185 
    186 /* Get a In-band Flow Analyzer collector. */
    187 extern int bcm_ifa_collector_get(
    188     int unit, 
    189     bcm_ifa_collector_info_t *collector_info);
    190 
    191 /* Attach an In-band Flow Analyzer collector. */
    192 extern int bcm_ifa_collector_attach(
    193     int unit, 
    194     bcm_collector_t collector_id, 
    195     int export_profile_id, 
    196     bcm_ifa_export_template_t template_id);
    197 
    198 /* Get the attached In-band Flow Analyzer collector and export profile. */
    199 extern int bcm_ifa_collector_attach_get(
    200     int unit, 
    201     bcm_collector_t *collector_id, 
    202     int *export_profile_id, 
    203     bcm_ifa_export_template_t *template_id);
    204 
    205 /* Detach In-band Flow Analyzer collector. */
    206 extern int bcm_ifa_collector_detach(
    207     int unit, 
    208     bcm_collector_t collector_id, 
    209     int export_profile_id, 
    210     bcm_ifa_export_template_t template_id);
    211 
    212 /* Set a In-band Flow Analyzer configuration information. */
    213 extern int bcm_ifa_config_info_set(
    214     int unit, 
    215     uint32 options, 
    216     bcm_ifa_config_info_t *config_data);
    217 
    218 /* Get a In-band Flow Analyzer Configuration information. */
    219 extern int bcm_ifa_config_info_get(
    220     int unit, 
    221     bcm_ifa_config_info_t *config_data);
    222 
    223 /* In-band flow analyzer - IFA statistics information */
    224 extern int bcm_ifa_stat_info_get(
    225     int unit, 
    226     bcm_ifa_stat_info_t *stat_data);
    227 
    228 #endif /* BCM_HIDE_DISPATCHABLE */
    229 
    230 /* Initialize a config information structure. */
    231 extern void bcm_ifa_config_info_t_init(
    232     bcm_ifa_config_info_t *config_info);
    233 
    234 /* Initialize a collector information structure. */
    235 extern void bcm_ifa_collector_info_t_init(
    236     bcm_ifa_collector_info_t *collector_info);
    237 
    238 #ifndef BCM_HIDE_DISPATCHABLE
    239 
    240 /* In-band flow analyzer - IFA statistics information */
    241 extern int bcm_ifa_stat_info_set(
    242     int unit, 
    243     bcm_ifa_stat_info_t *stat_data);
    244 
    245 #endif /* BCM_HIDE_DISPATCHABLE */
    246 
    247 /* Maximum number of queues supported by IFA-CC Eapp. */
    248 #define BCM_IFA_CC_MAX_NUM_QUEUE    0x200      
    249 
    250 /* 
    251  * Macro for bcm_ifa_cc_config_info _t flag to indicate usage of
    252  * QUEUE_ID, INT_PRI and CLASS_ID.
    253  */
    254 #define BCM_IFA_CC_QUEUE_ID_INT_PRI         0x1        
    255 #define BCM_IFA_CC_QUEUE_ID_INT_PRI_CLASS_ID 0x2        
    256 
    257 /* IFA-CC Configuration information. */
    258 typedef struct bcm_ifa_cc_config_s {
    259     uint8 flag;                         /* Indicate usage of queue_id, int_pri
    260                                            and class_id. */
    261     uint16 num_gports;                  /* Number of gports to be monitor by
    262                                            IFA-CC App. */
    263     uint8 class_id[BCM_IFA_CC_MAX_NUM_QUEUE]; /* Array of Class_ID assicated with
    264                                            Queue ID. */
    265     uint16 int_pri[BCM_IFA_CC_MAX_NUM_QUEUE]; /* Array of INT_PRI assicated with Queue
    266                                            ID. */
    267     bcm_gport_t gport_list[BCM_IFA_CC_MAX_NUM_QUEUE]; /* Array of gports that are being
    268                                            monitored by IFA-CC App. */
    269 } bcm_ifa_cc_config_t;
    270 
    271 /* Initialize ifa cc config structure. */
    272 extern void bcm_ifa_cc_config_t_init(
    273     bcm_ifa_cc_config_t *config_info);
    274 
    275 #ifndef BCM_HIDE_DISPATCHABLE
    276 
    277 /* Set IFA-CC Configuration. */
    278 extern int bcm_ifa_cc_config_set(
    279     int unit, 
    280     bcm_ifa_cc_config_t *config_data);
    281 
    282 /* Get IFA-CC Configuration. */
    283 extern int bcm_ifa_cc_config_get(
    284     int unit, 
    285     bcm_ifa_cc_config_t *config_data);
    286 
    287 #endif /* BCM_HIDE_DISPATCHABLE */
    288 
    289 /* IFA export element flags. */
    290 #define BCM_IFA_EXPORT_ELEMENT_FLAGS_ENTERPRISE (1 << 0)   /* Indicates that the
    291                                                           element is an
    292                                                           enterprise specific
    293                                                           element */
    294 
    295 /* 
    296  * Options that can be passed via options parameter during export
    297  * template creation.
    298  */
    299 #define BCM_IFA_EXPORT_TEMPLATE_WITH_ID (1 << 0)   /* Create an export template
    300                                                       with ID. */
    301 
    302 /* The different export element types that constitute an template. */
    303 typedef enum bcm_ifa_export_element_type_e {
    304     bcmIfaExportElementTypeIFAHeaders = 0, /* IFA Base and MetaData headers */
    305     bcmIfaExportElementTypeMetadataStack = 1, /* IFA MetaData stack */
    306     bcmIfaExportElementTypePktData = 2, /* IFA RX Packet Headers and Data */
    307     bcmIfaExportElementTypeCount = 3 
    308 } bcm_ifa_export_element_type_t;
    309 
    310 /* IFA export template elements information. */
    311 typedef struct bcm_ifa_export_element_info_s {
    312     uint32 flags;                       /* See BCM_IFA_EXPORT_ELEMENT_FLAGS_XXX. */
    313     bcm_ifa_export_element_type_t element; /* Type of export element. */
    314     uint32 data_size;                   /* Size of information element in the
    315                                            export record in bytes. If the
    316                                            data_size is given as 0, then the
    317                                            default RFC size is used. */
    318     uint16 info_elem_id;                /* Information element to be used, when
    319                                            the template set is exported. */
    320 } bcm_ifa_export_element_info_t;
    321 
    322 /* IFA template set transmit configuration. */
    323 typedef struct bcm_ifa_template_transmit_config_s {
    324     int retransmit_interval_secs;   /* Interval in seconds at which the template
    325                                        set has to be transmitted. */
    326     int initial_burst;              /* Number of times the template set needs to
    327                                        be sent before settling to a periodic
    328                                        export. */
    329 } bcm_ifa_template_transmit_config_t;
    330 
    331 #ifndef BCM_HIDE_DISPATCHABLE
    332 
    333 /* Create a ifa export template. */
    334 extern int bcm_ifa_export_template_create(
    335     int unit, 
    336     uint32 options, 
    337     bcm_ifa_export_template_t *id, 
    338     uint16 set_id, 
    339     int num_export_elements, 
    340     bcm_ifa_export_element_info_t *list_of_export_elements);
    341 
    342 /* Get a ifa export template. */
    343 extern int bcm_ifa_export_template_get(
    344     int unit, 
    345     bcm_ifa_export_template_t id, 
    346     uint16 *set_id, 
    347     int max_size, 
    348     bcm_ifa_export_element_info_t *list_of_export_elements, 
    349     int *list_size);
    350 
    351 #endif /* BCM_HIDE_DISPATCHABLE */
    352 
    353 /* Initialize ifa template transmit configuration. */
    354 extern void bcm_ifa_template_transmit_config_t_init(
    355     bcm_ifa_template_transmit_config_t *config);
    356 
    357 #ifndef BCM_HIDE_DISPATCHABLE
    358 
    359 /* Destroy a ifa export template. */
    360 extern int bcm_ifa_export_template_destroy(
    361     int unit, 
    362     bcm_ifa_export_template_t id);
    363 
    364 /* Set the template transmit configuration. */
    365 extern int bcm_ifa_template_transmit_config_set(
    366     int unit, 
    367     bcm_ifa_export_template_t template_id, 
    368     bcm_collector_t collector_id, 
    369     bcm_ifa_template_transmit_config_t *config);
    370 
    371 /* Set the template transmit configuration. */
    372 extern int bcm_ifa_template_transmit_config_get(
    373     int unit, 
    374     bcm_ifa_export_template_t template_id, 
    375     bcm_collector_t collector_id, 
    376     bcm_ifa_template_transmit_config_t *config);
    377 
    378 #endif /* BCM_HIDE_DISPATCHABLE */
    379 
    380 /* 
    381  * Options that can be passed via options parameter during IFA header
    382  * creation.
    383  */
    384 #define BCM_IFA_HEADER_OPTIONS_WITH_ID  (1 << 0)   /* Create the IFA header with
    385                                                       ID. */
    386 #define BCM_IFA_HEADER_OPTIONS_REPLACE  (1 << 1)   /* Replace the IFA header. */
    387 
    388 /* IFA header data. */
    389 typedef struct bcm_ifa_header_s {
    390     uint8 ip_protocol;  /* IP protocol to indicate IFA. */
    391     uint8 max_length;   /* The max length in the IFA base header. */
    392     uint8 hop_limit;    /* The hop limit in the IFA metadata header. */
    393 } bcm_ifa_header_t;
    394 
    395 /* IFA header data callback function prototype. */
    396 typedef int(*bcm_ifa_header_traverse_cb)(
    397     int unit, 
    398     int *header_id, 
    399     bcm_ifa_header_t *header, 
    400     void *user_data);
    401 
    402 /* Initialize the bcm_ifa_header_t struct. */
    403 extern void bcm_ifa_header_t_init(
    404     bcm_ifa_header_t *header);
    405 
    406 #ifndef BCM_HIDE_DISPATCHABLE
    407 
    408 /* Create the IFA header. */
    409 extern int bcm_ifa_header_create(
    410     int unit, 
    411     uint32 options, 
    412     int *header_id, 
    413     bcm_ifa_header_t *header);
    414 
    415 /* Get the IFA header. */
    416 extern int bcm_ifa_header_get(
    417     int unit, 
    418     int header_id, 
    419     bcm_ifa_header_t *header);
    420 
    421 /* Destroy the IFA header. */
    422 extern int bcm_ifa_header_destroy(
    423     int unit, 
    424     int header_id);
    425 
    426 /* Traverse all IFA headers. */
    427 extern int bcm_ifa_header_traverse(
    428     int unit, 
    429     bcm_ifa_header_traverse_cb cb, 
    430     void *user_data);
    431 
    432 #endif /* BCM_HIDE_DISPATCHABLE */
    433 
    434 #endif /* __BCM_IFA_H__ */