bfd_uc.h (21478B)
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-2020 Broadcom Inc. All rights reserved. 6 * 7 * BFD UC Internal header 8 */ 9 #ifndef _BCM_INT_DPP_BFD_UC_H_ 10 #define _BCM_INT_DPP_BFD_UC_H_ 11 12 #include <bcm/bfd.h> 13 #include <bcm_int/dpp/oam.h> 14 15 /* BFD endpoint object. */ 16 typedef struct bfd_endpoint_info_s { 17 uint32 flags; /* Control flags. */ 18 bcm_bfd_endpoint_t id; /* Endpoint identifier. */ 19 bcm_bfd_endpoint_t remote_id; /* Remote endpoint identifier. */ 20 bcm_bfd_tunnel_type_t type; /* Type of BFD encapsulation. */ 21 bcm_gport_t gport; /* Gport identifier. */ 22 bcm_gport_t tx_gport; /* TX gport associated with this 23 endpoint. */ 24 bcm_gport_t remote_gport; /* Gport identifier of trapping 25 destination: OAMP or CPU, local or 26 remote. */ 27 int bfd_period; /* For local endpoints, this is the BFD 28 transmission period in ms. */ 29 bcm_vpn_t vpn; /* VPN. */ 30 uint8 vlan_pri; /* VLAN tag priority. */ 31 uint8 inner_vlan_pri; /* Inner VLAN tag priority. */ 32 bcm_vrf_t vrf_id; /* Vrf identifier. */ 33 bcm_mac_t dst_mac; /* Destination MAC. */ 34 bcm_mac_t src_mac; /* Source MAC. */ 35 bcm_vlan_t pkt_inner_vlan_id; /* TX Packet inner Vlan Id. */ 36 bcm_ip_t dst_ip_addr; /* Destination IPv4 address. */ 37 uint8 dst_ip6_addr[16]; /* Destination IPv6 address. */ 38 bcm_ip_t src_ip_addr; /* Source IPv4 address. */ 39 uint8 src_ip6_addr[16]; /* Source IPv6 address. */ 40 uint8 ip_tos; /* IPv4 Tos / IPv6 Traffic Class. */ 41 uint8 ip_ttl; /* IPv4 TTL / IPv6 Hop Count. */ 42 bcm_ip_t inner_dst_ip_addr; /* Inner destination IPv4 address. */ 43 uint8 inner_dst_ip6_addr[16]; /* Inner destination IPv6 address. */ 44 bcm_ip_t inner_src_ip_addr; /* Inner source IPv4 address. */ 45 uint8 inner_src_ip6_addr[16]; /* Inner source IPv6 address. */ 46 uint8 inner_ip_tos; /* Inner IPv4 Tos / IPv6 Traffic Class. */ 47 uint8 inner_ip_ttl; /* Inner IPv4 TTL / IPv6 Hop Count. */ 48 uint32 udp_src_port; /* UDP source port for Ipv4, Ipv6. */ 49 bcm_mpls_label_t label; /* Incoming inner label. */ 50 bcm_mpls_label_t mpls_hdr; /* MPLS Header. */ 51 bcm_mpls_egress_label_t egress_label; /* The MPLS outgoing label information. */ 52 bcm_if_t egress_if; /* Egress interface. */ 53 uint8 mep_id[BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CC/CV TLV and Source MEP ID. */ 54 uint8 mep_id_length; /* Length of MPLS-TP CC/CV TLV and 55 MEP-ID. */ 56 bcm_cos_t int_pri; /* Egress queuing for outgoing BFD to 57 remote. */ 58 uint8 cpu_qid; /* CPU queue for BFD. */ 59 bcm_bfd_state_t local_state; /* Local session state. */ 60 uint32 local_discr; /* Local discriminator. */ 61 bcm_bfd_diag_code_t local_diag; /* Local diagnostic code. */ 62 uint32 local_flags; /* Flags combination on outgoing frames. */ 63 uint32 local_min_tx; /* Desired local min tx interval. */ 64 uint32 local_min_rx; /* Required local rx interval. */ 65 uint32 local_min_echo; /* Local minimum echo interval. */ 66 uint8 local_detect_mult; /* Local detection interval multiplier. */ 67 bcm_bfd_auth_type_t auth; /* Authentication type. */ 68 uint32 auth_index; /* Authentication index. */ 69 uint32 tx_auth_seq; /* Tx authentication sequence id. */ 70 uint32 rx_auth_seq; /* Rx authentication sequence id. */ 71 uint32 remote_flags; /* Remote flags. */ 72 bcm_bfd_state_t remote_state; /* Remote session state. */ 73 uint32 remote_discr; /* Remote discriminator. */ 74 bcm_bfd_diag_code_t remote_diag; /* Remote diagnostic code. */ 75 uint32 remote_min_tx; /* Desired remote min tx interval. */ 76 uint32 remote_min_rx; /* Required remote rx interval. */ 77 uint32 remote_min_echo; /* Remote minimum echo interval. */ 78 uint8 remote_detect_mult; /* Remote detection interval multiplier. */ 79 int sampling_ratio; /* 0 - No packets sampled to the CPU. 80 1-8 - Count of packets (with events) 81 that need to arrive before one is 82 sampled to the CPU. */ 83 uint8 loc_clear_threshold; /* Number of packets required to reset 84 the Loss-of-Continuity status per 85 endpoint. */ 86 uint32 ip_subnet_length; /* The subnet length for incoming packet 87 validity check. Value 0 indicates no 88 check is performed, positive values 89 indicate the amount of MSBs to be 90 compared. */ 91 uint8 remote_mep_id[BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CC/CV TLV and Remote MEP ID. */ 92 uint8 remote_mep_id_length; /* Length of MPLS-TP CC/CV TLV and 93 REMOTE MEP-ID. */ 94 uint8 mis_conn_mep_id[BCM_BFD_ENDPOINT_MAX_MEP_ID_LENGTH]; /* MPLS-TP CC/CV TLV and Mis 95 connectivity MEP ID. */ 96 uint8 mis_conn_mep_id_length; /* Length of MPLS-TP CC/CV TLV and Mis 97 connectivity MEP-ID. */ 98 uint32 bfd_detection_time; /* Optional: BFD Detection Time, in 99 microseconds. */ 100 bcm_vlan_t pkt_vlan_id; /* TX Packet Vlan Id. */ 101 bcm_vlan_t rx_pkt_vlan_id; /* RX Packet Vlan Id. */ 102 bcm_mpls_label_t gal_label; /* MPLS GAL label. */ 103 uint32 faults; /* Fault flags. */ 104 uint32 flags2; /* Second set of control flags. */ 105 int ipv6_extra_data_index; /* Pointer to first extended data entry */ 106 int punt_good_packet_period; /* BFD good packets sampling period. 107 Every punt_good_packet_period 108 milliseconds, a single packet is 109 punted to the CPU */ 110 uint8 bfd_period_cluster; /* Tx period group. All MEPs in a group 111 must be created with the same Tx 112 period. Modifying the Tx period in 113 one MEP affects the others. */ 114 } bfd_endpoint_info_t; 115 116 /* BFD Endpoint Configuration SW Data Structure */ 117 typedef struct bfd_endpoint_config_s { 118 int endpoint_index; 119 bcm_module_t modid; /* Destination module ID */ 120 bcm_port_t port; /* Destination port */ 121 bcm_port_t tx_port; /* Local physical port to TX BFD packet */ 122 int encap_type; /* Raw, UDP-IPv4/IPv6, used for UDP checksum */ 123 int encap_length; /* BFD Encapsulation length */ 124 int lkey_etype; /* Lookup key Ether Type */ 125 int lkey_offset; /* Lookup key offset */ 126 int lkey_length; /* Lookup key length */ 127 bfd_endpoint_info_t info; 128 int is_l3_vpn; /* 1 for L3 VPN, 0 for L2 VPN */ 129 uint8 dip_index; /* Used by m-hop entry*/ 130 uint8 acc_mep_profile;/* Used by m-hop entry*/ 131 uint8 non_acc_profile;/* Used by m-hop entry */ 132 uint8 local_echo; /*1 for BFD echo session*/ 133 } bfd_endpoint_config_t; 134 135 /* BFD Event Handler */ 136 typedef struct bfd_event_handler_s { 137 PARSER_HINT_PTR struct bfd_event_handler_s *next; 138 bcm_bfd_event_types_t event_types; 139 bcm_bfd_event_cb cb; 140 PARSER_HINT_PTR uint8 *user_data; 141 } bfd_event_handler_t; 142 143 typedef struct bfd_ipv6_no_wb_info_s { 144 int initialized; /* If set, BFD has been initialized */ 145 int rx_channel; /* Local RX DMA channel for BHH packets */ 146 int uc_num; /* uController number running BHH appl */ 147 int endpoint_count; /* Max number of BFD endpoints */ 148 int num_auth_sha1_keys; /* Max number of sha1 auth keys */ 149 int num_auth_sp_keys; /* Max number of simple pwd auth keys */ 150 bcm_cos_queue_t cpu_cosq; /* CPU cos queue for RX BFD packets */ 151 bfd_event_handler_t *event_handler_list; 152 int dma_buffer_len; /* DMA max buffer size */ 153 PARSER_HINT_ARR uint8 *dma_buffer; /* DMA buffer */ 154 sal_thread_t event_thread_id; /* Event handler thread id */ 155 int event_thread_kill; /* Signal Event thread exit */ 156 uint32 event_mask; /* Mask of all events */ 157 uint32 trace_addr; /* Address in the uC holding the stack trace */ 158 /* Protection Packet Feature */ 159 uint32 protection_packet_enable; /* BFD IPV6 Protection packet feature enable */ 160 uint32 protection_pkt_event_fifo_size; /* Indicates internal event FIFO threshold size */ 161 uint32 protection_pkt_event_fifo_timer; /* Indicates maximum wait timer to read internal event FIFO */ 162 int session_count; /* Max number of BFD sessions */ 163 uint8 use_local_discr_as_session_id; /* Use local discriminator as session ID feature enable */ 164 } bfd_ipv6_no_wb_info_t; 165 166 typedef struct bcm_dpp_bfd_ipv6_info_s 167 { 168 PARSER_HINT_ARR bfd_endpoint_config_t *endpoints; /* Array to Endpoints */ 169 PARSER_HINT_ARR bcm_bfd_auth_sha1_t *auth_sha1; /* Array of sha1 auth keys */ 170 PARSER_HINT_ARR bcm_bfd_auth_simple_password_t *auth_sp; /* Array simple pwd auth keys */ 171 PARSER_HINT_PTR SHR_BITDCL *endpoints_in_use; /* Indicates used endpoint indexes */ 172 PARSER_HINT_PTR SHR_BITDCL *sessions_in_use; /* Indicates used session indexes */ 173 PARSER_HINT_ARR bcm_bfd_endpoint_t *endpoint_to_session_map; /* Array from Endpoint IDs to session IDs map */ 174 } bcm_dpp_bfd_ipv6_info_t; 175 176 177 /* 178 * Function: 179 * bcm_petra_bfd_uc_is_init 180 * Purpose: 181 * Whether uKernel BFD has been inited. 182 * Parameters: 183 * unit (IN) unit number 184 */ 185 extern int 186 bcm_petra_bfd_uc_is_init(int unit); 187 188 /* 189 * Function: 190 * bcm_petra_bfd_uc_init 191 * Purpose: 192 * Send a BFD message to init the BFD function. 193 * Parameters: 194 * unit (IN) unit number 195 */ 196 extern int 197 bcm_petra_bfd_uc_init(int unit); 198 199 200 /* 201 * Function: 202 * bcm_petra_bfd_uc_deinit 203 * Purpose: 204 * Send a BFD message to deinit the BFD function. 205 * Parameters: 206 * unit (IN) unit number 207 */ 208 extern int 209 bcm_petra_bfd_uc_deinit(int unit); 210 211 /* 212 * Function: 213 * bcm_petra_bfd_uc_tx_start 214 * Purpose: 215 * Start all BFD endpoint TX BFD PDUs. 216 * Parameters: 217 * unit - (IN) Unit number. 218 * Returns: 219 * BCM_E_NONE Operation completed successfully 220 * BCM_E_NOT_FOUND Attempt to start TX which does not exist 221 * BCM_E_INTERNAL Unable to release resource / 222 * Failed to read memory or read or write register 223 * Notes: 224 */ 225 extern int 226 bcm_petra_bfd_uc_tx_start(int unit); 227 228 /* 229 * Function: 230 * _bcm_petra_bfd_uc_tx_stop 231 * Purpose: 232 * Stop all BFD endpoint TX BFD PDUs. 233 * Parameters: 234 * unit - (IN) Unit number. 235 * Returns: 236 * BCM_E_NONE Operation completed successfully 237 * BCM_E_NOT_FOUND Attempt to stop TX which does not exist 238 * BCM_E_INTERNAL Unable to release resource / 239 * Failed to read memory or read or write register 240 * Notes: 241 */ 242 extern int 243 bcm_petra_bfd_uc_tx_stop(int unit); 244 245 /* 246 * Function: 247 * bcm_petra_bfd_uc_endpoint_create 248 * Purpose: 249 * Send a BFD message to init the BFD function. 250 * Parameters: 251 * unit (IN) unit number 252 */ 253 extern int 254 bcm_petra_bfd_uc_endpoint_create(int unit, 255 bcm_bfd_endpoint_info_t *endpoint_info); 256 /* 257 * Function: 258 * bcm_petra_bfd_uc_endpoint_get 259 * Purpose: 260 * Send a BFD message to init the BFD function. 261 * Parameters: 262 * unit (IN) unit number 263 */ 264 extern int 265 bcm_petra_bfd_uc_endpoint_get(int unit, 266 bcm_bfd_endpoint_t endpoint, 267 bcm_bfd_endpoint_info_t *endpoint_info); 268 269 270 /* 271 * Function: 272 * bcm_petra_bfd_uc_endpoint_destroy 273 * Purpose: 274 * Destroy an BFD endpoint object. 275 * Parameters: 276 * unit - (IN) Unit number. 277 * endpoint - (IN) The ID of the BFD endpoint object to destroy. 278 * Returns: 279 * BCM_E_NONE Operation completed successfully 280 * BCM_E_NOT_FOUND Attempt to destroy endpoint which does not exist 281 * BCM_E_INTERNAL Unable to release resource / 282 * Failed to read memory or read or write register 283 * Notes: 284 */ 285 extern int 286 bcm_petra_bfd_uc_endpoint_destroy(int unit, bcm_bfd_endpoint_t endpoint); 287 288 /* 289 * Function: 290 * bcm_petra_bfd_uc_endpoint_destroy_all 291 * Purpose: 292 * Destroy all BFD endpoint objects. 293 * Parameters: 294 * unit - (IN) Unit number. 295 * Returns: 296 * BCM_E_NONE Operation completed successfully 297 * BCM_E_INTERNAL Unable to release resource / 298 * Failed to read memory or read or write register 299 * Notes: 300 */ 301 extern int 302 bcm_petra_bfd_uc_endpoint_destroy_all(int unit); 303 304 /* 305 * Function: 306 * bcm_petra_bfd_uc_endpoint_poll 307 * Purpose: 308 * Poll an BFD endpoint object. Valid only for endpoint in Demand 309 * Mode and in state bcmBFDStateUp. 310 * Parameters: 311 * unit - (IN) Unit number. 312 * endpoint - (IN) The ID of the BFD endpoint object to poll. 313 * Returns: 314 * BCM_E_NONE Operation completed successfully 315 * BCM_E_NOT_FOUND BFD Session ID not in use 316 * BCM_E_INTERNAL Unable to read or write resource 317 * BCM_E_PARAM Session not in Demand Mode/ 318 * Session not in UP state 319 * Notes: The poll operation will be initiated. Poll failure will be 320 * signalled via asynchronous callback (aka session failure) 321 */ 322 extern int 323 bcm_petra_bfd_uc_endpoint_poll(int unit, bcm_bfd_endpoint_t endpoint); 324 325 326 /* 327 * Function: 328 * bcm_petra_bfd_uc_event_register 329 * Purpose: 330 * Register a callback for handling BFD events. 331 * Parameters: 332 * unit - (IN) Unit number. 333 * event_types - (IN) The set of BFD events for which the specified 334 * callback will be invoked. 335 * cb - (IN) A pointer to the callback function. 336 * user_data - (IN) Pointer to user data to pass to the callback. 337 * Returns: 338 * BCM_E_NONE Operation completed successfully 339 * Notes: 340 */ 341 extern int 342 bcm_petra_bfd_uc_event_register(int unit, 343 bcm_bfd_event_types_t event_types, 344 bcm_bfd_event_cb cb, void *user_data); 345 346 /* 347 * Function: 348 * bcm_petra_bfd_uc_event_unregister 349 * Purpose: 350 * Unregister a callback for handling BFD events. 351 * Parameters: 352 * unit - (IN) Unit number. 353 * event_types - (IN) The set of BFD events for which the specified 354 * callback should not be invoked. 355 * cb - (IN) A pointer to the callback function. 356 * Returns: 357 * BCM_E_NONE Operation completed successfully 358 * Notes: 359 */ 360 extern int 361 bcm_petra_bfd_uc_event_unregister(int unit, 362 bcm_bfd_event_types_t event_types, 363 bcm_bfd_event_cb cb); 364 365 /* 366 * Function: 367 * bcm_petra_bfd_uc_endpoint_stat_get 368 * Purpose: 369 * Get BFD endpoint statistics. 370 * Parameters: 371 * unit - (IN) Unit number. 372 * endpoint - (IN) The ID of the endpoint object to get stats for. 373 * ctr_info - (IN/OUT) Pointer to endpoint count structure to receive 374 * the data. 375 * clear - (IN) If set, clear stats after read. 376 * Returns: 377 * BCM_E_NONE Operation completed successfully 378 * BCM_E_PARAM Null pointer to counter information structure 379 * BCM_E_MEMORY Unable to allocate memory 380 * BCM_E_INTERNAL Unable to obtain/release resource lock / 381 * Failed to read or write register 382 * Notes: 383 */ 384 extern int 385 bcm_petra_bfd_uc_endpoint_stat_get(int unit, 386 bcm_bfd_endpoint_t endpoint, 387 bcm_bfd_endpoint_stat_t *ctr_info, uint8 clear); 388 /* 389 * Function: 390 * bcm_petra_bfd_uc_auth_sha1_set 391 * Purpose: 392 * Set SHA1 authentication entry. 393 * Parameters: 394 * unit - (IN) Unit number. 395 * index - (IN) Index of the SHA1 entry to configure. 396 * sha1 - (IN) Pointer to SHA1 info structure. 397 * Returns: 398 * BCM_E_NONE Operation completed successfully 399 * BCM_E_PARAM Null pointer to SHA1 information structure 400 * BCM_E_MEMORY Unable to allocate memory 401 * BCM_E_INTERNAL Unable to obtain/release resource lock / 402 * Failed to read or write register 403 * Notes: 404 */ 405 extern int 406 bcm_petra_bfd_uc_auth_sha1_set(int unit, 407 int index, bcm_bfd_auth_sha1_t *sha1); 408 409 /* 410 * Function: 411 * bcm_petra_bfd_uc_auth_sha1_get 412 * Purpose: 413 * Get SHA1 authentication entry. 414 * Parameters: 415 * unit - (IN) Unit number. 416 * index - (IN) Index of the SHA1 entry to retrieve. 417 * sha1 - (IN/OUT) Pointer to SHA1 info structure to receive the data. 418 * Returns: 419 * BCM_E_NONE Operation completed successfully 420 * BCM_E_PARAM Null pointer to SHA1 information structure 421 * BCM_E_MEMORY Unable to allocate memory 422 * BCM_E_INTERNAL Unable to obtain/release resource lock / 423 * Failed to read or write register 424 * Notes: 425 */ 426 extern int 427 bcm_petra_bfd_uc_auth_sha1_get(int unit, 428 int index, bcm_bfd_auth_sha1_t *sha1); 429 430 /* 431 * Function: 432 * bcm_petra_bfd_uc_auth_simple_password_set 433 * Purpose: 434 * Set Simple Password authentication entry. 435 * Parameters: 436 * unit - (IN) Unit number. 437 * index - (IN) Index of the Simple Password entry to configure. 438 * sp - (IN) Pointer to Simple Password info structure. 439 * Returns: 440 * BCM_E_NONE Operation completed successfully 441 * BCM_E_PARAM Null pointer to SHA1 information structure 442 * BCM_E_MEMORY Unable to allocate memory 443 * BCM_E_INTERNAL Unable to obtain/release resource lock / 444 * Failed to read or write register 445 * Notes: 446 */ 447 extern int 448 bcm_petra_bfd_uc_auth_simple_password_set(int unit, 449 int index, 450 bcm_bfd_auth_simple_password_t *sp); 451 452 /* 453 * Function: 454 * bcm_petra_bfd_uc_auth_simple_password_get 455 * Purpose: 456 * Get Simple Password authentication entry. 457 * Parameters: 458 * unit - (IN) Unit number. 459 * index - (IN) Index of the Simple Password entry to retrieve. 460 * sp - (IN/OUT) Pointer to Simple Password info structure to 461 * receive the data. 462 * Returns: 463 * BCM_E_NONE Operation completed successfully 464 * BCM_E_PARAM Null pointer to SHA1 information structure 465 * BCM_E_MEMORY Unable to allocate memory 466 * BCM_E_INTERNAL Unable to obtain/release resource lock / 467 * Failed to read or write register 468 * Notes: 469 */ 470 extern int 471 bcm_petra_bfd_uc_auth_simple_password_get(int unit, 472 int index, 473 bcm_bfd_auth_simple_password_t *sp); 474 475 /* 476 * Function: 477 * bcm_petra_bfd_uc_dump_trace 478 * Purpose: 479 * Dump the BFD stack trace 480 * Parameters: 481 * unit - (IN) Unit number. 482 * Returns: 483 * None 484 * Notes: 485 */ 486 void 487 _bcm_petra_bfd_uc_dump_trace(int unit); 488 489 /* 490 * Function: 491 * bcm_petra_bfd_uc_discard_stat_get 492 * Purpose: 493 * Get global discarded packet statistics for BFD IPv6 FW. 494 * Parameters: 495 * unit - (IN) Unit number. 496 * discarded_info - (IN/OUT) Pointer to SHA1 info structure to receive the data. 497 * Returns: 498 * BCM_E_NONE Operation completed successfully 499 * BCM_E_PARAM Null pointer to discarded structure. 500 * BCM_E_INTERNAL Unable to reach FIRMWARE 501 * Notes: 502 */ 503 int 504 bcm_petra_bfd_uc_discard_stat_get(int unit, 505 bcm_bfd_discard_stat_t *discarded_info); 506 507 /* 508 * Function: 509 * bcm_petra_bfd_uc_discard_stat_set 510 * Purpose: 511 * Reset global discarded packet statistics for BFD IPv6 FW. 512 * Parameters: 513 * unit - (IN) Unit number. 514 * discarded_info - (IN) Pointer to SHA1 info structure to set the data. Ignored. 515 * Returns: 516 * BCM_E_NONE Operation completed successfully 517 * BCM_E_INTERNAL Unable to reach FIRMWARE 518 * Notes: 519 */ 520 int 521 bcm_petra_bfd_uc_discard_stat_set(int unit, 522 bcm_bfd_discard_stat_t *discarded_info); 523 524 #endif /*_BCM_INT_DPP_BFD_UC_H_*/ 525