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

bfd.h (32393B)


      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_BFD_H__
     11 #define __BCM_BFD_H__
     12 
     13 #if defined(INCLUDE_BFD)
     14 
     15 #include <shared/bfd.h>
     16 #include <bcm/mpls.h>
     17 
     18 /* Miscellaneous BFD defines. */
     19 #define BCM_BFD_ENDPOINT_INVALID            -1         /* Invalid BFD endpoint
     20                                                           ID. */
     21 #define BCM_BFD_ENDPOINT_DEFAULT0           -3         /* BFD default endpoint. */
     22 #define BCM_BFD_ENDPOINT_DEFAULT1           -4         /* BFD default endpoint. */
     23 #define BCM_BFD_ENDPOINT_DEFAULT2           -5         /* BFD default endpoint. */
     24 #define BCM_BFD_ENDPOINT_DEFAULT3           -6         /* BFD default endpoint. */
     25 #define BCM_BFD_INTPRI_MAX                  16         /* Internal priority max
     26                                                           value. */
     27 #define BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH  _SHR_BFD_ENDPOINT_MAX_MEP_ID_LENGTH /* MPLS-TP MEP_ID maximum
     28                                                           length. */
     29 
     30 /* BFD endpoint flags. */
     31 #define BCM_BFD_ENDPOINT_UPDATE             0x0001     /* Update an existing BFD
     32                                                           endpoint. */
     33 #define BCM_BFD_ENDPOINT_WITH_ID            0x0002     /* Use the specified
     34                                                           endpoint ID. */
     35 #define BCM_BFD_ENDPOINT_PASSIVE            0x0004     /* Specifies endpoint
     36                                                           takes passive role. */
     37 #define BCM_BFD_ENDPOINT_DEMAND             0x0008     /* Specifies local
     38                                                           endpoint is in demand
     39                                                           mode. */
     40 #define BCM_BFD_ENDPOINT_ENCAP_SET          0x0010     /* Update encapsulation
     41                                                           on existing BFD
     42                                                           endpoint. */
     43 #define BCM_BFD_ENDPOINT_PWE_RAW            0x0020     /* Use MPLS PWE RAW mode.
     44                                                           Valid only for PWE
     45                                                           Tunnel types. */
     46 #define BCM_BFD_ENDPOINT_PWE_ACH            0x0040     /* Use MPLS Associated
     47                                                           Channel Header.  Valid
     48                                                           only for PWE Tunnel
     49                                                           types. */
     50 #define BCM_BFD_ENDPOINT_IPV6               0x0080     /* Use IPv6
     51                                                           encapsulation. */
     52 #define BCM_BFD_ENDPOINT_MULTIHOP           0x0100     /* BFD IP/UDP multihop
     53                                                           endpoint. */
     54 #define BCM_BFD_ENDPOINT_MPLS_TP_AIS_LDI    0x0200     /* Set MPLS-TP AIS LDI. 
     55                                                           Valid only for MPLS-TP
     56                                                           Tunnel types. */
     57 #define BCM_BFD_ENDPOINT_MPLS_TP_LKR        0x0400     /* MPLS-TP Locked Report
     58                                                           (LKR). Valid only for
     59                                                           MPLS-TP Tunnel types. */
     60 #define BCM_BFD_ENDPOINT_KEY_TYPE_USE_YOUR_DISC 0x0800     /* Resolve BFD session ID
     61                                                           from your
     62                                                           discriminator.(Instead
     63                                                           of MPLS label) */
     64 #define BCM_BFD_ENDPOINT_MPLS_IP_DEST_RANDOM 0x1000     /* Randomize outgoing IP
     65                                                           dest addr. Valid only
     66                                                           for MPLS/PWE Tunnel
     67                                                           types. */
     68 #define BCM_BFD_ENDPOINT_MPLS_TP_POLL_SEQUENCE_ENABLE 0x2000     /* Enable poll sequence
     69                                                           for MPLS-TP
     70                                                           encapsulations.  Valid
     71                                                           only for MPLS-TP
     72                                                           Tunnel types. */
     73 #define BCM_BFD_ENDPOINT_SHA1_SEQUENCE_INCR 0x4000     /* Increment sequence
     74                                                           number.  Valid for
     75                                                           SHA1 authentication
     76                                                           only. */
     77 #define BCM_BFD_ENDPOINT_IN_HW              0x8000     /* Process the endpint in
     78                                                           HW. */
     79 #define BCM_BFD_ENDPOINT_STACK              0x10000    /* Endpoint is managed by
     80                                                           other unit in the
     81                                                           stack. */
     82 #define BCM_BFD_ENDPOINT_REMOTE_EVENT_DISABLE 0x20000    /* Do not generate
     83                                                           events. */
     84 #define BCM_BFD_ENDPOINT_RDI_AUTO_UPDATE    0x40000    /* Auto update defect
     85                                                           state on timeout event */
     86 #define BCM_BFD_ENDPOINT_RX_REMOTE_EVENT_DISABLE 0x80000    /* Do not generate events
     87                                                           for RX packets. */
     88 #define BCM_BFD_ENDPOINT_RX_RDI_AUTO_UPDATE 0x100000   /* Auto update defect
     89                                                           state on timeout event
     90                                                           for RX packets */
     91 #define BCM_BFD_ENDPOINT_RDI_ON_LOC         0x200000   /* MEP RDI update LOC
     92                                                           enable - update local
     93                                                           MEP RDI in case of
     94                                                           LOC. */
     95 #define BCM_BFD_ENDPOINT_RDI_CLEAR_ON_LOC_CLEAR 0x400000   /* MEP RDI update LOC
     96                                                           clean enable - update
     97                                                           local MEP RDI in case
     98                                                           of LOC clear (time-in)
     99                                                           event detected. */
    100 #define BCM_BFD_ENDPOINT_REMOTE_WITH_ID     0x800000   /* Use the specified
    101                                                           remote endpoint ID. */
    102 #define BCM_BFD_ENDPOINT_REMOTE_UPDATE_STATE_DISABLE 0x1000000  /* Disable updating RMEP
    103                                                           DB. */
    104 #define BCM_BFD_ENDPOINT_HW_ACCELERATION_SET 0x2000000  /* Configure only HW
    105                                                           accelerator
    106                                                           properties. */
    107 #define BCM_BFD_ECHO                        0x4000000  /* Create BFD echo
    108                                                           session. */
    109 #define BCM_BFD_ENDPOINT_EXPLICIT_DETECTION_TIME 0x8000000  /* BFD Detection Time is
    110                                                           set explicitly. */
    111 #define BCM_BFD_ENDPOINT_USE_PKT_VLAN_ID    0x10000000 /* Use to configure the
    112                                                           User provided Vlan ID. */
    113 #define BCM_BFD_ENDPOINT_MICRO_BFD          0x20000000 /* Use to configure micro
    114                                                           BFD session. */
    115 #define BCM_BFD_ENDPOINT_ADMIN_DOWN_PKT_ON_ENDPOINT_DEL 0x40000000 /* Trasmit ADMIN_DOWN
    116                                                           packet on session
    117                                                           deletion. */
    118 #define BCM_BFD_ENDPOINT_STANDBY_SSO_UPDATE 0x80000000 /* Standby endpoint
    119                                                           update for Statefull
    120                                                           Switchover. */
    121 
    122 /* Additional BFD endpoint flags. */
    123 #define BCM_BFD_ENDPOINT_FLAGS2_SEAMLESS_BFD_INITIATOR (1<<0)     /* Create/update Seamless
    124                                                           BFD initiator
    125                                                           endpoint. */
    126 #define BCM_BFD_ENDPOINT_FLAGS2_SEAMLESS_BFD_REFLECTOR (1<<1)     /* Create/update Seamless
    127                                                           BFD initiator
    128                                                           endpoint. */
    129 #define BCM_BFD_ENDPOINT_FLAGS2_USE_MY_DIP_DESTINATION (1<<2)     /* Verify DIP through
    130                                                           my-DIP-Destination. */
    131 #define BCM_BFD_ENDPOINT_FLAGS2_TX_STATISTICS (1<<3)     /* Enable OAMP Tx
    132                                                           statistics. */
    133 #define BCM_BFD_ENDPOINT_FLAGS2_RX_STATISTICS (1<<4)     /* Enable OAMP Rx
    134                                                           statistics. */
    135 #define BCM_BFD_ENDPOINT_FLAGS2_PUNT_NEXT_GOOD_PACKET (1<<5)     /* Write-only flag.
    136                                                           Specifies if the next
    137                                                           received good packet
    138                                                           should be punted to
    139                                                           the CPU */
    140 #define BCM_BFD_ENDPOINT_FLAGS2_ENTROPY_LABEL (1<<6)     /* Set Entropy Label
    141                                                           (without EL indicator
    142                                                           label). Specifies to
    143                                                           validate and insert
    144                                                           user-defined
    145                                                           Entropy(FAT) Label
    146                                                           (defined in mpls_hdr)
    147                                                           in VCCV BFD frames */
    148 #define BCM_BFD_ENDPOINT_FLAGS2_SINGLE_HOP_WITH_RANDOM_DIP (1<<7)     /* Use random destination
    149                                                           IP address in 127/8
    150                                                           range for Single-Hop
    151                                                           BFD endpoint. */
    152 
    153 /* Remote status flags. */
    154 #define BCM_BFD_ENDPOINT_REMOTE_DEMAND      0x0001     /* Remote endpoint is in
    155                                                           demand mode. */
    156 #define BCM_BFD_ENDPOINT_REMOTE_RX_AUTH_SEQ_KNOWN 0x002      /* Rx Authentication
    157                                                           Sequence ID is known. 
    158                                                           Valid for SHA1
    159                                                           authentication only. */
    160 
    161 /* BFD packet statistic options. */
    162 #define BCM_BFD_ENDPOINT_STAT_CLEAR 0x0001     /* Clear statistics. */
    163 #define BCM_BFD_ENDPOINT_STAT_64BIT 0x0002     /* Get 64bit statistics. */
    164 
    165 /* Simple Password authentication data. */
    166 #define BCM_BFD_SIMPLE_PASSWORD_KEY_LENGTH_MAX _SHR_BFD_AUTH_SIMPLE_PASSWORD_KEY_LENGTH 
    167 
    168 /* BFD endpoint local control flags. */
    169 #define BCM_BFD_ENDPOINT_LOCAL_FLAGS_M  0x00000001 /* Multipoint control flag. */
    170 #define BCM_BFD_ENDPOINT_LOCAL_FLAGS_D  0x00000002 /* Demand Control Flag. */
    171 #define BCM_BFD_ENDPOINT_LOCAL_FLAGS_A  0x00000004 /* Authentication Control
    172                                                       Flag. */
    173 #define BCM_BFD_ENDPOINT_LOCAL_FLAGS_C  0x00000008 /* Control Plane Independent
    174                                                       Control Flag. */
    175 #define BCM_BFD_ENDPOINT_LOCAL_FLAGS_F  0x00000010 /* Final Bit Control Flag. */
    176 #define BCM_BFD_ENDPOINT_LOCAL_FLAGS_P  0x00000020 /* Poll Bit Control Flag. */
    177 
    178 /* BFD Status flags. */
    179 #define BCM_BFD_STATUS_LOCAL_ADMIN_DOWN     0x00000001 /* BFD Local State Admin. */
    180 #define BCM_BFD_STATUS_LOCAL_DOWN           0x00000002 /* BFD Local State Down. */
    181 #define BCM_BFD_STATUS_LOCAL_INIT           0x00000004 /* BFD Local State Init. */
    182 #define BCM_BFD_STATUS_LOCAL_UP             0x00000008 /* BFD Local State Up. */
    183 #define BCM_BFD_STATUS_REMOTE_ADMIN_DOWN    0x00000010 /* BFD Remote State
    184                                                           Admin. */
    185 #define BCM_BFD_STATUS_REMOTE_DOWN          0x00000020 /* BFD Remote State Down. */
    186 #define BCM_BFD_STATUS_REMOTE_INIT          0x00000040 /* BFD Remote State Init. */
    187 #define BCM_BFD_STATUS_REMOTE_UP            0x00000080 /* BFD Remote State Up. */
    188 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_NONE 0x00000100 /* BFD Local Diag None. */
    189 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_CTRL_DETECT_TIME_EXPIRED 0x00000200 /* BFD Local Diag Detect
    190                                                           Time Expired. */
    191 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_ECHO_FAILED 0x00000400 /* BFD Local Diag Echo
    192                                                           Failed. */
    193 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_NEIGHBOR_SIGNALED_SESSION_DOWN 0x00000800 /* BFD Neighbor Signaled
    194                                                           Session Down. */
    195 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_FORWARDING_PLANE_RESET 0x00001000 /* Local diag Forwarding
    196                                                           Plane Reset. */
    197 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_PATH_DOWN 0x00002000 /* Local diag Path Down. */
    198 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_CONCATENATED_PATH_DOWN 0x00004000 /* Local Diag
    199                                                           Concatenated Path
    200                                                           Down. */
    201 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_ADMIN_DOWN 0x00008000 /* Local Diag
    202                                                           Administratively Down. */
    203 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_REVERSE_CONCATENATED_PATH_DOWN 0x00010000 /* Local Diag Reverse
    204                                                           Concatenated Path
    205                                                           Down. */
    206 #define BCM_BFD_STATUS_LOCAL_DIAG_CODE_MIS_CONNECTIVITY_DEFECT 0x00020000 /* Local Diag Mis conn
    207                                                           Defect. */
    208 
    209 /* BFD fault flags. */
    210 #define BCM_BFD_ENDPOINT_REMOTE_LOC 0x00000001 /* BFD endpoint time out */
    211 
    212 typedef struct bcm_bfd_auth_simple_password_s {
    213     uint8 length; 
    214     uint8 password[BCM_BFD_SIMPLE_PASSWORD_KEY_LENGTH_MAX]; 
    215 } bcm_bfd_auth_simple_password_t;
    216 
    217 /* SHA1 authentication data. */
    218 #define BCM_BFD_AUTH_SHA1_KEY_LENGTH    _SHR_BFD_AUTH_SHA1_KEY_LENGTH 
    219 
    220 typedef struct bcm_bfd_auth_sha1_s {
    221     uint8 enable; 
    222     uint32 sequence; 
    223     uint8 key[BCM_BFD_AUTH_SHA1_KEY_LENGTH]; 
    224 } bcm_bfd_auth_sha1_t;
    225 
    226 /* BFD Session States. */
    227 typedef enum bcm_bfd_state_e {
    228     bcmBFDStateAdminDown = _SHR_BFD_SESSION_STATE_ADMIN_DOWN, 
    229     bcmBFDStateDown = _SHR_BFD_SESSION_STATE_DOWN, 
    230     bcmBFDStateInit = _SHR_BFD_SESSION_STATE_INIT, 
    231     bcmBFDStateUp = _SHR_BFD_SESSION_STATE_UP, 
    232     bcmBFDStateCount = _SHR_BFD_SESSION_STATE_COUNT 
    233 } bcm_bfd_state_t;
    234 
    235 /* BFD Diagnostic Codes. */
    236 typedef enum bcm_bfd_diag_code_e {
    237     bcmBFDDiagCodeNone = _SHR_BFD_DIAG_CODE_NONE, 
    238     bcmBFDDiagCodeCtrlDetectTimeExpired = _SHR_BFD_DIAG_CODE_CTRL_DETECT_TIME_EXPIRED, 
    239     bcmBFDDiagCodeEchoFailed = _SHR_BFD_DIAG_CODE_ECHO_FAILED, 
    240     bcmBFDDiagCodeNeighbourSignalledDown = _SHR_BFD_DIAG_CODE_NEIGHBOR_SIGNALED_SESSION_DOWN, 
    241     bcmBFDDiagCodeForwardingPlaneReset = _SHR_BFD_DIAG_CODE_FORWARDING_PLANE_RESET, 
    242     bcmBFDDiagCodePathDown = _SHR_BFD_DIAG_CODE_PATH_DOWN, 
    243     bcmBFDDiagCodeConcatPathDown = _SHR_BFD_DIAG_CODE_CONCATENATED_PATH_DOWN, 
    244     bcmBFDDiagCodeAdminDown = _SHR_BFD_DIAG_CODE_ADMIN_DOWN, 
    245     bcmBFDDiagCodeRevConcatPathDown = _SHR_BFD_DIAG_CODE_REVERSE_CONCATENATED_PATH_DOWN, 
    246     bcmBFDDiagCodeMisConnectivityDefect = _SHR_BFD_DIAG_CODE_MIS_CONNECTIVITY_DEFECT, 
    247     bcmBFDDiagCodeCount = _SHR_BFD_DIAG_CODE_COUNT 
    248 } bcm_bfd_diag_code_t;
    249 
    250 /* BFD Authentication Types. */
    251 typedef enum bcm_bfd_auth_type_e {
    252     bcmBFDAuthTypeNone = _SHR_BFD_AUTH_TYPE_NONE, 
    253     bcmBFDAuthTypeSimplePassword = _SHR_BFD_AUTH_TYPE_SIMPLE_PASSWORD, 
    254     bcmBFDAuthTypeKeyedMD5 = _SHR_BFD_AUTH_TYPE_KEYED_MD5, 
    255     bcmBFDAuthTypeMeticulousKeyedMD5 = _SHR_BFD_AUTH_TYPE_METICULOUS_KEYED_MD5, 
    256     bcmBFDAuthTypeKeyedSHA1 = _SHR_BFD_AUTH_TYPE_KEYED_SHA1, 
    257     bcmBFDAuthTypeMeticulousKeyedSHA1 = _SHR_BFD_AUTH_TYPE_METICULOUS_KEYED_SHA1, 
    258     bcmBFDAuthTypeCount = _SHR_BFD_AUTH_TYPE_COUNT 
    259 } bcm_bfd_auth_type_t;
    260 
    261 /* BFD tunnel types. */
    262 typedef enum bcm_bfd_tunnel_type_e {
    263     bcmBFDTunnelTypeUdp = 0,            /* BFD over IPv4/v6. */
    264     bcmBFDTunnelTypeIp4in4 = 1,         /* BFD over IPv4-in-IPv4 tunnel. */
    265     bcmBFDTunnelTypeIp6in4 = 2,         /* BFD over IPv6-in-IPv4 tunnel. */
    266     bcmBFDTunnelTypeIp4in6 = 3,         /* BFD over IPv4-in-IPv6 tunnel. */
    267     bcmBFDTunnelTypeIp6in6 = 4,         /* BFD over IPv6-in-IPv6 tunnel. */
    268     bcmBFDTunnelTypeGRE = 5,            /* BFD over GRE IPv4-in-IPv4 tunnel. */
    269     bcmBFDTunnelTypeGre4In4 = bcmBFDTunnelTypeGRE, /* BFD over GRE IPv4-in-IPv4 tunnel. */
    270     bcmBFDTunnelTypeMpls = 6,           /* BFD over MPLS LSP. */
    271     bcmBFDTunnelTypePweControlWord = 7, /* BFD over PW with CW. */
    272     bcmBFDTunnelTypePweRouterAlert = 8, /* BFD over PW with Router Alert. */
    273     bcmBFDTunnelTypePweTtl = 9,         /* BFD over PW with TTL=1. */
    274     bcmBFDTunnelTypeMplsTpCc = 10,      /* BFD for MPLS-TP proactive CC. */
    275     bcmBFDTunnelTypeMplsTpCcCv = 11,    /* BFD for MPLS-TP proactive CC&CV. */
    276     bcmBFDTunnelTypeGre6In4 = 12,       /* BFD over GRE IPv6-in-IPv4 tunnel. */
    277     bcmBFDTunnelTypeGre4In6 = 13,       /* BFD over GRE IPv4-in-IPv6 tunnel. */
    278     bcmBFDTunnelTypeGre6In6 = 14,       /* BFD over GRE IPv6-in-IPv6 tunnel. */
    279     bcmBFDTunnelTypePweGal = 15,        /* BFD over PW with GAL, GACH. */
    280     bcmBFDTunnelTypeMplsPhp = 16,       /* BFD over MPLS LSP and PHP. */
    281     bcmBFDTunnelTypeCount = 17 
    282 } bcm_bfd_tunnel_type_t;
    283 
    284 /* BFD endpoint ID type. */
    285 typedef int bcm_bfd_endpoint_t;
    286 
    287 /* BFD endpoint object. */
    288 typedef struct bcm_bfd_endpoint_info_s {
    289     uint32 flags;                       /* Control flags. */
    290     bcm_bfd_endpoint_t id;              /* Endpoint identifier. */
    291     bcm_bfd_endpoint_t remote_id;       /* Remote endpoint identifier. */
    292     bcm_bfd_tunnel_type_t type;         /* Type of BFD encapsulation. */
    293     bcm_gport_t gport;                  /* Gport identifier. */
    294     bcm_gport_t tx_gport;               /* TX gport associated with this
    295                                            endpoint. */
    296     bcm_gport_t remote_gport;           /* Gport identifier of trapping
    297                                            destination: OAMP or CPU, local or
    298                                            remote. */
    299     int bfd_period;                     /* For local endpoints, this is the BFD
    300                                            transmission period in ms. */
    301     bcm_vpn_t vpn;                      /* VPN. */
    302     uint8 vlan_pri;                     /* VLAN tag priority. */
    303     uint8 inner_vlan_pri;               /* Inner VLAN tag priority. */
    304     bcm_vrf_t vrf_id;                   /* Vrf identifier. */
    305     bcm_mac_t dst_mac;                  /* Destination MAC. */
    306     bcm_mac_t src_mac;                  /* Source MAC. */
    307     bcm_vlan_t pkt_inner_vlan_id;       /* TX Packet inner Vlan Id. */
    308     bcm_ip_t dst_ip_addr;               /* Destination IPv4 address. */
    309     bcm_ip6_t dst_ip6_addr;             /* Destination IPv6 address. */
    310     bcm_ip_t src_ip_addr;               /* Source IPv4 address. */
    311     bcm_ip6_t src_ip6_addr;             /* Source IPv6 address. */
    312     uint8 ip_tos;                       /* IPv4 Tos / IPv6 Traffic Class. */
    313     uint8 ip_ttl;                       /* IPv4 TTL / IPv6 Hop Count. */
    314     bcm_ip_t inner_dst_ip_addr;         /* Inner destination IPv4 address. */
    315     bcm_ip6_t inner_dst_ip6_addr;       /* Inner destination IPv6 address. */
    316     bcm_ip_t inner_src_ip_addr;         /* Inner source IPv4 address. */
    317     bcm_ip6_t inner_src_ip6_addr;       /* Inner source IPv6 address. */
    318     uint8 inner_ip_tos;                 /* Inner IPv4 Tos / IPv6 Traffic Class. */
    319     uint8 inner_ip_ttl;                 /* Inner IPv4 TTL / IPv6 Hop Count. */
    320     uint32 udp_src_port;                /* UDP source port for Ipv4, Ipv6. */
    321     bcm_mpls_label_t label;             /* Incoming inner label. */
    322     bcm_mpls_label_t mpls_hdr;          /* MPLS Header. */
    323     bcm_mpls_egress_label_t egress_label; /* The MPLS outgoing label information. */
    324     bcm_if_t egress_if;                 /* Egress interface. */
    325     uint8 mep_id[BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CC/CV TLV and Source MEP ID. */
    326     uint8 mep_id_length;                /* Length of MPLS-TP CC/CV TLV and
    327                                            MEP-ID. */
    328     bcm_cos_t int_pri;                  /* Egress queuing for outgoing BFD to
    329                                            remote. */
    330     uint8 cpu_qid;                      /* CPU queue for BFD. */
    331     bcm_bfd_state_t local_state;        /* Local session state. */
    332     uint32 local_discr;                 /* Local discriminator. */
    333     bcm_bfd_diag_code_t local_diag;     /* Local diagnostic code. */
    334     uint32 local_flags;                 /* Flags combination on outgoing frames. */
    335     uint32 local_min_tx;                /* Desired local min tx interval. */
    336     uint32 local_min_rx;                /* Required local rx interval. */
    337     uint32 local_min_echo;              /* Local minimum echo interval. */
    338     uint8 local_detect_mult;            /* Local detection interval multiplier. */
    339     bcm_bfd_auth_type_t auth;           /* Authentication type. */
    340     uint32 auth_index;                  /* Authentication index. */
    341     uint32 tx_auth_seq;                 /* Tx authentication sequence id. */
    342     uint32 rx_auth_seq;                 /* Rx authentication sequence id. */
    343     uint32 remote_flags;                /* Remote flags. */
    344     bcm_bfd_state_t remote_state;       /* Remote session state. */
    345     uint32 remote_discr;                /* Remote discriminator. */
    346     bcm_bfd_diag_code_t remote_diag;    /* Remote diagnostic code. */
    347     uint32 remote_min_tx;               /* Desired remote min tx interval. */
    348     uint32 remote_min_rx;               /* Required remote rx interval. */
    349     uint32 remote_min_echo;             /* Remote minimum echo interval. */
    350     uint8 remote_detect_mult;           /* Remote detection interval multiplier. */
    351     int sampling_ratio;                 /* 0 - No packets sampled to the CPU.
    352                                            1-8 - Count of packets (with events)
    353                                            that need to arrive before one is
    354                                            sampled to the CPU. */
    355     uint8 loc_clear_threshold;          /* Number of packets required to reset
    356                                            the Loss-of-Continuity status per
    357                                            endpoint. */
    358     uint32 ip_subnet_length;            /* The subnet length for incoming packet
    359                                            validity check. Value 0 indicates no
    360                                            check is performed, positive values
    361                                            indicate the amount of MSBs to be
    362                                            compared. */
    363     uint8 remote_mep_id[BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CC/CV TLV and Remote MEP ID. */
    364     uint8 remote_mep_id_length;         /* Length of MPLS-TP CC/CV TLV and
    365                                            REMOTE MEP-ID. */
    366     uint8 mis_conn_mep_id[BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CC/CV TLV and Mis
    367                                            connectivity MEP ID. */
    368     uint8 mis_conn_mep_id_length;       /* Length of MPLS-TP CC/CV TLV and Mis
    369                                            connectivity MEP-ID. */
    370     uint32 bfd_detection_time;          /* Optional: BFD Detection Time, in
    371                                            microseconds. */
    372     bcm_vlan_t pkt_vlan_id;             /* TX Packet Vlan Id. */
    373     bcm_vlan_t rx_pkt_vlan_id;          /* RX Packet Vlan Id. */
    374     bcm_mpls_label_t gal_label;         /* MPLS GAL label. */
    375     uint32 faults;                      /* Fault flags. */
    376     uint32 flags2;                      /* Second set of control flags. */
    377     int ipv6_extra_data_index;          /* Pointer to first extended data entry */
    378     int punt_good_packet_period;        /* BFD good packets sampling period.
    379                                            Every punt_good_packet_period
    380                                            milliseconds, a single packet is
    381                                            punted to the CPU */
    382     uint8 bfd_period_cluster;           /* Tx period group. All MEPs in a group
    383                                            must be created with the same Tx
    384                                            period. Modifying the Tx period in
    385                                            one MEP affects the others. */
    386 } bcm_bfd_endpoint_info_t;
    387 
    388 /* BFD event types. */
    389 typedef enum bcm_bfd_event_type_e {
    390     bcmBFDEventStateChange = 0, 
    391     bcmBFDEventRemoteStateDiag = 1, 
    392     bcmBFDEventSessionDiscriminatorChange = 2, 
    393     bcmBFDEventAuthenticationChange = 3, 
    394     bcmBFDEventParameterChange = 4, 
    395     bcmBFDEventSessionError = 5, 
    396     bcmBFDEventEndpointRemote = 6, 
    397     bcmBFDEventEndpointRemoteUp = 7, 
    398     bcmBFDEventEndpointTimeout = 8, 
    399     bcmBFDEventEndpointTimein = 9, 
    400     bcmBFDEventEndpointTimeoutEarly = 10, 
    401     bcmBFDEventEndpointFlagsChange = 11, 
    402     bcmBFDEventEndpointRemotePollBitSet = 12, 
    403     bcmBFDEventEndpointRemoteFinalBitSet = 13, 
    404     bcmBFDEventEndpointLocalSessionStateAdminDown = 14, 
    405     bcmBFDEventEndpointLocalSessionStateDown = 15, 
    406     bcmBFDEventEndpointLocalSessionStateInit = 16, 
    407     bcmBFDEventEndpointLocalSessionStateUp = 17, 
    408     bcmBFDEventEndpointMisConnectivityDefect = 18, /* Misconnectivity Defect Detected */
    409     bcmBFDEventEndpointMisConnectivityDefectClear = 19, /* Misconnectivity Defect Cleared */
    410     bcmBFDEventEndpoinUnExpectedMeg = 20, /* UnExpectedMeg Defect Detected */
    411     bcmBFDEventEndpoinUnExpectedMegClear = 21, /* UnExpectedMeg Defect Cleared */
    412     bcmBFDEventCount = 22 
    413 } bcm_bfd_event_type_t;
    414 
    415 typedef struct bcm_bfd_event_types_s {
    416     SHR_BITDCL w[_SHR_BITDCLSIZE(bcmBFDEventCount)]; 
    417 } bcm_bfd_event_types_t;
    418 
    419 #define BCM_BFD_EVENT_TYPE_SET(_event_types, _event_type)  SHR_BITSET((_event_types).w, (_event_type)) 
    420 
    421 #define BCM_BFD_EVENT_TYPE_GET(_event_types, _event_type)  SHR_BITGET((_event_types).w, (_event_type)) 
    422 
    423 #define BCM_BFD_EVENT_TYPE_CLEAR(_event_types, _event_type)  SHR_BITCLR((_event_types).w, (_event_type)) 
    424 
    425 #define BCM_BFD_EVENT_TYPE_SET_ALL(_event_types)  SHR_BITSET_RANGE((_event_types).w, 0, bcmBFDEventCount) 
    426 
    427 #define BCM_BFD_EVENT_TYPE_CLEAR_ALL(_event_types)  SHR_BITCLR_RANGE((_event_types).w, 0, bcmBFDEventCount) 
    428 
    429 /* BFD endpoint statistics. */
    430 typedef struct bcm_bfd_endpoint_stat_s {
    431     uint32 packets_in;              /* Total packets in. */
    432     uint32 packets_out;             /* Total packets out. */
    433     uint32 packets_drop;            /* Total packets drop. */
    434     uint32 packets_auth_drop;       /* Packets drop due to authentication
    435                                        failure. */
    436     uint64 packets_in_64;           /* Total packets in 64bit count. */
    437     uint64 packets_out_64;          /* Total packets out 64bit count. */
    438     uint64 packets_drop_64;         /* Total packets drop 64bit count. */
    439     uint64 packets_auth_drop_64;    /* Packets drop due to authentication
    440                                        failure 64bit count. */
    441     uint64 packets_echo_reply;      /* Total number of echo reply packets
    442                                        processed. */
    443 } bcm_bfd_endpoint_stat_t;
    444 
    445 /* BFD Session and Diag status of each endpoint along with endpoint id. */
    446 typedef struct bcm_bfd_status_s {
    447     bcm_bfd_endpoint_t endpoint_id; /* Endpoint identifier. */
    448     uint32 session_status;          /* Session State and diag flags. */
    449 } bcm_bfd_status_t;
    450 
    451 /* Incoming bfd packets discarded statistics. */
    452 typedef struct bcm_bfd_discard_stat_s {
    453     uint32 bfd_ver_err;             /* Invalid BFD Version. */
    454     uint32 bfd_len_err;             /* BFD Length Error. */
    455     uint32 bfd_detect_mult;         /* BFD detect multiplier Zero. */
    456     uint32 bfd_my_disc;             /* BFD My discriminator Zero. */
    457     uint32 bfd_p_f_bit;             /* BFD poll and final bits set. */
    458     uint32 bfd_m_bit;               /* BFD M bit not equal to zero. */
    459     uint32 bfd_auth_type_mismatch;  /* BFD auth type mismatch. */
    460     uint32 bfd_auth_simple_err;     /* BFD auth simple password Error. */
    461     uint32 bfd_auth_m_sha1_err;     /* BFD auth SHA1 error. */
    462     uint32 bfd_sess_mismatch;       /* BFD Session mismatch. */
    463 } bcm_bfd_discard_stat_t;
    464 
    465 #ifndef BCM_HIDE_DISPATCHABLE
    466 
    467 /* Get 64-bit/32-bit BFD endpoint stats */
    468 extern int bcm_bfd_endpoint_stat_get(
    469     int unit, 
    470     bcm_bfd_endpoint_t endpoint, 
    471     bcm_bfd_endpoint_stat_t *ctr_info, 
    472     uint32 options);
    473 
    474 /* 
    475  * User should call this API - once to retrieve endpoint count
    476  * and again to retrieve the actual endpoint status.
    477  */
    478 extern int bcm_bfd_status_multi_get(
    479     int unit, 
    480     int max_endpoints, 
    481     bcm_bfd_status_t *status_arr, 
    482     int *count);
    483 
    484 #endif /* BCM_HIDE_DISPATCHABLE */
    485 
    486 /* Callback function type for BFD event handling. */
    487 typedef int (*bcm_bfd_event_cb)(
    488     int unit, 
    489     uint32 flags, 
    490     bcm_bfd_event_types_t events, 
    491     bcm_bfd_endpoint_t endpoint, 
    492     void *user_data);
    493 
    494 #ifndef BCM_HIDE_DISPATCHABLE
    495 
    496 /* Initialize the BFD subsystem */
    497 extern int bcm_bfd_init(
    498     int unit);
    499 
    500 /* Shut down the BFD subsystem. */
    501 extern int bcm_bfd_detach(
    502     int unit);
    503 
    504 #endif /* BCM_HIDE_DISPATCHABLE */
    505 
    506 /* Initialize a BFD endpoint information structure. */
    507 extern void bcm_bfd_endpoint_info_t_init(
    508     bcm_bfd_endpoint_info_t *endpoint_info);
    509 
    510 #ifndef BCM_HIDE_DISPATCHABLE
    511 
    512 /* Create or update an BFD endpoint object */
    513 extern int bcm_bfd_endpoint_create(
    514     int unit, 
    515     bcm_bfd_endpoint_info_t *endpoint_info);
    516 
    517 /* Get an BFD endpoint object. */
    518 extern int bcm_bfd_endpoint_get(
    519     int unit, 
    520     bcm_bfd_endpoint_t endpoint, 
    521     bcm_bfd_endpoint_info_t *endpoint_info);
    522 
    523 /* Start the Transmission of BFD PDUs. */
    524 extern int bcm_bfd_tx_start(
    525     int unit);
    526 
    527 /* Stop the Transmission of BFD PDUs. */
    528 extern int bcm_bfd_tx_stop(
    529     int unit);
    530 
    531 /* Destroy an BFD endpoint object */
    532 extern int bcm_bfd_endpoint_destroy(
    533     int unit, 
    534     bcm_bfd_endpoint_t endpoint);
    535 
    536 /* Destroy all BFD endpoint objects */
    537 extern int bcm_bfd_endpoint_destroy_all(
    538     int unit);
    539 
    540 /* Register a callback for handling BFD events */
    541 extern int bcm_bfd_event_register(
    542     int unit, 
    543     bcm_bfd_event_types_t event_types, 
    544     bcm_bfd_event_cb cb, 
    545     void *user_data);
    546 
    547 /* Unregister a callback for handling BFD events */
    548 extern int bcm_bfd_event_unregister(
    549     int unit, 
    550     bcm_bfd_event_types_t event_types, 
    551     bcm_bfd_event_cb cb);
    552 
    553 /* 
    554  * Poll an BFD endpoint object.  Valid only for BFD sessions in Demand
    555  * Mode and state of bcmBFDStateUp.
    556  */
    557 extern int bcm_bfd_endpoint_poll(
    558     int unit, 
    559     bcm_bfd_endpoint_t endpoint);
    560 
    561 /* Set SHA1 authentication entry */
    562 extern int bcm_bfd_auth_sha1_set(
    563     int unit, 
    564     int index, 
    565     bcm_bfd_auth_sha1_t *sha1);
    566 
    567 /* Get SHA1 authentication entry */
    568 extern int bcm_bfd_auth_sha1_get(
    569     int unit, 
    570     int index, 
    571     bcm_bfd_auth_sha1_t *sha1);
    572 
    573 /* Set Simple Password authentication entry */
    574 extern int bcm_bfd_auth_simple_password_set(
    575     int unit, 
    576     int index, 
    577     bcm_bfd_auth_simple_password_t *sp);
    578 
    579 /* Get Simple Password authentication entry */
    580 extern int bcm_bfd_auth_simple_password_get(
    581     int unit, 
    582     int index, 
    583     bcm_bfd_auth_simple_password_t *sp);
    584 
    585 /* Reset the bfd discarded statistics in FW. */
    586 extern int bcm_bfd_discard_stat_set(
    587     int unit, 
    588     bcm_bfd_discard_stat_t *discarded_info);
    589 
    590 /* Get the bfd discarded statistics from FW. */
    591 extern int bcm_bfd_discard_stat_get(
    592     int unit, 
    593     bcm_bfd_discard_stat_t *discarded_info);
    594 
    595 #endif /* defined(INCLUDE_BFD) */
    596 
    597 #endif /* BCM_HIDE_DISPATCHABLE */
    598 
    599 #endif /* __BCM_BFD_H__ */