bfd.h (6749B)
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 * IPMC Internal header 8 */ 9 #ifndef _BCM_INT_DPP_BFD_H_ 10 #define _BCM_INT_DPP_BFD_H_ 11 12 #include <bcm/bfd.h> 13 #include <bcm_int/dpp/oam.h> 14 #include <bcm_int/dpp/oam_sw_db.h> 15 #include <bcm_int/dpp/oam_hw_db.h> 16 #include <bcm_int/dpp/oam_resource.h> 17 #include <bcm_int/dpp/oam_dissect.h> 18 19 /*ttl tos profile for bfd ipv4 single hop*/ 20 #define _BCM_BFD_IPV4_SINGLE_HOP_TTL_PROFILE 15 21 #define _BCM_BFD_IPV4_ECHO_MIN_INTERVAL_PROFILE 14 22 23 /* Seamless BFD macros */ 24 #define _BCM_BFD_RESERVED_UDP_PORT_FOR_SBFD 7784 25 #define _BCM_BFD_SEAMLESS_BFD_FEATURE_ENABLED(unit) ((SOC_DPP_CONFIG(unit))->pp.bfd_sbfd_enable == 1) 26 #define _BCM_BFD_SEAMLESS_BFD_REFLECTOR_CONFIG(unit) ((SOC_DPP_CONFIG(unit))->pp.sbfd_reflector_is_configured == 1) 27 #define _BCM_BFD_ENDPOINT_IS_SBFD_INITIATOR(unit, endpoint_info) (_BCM_BFD_SEAMLESS_BFD_FEATURE_ENABLED(unit) && ((endpoint_info->flags2 & BCM_BFD_ENDPOINT_FLAGS2_SEAMLESS_BFD_INITIATOR) != 0)) 28 #define _BCM_BFD_ENDPOINT_IS_SBFD_REFLECTOR(unit, endpoint_info) (_BCM_BFD_SEAMLESS_BFD_FEATURE_ENABLED(unit) && ((endpoint_info->flags2 & BCM_BFD_ENDPOINT_FLAGS2_SEAMLESS_BFD_REFLECTOR) != 0)) 29 #define _BCM_BFD_ENDPOINT_IS_SBFD(unit, endpoint_info) ((_BCM_BFD_ENDPOINT_IS_SBFD_INITIATOR(unit, endpoint_info))||(_BCM_BFD_ENDPOINT_IS_SBFD_REFLECTOR(unit, endpoint_info))) 30 #define _BCM_BFD_NOF_SBFD_ENDPOINTS_GET(unit, num_sbfd_endpoints) do {\ 31 if (_BCM_BFD_SEAMLESS_BFD_FEATURE_ENABLED(unit)) {\ 32 BCMDNX_IF_ERR_EXIT(sw_state_access[unit].dpp.bcm.bfd.no_of_sbfd_endpoints.get(unit, &num_sbfd_endpoints));\ 33 }\ 34 }while(0) 35 36 #define _BCM_BFD_NOF_SBFD_ENDPOINTS_INCR(unit) do {\ 37 uint32 num_sbfd_endpoints = 0;\ 38 if (_BCM_BFD_SEAMLESS_BFD_FEATURE_ENABLED(unit)) {\ 39 BCMDNX_IF_ERR_EXIT(sw_state_access[unit].dpp.bcm.bfd.no_of_sbfd_endpoints.get(unit, &num_sbfd_endpoints));\ 40 num_sbfd_endpoints++;\ 41 BCMDNX_IF_ERR_EXIT(sw_state_access[unit].dpp.bcm.bfd.no_of_sbfd_endpoints.set(unit, num_sbfd_endpoints));\ 42 }\ 43 }while(0) 44 45 #define _BCM_BFD_NOF_SBFD_ENDPOINTS_DECR(unit) do {\ 46 uint32 num_sbfd_endpoints = 0;\ 47 if (_BCM_BFD_SEAMLESS_BFD_FEATURE_ENABLED(unit)) {\ 48 BCMDNX_IF_ERR_EXIT(sw_state_access[unit].dpp.bcm.bfd.no_of_sbfd_endpoints.get(unit, &num_sbfd_endpoints));\ 49 num_sbfd_endpoints--;\ 50 BCMDNX_IF_ERR_EXIT(sw_state_access[unit].dpp.bcm.bfd.no_of_sbfd_endpoints.set(unit, num_sbfd_endpoints));\ 51 }\ 52 }while(0) 53 54 /* Tx Rate is in 3.33 (JER - 1.67) ms units 55 value in HW is one lower then what was calculated, thus, incrementing 56 In case transmit disable(bfd_period = 0) traffic still generated,but forwarded to invalid port,so we setting the maximal rate in order to create less traffic*/ 57 #define _BCM_BFD_ENDPOINT_INFO_BFD_PERIOD_TO_MEP_DB_TX_RATE(bfd_period) \ 58 ((bfd_period == 0) ? 0x1ff : (SOC_SAND_DIV_ROUND(bfd_period * 100, SOC_IS_ARADPLUS_AND_BELOW(unit) ? 333 : 167) -1)) 59 60 #define BFD_ACCESS sw_state_access[unit].dpp.bcm.bfd 61 62 /* 63 * Struct to maintians tx rates status 64 */ 65 typedef struct bcm_dpp_bfd_tx_rates_s { 66 uint32 tx_rate[8]; 67 uint32 ref_count[8]; 68 sal_time_t update_time_secs[8]; 69 sal_usecs_t update_time_usecs[8]; 70 } bcm_dpp_bfd_tx_rates_t; 71 72 volatile bcm_dpp_bfd_tx_rates_t update_bfd_tx_rates; 73 typedef struct { 74 int ref_counter; 75 int tos_value; 76 } bcm_dpp_bfd_pp_s_hop; 77 78 typedef struct { 79 int YourDiscriminator_ref_count; 80 bcm_dpp_bfd_pp_s_hop s_hop; 81 SOC_PPC_BFD_INIT_TRAP_INFO trap_info; 82 uint32 mpls_udp_sport_ref_counter; 83 ENDPOINT_LIST_PTR _bcm_bfd_endpoint_list ; 84 uint32 ipv4_udp_sport_ref_counter; 85 uint32 ipv4_multi_hop_acc_ref_counter; 86 uint32 pdu_ref_counter; 87 uint32 mpls_tp_cc_ref_counter; 88 uint32 tx_rate_value[8]; 89 uint32 tx_rate_ref_counter[8]; 90 uint32 no_of_sbfd_endpoints; 91 uint32 reflector_trap_id; 92 bcm_bfd_state_t reflector_status; 93 uint8 no_of_sbfd_reflector; 94 } bcm_dpp_bfd_info_t; 95 96 97 typedef struct { 98 uint8 free_tx_gport; 99 uint8 free_src_ip_profile; 100 uint8 free_tos_ttl_profile; 101 uint8 free_bfd_tx_rate; 102 uint8 free_req_interval_pointer_local_min_rx; 103 uint8 free_req_interval_pointer_local_min_tx; 104 uint8 free_pwe_push_profile; 105 uint8 free_mhop_itmh_attributes; 106 uint8 free_tx_itmh_attributes; 107 uint8 free_flags; 108 } _bcm_bfd_mep_db_entry_pointers_to_free; 109 110 111 void bcm_dpp_bfd_endpoint_diag_print(bcm_bfd_endpoint_info_t* endpoint_info); 112 113 114 /*Function shared by OAM diagnostics and bfd diagnostics. 115 Simply prints information on an egress label*/ 116 void bcm_dpp_print_mpls_egress_label(bcm_mpls_egress_label_t* egress_label); 117 118 119 int _bcm_bfd_endpoint_info_to_lem_info(int unit, const bcm_bfd_endpoint_info_t *ep_info, ARAD_PP_LEM_BFD_ONE_HOP_ENTRY_INFO *lem_info, int trap_code, uint8 fwd_strenght, int snp_strength); 120 121 int _bcm_bfd_tx_rate_profile_alloc(int unit, uint32 tx_rate, uint8 *mep_db_ccm_interval); 122 123 int _bcm_bfd_tx_rate_profile_free(int unit, uint32 tx_rate); 124 125 int _bcm_bfd_tx_rate_profile_index_free(int unit, uint8 tx_rate_index); 126 127 int _bcm_bfd_set_and_allocate_bfd_rates(int unit, uint32 tx_rate, uint32 existing_tx_rate, uint8 *tx_rate_index, uint8 is_update); 128 #endif /*_BCM_INT_DPP_BFD_H_*/