bfd.h (4782B)
1 /** \file dnx/bfd/bfd.h 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 #ifndef BFD_INIT_H_INCLUDED 10 /* 11 * { 12 */ 13 #define BFD_INIT_H_INCLUDED 14 15 #ifndef BCM_DNX_SUPPORT 16 #error "This file is for use by DNX (JR2) family only!" 17 #endif 18 19 /* 20 * } 21 */ 22 #include <soc/dnx/dbal/dbal.h> 23 24 #define DNX_BFD_IPV6_HEADER_SIZE 40 25 26 #define DNX_BFD_IPV6_PSEUDO_HEADER_SIZE 36 27 28 #define DNX_BFD_IPV6_SOUCRE_ADDRESS_OFFSET 8 29 30 #define DNX_BFD_IPV6_DESTINATION_ADDRESS_OFFSET 24 31 32 #define DNX_BFD_UDP_HEADER_SIZE 8 33 34 #define DNX_BFD_BFD_HEADER_SIZE 24 35 36 #define DNX_BFD_CHECKSUM_HEADER_SIZE (DNX_BFD_IPV6_PSEUDO_HEADER_SIZE + DNX_BFD_UDP_HEADER_SIZE + DNX_BFD_BFD_HEADER_SIZE) 37 38 #define DNX_BFD_UDP_OVER_IPV6_HEADER_SIZE (DNX_BFD_UDP_HEADER_SIZE + DNX_BFD_IPV6_HEADER_SIZE) 39 40 #define DNX_BFD_IPV6_NOF_EXTRA_DATA_ENTRIES 2 41 42 #define DNX_BFD_SBFD_REFLECTOR_UDP 7784 43 44 #define DNX_BFD_OAM_LIF_FROM_TCAM_INSTRUCTION 0X400000 45 46 /* BFDoIPv6 network headers - used for the implementation of BFDoIPv6 47 * OAMP-PE program removes IPv4 header and adds IPv6 header that is taken from additional(extra) data 48 * we use these headers structures for conveniently build the headers. 49 */ 50 51 /* IPv6 header */ 52 typedef struct 53 { 54 uint32 version_prior_flow_label; /* 4 bits version, 8 bits prior, 20 bits flow-ID */ 55 uint16 payload_length; 56 uint8 next_header; 57 uint8 hop_limit; 58 bcm_ip6_t source_address; 59 bcm_ip6_t destination_address; 60 } bcm_bfd_ipv6_header_t; 61 62 /* IPv6 pseudo header - used for UDP checksum calculation */ 63 typedef struct 64 { 65 bcm_ip6_t source_address; 66 bcm_ip6_t destination_address; 67 uint8 zero; 68 uint8 protocol; 69 uint16 udp_length; 70 } bcm_bfd_ipv6_pseudo_header_t; 71 72 /* UDP header */ 73 typedef struct 74 { 75 uint16 source_port; 76 uint16 destination_port; 77 uint16 length; 78 uint16 checksum; 79 } bcm_bfd_udp_header_t; 80 81 /* bfd header - used for UDP checksum calculation (OAMP-PE needs only UDP and IPv6 headers) */ 82 typedef struct 83 { 84 uint8 vers_diag; /* 3 bits vers, 5 bits diag */ 85 uint8 sta_flags; /* 2 bits sta, 6 bits flags */ 86 uint8 detect_mult; 87 uint8 length; 88 uint32 my_discriminator; 89 uint32 your_discriminator; 90 uint32 desired_min_tx_interval; 91 uint32 required_min_rx_interval; 92 uint32 required_min_echo_rx_interval; 93 } bcm_bfd_bfd_header_t; 94 95 /* in UDP, the checksum of IPv6 pseudo header, UDP header and UDP data 96 * (bfd in our case) is being calculated and saved in the checksum field 97 * before sending the packet 98 */ 99 100 typedef struct 101 { 102 bcm_bfd_ipv6_pseudo_header_t ipv6_pseudo_header; 103 bcm_bfd_udp_header_t udp_header; 104 bcm_bfd_bfd_header_t bfd_header; 105 } bcm_bfd_checksum_header_t; 106 107 /* this represents the structure of the data we should send to the OAMP-PE */ 108 typedef struct 109 { 110 bcm_bfd_ipv6_header_t ipv6_header; 111 bcm_bfd_udp_header_t udp_header; 112 } bcm_bfd_upd_over_ipv6_header_t; 113 114 /** 115 * \brief - Initialize BFD module. 116 * This function calls initialization functions for BFD 117 * procedures 118 * 119 * Called from init sequence as part of dnx init pp sequence 120 * 121 * \param [in] unit - Identifying number of hardware unit used. 122 * 123 * \return 124 * shr_error_e 125 * 126 * \remark 127 * * None 128 * \see 129 * * None 130 */ 131 shr_error_e dnx_bfd_init( 132 int unit); 133 134 /** 135 * \brief - This function sets the value of the my-BFD-DIP destination. 136 * This value can then be used to create BFD endpoints that use 137 * DIPs that will not be stored in the 16-entry hard logic table, 138 * thus allowing more than 16 different DIPs. 139 * 140 * \param [in] unit - Number of hardware unit used. 141 * \param [in] destination - value to write to register. 142 * 143 * \return 144 * shr_error_e 145 * 146 * \remark 147 * * None 148 * \see 149 * * None 150 */ 151 shr_error_e dnx_bfd_my_dip_destination_set( 152 int unit, 153 uint32 destination); 154 155 /** 156 * \brief - This function reads the value of the my-BFD-DIP destination. 157 * 158 * \param [in] unit - Number of hardware unit used. 159 * \param [out] destination - pointer to which result should be written. 160 * 161 * \return 162 * shr_error_e 163 * 164 * \remark 165 * * None 166 * \see 167 * * None 168 */ 169 shr_error_e dnx_bfd_my_dip_destination_get( 170 int unit, 171 uint32 *destination); 172 173 /** 174 * \brief - Modify the MP profile ID for a BFD EP. 175 * Delete ACC-MEP-action-DB entry and create a new one. 176 * 177 * \param [in] unit - Number of hardware unit used. 178 * \param [in] endpoint - ID of endpoint to modify. 179 * \param [in] new_profile_id - profile ID to set. 180 * 181 * \return 182 * shr_error_e 183 * 184 * \remark 185 * * None 186 * \see 187 * * None 188 */ 189 shr_error_e dnx_bfd_modify_mp_profile_id( 190 int unit, 191 int endpoint, 192 int new_profile_id); 193 194 #endif /* BFD_INIT_H_INCLUDED */