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

flow.h (42359B)


      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_FLOW_H__
     14 #define __BCM_FLOW_H__
     15 
     16 #include <bcm/types.h>
     17 #include <bcm/l3.h>
     18 #include <bcm/tunnel.h>
     19 #include <bcm/vlan.h>
     20 
     21 /* flow handle */
     22 typedef uint32 bcm_flow_handle_t;
     23 
     24 /* flow option ID */
     25 typedef uint32 bcm_flow_option_id_t;
     26 
     27 /* flow field ID */
     28 typedef uint32 bcm_flow_field_id_t;
     29 
     30 #if defined(INCLUDE_L3)
     31 /* initialize the bcm_flow_logical_field_t structure. */
     32 extern void bcm_flow_logical_field_t_init(
     33     bcm_flow_logical_field_t *logical_field);
     34 #endif
     35 
     36 #if defined(INCLUDE_L3)
     37 /* Flow match options */
     38 #define BCM_FLOW_MATCH_OPTION_REPLACE   (1 << 1)   /* replace object attributes
     39                                                       for a match criteria. */
     40 #endif
     41 
     42 #if defined(INCLUDE_L3)
     43 /* Flow match valid elements. */
     44 #define BCM_FLOW_MATCH_VNID_VALID           (1 << 0)   /* VN_ID element is valid
     45                                                           for this match. */
     46 #define BCM_FLOW_MATCH_VLAN_VALID           (1 << 1)   /* vlan element valid. */
     47 #define BCM_FLOW_MATCH_INNER_VLAN_VALID     (1 << 2)   /* inner vlan element
     48                                                           valid. */
     49 #define BCM_FLOW_MATCH_PORT_VALID           (1 << 3)   /* port element valid. */
     50 #define BCM_FLOW_MATCH_SIP_VALID            (1 << 4)   /* source IPv4 address
     51                                                           element valid. */
     52 #define BCM_FLOW_MATCH_SIP_V6_VALID         (1 << 5)   /* source IPv6 address
     53                                                           element valid. */
     54 #define BCM_FLOW_MATCH_DIP_VALID            (1 << 6)   /* destination IPv4
     55                                                           address element valid. */
     56 #define BCM_FLOW_MATCH_DIP_V6_VALID         (1 << 7)   /* destination IPv6
     57                                                           address element valid. */
     58 #define BCM_FLOW_MATCH_VPN_VALID            (1 << 8)   /* VPN element valid. */
     59 #define BCM_FLOW_MATCH_FLOW_PORT_VALID      (1 << 9)   /* flow port element
     60                                                           valid. */
     61 #define BCM_FLOW_MATCH_IIF_VALID            (1 << 10)  /* iif element valid. */
     62 #define BCM_FLOW_MATCH_FLEX_KEY_VALID       (1 << 11)  /* logical field elements
     63                                                           for key valid. */
     64 #define BCM_FLOW_MATCH_FLEX_DATA_VALID      (1 << 12)  /* logical field elements
     65                                                           for data valid. */
     66 #define BCM_FLOW_MATCH_UDP_SRC_PORT_VALID   (1 << 13)  /* udp source port field
     67                                                           valid. */
     68 #define BCM_FLOW_MATCH_UDP_DST_PORT_VALID   (1 << 14)  /* udp destination port
     69                                                           field valid. */
     70 #define BCM_FLOW_MATCH_PROTOCOL_VALID       (1 << 15)  /* protocol field valid. */
     71 #define BCM_FLOW_MATCH_MPLS_LABEL_VALID     (1 << 16)  /*  mpls label field
     72                                                           valid. */
     73 #endif
     74 
     75 #if defined(INCLUDE_L3)
     76 /* flow match criteria. */
     77 typedef enum bcm_flow_match_criteria_e {
     78     BCM_FLOW_MATCH_CRITERIA_INVALID = 0, /* Illegal. */
     79     BCM_FLOW_MATCH_CRITERIA_PORT = 1,   /* {Module, Port} or Trunk. */
     80     BCM_FLOW_MATCH_CRITERIA_PORT_VLAN = 2, /* Mod/port/trunk + outer VLAN. */
     81     BCM_FLOW_MATCH_CRITERIA_PORT_INNER_VLAN = 3, /* Mod/port/trunk + inner VLAN. */
     82     BCM_FLOW_MATCH_CRITERIA_PORT_VLAN_STACKED = 4, /* Mod/port/trunk + outer/inner VLAN. */
     83     BCM_FLOW_MATCH_CRITERIA_VLAN_PRI = 5, /* Mod/port/trunk + VLAN-PRI + VLAN-CFI. */
     84     BCM_FLOW_MATCH_CRITERIA_VN_ID = 6,  /* Match VN_ID */
     85     BCM_FLOW_MATCH_CRITERIA_SIP = 7,    /* Match source IP address */
     86     BCM_FLOW_MATCH_CRITERIA_SIP_VNID = 8, /* Match source IP address and vn_id */
     87     BCM_FLOW_MATCH_CRITERIA_FLEX = 9,   /* Match key specified in logical fields */
     88     BCM_FLOW_MATCH_CRITERIA_MPLS_LABEL = 10, /* Match MPLS label */
     89     BCM_FLOW_MATCH_CRITERIA_COUNT = 11  /* Must be last. */
     90 } bcm_flow_match_criteria_t;
     91 #endif
     92 
     93 #if defined(INCLUDE_L3)
     94 /* Flow match config structure */
     95 typedef struct bcm_flow_match_config_s {
     96     uint32 vnid;                        /* VN_ID. */
     97     bcm_vlan_t vlan;                    /* Outer VLAN ID to match. */
     98     bcm_vlan_t inner_vlan;              /* Inner VLAN ID to match. */
     99     bcm_gport_t port;                   /* Match port / trunk */
    100     bcm_ip_t sip;                       /* source IPv4 address */
    101     bcm_ip_t sip_mask;                  /* source IPv4 address mask */
    102     bcm_ip6_t sip6;                     /* source IPv6 address */
    103     bcm_ip6_t sip6_mask;                /* source IPv6 address mask */
    104     bcm_ip_t dip;                       /* destination IPv4 address */
    105     bcm_ip_t dip_mask;                  /* destination IPv4 address mask */
    106     bcm_ip6_t dip6;                     /* destination IPv6 address */
    107     bcm_ip6_t dip6_mask;                /* destination IPv6 address mask */
    108     uint16 udp_dst_port;                /* udp destination port. */
    109     uint16 udp_src_port;                /* udp source port. */
    110     uint16 protocol;                    /* IP protocol type. */
    111     bcm_mpls_label_t mpls_label;        /* MPLS label. */
    112     bcm_gport_t flow_port;              /* flow port id representing a SVP */
    113     bcm_vpn_t vpn;                      /* VPN representing a vfi or vrf */
    114     bcm_if_t intf_id;                   /* l3 interface id */
    115     uint32 options;                     /* BCM_FLOW_MATCH_OPTION_xxx. */
    116     bcm_flow_match_criteria_t criteria; /* flow match criteria. */
    117     uint32 valid_elements;              /* bitmap of valid fields for the match
    118                                            action */
    119     bcm_flow_handle_t flow_handle;      /* flow handle derived from flow name */
    120     uint32 flow_option;                 /* flow option derived from flow option
    121                                            name */
    122 } bcm_flow_match_config_t;
    123 #endif
    124 
    125 /* bcm_flow_match_traverse callback */
    126 #if defined(INCLUDE_L3)
    127 typedef int (*bcm_flow_match_traverse_cb)(
    128     int unit, 
    129     bcm_flow_match_config_t *info, 
    130     uint32 num_of_fields, 
    131     bcm_flow_logical_field_t *field, 
    132     void *user_data);
    133 #endif
    134 
    135 #if defined(INCLUDE_L3)
    136 /* initialize the bcm_flow_match_config_t structure. */
    137 extern void bcm_flow_match_config_t_init(
    138     bcm_flow_match_config_t *flow_match);
    139 #endif
    140 
    141 #ifndef BCM_HIDE_DISPATCHABLE
    142 
    143 #if defined(INCLUDE_L3)
    144 /* Add a flow match rule. */
    145 extern int bcm_flow_match_add(
    146     int unit, 
    147     bcm_flow_match_config_t *info, 
    148     uint32 num_of_fields, 
    149     bcm_flow_logical_field_t *field);
    150 #endif
    151 
    152 #if defined(INCLUDE_L3)
    153 /* Delete a flow match rule on the given match key. */
    154 extern int bcm_flow_match_delete(
    155     int unit, 
    156     bcm_flow_match_config_t *info, 
    157     uint32 num_of_fields, 
    158     bcm_flow_logical_field_t *field);
    159 #endif
    160 
    161 #if defined(INCLUDE_L3)
    162 /* Get the match attributes on the given match key. */
    163 extern int bcm_flow_match_get(
    164     int unit, 
    165     bcm_flow_match_config_t *info, 
    166     uint32 num_of_fields, 
    167     bcm_flow_logical_field_t *field);
    168 #endif
    169 
    170 #if defined(INCLUDE_L3)
    171 /* Traverse match entries. */
    172 extern int bcm_flow_match_traverse(
    173     int unit, 
    174     bcm_flow_match_traverse_cb cb, 
    175     void *user_data);
    176 #endif
    177 
    178 #endif /* BCM_HIDE_DISPATCHABLE */
    179 
    180 #if defined(INCLUDE_L3)
    181 /* Flow tunnel initiator valid elements. */
    182 #define BCM_FLOW_TUNNEL_INIT_TTL_VALID      (1 << 0)   
    183 #define BCM_FLOW_TUNNEL_INIT_DMAC_VALID     (1 << 1)   
    184 #define BCM_FLOW_TUNNEL_INIT_DIP_VALID      (1 << 2)   
    185 #define BCM_FLOW_TUNNEL_INIT_SIP_VALID      (1 << 3)   
    186 #define BCM_FLOW_TUNNEL_INIT_SIP6_VALID     (1 << 4)   
    187 #define BCM_FLOW_TUNNEL_INIT_DIP6_VALID     (1 << 5)   
    188 #define BCM_FLOW_TUNNEL_INIT_FLOW_LABEL_VALID (1 << 6)   
    189 #define BCM_FLOW_TUNNEL_INIT_DSCP_VALID     (1 << 7)   
    190 #define BCM_FLOW_TUNNEL_INIT_UDP_SPORT_VALID (1 << 8)   
    191 #define BCM_FLOW_TUNNEL_INIT_UDP_DPORT_VALID (1 << 9)   
    192 #define BCM_FLOW_TUNNEL_INIT_SMAC_VALID     (1 << 10)  
    193 #define BCM_FLOW_TUNNEL_INIT_VLAN_VALID     (1 << 11)  
    194 #define BCM_FLOW_TUNNEL_INIT_TPID_VALID     (1 << 12)  
    195 #define BCM_FLOW_TUNNEL_INIT_PKT_PRI_VALID  (1 << 13)  
    196 #define BCM_FLOW_TUNNEL_INIT_PKT_CFI_VALID  (1 << 14)  
    197 #define BCM_FLOW_TUNNEL_INIT_IP4_ID_VALID   (1 << 15)  
    198 #define BCM_FLOW_TUNNEL_INIT_FLEX_VALID     (1 << 16)  
    199 #endif
    200 
    201 #if defined(INCLUDE_L3)
    202 /* Flow tunneling initiator structure. */
    203 typedef struct bcm_flow_tunnel_initiator_s {
    204     uint32 flags;                       /* Configuration flags. */
    205     bcm_tunnel_type_t type;             /* Tunnel type. */
    206     int ttl;                            /* Tunnel header TTL. */
    207     bcm_mac_t dmac;                     /* Destination MAC address. */
    208     bcm_ip_t dip;                       /* Tunnel header DIP (IPv4). */
    209     bcm_ip_t sip;                       /* Tunnel header SIP (IPv4). */
    210     bcm_ip6_t sip6;                     /* Tunnel header SIP (IPv6). */
    211     bcm_ip6_t dip6;                     /* Tunnel header DIP (IPv6). */
    212     uint32 flow_label;                  /* Tunnel header flow label (IPv6). */
    213     bcm_tunnel_dscp_select_t dscp_sel;  /* Tunnel header DSCP select. */
    214     int dscp;                           /* Tunnel header DSCP value. */
    215     int dscp_map;                       /* DSCP-map ID. */
    216     bcm_gport_t tunnel_id;              /* Tunnel ID */
    217     uint16 udp_dst_port;                /* Destination UDP port */
    218     uint16 udp_src_port;                /* Source UDP port */
    219     bcm_mac_t smac;                     /* Src MAC */
    220     bcm_vlan_t vlan;                    /* Tunnel VLAN */
    221     uint16 tpid;                        /* Tunnel TPID */
    222     uint8 pkt_pri;                      /* Tunnel priority */
    223     uint8 pkt_cfi;                      /* Tunnel CFI */
    224     uint16 ip4_id;                      /* IPv4 ID. */
    225     bcm_if_t l3_intf_id;                /* l3 Interface ID. */
    226     bcm_gport_t flow_port;              /* Flow port ID */
    227     uint32 valid_elements;              /* bitmap of valid fields */
    228     uint32 flow_handle;                 /* flow handle */
    229     uint32 flow_option;                 /* flow option */
    230 } bcm_flow_tunnel_initiator_t;
    231 #endif
    232 
    233 #if defined(INCLUDE_L3)
    234 /* Initialize a bcm_flow_tunnel_initiator_t structure. */
    235 extern void bcm_flow_tunnel_initiator_t_init(
    236     bcm_flow_tunnel_initiator_t *info);
    237 #endif
    238 
    239 #ifndef BCM_HIDE_DISPATCHABLE
    240 
    241 #if defined(INCLUDE_L3)
    242 /* Create Flow Tunnel Initiator */
    243 extern int bcm_flow_tunnel_initiator_create(
    244     int unit, 
    245     bcm_flow_tunnel_initiator_t *info, 
    246     uint32 num_of_fields, 
    247     bcm_flow_logical_field_t *field);
    248 #endif
    249 
    250 #if defined(INCLUDE_L3)
    251 /* Delete Flow Tunnel Initiator */
    252 extern int bcm_flow_tunnel_initiator_destroy(
    253     int unit, 
    254     bcm_gport_t flow_tunnel_id);
    255 #endif
    256 
    257 #if defined(INCLUDE_L3)
    258 /* Get the Flow Tunnel Initiator based on the tunnelId */
    259 extern int bcm_flow_tunnel_initiator_get(
    260     int unit, 
    261     bcm_flow_tunnel_initiator_t *info, 
    262     uint32 num_of_fields, 
    263     bcm_flow_logical_field_t *field);
    264 #endif
    265 
    266 #endif /* BCM_HIDE_DISPATCHABLE */
    267 
    268 /* bcm_flow_tunnel_initiator_traverse callback */
    269 #if defined(INCLUDE_L3)
    270 typedef int (*bcm_flow_tunnel_initiator_traverse_cb)(
    271     int unit, 
    272     bcm_flow_tunnel_initiator_t *info, 
    273     uint32 num_of_fields, 
    274     bcm_flow_logical_field_t *field, 
    275     void *user_data);
    276 #endif
    277 
    278 #ifndef BCM_HIDE_DISPATCHABLE
    279 
    280 #if defined(INCLUDE_L3)
    281 /* traverse flow tunnel initiator entries. */
    282 extern int bcm_flow_tunnel_initiator_traverse(
    283     int unit, 
    284     bcm_flow_tunnel_initiator_traverse_cb cb, 
    285     void *user_data);
    286 #endif
    287 
    288 #endif /* BCM_HIDE_DISPATCHABLE */
    289 
    290 #if defined(INCLUDE_L3)
    291 /* Flow tunnel terminator valid elements. */
    292 #define BCM_FLOW_TUNNEL_TERM_VRF_VALID      (1 << 0)   
    293 #define BCM_FLOW_TUNNEL_TERM_SIP_VALID      (1 << 1)   
    294 #define BCM_FLOW_TUNNEL_TERM_DIP_VALID      (1 << 2)   
    295 #define BCM_FLOW_TUNNEL_TERM_SIP_MASK_VALID (1 << 3)   
    296 #define BCM_FLOW_TUNNEL_TERM_DIP_MASK_VALID (1 << 4)   
    297 #define BCM_FLOW_TUNNEL_TERM_SIP6_VALID     (1 << 5)   
    298 #define BCM_FLOW_TUNNEL_TERM_DIP6_VALID     (1 << 6)   
    299 #define BCM_FLOW_TUNNEL_TERM_SIP6_MASK_VALID (1 << 7)   
    300 #define BCM_FLOW_TUNNEL_TERM_DIP6_MASK_VALID (1 << 8)   
    301 #define BCM_FLOW_TUNNEL_TERM_UDP_SRC_PORT_VALID (1 << 9)   
    302 #define BCM_FLOW_TUNNEL_TERM_UDP_DST_PORT_VALID (1 << 10)  
    303 #define BCM_FLOW_TUNNEL_TERM_VLAN_VALID     (1 << 11)  
    304 #define BCM_FLOW_TUNNEL_TERM_PROTOCOL_VALID (1 << 12)  
    305 #define BCM_FLOW_TUNNEL_TERM_FLEX_KEY_VALID (1 << 13)  
    306 #define BCM_FLOW_TUNNEL_TERM_FLEX_DATA_VALID (1 << 14)  
    307 #endif
    308 
    309 #if defined(INCLUDE_L3)
    310 /* Flow tunnel terminator multicast tunnel states - bug flags */
    311 #define BCM_FLOW_MULTICAST_TUNNEL_STATE_BUD_ENABLE (1 << 1)   
    312 #define BCM_FLOW_MULTICAST_TUNNEL_STATE_BUD_DISABLE (1 << 2)   
    313 #endif
    314 
    315 #if defined(INCLUDE_L3)
    316 /* Flow tunneling terminator structure. */
    317 typedef struct bcm_flow_tunnel_terminator_s {
    318     uint32 flags;           /* Configuration flags. Use BCM_TUNNEL flags */
    319     uint32 multicast_flag;  /* VXLAN Multicast trigger flags. */
    320     bcm_vrf_t vrf;          /* Virtual router instance. */
    321     bcm_ip_t sip;           /* SIP for tunnel header match. */
    322     bcm_ip_t dip;           /* DIP for tunnel header match. */
    323     bcm_ip_t sip_mask;      /* Source IP mask. */
    324     bcm_ip_t dip_mask;      /* Destination IP mask. */
    325     bcm_ip6_t sip6;         /* SIP for tunnel header match (IPv6). */
    326     bcm_ip6_t dip6;         /* DIP for tunnel header match (IPv6). */
    327     bcm_ip6_t sip6_mask;    /* Source IP mask (IPv6). */
    328     bcm_ip6_t dip6_mask;    /* Destination IP mask (IPv6). */
    329     uint32 udp_dst_port;    /* UDP dst port for UDP packets. */
    330     uint32 udp_src_port;    /* UDP src port for UDP packets */
    331     bcm_tunnel_type_t type; /* Tunnel type */
    332     bcm_vlan_t vlan;        /* The VLAN ID for IPMC lookup */
    333     uint32 protocol;        /* Protocol type */
    334     uint32 valid_elements;  /* bitmap of valid fields */
    335     uint32 flow_handle;     /* flow handle */
    336     uint32 flow_option;     /* flow option */
    337 } bcm_flow_tunnel_terminator_t;
    338 #endif
    339 
    340 #if defined(INCLUDE_L3)
    341 /* Initialize a bcm_flow_tunnel_terminator_t structure. */
    342 extern void bcm_flow_tunnel_terminator_t_init(
    343     bcm_flow_tunnel_terminator_t *info);
    344 #endif
    345 
    346 #ifndef BCM_HIDE_DISPATCHABLE
    347 
    348 #if defined(INCLUDE_L3)
    349 /* Create Flow Tunnel Terminator */
    350 extern int bcm_flow_tunnel_terminator_create(
    351     int unit, 
    352     bcm_flow_tunnel_terminator_t *info, 
    353     uint32 num_of_fields, 
    354     bcm_flow_logical_field_t *field);
    355 #endif
    356 
    357 #if defined(INCLUDE_L3)
    358 /* Delete Flow Tunnel terminator */
    359 extern int bcm_flow_tunnel_terminator_destroy(
    360     int unit, 
    361     bcm_flow_tunnel_terminator_t *info, 
    362     uint32 num_of_fields, 
    363     bcm_flow_logical_field_t *field);
    364 #endif
    365 
    366 #if defined(INCLUDE_L3)
    367 /* Get the Flow Tunnel terminator based on the tunnelId */
    368 extern int bcm_flow_tunnel_terminator_get(
    369     int unit, 
    370     bcm_flow_tunnel_terminator_t *info, 
    371     uint32 num_of_fields, 
    372     bcm_flow_logical_field_t *field);
    373 #endif
    374 
    375 #endif /* BCM_HIDE_DISPATCHABLE */
    376 
    377 /* bcm_flow_tunnel_terminator_traverse callback */
    378 #if defined(INCLUDE_L3)
    379 typedef int (*bcm_flow_tunnel_terminator_traverse_cb)(
    380     int unit, 
    381     bcm_flow_tunnel_terminator_t *info, 
    382     uint32 num_of_fields, 
    383     bcm_flow_logical_field_t *field, 
    384     void *user_data);
    385 #endif
    386 
    387 #ifndef BCM_HIDE_DISPATCHABLE
    388 
    389 #if defined(INCLUDE_L3)
    390 /* traverse flow tunnel terminator entries. */
    391 extern int bcm_flow_tunnel_terminator_traverse(
    392     int unit, 
    393     bcm_flow_tunnel_terminator_traverse_cb cb, 
    394     void *user_data);
    395 #endif
    396 
    397 #endif /* BCM_HIDE_DISPATCHABLE */
    398 
    399 #if defined(INCLUDE_L3)
    400 /* Flow port encap valid elements. */
    401 #define BCM_FLOW_PORT_ENCAP_PORT_VALID      (1 << 0)   /* flow port(DVP) valid */
    402 #define BCM_FLOW_PORT_ENCAP_CLASS_ID_VALID  (1 << 1)   /* class id valid. */
    403 #define BCM_FLOW_PORT_ENCAP_MTU_VALID       (1 << 2)   /* mtu valid. */
    404 #define BCM_FLOW_PORT_ENCAP_FLAGS_VALID     (1 << 3)   /* flags valid. */
    405 #define BCM_FLOW_PORT_ENCAP_NETWORK_GROUP_VALID (1 << 4)   /* network group valid. */
    406 #define BCM_FLOW_PORT_ENCAP_DVP_GROUP_VALID (1 << 5)   /* DVP group valid. */
    407 #define BCM_FLOW_PORT_ENCAP_FLEX_DATA_VALID (1 << 6)   /* logical field valid. */
    408 #define BCM_FLOW_PORT_ENCAP_PKT_PRI_VALID   (1 << 7)   /* service tag priority
    409                                                           valid. */
    410 #define BCM_FLOW_PORT_ENCAP_PKT_CFI_VALID   (1 << 8)   /* service tag CFI valid. */
    411 #define BCM_FLOW_PORT_ENCAP_TPID_VALID      (1 << 9)   /* service tag TPID
    412                                                           valid. */
    413 #define BCM_FLOW_PORT_ENCAP_VLAN_VALID      (1 << 10)  /* vlan valid */
    414 #define BCM_FLOW_PORT_ENCAP_EGRESS_IF_VALID (1 << 11)  /* egress object valid */
    415 #endif
    416 
    417 #if defined(INCLUDE_L3)
    418 /* Flow port encap set options */
    419 #define BCM_FLOW_PORT_ENCAP_OPTION_REPLACE  (1 << 1)   /* replace encap
    420                                                           attributes. */
    421 #define BCM_FLOW_PORT_ENCAP_OPTION_CLEAR    (1 << 2)   /* clear encap
    422                                                           attributes. */
    423 #endif
    424 
    425 #if defined(INCLUDE_L3)
    426 /* Flow port encap flags for hardware control parameters */
    427 #define BCM_FLOW_PORT_ENCAP_FLAG_SERVICE_TAGGED (1 << 0)   /* service tag mode for
    428                                                           the given encap
    429                                                           criteria. */
    430 #define BCM_FLOW_PORT_ENCAP_FLAG_SERVICE_VLAN_ADD (1 << 1)   /* Add SD-TAG vlan. */
    431 #define BCM_FLOW_PORT_ENCAP_FLAG_SERVICE_VLAN_TPID_REPLACE (1 << 2)   /* Replace Vlan and TPID. */
    432 #define BCM_FLOW_PORT_ENCAP_FLAG_VLAN_REPLACE (1 << 3)   /* Replace vlan. */
    433 #define BCM_FLOW_PORT_ENCAP_FLAG_VLAN_DELETE (1 << 4)   /* Delete vlan. */
    434 #define BCM_FLOW_PORT_ENCAP_FLAG_VLAN_PRI_TPID_REPLACE (1 << 5)   /* Replace vlan, priority
    435                                                           and tpid. */
    436 #define BCM_FLOW_PORT_ENCAP_FLAG_VLAN_PRI_REPLACE (1 << 6)   /* Replace vlan and
    437                                                           priority. */
    438 #define BCM_FLOW_PORT_ENCAP_FLAG_PRI_REPLACE (1 << 7)   /* Replace priority. */
    439 #define BCM_FLOW_PORT_ENCAP_FLAG_TPID_REPLACE (1 << 8)   /* Replace TPID. */
    440 #define BCM_FLOW_PORT_ENCAP_FLAG_LOCAL      (1 << 9)   /* Encapsulate the FLOW
    441                                                           tunnel on local device */
    442 #define BCM_FLOW_PORT_ENCAP_FLAG_DROP       (1 << 10)  /* Multicast drop control */
    443 #endif
    444 
    445 #if defined(INCLUDE_L3)
    446 /* flow port encap config structure. */
    447 typedef struct bcm_flow_port_encap_s {
    448     bcm_gport_t flow_port;          /* flow port id identifies DVP. */
    449     uint32 options;                 /* BCM_FLOW_PORT_ENCAP_xxx. */
    450     uint32 flags;                   /* BCM_FLOW_PORT_ENCAP_FLAG_xxx. */
    451     uint32 class_id;                /* class id. */
    452     uint16 mtu;                     /* MTU. */
    453     uint32 network_group;           /* network group ID */
    454     uint32 dvp_group;               /* DVP group ID */
    455     uint8 pri;                      /* service tag priority. */
    456     uint8 cfi;                      /* service tag cfi */
    457     uint16 tpid;                    /* service tag tpid */
    458     bcm_vlan_t vlan;                /* service VLAN ID. */
    459     bcm_if_t egress_if;             /* egress object */
    460     uint32 valid_elements;          /* bitmap of valid fields for hardware
    461                                        parameters */
    462     bcm_flow_handle_t flow_handle;  /* flow handle */
    463     uint32 flow_option;             /* flow option id */
    464 } bcm_flow_port_encap_t;
    465 #endif
    466 
    467 #if defined(INCLUDE_L3)
    468 /* Initialize flow port encap config structure. */
    469 extern void bcm_flow_port_encap_t_init(
    470     bcm_flow_port_encap_t *info);
    471 #endif
    472 
    473 #ifndef BCM_HIDE_DISPATCHABLE
    474 
    475 #if defined(INCLUDE_L3)
    476 /* set the egress encapsulation for the given dvp. */
    477 extern int bcm_flow_port_encap_set(
    478     int unit, 
    479     bcm_flow_port_encap_t *info, 
    480     uint32 num_of_fields, 
    481     bcm_flow_logical_field_t *field);
    482 #endif
    483 
    484 #if defined(INCLUDE_L3)
    485 /* get the encapsulation attributes for the given DVP. */
    486 extern int bcm_flow_port_encap_get(
    487     int unit, 
    488     bcm_flow_port_encap_t *info, 
    489     uint32 num_of_fields, 
    490     bcm_flow_logical_field_t *field);
    491 #endif
    492 
    493 #endif /* BCM_HIDE_DISPATCHABLE */
    494 
    495 #if defined(INCLUDE_L3)
    496 /* Flow encap options */
    497 #define BCM_FLOW_ENCAP_OPTION_REPLACE   (1 << 1)   /* replace object attributes
    498                                                       for a encap criteria. */
    499 #endif
    500 
    501 #if defined(INCLUDE_L3)
    502 /* Flow encap flags for hardware control parameters */
    503 #define BCM_FLOW_ENCAP_FLAG_SERVICE_TAGGED  (1 << 0)   /* service tag mode for
    504                                                           the given encap
    505                                                           criteria. */
    506 #define BCM_FLOW_ENCAP_FLAG_SERVICE_VLAN_ADD (1 << 1)   /* Add SD-TAG vlan. */
    507 #define BCM_FLOW_ENCAP_FLAG_SERVICE_VLAN_TPID_REPLACE (1 << 2)   /* Replace Vlan and TPID. */
    508 #define BCM_FLOW_ENCAP_FLAG_VLAN_REPLACE    (1 << 3)   /* Replace vlan. */
    509 #define BCM_FLOW_ENCAP_FLAG_VLAN_DELETE     (1 << 4)   /* Delete vlan. */
    510 #define BCM_FLOW_ENCAP_FLAG_VLAN_PRI_TPID_REPLACE (1 << 5)   /* Replace vlan, priority
    511                                                           and tpid. */
    512 #define BCM_FLOW_ENCAP_FLAG_VLAN_PRI_REPLACE (1 << 6)   /* Replace vlan and
    513                                                           priority. */
    514 #define BCM_FLOW_ENCAP_FLAG_PRI_REPLACE     (1 << 7)   /* Replace priority. */
    515 #define BCM_FLOW_ENCAP_FLAG_TPID_REPLACE    (1 << 8)   /* Replace TPID. */
    516 #endif
    517 
    518 #if defined(INCLUDE_L3)
    519 /* Flow encap valid elements for hardware parameters. */
    520 #define BCM_FLOW_ENCAP_VNID_VALID           (1 << 0)   /* VN_ID element is valid
    521                                                           for this encap. */
    522 #define BCM_FLOW_ENCAP_VLAN_VALID           (1 << 1)   /* vlan valid */
    523 #define BCM_FLOW_ENCAP_FLOW_PORT_VALID      (1 << 2)   /* flow port valid */
    524 #define BCM_FLOW_ENCAP_VPN_VALID            (1 << 3)   /* vpn valid. */
    525 #define BCM_FLOW_ENCAP_INTF_VALID           (1 << 4)   /* interface valid. */
    526 #define BCM_FLOW_ENCAP_PKT_PRI_VALID        (1 << 5)   /* service tag priority
    527                                                           valid. */
    528 #define BCM_FLOW_ENCAP_PKT_CFI_VALID        (1 << 6)   /* service tag CFI valid. */
    529 #define BCM_FLOW_ENCAP_TPID_VALID           (1 << 7)   /* service tag TPID
    530                                                           valid. */
    531 #define BCM_FLOW_ENCAP_FLEX_KEY_VALID       (1 << 8)   /* logical fields for
    532                                                           key. */
    533 #define BCM_FLOW_ENCAP_FLEX_DATA_VALID      (1 << 9)   /* logical fields for
    534                                                           attributes. */
    535 #define BCM_FLOW_ENCAP_DVP_GROUP_VALID      (1 << 10)  /* DVP group ID. */
    536 #define BCM_FLOW_ENCAP_OIF_GROUP_VALID      (1 << 11)  /* L3 OUT interface group
    537                                                           ID. */
    538 #define BCM_FLOW_ENCAP_FLAGS_VALID          (1 << 12)  /* flags for hardware
    539                                                           control parameters. */
    540 #define BCM_FLOW_ENCAP_SRC_FLOW_PORT_VALID  (1 << 13)  /* SVP valid. */
    541 #define BCM_FLOW_ENCAP_CLASS_ID_VALID       (1 << 14)  /* CLASS_ID valid. */
    542 #endif
    543 
    544 #if defined(INCLUDE_L3)
    545 /* flow encap criteria. */
    546 typedef enum bcm_flow_encap_criteria_e {
    547     BCM_FLOW_ENCAP_CRITERIA_INVALID = 0, /* Illegal. */
    548     BCM_FLOW_ENCAP_CRITERIA_DVP = 1,    /* DVP used as a key. */
    549     BCM_FLOW_ENCAP_CRITERIA_VFI = 2,    /* VFI key. */
    550     BCM_FLOW_ENCAP_CRITERIA_VFI_DVP = 3, /* VFI + DVP key. */
    551     BCM_FLOW_ENCAP_CRITERIA_VRF_MAPPING = 4, /* VRF mapping key. */
    552     BCM_FLOW_ENCAP_CRITERIA_L3_INTF = 5, /* L3 interface key. */
    553     BCM_FLOW_ENCAP_CRITERIA_VFI_DVP_GROUP = 6, /* VFI + DVP group key. */
    554     BCM_FLOW_ENCAP_CRITERIA_FLEX = 7,   /* flex key from logical fields */
    555     BCM_FLOW_ENCAP_CRITERIA_SVP_DVP = 8, /* SVP + DVP key. */
    556     BCM_FLOW_ENCAP_CRITERIA_COUNT = 9   /* Must be last. */
    557 } bcm_flow_encap_criteria_t;
    558 #endif
    559 
    560 #if defined(INCLUDE_L3)
    561 /* Flow encap config structure */
    562 typedef struct bcm_flow_encap_config_s {
    563     bcm_vpn_t vpn;                      /* VPN representing a vfi or vrf */
    564     bcm_gport_t flow_port;              /* flow port id representing a DVP */
    565     bcm_if_t intf_id;                   /* l3 interface id */
    566     uint32 dvp_group;                   /* DVP group ID */
    567     uint32 oif_group;                   /* L3 OUT interface group ID */
    568     uint32 vnid;                        /* VN_ID. */
    569     uint8 pri;                          /* service tag priority. */
    570     uint8 cfi;                          /* service tag cfi */
    571     uint16 tpid;                        /* service tag tpid */
    572     bcm_vlan_t vlan;                    /* service VLAN ID. */
    573     uint32 flags;                       /* BCM_FLOW_ENCAP_FLAG_xxx. */
    574     uint32 options;                     /* BCM_FLOW_ENCAP_OPTION_xxx. */
    575     bcm_flow_encap_criteria_t criteria; /* flow encap criteria. */
    576     uint32 valid_elements;              /* bitmap of valid fields for the encap
    577                                            action */
    578     bcm_flow_handle_t flow_handle;      /* flow handle derived from flow name */
    579     uint32 flow_option;                 /* flow option derived from flow option
    580                                            name */
    581     bcm_gport_t src_flow_port;          /* flow port id representing a SVP */
    582     uint32 class_id;                    /* used by EFP as input key */
    583 } bcm_flow_encap_config_t;
    584 #endif
    585 
    586 /* bcm_flow_encap_traverse callback */
    587 #if defined(INCLUDE_L3)
    588 typedef int (*bcm_flow_encap_traverse_cb)(
    589     int unit, 
    590     bcm_flow_encap_config_t *info, 
    591     uint32 num_of_fields, 
    592     bcm_flow_logical_field_t *field, 
    593     void *user_data);
    594 #endif
    595 
    596 #if defined(INCLUDE_L3)
    597 /* Initialize flow encap config structure. */
    598 extern void bcm_flow_encap_config_t_init(
    599     bcm_flow_encap_config_t *flow_encap);
    600 #endif
    601 
    602 #ifndef BCM_HIDE_DISPATCHABLE
    603 
    604 #if defined(INCLUDE_L3)
    605 /* Add a flow encap rule. */
    606 extern int bcm_flow_encap_add(
    607     int unit, 
    608     bcm_flow_encap_config_t *info, 
    609     uint32 num_of_fields, 
    610     bcm_flow_logical_field_t *field);
    611 #endif
    612 
    613 #if defined(INCLUDE_L3)
    614 /* Delete a flow encap rule on the given encap key. */
    615 extern int bcm_flow_encap_delete(
    616     int unit, 
    617     bcm_flow_encap_config_t *info, 
    618     uint32 num_of_fields, 
    619     bcm_flow_logical_field_t *field);
    620 #endif
    621 
    622 #if defined(INCLUDE_L3)
    623 /* Get the encap attributes on the given encap key. */
    624 extern int bcm_flow_encap_get(
    625     int unit, 
    626     bcm_flow_encap_config_t *info, 
    627     uint32 num_of_fields, 
    628     bcm_flow_logical_field_t *field);
    629 #endif
    630 
    631 #if defined(INCLUDE_L3)
    632 /* Traverse encap entries. */
    633 extern int bcm_flow_encap_traverse(
    634     int unit, 
    635     bcm_flow_encap_traverse_cb cb, 
    636     void *user_data);
    637 #endif
    638 
    639 #endif /* BCM_HIDE_DISPATCHABLE */
    640 
    641 #if defined(INCLUDE_L3)
    642 /* BCM_FLOW_* flags. */
    643 #define BCM_FLOW_PORT_WITH_ID           (1 << 0)   /* create FLOW port with
    644                                                       specified ID */
    645 #define BCM_FLOW_PORT_NETWORK           (1 << 1)   /* Network facing interface */
    646 #define BCM_FLOW_PORT_COUNTED           (1 << 2)   /* Maintain packet/byte
    647                                                       counts */
    648 #define BCM_FLOW_PORT_REPLACE           (1 << 3)   /* Replace existing entry */
    649 #define BCM_FLOW_PORT_SERVICE_TAGGED    (1 << 4)   /* Service tag mode */
    650 #define BCM_FLOW_PORT_DEFAULT           (1 << 5)   /* Create VXLAN Default
    651                                                       Network Port */
    652 #define BCM_FLOW_PORT_DEFAULT_L2GRE     (1 << 6)   /* Create L2GRE Default
    653                                                       Network Port */
    654 #define BCM_FLOW_PORT_DEFAULT_GPE       (1 << 7)   /* Create GPE Default Network
    655                                                       Port */
    656 #define BCM_FLOW_PORT_DEFAULT_GENEVE    (1 << 8)   /* Create GENEVE Default
    657                                                       Network Port */
    658 #endif
    659 
    660 /* Flex Flow VP Config Structure. */
    661 typedef struct bcm_flow_port_s {
    662     bcm_gport_t flow_port_id;           /* GPORT identifier. */
    663     uint32 flags;                       /* BCM_FLOW_PORT_xxx. */
    664     uint32 if_class;                    /* Interface Class ID. */
    665     bcm_switch_network_group_t network_group_id; /* Split Horizon network group
    666                                            identifier. */
    667     uint16 egress_service_tpid;         /* Service Vlan TPID Value. */
    668 } bcm_flow_port_t;
    669 
    670 #ifndef BCM_HIDE_DISPATCHABLE
    671 
    672 #if defined(INCLUDE_L3)
    673 /* Initialize flexflow module. */
    674 extern int bcm_flow_init(
    675     int unit);
    676 #endif
    677 
    678 #if defined(INCLUDE_L3)
    679 /* Detach flexflow module. */
    680 extern int bcm_flow_cleanup(
    681     int unit);
    682 #endif
    683 
    684 #endif /* BCM_HIDE_DISPATCHABLE */
    685 
    686 #if defined(INCLUDE_L3)
    687 /* Initialize a FLOW port config structure. */
    688 extern void bcm_flow_port_t_init(
    689     bcm_flow_port_t *flow_port);
    690 #endif
    691 
    692 #ifndef BCM_HIDE_DISPATCHABLE
    693 
    694 #if defined(INCLUDE_L3)
    695 /* Create an Access/Network FLEX-FLOW port. */
    696 extern int bcm_flow_port_create(
    697     int unit, 
    698     bcm_vpn_t vpn, 
    699     bcm_flow_port_t *flow_port);
    700 #endif
    701 
    702 #if defined(INCLUDE_L3)
    703 /* Destroy an Access/Network FLEX-FLOW port. */
    704 extern int bcm_flow_port_destroy(
    705     int unit, 
    706     bcm_vpn_t vpn, 
    707     bcm_gport_t flow_port);
    708 #endif
    709 
    710 #if defined(INCLUDE_L3)
    711 /* Get Access/Network FLEX-FLOW port. */
    712 extern int bcm_flow_port_get(
    713     int unit, 
    714     bcm_vpn_t vpn, 
    715     bcm_flow_port_t *flow_port);
    716 #endif
    717 
    718 #if defined(INCLUDE_L3)
    719 /* Get all Access/Network FLEX-FLOW port. */
    720 extern int bcm_flow_port_get_all(
    721     int unit, 
    722     bcm_vpn_t vpn, 
    723     int port_max, 
    724     bcm_flow_port_t *flow_port, 
    725     int *port_count);
    726 #endif
    727 
    728 #endif /* BCM_HIDE_DISPATCHABLE */
    729 
    730 #if defined(INCLUDE_L3)
    731 /* FLOW VPN Definitions. */
    732 #define BCM_FLOW_VPN_ELINE      0x0001     /* ELINE FLOW VPN */
    733 #define BCM_FLOW_VPN_ELAN       0x0002     /* ELAN FLOW VPN */
    734 #define BCM_FLOW_VPN_WITH_ID    0x0004     /* With Id FLOW VPN */
    735 #define BCM_FLOW_VPN_REPLACE    0x0008     /* Replace VPN Id FLOW VPN */
    736 #define BCM_FLOW_VPN_INVALID    0xFFFF     /* Invalid FLOW VPN */
    737 #endif
    738 
    739 /* Flow L2 VPN Config Structure. */
    740 typedef struct bcm_flow_vpn_config_s {
    741     uint32 flags;                       /* L2 VPN config flags. */
    742     bcm_multicast_t broadcast_group;    /* broadcast group. */
    743     bcm_multicast_t unknown_unicast_group; /* unknown unicast group. */
    744     bcm_multicast_t unknown_multicast_group; /* unknown multicast group. */
    745     bcm_vlan_protocol_packet_ctrl_t protocol_pkt; /* protocol packet handling */
    746     bcm_gport_t match_port_class;       /* port class */
    747 } bcm_flow_vpn_config_t;
    748 
    749 /* bcm_flow_vpn_traverse callback */
    750 #if defined(INCLUDE_L3)
    751 typedef int (*bcm_flow_vpn_traverse_cb)(
    752     int unit, 
    753     bcm_vpn_t vpn, 
    754     bcm_flow_vpn_config_t *info, 
    755     void *user_data);
    756 #endif
    757 
    758 #if defined(INCLUDE_L3)
    759 /* Initialize flow vpn config structure. */
    760 extern void bcm_flow_vpn_config_t_init(
    761     bcm_flow_vpn_config_t *info);
    762 #endif
    763 
    764 #ifndef BCM_HIDE_DISPATCHABLE
    765 
    766 #if defined(INCLUDE_L3)
    767 /* Create a Flow L2 VPN. */
    768 extern int bcm_flow_vpn_create(
    769     int unit, 
    770     bcm_vpn_t *vpn, 
    771     bcm_flow_vpn_config_t *info);
    772 #endif
    773 
    774 #if defined(INCLUDE_L3)
    775 /* Destroy a Flow L2 VPN. */
    776 extern int bcm_flow_vpn_destroy(
    777     int unit, 
    778     bcm_vpn_t vpn);
    779 #endif
    780 
    781 #if defined(INCLUDE_L3)
    782 /* Destroy all Flow L2 VPN's. */
    783 extern int bcm_flow_vpn_destroy_all(
    784     int unit);
    785 #endif
    786 
    787 #if defined(INCLUDE_L3)
    788 /* Get Flow VPN information. */
    789 extern int bcm_flow_vpn_get(
    790     int unit, 
    791     bcm_vpn_t vpn, 
    792     bcm_flow_vpn_config_t *info);
    793 #endif
    794 
    795 #if defined(INCLUDE_L3)
    796 /* Traverse Flow VPN entries. */
    797 extern int bcm_flow_vpn_traverse(
    798     int unit, 
    799     bcm_flow_vpn_traverse_cb cb, 
    800     void *user_data);
    801 #endif
    802 
    803 #if defined(INCLUDE_L3)
    804 /* Get the handle for the flow name. */
    805 extern int bcm_flow_handle_get(
    806     int unit, 
    807     const char *flow_name, 
    808     bcm_flow_handle_t *handle);
    809 #endif
    810 
    811 #if defined(INCLUDE_L3)
    812 /* Get the option id for flow option name. */
    813 extern int bcm_flow_option_id_get(
    814     int unit, 
    815     bcm_flow_handle_t flow_handle, 
    816     const char *flow_option_name, 
    817     bcm_flow_option_id_t *option_id);
    818 #endif
    819 
    820 #if defined(INCLUDE_L3)
    821 /* Get the field id for logical field name in a flow. */
    822 extern int bcm_flow_logical_field_id_get(
    823     int unit, 
    824     bcm_flow_handle_t flow_handle, 
    825     const char *field_name, 
    826     bcm_flow_field_id_t *field_id);
    827 #endif
    828 
    829 #endif /* BCM_HIDE_DISPATCHABLE */
    830 
    831 #if defined(INCLUDE_L3)
    832 /* Flow Functions. */
    833 typedef enum bcm_flow_function_type_e {
    834     bcmFlowFuncTypeStart = 0,           /* Start. */
    835     bcmFlowFuncTypeMatch = 1,           /* Match. */
    836     bcmFlowFuncTypeEncap = 2,           /* Encap. */
    837     bcmFlowFuncTypeTunnelInit = 3,      /* Tunnel Initiator. */
    838     bcmFlowFuncTypeTunnelTerm = 4,      /* Tunnel Terminator. */
    839     bcmFlowFuncTypeEncapSet = 5,        /* Encap set. */
    840     bcmFlowFuncTypeL2Switch = 6,        /* L2 Switch. */
    841     bcmFlowFuncTypeL3Host = 7,          /* L3 Host. */
    842     bcmFlowFuncTypeL3Route = 8,         /* L3 Route. */
    843     bcmFlowFuncTypeEgressObj = 9,       /* Egress  Object. */
    844     bcmFlowFuncTypeEgressLabel = 10,    /* Egress Label. */
    845     bcmFlowFuncTypeEgressIntf = 11,     /* Egress Intf. */
    846     bcmFlowFuncTypeEnd = 12             /* End. */
    847 } bcm_flow_function_type_t;
    848 
    849 #define BCM_FLOW_FUNCTION_TYPE \
    850 { \
    851     "bcmFlowFuncTypeStart", \
    852     "bcmFlowFuncTypeMatch", \
    853     "bcmFlowFuncTypeEncap", \
    854     "bcmFlowFuncTypeTunnelInit", \
    855     "bcmFlowFuncTypeTunnelTerm", \
    856     "bcmFlowFuncTypeEncapSet", \
    857     "bcmFlowFuncTypeL2Switch", \
    858     "bcmFlowFuncTypeL3Host", \
    859     "bcmFlowFuncTypeL3Route", \
    860     "bcmFlowFuncTypeEgressObj", \
    861     "bcmFlowFuncTypeEgressLabel", \
    862     "bcmFlowFuncTypeEgressIntf", \
    863     "bcmFlowFuncTypeEnd"  \
    864 }
    865 #endif
    866 
    867 #if defined(INCLUDE_L3)
    868 /* Flow stat info valid elements. */
    869 #define BCM_FLOW_STAT_FLOW_PORT_VALID       (1 << 0)   /* flow port element
    870                                                           valid. */
    871 #define BCM_FLOW_STAT_PORT_VALID            (1 << 1)   /* port element valid. */
    872 #define BCM_FLOW_STAT_VPN_VALID             (1 << 2)   /* VN_ID element is valid
    873                                                           for this match. */
    874 #define BCM_FLOW_STAT_INNER_VLAN_VALID      (1 << 3)   /* Inner vlan element
    875                                                           valid. */
    876 #define BCM_FLOW_STAT_VLAN_VALID            (1 << 4)   /* vlan element valid. */
    877 #define BCM_FLOW_STAT_VNID_VALID            (1 << 5)   /* VNID element valid. */
    878 #define BCM_FLOW_STAT_SIP_VALID             (1 << 6)   /* source IPv4 address
    879                                                           element valid. */
    880 #define BCM_FLOW_STAT_DIP_VALID             (1 << 7)   /* Destination IPv4
    881                                                           address element valid. */
    882 #define BCM_FLOW_STAT_SIP_MASK_VALID        (1 << 8)   /* source IPv4 address
    883                                                           mask element valid. */
    884 #define BCM_FLOW_STAT_DIP_MASK_VALID        (1 << 9)   /* Destination IPv4
    885                                                           address mask element
    886                                                           valid. */
    887 #define BCM_FLOW_STAT_SIP6_VALID            (1 << 10)  /* source IPv6 address
    888                                                           element valid. */
    889 #define BCM_FLOW_STAT_DIP6_VALID            (1 << 11)  /* Destination IPv6
    890                                                           address element valid. */
    891 #define BCM_FLOW_STAT_SIP6_MASK_VALID       (1 << 12)  /* source IPv6 address
    892                                                           mask element valid. */
    893 #define BCM_FLOW_STAT_DIP6_MASK_VALID       (1 << 13)  /* Destination IPv6
    894                                                           address mask element
    895                                                           valid. */
    896 #define BCM_FLOW_STAT_UDP_SRC_PORT_VALID    (1 << 14)  /* UDP source port
    897                                                           element valid. */
    898 #define BCM_FLOW_STAT_UDP_DST_PORT_VALID    (1 << 15)  /* UDP Destination port
    899                                                           element valid. */
    900 #define BCM_FLOW_STAT_PROTOCOL_VALID        (1 << 16)  /* Protocol element
    901                                                           valid. */
    902 #define BCM_FLOW_STAT_TUNNEL_ID_VALID       (1 << 17)  /* Tunnel ID element
    903                                                           valid. */
    904 #define BCM_FLOW_STAT_EGRESS_IF_VALID       (1 << 18)  /* Egress nexthop object
    905                                                           index element valid. */
    906 #define BCM_FLOW_STAT_INTF_ID_VALID         (1 << 19)  /* L3 interface id
    907                                                           element valid. */
    908 #define BCM_FLOW_STAT_MAC_VALID             (1 << 20)  /* L2 MAC address element
    909                                                           valid. */
    910 #define BCM_FLOW_STAT_L3A_FLAGS_VALID       (1 << 21)  /* BCM_L3_xxx flag
    911                                                           definitions. */
    912 #define BCM_FLOW_STAT_L3A_VRF_VALID         (1 << 22)  /* Virtual router
    913                                                           instance. */
    914 #define BCM_FLOW_STAT_DVP_GROUP_VALID       (1 << 23)  /* DVP group ID */
    915 #define BCM_FLOW_STAT_OIF_GROUP_VALID       (1 << 24)  /* L3 Out Interface Group
    916                                                           ID */
    917 #define BCM_FLOW_STAT_MATCH_CRITERIA_VALID  (1 << 25)  /* DVP group ID */
    918 #define BCM_FLOW_STAT_ENCAP_CRITERIA_VALID  (1 << 26)  /* L3 Out Interface Group
    919                                                           ID */
    920 #define BCM_FLOW_STAT_MPLS_LABEL_VALID      (1 << 27)  /* Mpls Label is valid */
    921 #define BCM_FLOW_STAT_FLEX_KEY_VALID        (1 << 28)  /* Flex Key element
    922                                                           valid. */
    923 #endif
    924 
    925 #if defined(INCLUDE_L3)
    926 /* flow Stat. */
    927 typedef enum bcm_flow_stat_e {
    928     bcmFlowInPackets = 1,   /* Flow InPackets */
    929     bcmFlowOutPackets = 2,  /* Flow OutPackets */
    930     bcmFlowInBytes = 3,     /* Flow InBytes */
    931     bcmFlowOutBytes = 4     /* Flow OutBytes */
    932 } bcm_flow_stat_t;
    933 #endif
    934 
    935 #if defined(INCLUDE_L3)
    936 /* Flow stat info structure */
    937 typedef struct bcm_flow_stat_info_s {
    938     bcm_gport_t flow_port;              /* Flow port */
    939     bcm_gport_t port;                   /* Match port /trunk */
    940     bcm_vpn_t vpn;                      /* VPN representing a vfi or vrf */
    941     bcm_vlan_t inner_vlan;              /* Inner VLAN ID to match. */
    942     bcm_vlan_t vlan;                    /* VLAN ID to match. */
    943     uint32 vnid;                        /* VN_ID. */
    944     bcm_ip_t sip;                       /* source IPv4 address */
    945     bcm_ip_t dip;                       /* destination IPv4 address */
    946     bcm_ip_t sip_mask;                  /* source IPv4 address mask */
    947     bcm_ip_t dip_mask;                  /* destination IPv4 address mask */
    948     bcm_ip6_t sip6;                     /* source IPv6 address */
    949     bcm_ip6_t dip6;                     /* destination IPv6 address */
    950     bcm_ip6_t sip6_mask;                /* source IPv6 address mask */
    951     bcm_ip6_t dip6_mask;                /* destination IPv6 address mask */
    952     uint16 udp_src_port;                /* udp source port. */
    953     uint16 udp_dst_port;                /* udp destination port. */
    954     uint16 protocol;                    /* IP protocol type. */
    955     bcm_gport_t tunnel_id;              /* Tunnel ID */
    956     bcm_if_t egress_if;                 /* egress object */
    957     bcm_if_t intf_id;                   /* l3 interface id */
    958     bcm_mac_t mac;                      /* 802.3 MAC address. */
    959     uint32 l3a_flags;                   /* See BCM_L3_xxx flag definitions. */
    960     bcm_vrf_t l3a_vrf;                  /* Virtual router instance. */
    961     uint32 oif_group;                   /* L3 OUT interface group ID */
    962     uint32 dvp_group;                   /* DVP group ID */
    963     bcm_flow_match_criteria_t match_criteria; /* flow match criteria. */
    964     bcm_flow_encap_criteria_t encap_criteria; /* flow encap criteria. */
    965     bcm_mpls_label_t mpls_label;        /* MPLS label. */
    966     uint32 valid_elements;              /* bitmap of valid fields */
    967     uint32 flow_handle;                 /* flow handle derived from flow name */
    968     uint32 flow_option;                 /* flow option derived from flow option
    969                                            name */
    970     bcm_flow_function_type_t function_type; /* flow function type */
    971 } bcm_flow_stat_info_t;
    972 #endif
    973 
    974 #if defined(INCLUDE_L3)
    975 /* initialize the bcm_flow_stat_info_t structure. */
    976 extern void bcm_flow_stat_info_t_init(
    977     bcm_flow_stat_info_t *flow_stat_info);
    978 #endif
    979 
    980 #ifndef BCM_HIDE_DISPATCHABLE
    981 
    982 #if defined(INCLUDE_L3)
    983 /* Get the accounting stat object associated with the flex view. */
    984 extern int bcm_flow_stat_object_get(
    985     int unit, 
    986     bcm_flow_handle_t flow_handle, 
    987     bcm_flow_option_id_t flow_option_id, 
    988     bcm_flow_function_type_t function_type, 
    989     bcm_stat_object_t *stat_object);
    990 #endif
    991 
    992 #if defined(INCLUDE_L3)
    993 /* Attach counter entries to the given flex view table. */
    994 extern int bcm_flow_stat_attach(
    995     int unit, 
    996     bcm_flow_stat_info_t *flow_stat_info, 
    997     uint32 num_of_fields, 
    998     bcm_flow_logical_field_t *field, 
    999     uint32 stat_counter_id);
   1000 #endif
   1001 
   1002 #if defined(INCLUDE_L3)
   1003 /* Detach counter entries to the given flex view table. */
   1004 extern int bcm_flow_stat_detach(
   1005     int unit, 
   1006     bcm_flow_stat_info_t *flow_stat_info, 
   1007     uint32 num_of_fields, 
   1008     bcm_flow_logical_field_t *field, 
   1009     uint32 stat_counter_id);
   1010 #endif
   1011 
   1012 #if defined(INCLUDE_L3)
   1013 /* Get Stat couter id associated with logical view. */
   1014 extern int bcm_flow_stat_id_get(
   1015     int unit, 
   1016     bcm_flow_stat_info_t *flow_stat_info, 
   1017     uint32 num_of_fields, 
   1018     bcm_flow_logical_field_t *field, 
   1019     bcm_stat_object_t stat_object, 
   1020     uint32 *stat_counter_id);
   1021 #endif
   1022 
   1023 #endif /* BCM_HIDE_DISPATCHABLE */
   1024 
   1025 #endif /* __BCM_FLOW_H__ */