bfd_msg.h (11189B)
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_msg.h 8 * Purpose: BFD Messages definitions common to SDK and uKernel. 9 * 10 * Messages between SDK and uKernel. 11 */ 12 13 #ifndef _SOC_SHARED_BFD_MSG_H_ 14 #define _SOC_SHARED_BFD_MSG_H_ 15 16 #ifdef BCM_UKERNEL 17 /* Build for uKernel not SDK */ 18 #include "sdk_typedefs.h" 19 #else 20 #include <sal/types.h> 21 #endif 22 23 #include <soc/shared/mos_msg_common.h> 24 #include <soc/shared/bfd_pkt.h> 25 #include <shared/bfd.h> 26 27 28 /******************************** 29 * BFD Control Messages 30 * 31 * SDK Host <--> uController 32 */ 33 34 35 /* 36 * BFD Encapsulation data 37 * 38 * The BFD Encapsulation is built in the SDK for each session 39 * and stored in the uKernel. It does NOT include the 40 * BFD Control Packet (this is built in the uKernel side). 41 * 42 * The BFD Encapsulation maximum length SHR_BFD_MAX_ENCAP_LENGTH 43 * is calculated using the largest possible encapsulation type size. 44 * 45 * HG2 + L2 + L2-Overhead + IPv6 + GRE + IPv6 + UDP 46 * 16 + 14 + 36 + 40 + 8 + 40 + 8 = 162 bytes 47 * 48 * NOTE: 49 * L2-Overhead 50 * This value is calculated from the difference between the 51 * latest L2 Ethernet frame and the original L2 Ethernet frame sizes: 52 * 1536 - 1500 = 36 53 * 54 * The Encapsulation length does NOT include BFD Control packet or CRC. 55 56 * The final packet length will add 57 * + BFD + [BFD_AUTH] + FCS 58 * + 24 + [28 ] + 4 = 228 59 * 60 * 61 * See following definitions for a given 'BFD-x' session encapsulation: 62 * 63 * |------------ 'encap_length-x'--------| 64 * | 65 * +-------------------------------------+ 66 * | BFD-x | 67 * | [HG] L2 [MPLS..] .....[IP/UDP] | 68 * +-------------------------------------+ 69 * | ^ 70 * | | 71 * +----- 'lkey_offset-x'-----+ 72 * 73 * NOTE: 74 * The Lookup Key (lkey_etype/lkey_offset/lkey_length) is used by 75 * the SW to match an initial RX BFD packet to an existing session entry. 76 * An initial BFD packet has 'your_discriminator' set to 0, so HW is not able 77 * to make a 'hit' on the corresponding session entry. 78 * 79 * Note that 'lkey_offset' is the offset relative the start of a 80 * given BFD encapsulation. 81 */ 82 #define SHR_BFD_MAX_ENCAP_LENGTH 162 83 84 85 /* Config flags sent as part of MOS_MSG_SUBCLASS_BFD_INIT 86 * bfd_sdk_msg_ctrl_init_t.config_flags 87 * 32 bits. 88 */ 89 #define BFD_CONFIG_SESSION_DOWN_EVENT_ON_CREATE 0x00000001 90 #define BFD_CONFIG_SESSION_ID_AS_DISCR 0x00000002 91 #define BFD_CONFIG_STATIC_REMOTE_DISCR 0x00000004 92 #define BFD_CONFIG_CONTROL_PLANE_BIT 0x00000008 93 #define BFD_CONFIG_NO_DOWN_PKT_ON_SESS_DELETE 0x00000010 94 #define BFD_CONFIG_NOT_CHECK_TRAP_CODE_ON_RX_PKT 0x00000020 95 #define BFD_CONFIG_LOCALDISCR_AS_SESSION_ID 0x00000040 96 97 /* 98 * BFD Session Set control message 99 */ 100 typedef struct shr_bfd_msg_ctrl_sess_set_s { 101 uint32 sess_id; 102 uint32 flags; 103 uint8 passive; 104 uint8 local_demand; 105 uint8 local_diag; 106 uint8 local_detect_mult; 107 uint32 local_discriminator; 108 uint32 remote_discriminator; 109 uint32 local_min_tx; 110 uint32 local_min_rx; 111 uint32 local_min_echo_rx; 112 uint8 auth_type; 113 uint32 auth_key; 114 uint32 xmt_auth_seq; 115 uint8 encap_type; /* Raw, UDP-IPv4/IPv6, used for UDP checksum */ 116 uint32 encap_length; /* BFD encapsulation length */ 117 uint8 encap_data[SHR_BFD_MAX_ENCAP_LENGTH]; /* Encapsulation data */ 118 uint16 lkey_etype; /* Lookup key Ether Type */ 119 uint16 lkey_offset; /* Lookup key offset */ 120 uint16 lkey_length; /* Lookup key length */ 121 uint32 mep_id_length; /* MPLS-TP CV Source MEP-ID TLV length */ 122 uint8 mep_id[_SHR_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CV 123 Source MEP-ID */ 124 uint8 mpls_label[SHR_BFD_MPLS_LABEL_LENGTH]; /* Incoming inner MPLS 125 label packet format */ 126 uint32 tx_port; 127 uint32 tx_cos; 128 uint32 tx_pri; 129 uint32 tx_qnum; 130 #ifdef SDK_45223_DISABLED 131 uint32 remote_mep_id_length; 132 uint8 remote_mep_id[_SHR_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CV 133 Remote MEP-ID */ 134 #endif 135 } shr_bfd_msg_ctrl_sess_set_t; 136 137 /* 138 * BFD Session Get control message 139 */ 140 typedef struct shr_bfd_msg_ctrl_sess_get_s { 141 uint32 sess_id; 142 uint8 enable; 143 uint8 passive; 144 uint8 local_demand; 145 uint8 remote_demand; 146 uint8 local_diag; 147 uint8 remote_diag; 148 uint8 local_sess_state; 149 uint8 remote_sess_state; 150 uint8 local_detect_mult; 151 uint8 remote_detect_mult; 152 uint32 local_discriminator; 153 uint32 remote_discriminator; 154 uint32 local_min_tx; 155 uint32 remote_min_tx; 156 uint32 local_min_rx; 157 uint32 remote_min_rx; 158 uint32 local_min_echo_rx; 159 uint32 remote_min_echo_rx; 160 uint8 auth_type; 161 uint32 auth_key; 162 uint32 xmt_auth_seq; 163 uint32 rcv_auth_seq; 164 uint8 encap_type; /* Raw, UDP-IPv4/IPv6, used for UDP checksum */ 165 uint32 encap_length; /* BFD encapsulation length */ 166 uint8 encap_data[SHR_BFD_MAX_ENCAP_LENGTH]; /* Encapsulation data */ 167 uint16 lkey_etype; /* Lookup key Ether Type */ 168 uint16 lkey_offset; /* Lookup key offset */ 169 uint16 lkey_length; /* Lookup key length */ 170 uint32 mep_id_length; /* MPLS-TP CV Source MEP-ID TLV length */ 171 uint8 mep_id[_SHR_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CV 172 Source MEP-ID */ 173 uint8 mpls_label[SHR_BFD_MPLS_LABEL_LENGTH]; /* Incoming inner MPLS 174 label packet format */ 175 uint32 tx_port; 176 uint32 tx_cos; 177 uint32 tx_pri; 178 uint32 tx_qnum; 179 #ifdef SDK_45223_DISABLED 180 uint32 remote_mep_id_length; 181 uint8 remote_mep_id[_SHR_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CV 182 Remote MEP-ID */ 183 uint32 mis_conn_mep_id_length; 184 uint8 mis_conn_mep_id[_SHR_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CV 185 Mis connectivity MEP-ID */ 186 #endif 187 } shr_bfd_msg_ctrl_sess_get_t; 188 189 /* 190 * BFD SHA1 Authentication control message 191 */ 192 typedef struct shr_bfd_msg_ctrl_auth_sha1_s { 193 uint32 index; 194 uint8 enable; 195 uint32 sequence; 196 uint8 key[_SHR_BFD_AUTH_SHA1_KEY_LENGTH]; 197 } shr_bfd_msg_ctrl_auth_sha1_t; 198 199 /* 200 * BFD Simple Password Authentication control message 201 * 202 * Set length to zero to disable entry. 203 */ 204 typedef struct shr_bfd_msg_ctrl_auth_sp_s { 205 uint32 index; 206 uint8 length; 207 uint8 password[_SHR_BFD_AUTH_SIMPLE_PASSWORD_KEY_LENGTH]; 208 } shr_bfd_msg_ctrl_auth_sp_t; 209 210 /* 211 * BFD Statistics control messages (Request/Reply) 212 */ 213 typedef struct shr_bfd_msg_ctrl_stat_req_s { 214 uint32 sess_id; /* BFD session (endpoint) id */ 215 uint32 clear; /* Clear stats */ 216 } shr_bfd_msg_ctrl_stat_req_t; 217 218 typedef struct shr_bfd_msg_ctrl_stat_reply_s { 219 uint32 sess_id; /* BFD session (endpoint) id */ 220 uint32 packets_in; /* Total packets in */ 221 uint32 packets_out; /* Total packets out */ 222 uint32 packets_drop; /* Total packets drop */ 223 uint32 packets_auth_drop; /* Packets drop due to authentication failure */ 224 } shr_bfd_msg_ctrl_stat_reply_t; 225 226 227 228 /**************************************** 229 * BFD event message 230 */ 231 #define BFD_BTE_EVENT_STATE 0x0001 232 #define BFD_BTE_EVENT_REMOTE_STATE_DIAG 0x0002 233 #define BFD_BTE_EVENT_DISCRIMINATOR 0x0004 234 #define BFD_BTE_EVENT_AUTHENTICATION 0x0008 235 #define BFD_BTE_EVENT_PARAMETER 0x0010 236 #define BFD_BTE_EVENT_ERROR 0x0020 237 #define BFD_BTE_EVENT_FLAGS_CHANGE 0x0800 238 #define BFD_BTE_EVENT_REMOTE_POLL_BIT_SET 0x0040 239 #define BFD_BTE_EVENT_REMOTE_FINAL_BIT_SET 0x0080 240 #define BFD_BTE_EVENT_SESSION_STATE_ADMIN_DOWN 0x0100 241 #define BFD_BTE_EVENT_SESSION_STATE_DOWN 0x0200 242 #define BFD_BTE_EVENT_SESSION_STATE_INIT 0x0400 243 #define BFD_BTE_EVENT_SESSION_STATE_UP 0x1000 244 #define BFD_BTE_EVENT_SESSION_MISCONN_DEFECT 0x2000 245 #define BFD_BTE_EVENT_SESSION_MISCONN_CLEAR 0x4000 246 #define BFD_BTE_EVENT_SESSION_TIMEOUT 0x8000 247 #define BFD_BTE_EVENT_SESSION_TIMEIN 0x10000 248 #define BFD_BTE_EVENT_UNEXPECTED_MEG 0x20000 249 #define BFD_BTE_EVENT_UNEXPECTED_MEG_CLEAR 0x40000 250 251 /* BFD EVENT flags. */ 252 #define BFD_BTE_EVENT_LOCAL_ADMIN_DOWN 0x00000001 /* BFD Local State Admin. */ 253 #define BFD_BTE_EVENT_LOCAL_DOWN 0x00000002 /* BFD Local State Down. */ 254 #define BFD_BTE_EVENT_LOCAL_INIT 0x00000004 /* BFD Local State Init. */ 255 #define BFD_BTE_EVENT_LOCAL_UP 0x00000008 /* BFD Local State Up. */ 256 #define BFD_BTE_EVENT_REMOTE_ADMIN_DOWN 0x00000010 /* BFD Remote State Admin. */ 257 #define BFD_BTE_EVENT_REMOTE_DOWN 0x00000020 /* BFD Remote State Down. */ 258 #define BFD_BTE_EVENT_REMOTE_INIT 0x00000040 /* BFD Remote State Init. */ 259 #define BFD_BTE_EVENT_REMOTE_UP 0x00000080 /* BFD Remote State Up. */ 260 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_NONE 0x00000100 /* BFD Local Diag None. */ 261 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_CTRL_DETECT_TIME_EXPIRED 0x00000200 /* BFD Local Diag Detect 262 Time Expired. */ 263 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_ECHO_FAILED 0x00000400 /* BFD Local Diag Echo Failed. */ 264 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_NEIGHBOR_SIGNALED_SESSION_DOWN 0x00000800 /* BFD Neighbor Signaled 265 Session Down. */ 266 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_FORWARDING_PLANE_RESET 0x00001000 /* Local diag Forwarding 267 Plane Reset. */ 268 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_PATH_DOWN 0x00002000 /* Local diag Path Down. */ 269 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_CONCATENATED_PATH_DOWN 0x00004000 /* Local Diag 270 Concatenated Path Down. */ 271 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_ADMIN_DOWN 0x00008000 /* Local Diag Administratively Down. */ 272 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_REVERSE_CONCATENATED_PATH_DOWN 0x00010000 /* Local Diag Reverse 273 Concatenated Path Down. */ 274 #define BFD_BTE_EVENT_LOCAL_DIAG_CODE_MIS_CONNECTIVITY_DEFECT 0x00020000 /* Local Diag Mis conn Defect. */ 275 276 /* 277 * The BFD event message is defined as a short message (use mos_msg_data_t). 278 * 279 * The fields of mos_msg_data_t are used as followed: 280 * mclass (uint8) - MOS_MSG_CLASS_BFD_EVENT 281 * subclass (uint8) - Unused 282 * len (uint16) - BFD Session ID 283 * data (uint32) - Events mask 284 */ 285 typedef mos_msg_data_t bfd_msg_event_t; 286 287 288 #endif /* _SOC_SHARED_BFD_MSG_H_ */