mpls.h (10364B)
1 /* 2 * \file bcm_int/dnx/mpls/mpls.h 3 * Internal DNX MPLS APIs 4 * 5 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 6 * 7 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 8 */ 9 10 #ifndef _MPLS_H_INCLUDED__ 11 /* 12 * { 13 */ 14 #define _MPLS_H_INCLUDED__ 15 16 #ifndef BCM_DNX_SUPPORT 17 #error "This file is for use by DNX (JR2) family only!" 18 #endif 19 20 #include <soc/dnx/dbal/dbal.h> 21 #include <soc/dnx/dbal/auto_generated/dbal_defines_fields.h> 22 23 #include <bcm/mpls.h> 24 25 /* 26 * DEFINES 27 * { 28 */ 29 30 /** MPLS GAL Label */ 31 #define MPLS_LABEL_GAL 13 32 /** MAX value for MPLS reserved label */ 33 #define MPLS_MAX_RESERVED_LABEL 15 34 35 /** 36 * Maximal allowed MPLS label - 20LSB 37 */ 38 #define DNX_MPLS_LABEL_MAX(unit) (unsigned int)(SAL_UPTO_BIT(dnx_data_mpls.general.nof_bits_mpls_label_get(unit))) 39 40 /** 41 * Ckecks whether the given label is not larger than the allowed for MPLS label 42 */ 43 #define DNX_MPLS_LABEL_IN_RANGE(unit,_label_) (((unsigned int)_label_) <= DNX_MPLS_LABEL_MAX(unit)) 44 45 #define DNX_VPN_ID_MASK 0xffff 46 #define DNX_VPN_IS_SET(_vpn_) ((_vpn_) != 0) 47 #define DNX_VPN_ID_SET(_vpn_, _id_) ((_vpn_) = ((_id_) & DNX_VPN_ID_MASK)) 48 #define DNX_VPN_ID_GET(_vpn_) ((_vpn_) & DNX_VPN_ID_MASK) 49 50 /** Current TTL Exp MPLS Label */ 51 #define TTL_EXP_CURRENT_MPLS_LABEL DBAL_ENUM_FVAL_TTL_EXP_LABEL_INDEX_CURRENT_MPLS_LABEL 52 /** Next TTL Exp MPLS Label */ 53 #define TTL_EXP_NEXT_MPLS_LABEL DBAL_ENUM_FVAL_TTL_EXP_LABEL_INDEX_NEXT_MPLS_LABEL 54 /** No MPLS Labels To terminate */ 55 #define NO_MPLS_LABELS_TO_TERMINATE DBAL_ENUM_FVAL_LABELS_TO_TERMINATE_NO_LABELS 56 /** One MPLS Label To terminate */ 57 #define ONE_MPLS_LABEL_TO_TERMINATE DBAL_ENUM_FVAL_LABELS_TO_TERMINATE_ONE_LABEL 58 /** Two MPLS Labels To terminate */ 59 #define TWO_MPLS_LABELS_TO_TERMINATE DBAL_ENUM_FVAL_LABELS_TO_TERMINATE_TWO_LABELS 60 /** Three MPLS Labels To terminate */ 61 #define THREE_MPLS_LABEL_TO_TERMINATE DBAL_ENUM_FVAL_LABELS_TO_TERMINATE_THREE_LABELS 62 /** One or two MPLS Labels To terminate */ 63 #define ONE_OR_TWO_MPLS_LABELS_TO_TERMINATE DBAL_ENUM_FVAL_LABELS_TO_TERMINATE_THREE_LABELS 64 65 /** Default value of alternate marking special label */ 66 #define DNX_MPLS_ALTERNATE_MARKING_SL_DEFAULT 0x10 67 /* 68 * } 69 */ 70 71 /* 72 * Types 73 * { 74 */ 75 76 /** 77 * \brief 78 * MPLS labels match types 79 * These types are supported for lookup in ISEM 80 */ 81 typedef enum 82 { 83 DNX_MPLS_LABEL_MATCH_TYPE_INVALID = -1, 84 85 DNX_MPLS_LABEL_MATCH_TYPE_SINGLE_LABEL = 0, 86 DNX_MPLS_LABEL_MATCH_TYPE_TWO_LABELS = 1, 87 DNX_MPLS_LABEL_MATCH_TYPE_INTF_PLUS_LABEL = 2, 88 89 /* 90 * Must be last 91 */ 92 DNX_MPLS_LABEL_MATCH_TYPE_NOF 93 } dnx_mpls_match_type_e; 94 95 /* 96 * } 97 * Types 98 */ 99 100 /* 101 * ENUMs 102 * { 103 */ 104 105 /** 106 * \brief 107 * EEI identifier 108 * In JR2 mode, 1 for pop command, 2 for swap command, (total 8) multi swap command use 2~9 109 * In JR1 mode, 8 for EEI php, 9 for EEI swap 110 */ 111 typedef enum 112 { 113 DNX_EEI_IDENTIFIER_0 = 0, 114 DNX_EEI_IDENTIFIER_POP, /* same value FHEI_MPLS_COMMAND_POP */ 115 DNX_EEI_IDENTIFIER_SWAP, /* same value FHEI_MPLS_COMMAND_SWAP */ 116 DNX_EEI_IDENTIFIER_MULTI_SWAP_START = DNX_EEI_IDENTIFIER_SWAP, /** multi swap start*/ 117 DNX_EEI_IDENTIFIER_EEI_PHP = 8, 118 DNX_EEI_IDENTIFIER_EEI_SWAP = 9, 119 DNX_EEI_IDENTIFIER_MULTI_SWAP_LAST = DNX_EEI_IDENTIFIER_EEI_SWAP, /**LAST MULTI SWAP EEI Identifier*/ 120 DNX_EEI_IDENTIFIER_VLAN_EDIT = 15,/**VLAN_EDIT EEI Identifier*/ 121 /** Must be last */ 122 DNX_EEI_IDENTIFIER_NOF 123 } dnx_eei_identifier_e; 124 125 #define DNX_NOF_SWAP_REMARK_PROFILE (DNX_EEI_IDENTIFIER_MULTI_SWAP_LAST - DNX_EEI_IDENTIFIER_MULTI_SWAP_START + 1) 126 127 /* 128 * } 129 */ 130 131 /** 132 * \brief - Initialize MPLS module. \n 133 * Set default value in termination profile label table. 134 * \par DIRECT_INPUT: 135 * \param [in] unit - Unit-ID 136 * \par INDIRECT INPUT: 137 * \par DIRECT OUTPUT: 138 * shr_error_e 139 */ 140 shr_error_e dnx_mpls_module_init( 141 int unit); 142 143 /** 144 * \brief - Fill eei info according to field_id 145 * DBAL_FIELD_EEI_MPLS_POP_COMMAND EEI structure: 146 * 147 * Identifier[23:20] - pop command (8), 148 * push command (0), 149 * encapsulation pointer (3) 150 * Reserved[19:11] 151 * Remark-profile[10:8] - retreived from qos_map_id 152 * Model-is-Pipe-MSB[7] - always 1 for php 153 * Upper-Layer-Type[4] - irrelevant, not used 154 * Model-is-Pipe[5] - always 1 for php 155 * CW[4] - irrelevant, not used 156 * Upper-Layer-Type[3:0] - irrelevant, not used 157 * 158 * \param [in] unit - Relevant unit 159 * \param [in] qos_map_id - Quality Of Service 160 * \param [in] qos_model - qos model is pipe or uniform 161 * \param [in] ttl_model - ttl model is pipe or uniform 162 * \param [in] upper_layer_type - upper layer protocol 163 * \param [out] full_field_val - Returns the eei buffer 164 * 165 * \return 166 * Error indication according to shr_error_e enum 167 * 168 * \remark 169 * * None 170 * \see 171 * * None 172 */ 173 shr_error_e dnx_mpls_eei_php_information_fill( 174 int unit, 175 int qos_map_id, 176 dbal_enum_value_field_model_type_e qos_model, 177 dbal_enum_value_field_model_type_e ttl_model, 178 dbal_enum_value_field_jr_fwd_code_e upper_layer_type, 179 uint32 *full_field_val); 180 181 /** 182 * \brief - Get eei info according to field_id 183 * Only qos_map_id is relevant as other fields are fixed 184 * 185 * \param [in] unit - Relevant unit 186 * \param [in] full_field_val - Returns the eei buffer 187 * \param [out] qos_map_id - Quality Of Service 188 * \param [out] qos_model - qos model is pipe or uniform 189 * \param [out] ttl_model - ttl model is pipe or uniform 190 * \param [out] upper_layer_type - upper layer protocol 191 * 192 * \return 193 * Error indication according to shr_error_e enum 194 * 195 * \remark 196 * * None 197 * \see 198 * * None 199 */ 200 shr_error_e dnx_mpls_eei_php_information_retrieve( 201 int unit, 202 uint32 full_field_val, 203 int *qos_map_id, 204 dbal_enum_value_field_model_type_e * qos_model, 205 dbal_enum_value_field_model_type_e * ttl_model, 206 dbal_enum_value_field_jr_fwd_code_e * upper_layer_type); 207 208 /** 209 * \brief - Fill eei info according to field_id 210 * DBAL_FIELD_EEI_ENCAPSULATION_POINTER EEI structure: 211 * 212 * Identifier[23:20] - pop command (8), 213 * swap command (9) 214 * push command (0-7), 215 * encapsulation pointer (3,0b11xx) 216 * enc_pointer [15:0] outlif pointer[15:0] 217 * Host-index[19:16] - host idx 218 * enc-pointer-MSB[21:20] - out lif pointer[17:16] 219 * 220 * \param [in] unit - Relevant unit 221 * \param [in] out_lif - out lif 222 * \param [in] host_idx - host index 223 * \param [out] full_field_val - Returns the eei buffer 224 * 225 * \return 226 * Error indication according to shr_error_e enum 227 * 228 * \remark 229 * * None 230 * \see 231 * * None 232 */ 233 shr_error_e dnx_mpls_eei_enc_pointer_information_fill( 234 int unit, 235 bcm_if_t out_lif, 236 uint8 host_idx, 237 uint32 *full_field_val); 238 239 /** 240 * \brief - Get eei info according to field_id 241 * 242 * \param [in] unit - Relevant unit 243 * \param [in] full_field_val - Returns the eei buffer 244 * \param [out] out_lif - Out LIF 245 * \param [out] host_idx - Host Index 246 * 247 * \return 248 * Error indication according to shr_error_e enum 249 * 250 * \remark 251 * * None 252 * \see 253 * * None 254 */ 255 shr_error_e dnx_mpls_eei_enc_pointer_information_retrieve( 256 int unit, 257 uint32 full_field_val, 258 bcm_if_t * out_lif, 259 uint8 *host_idx); 260 261 /** 262 * \brief - Fill eei info according to field_id 263 * DBAL_FIELD_EEI_MPLS_PUSH_COMMAND EEI structure: 264 * 265 * Identifier[23:20] - pop command (8), 266 * swap command (9) 267 * push command (0-7), 268 * encapsulation pointer (3,0b11xx) 269 * mpls_label [19:0] label for push 270 * push_cmd [22:20] - push command 271 * 272 * \param [in] unit - Relevant unit 273 * \param [in] push_cmd - push command 274 * \param [in] mpls_label - mpls label 275 * \param [out] full_field_val - Returns the eei buffer 276 * 277 * \return 278 * Error indication according to shr_error_e enum 279 * 280 * \remark 281 * * None 282 * \see 283 * * None 284 */ 285 shr_error_e dnx_mpls_eei_push_information_fill( 286 int unit, 287 uint32 mpls_label, 288 int push_cmd, 289 uint32 *full_field_val); 290 291 /** 292 * \brief - Get eei info according to field_id 293 * 294 * \param [in] unit - Relevant unit 295 * \param [in] full_field_val - Returns the eei buffer 296 * \param [out] push_cmd - push command 297 * \param [out] mpls_label - mpls label 298 * 299 * \return 300 * Error indication according to shr_error_e enum 301 * 302 * \remark 303 * * None 304 * \see 305 * * None 306 */ 307 shr_error_e dnx_mpls_eei_push_information_retrieve( 308 int unit, 309 uint32 full_field_val, 310 uint32 *mpls_label, 311 int *push_cmd); 312 313 /** 314 * \brief - Set Alternate Special Label value. This is a global system configuration for both 315 * encapsulation (virtual PEMLA register and termination (special label map table). 316 * 317 * \param [in] unit - Relevant unit. 318 * \param [in] special_label_value - Special label value 319 * \return 320 * Error indication according to shr_error_e enum 321 * 322 * \remark 323 * None 324 * \see 325 * * None 326 */ 327 shr_error_e dnx_mpls_alternate_marking_special_label_set( 328 int unit, 329 uint32 special_label_value); 330 /** 331 * \brief - Get value of Alternate Special Label value. 332 * 333 * \param [in] unit - Relevant unit. 334 * \param [out] special_label_value - Special label value 335 * \return 336 * Error indication according to shr_error_e enum 337 * 338 * \remark 339 * None 340 * \see 341 * * None 342 */ 343 shr_error_e dnx_mpls_alternate_marking_special_label_get( 344 int unit, 345 uint32 *special_label_value); 346 347 /** 348 * \brief 349 * Set a special label to non special one. 350 * \param [in] unit - Relevant unit. 351 * \param [in] label - label. 352 * \param [in] enable - enable. 353 354 * \return 355 * shr_error_e - Non-zero in case of an error. 356 */ 357 shr_error_e dnx_mpls_special_label_as_general_label_set( 358 int unit, 359 int label, 360 int enable); 361 362 /** 363 * \brief 364 * Get a special label to non special one. 365 * \param [in] unit - Relevant unit. 366 * \param [in] label - label. 367 * \param [out] enable - enable. 368 369 * \return 370 * shr_error_e - Non-zero in case of an error. 371 */ 372 shr_error_e dnx_mpls_special_label_as_general_label_get( 373 int unit, 374 int label, 375 int *enable); 376 377 /* 378 * } 379 */ 380 381 #endif/*_MPLS_H_INCLUDED__*/