mpls.c (6135B)
1 2 /* 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 7 * 8 * File: mpls.c 9 * Purpose: Manages common MPLS functions 10 */ 11 12 #ifdef INCLUDE_L3 13 14 #include <sal/core/libc.h> 15 16 #include <soc/drv.h> 17 #include <soc/mem.h> 18 #include <soc/l2u.h> 19 #include <soc/util.h> 20 #include <soc/debug.h> 21 22 #include <bcm/l2.h> 23 #include <bcm/l3.h> 24 #include <bcm/port.h> 25 #include <bcm/error.h> 26 #include <bcm/vlan.h> 27 #include <bcm/rate.h> 28 #include <bcm/ipmc.h> 29 #include <bcm/mpls.h> 30 #include <bcm/stack.h> 31 #include <bcm/topo.h> 32 #include <bcm/stat.h> 33 34 /* 35 * Function: 36 * bcm_mpls_port_t_init 37 * Purpose: 38 * Initialize the MPLS port struct 39 * Parameters: 40 * port_info - Pointer to the struct to be init'ed 41 */ 42 43 void 44 bcm_mpls_port_t_init(bcm_mpls_port_t *port_info) 45 { 46 if (port_info != NULL) { 47 sal_memset(port_info, 0, sizeof(*port_info)); 48 49 port_info->port = BCM_GPORT_INVALID; 50 port_info->match_vlan = BCM_VLAN_INVALID; 51 port_info->match_inner_vlan = BCM_VLAN_INVALID; 52 port_info->egress_service_vlan = BCM_VLAN_INVALID; 53 port_info->egress_class_id = BCM_CLASS_ID_INVALID; 54 port_info->pw_seq_number = 1; 55 port_info->inlif_counting_profile = BCM_STAT_LIF_COUNTING_PROFILE_NONE; 56 bcm_mpls_egress_label_t_init(&port_info->egress_label); 57 bcm_mpls_egress_label_t_init(&port_info->egress_tunnel_label); 58 } 59 return; 60 } 61 62 /* 63 * Function: 64 * bcm_mpls_egress_label_t_init 65 * Purpose: 66 * Initialize MPLS egress label object struct. 67 * Parameters: 68 * label - Pointer to MPLS egress label object struct. 69 */ 70 71 void 72 bcm_mpls_egress_label_t_init(bcm_mpls_egress_label_t *label) 73 { 74 if (label != NULL) { 75 sal_memset(label, 0, sizeof(*label)); 76 label->label = BCM_MPLS_LABEL_INVALID; 77 label->outlif_counting_profile = BCM_STAT_LIF_COUNTING_PROFILE_NONE; 78 label->egress_qos_model.egress_qos = bcmQosEgressModelUniform; 79 label->egress_qos_model.egress_ttl = bcmQosEgressModelUniform; 80 } 81 return; 82 } 83 84 /* 85 * Function: 86 * bcm_mpls_tunnel_switch_t_init 87 * Purpose: 88 * Initialize MPLS tunnel switch object struct. 89 * Parameters: 90 * switch - Pointer to MPLS tunnel switch object struct. 91 */ 92 93 void 94 bcm_mpls_tunnel_switch_t_init(bcm_mpls_tunnel_switch_t *info) 95 { 96 if (info != NULL) { 97 sal_memset(info, 0, sizeof(*info)); 98 info->label = BCM_MPLS_LABEL_INVALID; 99 info->action = BCM_MPLS_SWITCH_ACTION_INVALID; 100 info->action_if_bos = info->action_if_not_bos = info->action; 101 info->inlif_counting_profile = BCM_STAT_LIF_COUNTING_PROFILE_NONE; 102 103 bcm_mpls_egress_label_t_init(&info->egress_label); 104 info->tunnel_if = BCM_IF_INVALID; 105 } 106 return; 107 } 108 109 /* 110 * Function: 111 * bcm_mpls_entropy_identifier_t_init 112 * Purpose: 113 * Initialize MPLS entropy identifier object struct. 114 * Parameters: 115 * switch - Pointer to MPLS entropy identifier object struct. 116 */ 117 118 void 119 bcm_mpls_entropy_identifier_t_init(bcm_mpls_entropy_identifier_t *info) 120 { 121 if (info != NULL) { 122 sal_memset(info, 0, sizeof(*info)); 123 info->label = BCM_MPLS_LABEL_INVALID; 124 } 125 return; 126 } 127 128 /* 129 * Function: 130 * bcm_mpls_exp_map_t_init 131 * Purpose: 132 * Initialize MPLS EXP map object struct. 133 * Parameters: 134 * exp_map - Pointer to MPLS EXP map object struct. 135 */ 136 137 void 138 bcm_mpls_exp_map_t_init(bcm_mpls_exp_map_t *exp_map) 139 { 140 if (exp_map != NULL) { 141 sal_memset(exp_map, 0, sizeof(*exp_map)); 142 } 143 return; 144 } 145 146 147 /* 148 * Function: 149 * bcm_mpls_vpn_config_t_init 150 * Purpose: 151 * Initialize the MPLS VPN config structure 152 * Parameters: 153 * info - Pointer to the struct to be init'ed 154 */ 155 156 void 157 bcm_mpls_vpn_config_t_init(bcm_mpls_vpn_config_t *info) 158 { 159 if (info != NULL) { 160 sal_memset(info, 0, sizeof(*info)); 161 } 162 return; 163 } 164 165 /* 166 * Function: 167 * bcm_mpls_range_action_t_init 168 * Purpose: 169 * Initialize the MPLS Range action structure 170 * Parameters: 171 * info - Pointer to the struct to be init'ed 172 */ 173 174 void 175 bcm_mpls_range_action_t_init(bcm_mpls_range_action_t *info) 176 { 177 if (info != NULL) { 178 sal_memset(info, 0, sizeof(*info)); 179 } 180 return; 181 } 182 183 /* 184 * Function: 185 * bcm_mpls_stat_info_t_init 186 * Purpose: 187 * Initialize the MPLS tunnel Stat info structure 188 * Parameters: 189 * stat_info - Pointer to the MPLS tunnel stat struct to be init'ed 190 */ 191 192 void 193 bcm_mpls_stat_info_t_init(bcm_mpls_stat_info_t *stat_info) 194 { 195 if (stat_info != NULL) { 196 sal_memset(stat_info, 0, sizeof(*stat_info)); 197 } 198 return; 199 } 200 /* 201 * Function: 202 * bcm_mpls_special_label_t_init 203 * Purpose: 204 * Initialize the MPLS special label structure 205 * Parameters: 206 * stat_info - Pointer to the MPLS special label struct to be init'ed 207 */ 208 void 209 bcm_mpls_special_label_t_init(bcm_mpls_special_label_t *label_info) 210 { 211 if (label_info != NULL) { 212 sal_memset(label_info, 0, sizeof(*label_info)); 213 214 label_info->label_value = BCM_MPLS_LABEL_INVALID; 215 } 216 return; 217 } 218 219 /* 220 * Function: 221 * bcm_mpls_special_label_push_element_init 222 * Purpose: 223 * Initialize the MPLS special label element structure 224 * Parameters: 225 * stat_info - Pointer to the MPLS special label element 226 * struct to be init'ed 227 */ 228 void 229 bcm_mpls_special_label_push_element_t_init( 230 bcm_mpls_special_label_push_element_t *element) 231 { 232 if (element != NULL) { 233 sal_memset(element, 0, sizeof(*element)); 234 235 element->gport = BCM_GPORT_INVALID; 236 } 237 return; 238 } 239 240 /* 241 * Function: 242 * bcm_mpls_esi_info_t_init 243 * Purpose: 244 * Initialize the ESI info structure 245 * Parameters: 246 * esi_info - Pointer to the Esi info 247 * struct to be init'ed 248 */ 249 void 250 bcm_mpls_esi_info_t_init( 251 bcm_mpls_esi_info_t *esi_info) 252 { 253 if (esi_info != NULL) { 254 sal_memset(esi_info, 0, sizeof(*esi_info)); 255 256 esi_info->src_port = BCM_GPORT_INVALID; 257 } 258 return; 259 } 260 261 #else 262 int _bcm_mpls_not_empty; 263 264 #endif /* INCLUDE_L3 */