bfd.h (7592B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: bfd.h 8 * Purpose: BFD definitions common to SDK and uKernel 9 * 10 * Notes: Definition changes should be avoided in order to 11 * maintain compatibility between SDK and uKernel since 12 * both images are built and loaded separately. 13 */ 14 15 #ifndef _SOC_SHARED_BFD_H 16 #define _SOC_SHARED_BFD_H 17 18 #ifdef BCM_UKERNEL 19 /* Build for uKernel not SDK */ 20 #include "sdk_typedefs.h" 21 #else 22 #include <sal/types.h> 23 #endif 24 25 #include <shared/bfd.h> 26 27 28 /***************************************** 29 * BFD uController Error codes 30 */ 31 typedef enum shr_bfd_uc_error_e { 32 SHR_BFD_UC_E_NONE = 0, 33 SHR_BFD_UC_E_INTERNAL, 34 SHR_BFD_UC_E_MEMORY, 35 SHR_BFD_UC_E_UNIT, 36 SHR_BFD_UC_E_PARAM, 37 SHR_BFD_UC_E_EMPTY, 38 SHR_BFD_UC_E_FULL, 39 SHR_BFD_UC_E_NOT_FOUND, 40 SHR_BFD_UC_E_EXISTS, 41 SHR_BFD_UC_E_TIMEOUT, 42 SHR_BFD_UC_E_BUSY, 43 SHR_BFD_UC_E_FAIL, 44 SHR_BFD_UC_E_DISABLED, 45 SHR_BFD_UC_E_BADID, 46 SHR_BFD_UC_E_RESOURCE, 47 SHR_BFD_UC_E_CONFIG, 48 SHR_BFD_UC_E_UNAVAIL, 49 SHR_BFD_UC_E_INIT, 50 SHR_BFD_UC_E_PORT 51 } shr_bfd_uc_error_t; 52 53 #define SHR_BFD_UC_SUCCESS(rv) ((rv) == SHR_BFD_UC_E_NONE) 54 #define SHR_BFD_UC_FAILURE(rv) ((rv) != SHR_BFD_UC_E_NONE) 55 56 /* 57 * Macro: 58 * SHR_BFD_IF_ERROR_RETURN 59 * Purpose: 60 * Evaluate _op as an expression, and if an error, return. 61 * Notes: 62 * This macro uses a do-while construct to maintain expected 63 * "C" blocking, and evaluates "op" ONLY ONCE so it may be 64 * a function call that has side affects. 65 */ 66 67 #define SHR_BFD_IF_ERROR_RETURN(op) \ 68 do { \ 69 int __rv__; \ 70 if ((__rv__ = (op)) != SHR_BFD_UC_E_NONE) { \ 71 return(__rv__); \ 72 } \ 73 } while(0) 74 75 76 /* 77 * BFD for Unknown Remote Discriminator 78 * 'your_discriminator' zero 79 */ 80 #define SHR_BFD_DISCR_UNKNOWN_SESSION_ID 0x7FF /* Session ID */ 81 #define SHR_BFD_DISCR_UNKNOWN_YOUR_DISCR 0 /* Discriminator */ 82 83 /* 84 * BFD Session Set flags 85 */ 86 #define SHR_BFD_SESS_SET_F_CREATE 0x00000001 87 #define SHR_BFD_SESS_SET_F_LOCAL_DISC 0x00000002 88 #define SHR_BFD_SESS_SET_F_LOCAL_MIN_TX 0x00000004 89 #define SHR_BFD_SESS_SET_F_LOCAL_MIN_RX 0x00000008 90 #define SHR_BFD_SESS_SET_F_LOCAL_MIN_ECHO_RX 0x00000010 91 #define SHR_BFD_SESS_SET_F_LOCAL_DIAG 0x00000020 92 #define SHR_BFD_SESS_SET_F_LOCAL_DEMAND 0x00000040 93 #define SHR_BFD_SESS_SET_F_LOCAL_DETECT_MULT 0x00000080 94 #define SHR_BFD_SESS_SET_F_SESSION_DESTROY 0x00000100 95 #define SHR_BFD_SESS_SET_F_SHA1_XMT_SEQ_INCR 0x00000200 96 #define SHR_BFD_SESS_SET_F_ENCAP 0x00000400 97 #define SHR_BFD_SESS_SET_F_REMOTE_DISC 0x00000800 98 #define SHR_BFD_SESS_SET_F_AUTH_TYPE 0x00001000 99 #define SHR_BFD_SESS_SET_F_LOCAL_ECHO 0x00002000 100 #define SHR_BFD_SESS_SET_F_MEP_ID_LENGTH 0x00004000 101 #define SHR_BFD_SESS_SET_F_MEP_ID 0x00008000 102 #define SHR_BFD_SESS_SET_F_REMOTE_MEP_ID_LENGTH 0x00010000 103 #define SHR_BFD_SESS_SET_F_REMOTE_MEP_ID 0x00020000 104 #define SHR_BFD_SESS_SET_F_TRUNK 0x00040000 105 #define SHR_BFD_SESS_SET_F_MICRO_BFD 0x00080000 106 #define SHR_BFD_SESS_SET_F_SAMPLING_RATIO 0x00100000 107 #define SHR_BFD_SESS_SET_F_MPLS_PHP 0x00200000 108 #define SHR_BFD_SESS_SET_F_ADMIN_DOWN_PKT_ON_SESS_DEL 0x00400000 109 #define SHR_BFD_SESS_SET_F_SSO_UPDATE 0x00800000 110 /* 111 * BFD sampling flags 112 */ 113 #define SHR_BFD_SAMPLING_F_TRIGGER 0x80 114 115 /* 116 * BFD Encapsulation types 117 */ 118 #define SHR_BFD_ENCAP_TYPE_RAW 0 119 #define SHR_BFD_ENCAP_TYPE_V4UDP 1 120 #define SHR_BFD_ENCAP_TYPE_V6UDP 2 121 #define SHR_BFD_ENCAP_TYPE_MPLS_TP_CC 3 /* MPLS-TP CC only mode */ 122 #define SHR_BFD_ENCAP_TYPE_MPLS_TP_CC_CV 4 /* MPLS-TP CC CV */ 123 #define SHR_BFD_ENCAP_TYPE_MPLS_PHP 5 /* MPLS PHP*/ 124 125 /* BFD debug log macros */ 126 127 /* Size of the metadata prefixed to the buffer */ 128 #define SHR_BFD_TRACE_LOG_METADATA_SIZE 6 129 130 /* Index 0 has the size */ 131 #define SHR_BFD_TRACE_LOG_SIZE(buf) (buf)[4] 132 133 /* Index 1 has the current index in the buffer */ 134 #define SHR_BFD_TRACE_LOG_CUR_IDX(buf) (buf)[5] 135 136 /* Increment the current index */ 137 #define SHR_BFD_TRACE_LOG_IDX_INCR(buf, idx) \ 138 ((idx) + 1) > SHR_BFD_TRACE_LOG_SIZE(buf) ? SHR_BFD_TRACE_LOG_METADATA_SIZE \ 139 : ((idx) + 1) 140 141 /* Decrement the current index */ 142 #define SHR_BFD_TRACE_LOG_IDX_DECR(buf, idx) \ 143 ((idx) == SHR_BFD_TRACE_LOG_METADATA_SIZE) ? (SHR_BFD_TRACE_LOG_SIZE(buf) - 1) \ 144 : ((idx) - 1) 145 146 /* BFD filenames, used for debugging, don't change the order */ 147 #define SHR_BFD_FILENAMES \ 148 { \ 149 "Invalid ", \ 150 "bfd_control.c ", \ 151 "bfd_rx.c ", \ 152 "bfd_shell.c ", \ 153 "bfd_static.c ", \ 154 "bfd_test.c ", \ 155 "bfd_timer.c ", \ 156 "bfd_tx.c ", \ 157 "bfd_uc_pack.c ", \ 158 "bfd_util.c " \ 159 } 160 161 /* Enums for BFD filenames, used for debugging, don't change the order */ 162 typedef enum shr_bfd_filenames_e { 163 SHR_BFD_FILENAME_INVALID = 0, 164 SHR_BFD_FILENAME_BFD_CONTROL_C = 1, 165 SHR_BFD_FILENAME_BFD_RX_C = 2, 166 SHR_BFD_FILENAME_BFD_SHELL_C = 3, 167 SHR_BFD_FILENAME_BFD_STATIC_C = 4, 168 SHR_BFD_FILENAME_BFD_TEST_C = 5, 169 SHR_BFD_FILENAME_BFD_TIMER_C = 6, 170 SHR_BFD_FILENAME_BFD_TX_C = 7, 171 SHR_BFD_FILENAME_BFD_UC_PACK_C = 8, 172 SHR_BFD_FILENAME_BFD_UTIL_C = 9, 173 SHR_BFD_FILENAME_MAX 174 } shr_bfd_filenames_t; 175 176 /* BFD tunnel types. */ 177 typedef enum shr_bfd_uc_match_id_type_e { 178 SHR_BFD_UC_SINGLE_TAG = 0, /* BFD with single vlan tag. */ 179 SHR_BFD_UC_DOUBLE_TAG = 1, /* BFD with double vlan tag. */ 180 SHR_BFD_UC_OUTER_IPV4 = 2, /* BFD with outer IPv4 tunnel. */ 181 SHR_BFD_UC_OUTER_IPV6 = 3, /* BFD with outer IPv6 tunnel. */ 182 SHR_BFD_UC_GRE = 4, /* BFD with GRE tunnel. */ 183 SHR_BFD_UC_OUTER_UDP = 5, /* BFD with outer IPv4/UDP tunnel. */ 184 SHR_BFD_UC_OUTER_BFD = 6, /* BFD over IPv4/v6. */ 185 SHR_BFD_UC_IPV4_IN = 7, /* BFD with IPv4-in-IPv6/IPv4 tunnel. */ 186 SHR_BFD_UC_IPV6_IN = 8, /* BFD with IPv6-in-IPv6/IPv4 tunnel. */ 187 SHR_BFD_UC_GRE_IN = 9, /* BFD with GRE-in-IPv6/IPv4 tunnel. */ 188 SHR_BFD_UC_INNER_UDP = 10, /* BFD with IPv4-in-IPv6/IPv4 UDP tunnel. */ 189 SHR_BFD_UC_INNER_BFD = 11, /* BFD over IPv6/IPv4-in-IPv6/IPv4 tunnel. */ 190 SHR_BFD_UC_MPLS = 12, /* BFD over MPLS. */ 191 SHR_BFD_UC_MPLS_LABEL = 13, /* BFD over MPLS label details. */ 192 SHR_BFD_UC_IPINGRE = 14, /* BFD with IP-in-GRE */ 193 SHR_BFD_UC_IPINIP = 15, /* BFD with IP-in-IP */ 194 SHR_BFD_UC_MATCH_ID_TYPE_COUNT = 16 195 } shr_bfd_uc_match_id_type_t; 196 197 #endif /* _SOC_SHARED_BFD_H */