failover.h (8799B)
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 * This file contains Failover module definitions internal to the BCM library. 8 */ 9 #ifndef _BCM_INT_ESW_FAILOVER_H_ 10 #define _BCM_INT_ESW_FAILOVER_H_ 11 12 #if defined(INCLUDE_L3) 13 14 #define _BCM_FAILOVER_1_PLUS_PROTECTION 0x1 15 #define _BCM_FAILOVER_DEFAULT_MODE 0x0 16 #define _BCM_FAILOVER_1_1_MC_PROTECTION_MODE 0x2 17 #define _BCM_FAILOVER_INGRESS 0x4 18 #define _BCM_FAILOVER_MULTI_LEVEL 0x8 19 #define _BCM_FAILOVER_ING_MC_PROTECTION_MODE 0x10 20 21 22 #define FAILOVER_TYPE_SHIFT 24 23 #define FAILOVER_TYPE_MASK 0xff000000 24 #define FAILOVER_ID_MASK 0x00ffffff 25 26 #define _BCM_ENCAP_TYPE_IN_FAILOVER_ID(failover_id, type) \ 27 (failover_id = ((type << FAILOVER_TYPE_SHIFT) | (failover_id))) 28 29 #define _BCM_GET_FAILOVER_ID(failover_id) \ 30 failover_id = failover_id & FAILOVER_ID_MASK 31 32 #define _BCM_GET_FAILOVER_TYPE(failover_id, type) \ 33 type = ((failover_id & FAILOVER_TYPE_MASK) >> FAILOVER_TYPE_SHIFT) 34 35 #define _BCM_FAILOVER_IS_MULTI_LEVEL(failover_id) \ 36 (((failover_id & FAILOVER_TYPE_MASK) >> FAILOVER_TYPE_SHIFT) == \ 37 _BCM_FAILOVER_MULTI_LEVEL) 38 39 #define _FAILOVER_FIXED_NH_OFFSET_ON 0x80000000 40 #define _BCM_FAILOVER_ID_HAS_FIXED_NH_OFFSET(failover_id) \ 41 ((failover_id & _FAILOVER_FIXED_NH_OFFSET_ON) == _FAILOVER_FIXED_NH_OFFSET_ON) 42 43 /* 44 * Software book keeping for Failover related information 45 */ 46 typedef struct _bcm_failover_bookkeeping_s { 47 int initialized; /* Set to TRUE when Failover module initialized */ 48 int prot_offset; /* TH3 fixed protection offset (0 when disable) */ 49 SHR_BITDCL *prot_group_bitmap; /* INITIAL_PROT_GROUP usage bitmap */ 50 SHR_BITDCL *prot_nhi_bitmap; /* INITIAL_PROT_NHI usage bitmap */ 51 SHR_BITDCL *mmu_prot_group_bitmap; /* MMU_PROT_GROUP usage bitmap */ 52 SHR_BITDCL *egress_prot_group_bitmap; /* EGRESS_PROT_GROUP usage bitmap */ 53 SHR_BITDCL *ingress_prot_group_bitmap; /* RX_PROT_GROUP usage bitmap */ 54 SHR_BITDCL *multi_level_failover_bitmap; /* multi level failover bitmap */ 55 int *init_prot_to_multi_failover_id; /* multi failover ids are only in s/w 56 * therefore we need to keep track of 57 * them to return ids back to user 58 * in case of get and traverse */ 59 sal_mutex_t failover_mutex; /* Protection mutex. */ 60 } _bcm_failover_bookkeeping_t; 61 62 #define FAILOVER_INFO(_unit_) (&_bcm_failover_bk_info[_unit_]) 63 64 #define BCM_MULTI_LEVEL_FAILOVER_BITMAP(_u_) (FAILOVER_INFO(_u_)->multi_level_failover_bitmap) 65 #define BCM_MULTI_LEVEL_FAILOVER_ID_MAP(_u_) (FAILOVER_INFO(_u_)->init_prot_to_multi_failover_id) 66 #define BCM_FAILOVER_PROT_GROUP_MAP(_u_) (FAILOVER_INFO(_u_)->prot_group_bitmap) 67 #define BCM_FAILOVER_INGRESS_PROT_GROUP_MAP(_u_) (FAILOVER_INFO(_u_)->ingress_prot_group_bitmap) 68 69 /* 70 * Multi level protection status bits. 71 */ 72 #define LVL_1_PROT_ENABLE 6 73 #define LVL_1_PROT_MODE 5 74 #define LVL_2_PROT_ENABLE 4 75 #define LVL_2_PROT_MODE 3 76 #define LVL_2_1_REP_ENABLE 2 77 #define LVL_2_0_REP_ENABLE 1 78 #define LVL_1_REP_ENABLE 0 79 80 /* 81 * Software structure for bookkeeping multi level failovers. 82 */ 83 typedef struct bcmi_failover_multi_level_info_s { 84 bcm_failover_t parent_failover_id; 85 uint32 parent_failover_type; 86 bcm_failover_t child_group_1; 87 bcm_failover_t child_group_2; 88 }bcmi_failover_multi_level_info_t; 89 90 /* 91 * INITIAL_PROT_GROUP usage bitmap operations 92 */ 93 #define _BCM_FAILOVER_PROT_GROUP_MAP_USED_GET(_u_, _map_) \ 94 SHR_BITGET(FAILOVER_INFO(_u_)->prot_group_bitmap, (_map_)) 95 #define _BCM_FAILOVER_PROT_GROUP_MAP_USED_SET(_u_, _map_) \ 96 SHR_BITSET(FAILOVER_INFO((_u_))->prot_group_bitmap, (_map_)) 97 #define _BCM_FAILOVER_PROT_GROUP_MAP_USED_CLR(_u_, _map_) \ 98 SHR_BITCLR(FAILOVER_INFO((_u_))->prot_group_bitmap, (_map_)) 99 #define _BCM_FAILOVER_PROT_GROUP_MAP_IS_VALID(_u_) \ 100 (FAILOVER_INFO((_u_))->prot_group_bitmap != NULL) 101 102 #define _BCM_FAILOVER_MMU_PROT_GROUP_MAP_USED_GET(_u_, _map_) \ 103 SHR_BITGET(FAILOVER_INFO(_u_)->mmu_prot_group_bitmap, (_map_)) 104 #define _BCM_FAILOVER_MMU_PROT_GROUP_MAP_USED_SET(_u_, _map_) \ 105 SHR_BITSET(FAILOVER_INFO((_u_))->mmu_prot_group_bitmap, (_map_)) 106 #define _BCM_FAILOVER_MMU_PROT_GROUP_MAP_USED_CLR(_u_, _map_) \ 107 SHR_BITCLR(FAILOVER_INFO((_u_))->mmu_prot_group_bitmap, (_map_)) 108 109 110 /* 111 * EGR_TX_PROT_GROUP usage bitmap operations 112 */ 113 #define _BCM_FAILOVER_EGRESS_PROT_GROUP_MAP_USED_GET(_u_, _map_) \ 114 SHR_BITGET(FAILOVER_INFO(_u_)->egress_prot_group_bitmap, (_map_)) 115 #define _BCM_FAILOVER_EGRESS_PROT_GROUP_MAP_USED_SET(_u_, _map_) \ 116 SHR_BITSET(FAILOVER_INFO((_u_))->egress_prot_group_bitmap, (_map_)) 117 #define _BCM_FAILOVER_EGRESS_PROT_GROUP_MAP_USED_CLR(_u_, _map_) \ 118 SHR_BITCLR(FAILOVER_INFO((_u_))->egress_prot_group_bitmap, (_map_)) 119 120 /* 121 * RX_PROT_GROUP usage bitmap operations 122 */ 123 #define _BCM_FAILOVER_INGRESS_PROT_GROUP_MAP_USED_GET(_u_, _map_) \ 124 SHR_BITGET(FAILOVER_INFO(_u_)->ingress_prot_group_bitmap, (_map_)) 125 #define _BCM_FAILOVER_INGRESS_PROT_GROUP_MAP_USED_SET(_u_, _map_) \ 126 SHR_BITSET(FAILOVER_INFO((_u_))->ingress_prot_group_bitmap, (_map_)) 127 #define _BCM_FAILOVER_INGRESS_PROT_GROUP_MAP_USED_CLR(_u_, _map_) \ 128 SHR_BITCLR(FAILOVER_INFO((_u_))->ingress_prot_group_bitmap, (_map_)) 129 130 /* 131 * INITIAL_PROT_NHI usage bitmap operations 132 */ 133 #define _BCM_FAILOVER_PROT_NHI_MAP_USED_GET(_u_, _map_) \ 134 SHR_BITGET(FAILOVER_INFO(_u_)->prot_nhi_bitmap, (_map_)) 135 #define _BCM_FAILOVER_PROT_NHI_MAP_USED_SET(_u_, _map_) \ 136 SHR_BITSET(FAILOVER_INFO((_u_))->prot_nhi_bitmap, (_map_)) 137 #define _BCM_FAILOVER_PROT_NHI_MAP_USED_CLR(_u_, _map_) \ 138 SHR_BITCLR(FAILOVER_INFO((_u_))->prot_nhi_bitmap, (_map_)) 139 #define _BCM_FAILOVER_PROT_NHI_MAP_IS_VALID(_u_) \ 140 (FAILOVER_INFO((_u_))->prot_nhi_bitmap != NULL) 141 142 /* 143 * RX_PROT_GROUP usage bitmap operations 144 */ 145 #define _BCM_FAILOVER_MULTI_LEVEL_MAP_USED_GET(_u_, _map_) \ 146 SHR_BITGET(FAILOVER_INFO(_u_)->multi_level_failover_bitmap, (_map_)) 147 #define _BCM_FAILOVER_MULTI_LEVEL_MAP_USED_SET(_u_, _map_) \ 148 SHR_BITSET(FAILOVER_INFO((_u_))->multi_level_failover_bitmap, (_map_)) 149 #define _BCM_FAILOVER_MULTI_LEVEL_MAP_USED_CLR(_u_, _map_) \ 150 SHR_BITCLR(FAILOVER_INFO((_u_))->multi_level_failover_bitmap, (_map_)) 151 152 /* 153 * multi level failover id to nh_id get/set macros. 154 */ 155 #define _BCM_FAILOVER_MULTI_LEVEL_FAILOVER_ID_SET(_u_, nh_id, failover_id) \ 156 ((FAILOVER_INFO(_u_)->init_prot_to_multi_failover_id[nh_id]) = failover_id) 157 #define _BCM_FAILOVER_MULTI_LEVEL_FAILOVER_ID_GET(_u_, nh_id, failover_id) \ 158 (failover_id = (FAILOVER_INFO(_u_)->init_prot_to_multi_failover_id[nh_id])) 159 160 extern _bcm_failover_bookkeeping_t _bcm_failover_bk_info[BCM_MAX_NUM_UNITS]; 161 162 extern int _bcm_esw_failover_id_check(int unit, bcm_failover_t failover_id); 163 extern int _bcm_esw_failover_egr_check(int unit, bcm_l3_egress_t *egr); 164 extern int _bcm_esw_failover_prot_nhi_create(int unit, uint32 flags, int nh_index, int prot_nh_index, 165 bcm_multicast_t mc_group, bcm_failover_t failover_id); 166 extern int _bcm_esw_failover_prot_nhi_cleanup(int unit, int nh_index); 167 extern int _bcm_esw_failover_prot_nhi_get (int unit, int nh_index, 168 bcm_failover_t *failover_id, int *prot_nh_index, int *multicast_group); 169 extern int _bcm_esw_failover_mpls_check(int unit, bcm_mpls_port_t *mpls_port); 170 extern int _bcm_esw_failover_prot_nhi_update (int unit, int old_nh_index, int new_nh_index); 171 extern int _bcm_esw_failover_extender_check(int unit, bcm_extender_port_t *extender_port); 172 extern int _bcm_esw_failover_ecmp_prot_nhi_create(int unit, int ecmp, int index, 173 int nh_index, bcm_failover_t failover_id, int prot_nh_index); 174 extern int _bcm_esw_failover_ecmp_prot_nhi_cleanup(int unit, int ecmp, int index, int nh_index); 175 extern int _bcm_esw_failover_ecmp_prot_nhi_get(int unit, int ecmp, int index, 176 int nh_index, bcm_failover_t *failover_id, int *prot_nh_index); 177 extern int _bcm_esw_failover_ecmp_prot_nhi_update(int unit, int ecmp, int index, 178 int old_nh_index, int new_nh_index); 179 180 181 extern void bcmi_esw_failover_dependent_free_resources(int unit); 182 #ifndef BCM_SW_STATE_DUMP_DISABLE 183 extern void _bcm_tr2_failover_sw_dump(int unit); 184 #endif /* BCM_SW_STATE_DUMP_DISABLE */ 185 186 #ifdef BCM_WARM_BOOT_SUPPORT 187 extern int 188 bcm_esw_failover_sync(int unit); 189 190 #endif 191 #endif /* INCLUDE_L3 */ 192 193 #endif /* !_BCM_INT_ESW_FAILOVER_H_ */