openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

mpls_tunnel_term.h (13566B)


      1 /** \file mpls_tunnel_term.h
      2  *      General MPLS functionality for DNX tunnel termination. 
      3  *      Used by mpls.c
      4  */
      5 /*
      6  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      7  * 
      8  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      9  */
     10 
     11 #ifndef _MPLS_TUNNEL_TERM_H_INCLUDED__
     12 /*
     13  * {
     14  */
     15 #define _MPLS_TUNNEL_TERM_H_INCLUDED__
     16 
     17 #ifndef BCM_DNX_SUPPORT
     18 #error "This file is for use by DNX (JR2) family only!"
     19 #endif
     20 
     21 #include <bcm/mpls.h>
     22 #include <soc/dnx/dbal/dbal.h>
     23 #include <soc/dnx/dbal/auto_generated/dbal_defines_fields.h>
     24 #include <bcm_int/dnx/mpls/mpls.h>
     25 /*
     26  * TYPEDEFs
     27  * {
     28  */
     29 /** actions supported by dnx_mpls_termination_lookup() */
     30 typedef enum
     31 {
     32     TERM_LOOKUP_SET,
     33     TERM_LOOKUP_GET,
     34     TERM_LOOKUP_DELETE,
     35     TERM_LOOKUP_FORCE_SET
     36 } dnx_mpls_termination_lookup_action_e;
     37 
     38 typedef enum
     39 {
     40     TERM_MATCH_CRITERIA_LABEL,
     41     TERM_MATCH_CRITERIA_LABEL_2ND_PASS_DB,
     42     TERM_MATCH_CRITERIA_LABEL_BOS,
     43     TERM_MATCH_CRITERIA_TWO_LABELS,
     44     TERM_MATCH_CRITERIA_TWO_LABELS_2ND_PASS_DB,
     45     TERM_MATCH_CRITERIA_INTF_LABEL,
     46     TERM_MATCH_CRITERIA_INTF_LABEL_2ND_PASS_DB,
     47     TERM_MATCH_CRITERIA_VLAN_DOMAIN_LABEL,
     48 
     49     NOF_TERM_MATCH_CRITERIA
     50 } dnx_mpls_termination_match_criteria_e;
     51 
     52 /**
     53  * \brief Carry MPLS label match information for dnx_mpls_termination_lookup
     54  */
     55 typedef struct dnx_mpls_term_match_s
     56 {
     57     dnx_mpls_termination_match_criteria_e match_criteria;
     58     /**
     59      * \brief Always used
     60      */
     61     bcm_mpls_label_t label;
     62     /**
     63      * \brief Used when criteria == TERM_MATCH_CRITERIA_TWO_LABELS
     64      */
     65     bcm_mpls_label_t context_label;
     66     /**
     67      * \brief Used when criteria == TERM_MATCH_CRITERIA_INTF_LABEL
     68      */
     69     bcm_if_t context_intf;
     70     /**
     71      * \brief Used when criteria == TERM_MATCH_CRITERIA_LABEL_BOS
     72      */
     73     uint8 bos_val;
     74     /**
     75      * \brief Always used
     76      */
     77     uint32 service_tagged;
     78     /**
     79      * \brief Vlan domain
     80      */
     81     uint32 vlan_domain;
     82 } dnx_mpls_term_match_t;
     83 
     84 /*
     85  * Structure used for both MPLS module internal implementation and template MNGR MPLS algo
     86  */
     87 typedef struct
     88 {
     89     dbal_enum_value_field_labels_to_terminate_e labels_to_terminate;
     90     dbal_enum_value_field_ttl_exp_label_index_e ttl_exp_label_index;
     91     int reject_ttl_0;
     92     int reject_ttl_1;
     93     int has_cw;
     94     int expect_bos;
     95     int check_bos;
     96 } dnx_mpls_termination_profile_t;
     97 
     98 /*
     99  * }
    100  */
    101 #if defined(INCLUDE_L3)
    102 /* { */
    103 /*
    104  * TYPEDEFs related to special labels.
    105  * {
    106  */
    107 /*
    108  * }
    109  */
    110 /*
    111  * DEFINEs related to special labels.
    112  * {
    113  */
    114 /**
    115  * \brief
    116  *   Verify whether '_special_label_type' (of type the bcm_mpls_special_label_type_t) is valid for specified unit
    117  *   We assume that 'bcmMplsSpecialLabelTypeNone' is the first legal type
    118  *   We assume that 'bcmMplsSpecialLabelTypeFrr' is the last legal type
    119  */
    120 #define DNX_MPLS_SPECIAL_LABEL_VERIFY(_unit,_special_label_type)                               \
    121     if (((int) (_special_label_type) > (int) (bcmMplsSpecialLabelTypeFrr)) ||                  \
    122                     ((int) (_special_label_type) < (int) (bcmMplsSpecialLabelTypeNone)))       \
    123     {                                                                                          \
    124         SHR_ERR_EXIT(_SHR_E_PARAM,                                                             \
    125                      "special_label_type (%d) is out of range (Should be between %d and %d)\r\n",   \
    126                      _special_label_type, bcmMplsSpecialLabelTypeNone, bcmMplsSpecialLabelTypeFrr); \
    127     }
    128 /*
    129  * }
    130  */
    131 /*
    132  * Procedures related to special labels.
    133  * {
    134  */
    135 /**
    136  * \brief
    137  *   Initialize structure carrying info related to special label
    138  *
    139  * \param [in] unit -
    140  *   Identifier of HW platform.
    141  * \param [out] bcm_mpls_special_label_p -
    142  *   Pointer to a structure of type 'bcm_mpls_special_label_t' to
    143  *   be initialized.
    144  * \return
    145  *   \retval Zero - On success
    146  *   \retval Error - Identifier as per shr_error_e
    147  * \remark
    148  *   None.
    149  * \see
    150  *   * dnx_mpls_special_label_identifier_traverse
    151  */
    152 shr_error_e dnx_bcm_mpls_special_label_t_init(
    153     int unit,
    154     bcm_mpls_special_label_t * bcm_mpls_special_label_p);
    155 /*
    156  * }
    157  */
    158 /*
    159  * Procedures related to FRR feature.
    160  * {
    161  */
    162 /**
    163  * \brief
    164  *   Add one entry (on FRR label on TCAM, MPLS_FRR_TCAM_DB)
    165  *
    166  * \param [in] unit -
    167  *   Identifier of HW platform.
    168  * \param [in] label_info_p -
    169  *   Pointer to a structure of type 'bcm_mpls_special_label_t'. This
    170  *   procedure only uses the 'label_value' which is an identifier of
    171  *   the MPLS label to add to the table.
    172  * \return
    173  *   \retval Zero - On success
    174  *   \retval Error - Identifier as per shr_error_e
    175  * \remark
    176  *   None.
    177  * \see
    178  *   * dnx_mpls_frr_label_identifier_traverse
    179  */
    180 shr_error_e dnx_mpls_frr_label_identifier_add(
    181     int unit,
    182     bcm_mpls_special_label_t * label_info_p);
    183 /**
    184  * \brief
    185  *   Get indication on whether an entry with indicated MPLS label exists (on
    186  *   FRR label on TCAM, MPLS_FRR_TCAM_DB)
    187  *
    188  * \param [in] unit -
    189  *   Identifier of HW platform.
    190  * \param [in] label_info_p -
    191  *   Pointer to a structure of type 'bcm_mpls_special_label_t'. This
    192  *   procedure only uses the 'label_value' which is an identifier of
    193  *   the MPLS label to search for on the table.
    194  *   If search is successful, this procedure returns without an error.
    195  *   else (in case of error)
    196  *     If specified 'label_value' is not found, no error log is ejected but
    197  *     return value is '_SHR_E_NOT_FOUND'
    198  *     Otherwise error log is ejected and returned error is as encountered.
    199  * \return
    200  *   \retval Zero - On success
    201  *   \retval Error - Identifier as per shr_error_e. If indicated label is not
    202  *     found, the error '_SHR_E_NOT_FOUND' is returned. No error log will be
    203  *     ejected in this case.
    204  * \remark
    205  *   None.
    206  * \see
    207  *   * bcm_dnx_mpls_special_label_identifier_get
    208  */
    209 shr_error_e dnx_mpls_frr_label_identifier_get(
    210     int unit,
    211     bcm_mpls_special_label_t * label_info_p);
    212 /**
    213  * \brief
    214  *   Delete an entry with indicated MPLS label (on FRR label on TCAM,
    215  *   MPLS_FRR_TCAM_DB)
    216  *
    217  * \param [in] unit -
    218  *   Identifier of HW platform.
    219  * \param [in] label_info_p -
    220  *   Pointer to a structure of type 'bcm_mpls_special_label_t'. This
    221  *   procedure only uses the 'label_value' which is an identifier of
    222  *   the MPLS label to search for on the table.
    223  *   If entry is not found (or some other error is encountered) error log
    224  *   is ejected and returned error is as encountered.
    225  * \return
    226  *   \retval Zero - On success
    227  *   \retval Error - Identifier as per shr_error_e.
    228  * \remark
    229  *   None.
    230  * \see
    231  *   * bcm_dnx_mpls_special_label_identifier_get
    232  */
    233 shr_error_e dnx_mpls_frr_label_identifier_delete(
    234     int unit,
    235     bcm_mpls_special_label_t * label_info_p);
    236 
    237 shr_error_e dnx_mpls_frr_label_identifier_delete_all(
    238     int unit);
    239 
    240 /**
    241  * \brief
    242  *   Traverse over all entries (MPLS labels) on FRR label on TCAM,
    243  *   MPLS_FRR_TCAM_DB, and invoke call-back procedure per each.
    244  *
    245  * \param [in] unit -
    246  *   Identifier of HW platform.
    247  * \param [in] cb -
    248  *   Pointer to call-back procedure. This procedure goes through all
    249  *   entries of specified table and invokes this procedure per each.
    250  * \param [in] user_data_p -
    251  *   Pointer to general data. This procedure passes this pointer to
    252  *   the call-back procedure, 'cb'.
    253  * \return
    254  *   \retval Zero - On success
    255  *   \retval Error - Identifier as per shr_error_e.
    256  * \remark
    257  *   None.
    258  * \see
    259  *   * bcm_dnx_mpls_special_label_identifier_traverse
    260  */
    261 shr_error_e dnx_mpls_frr_label_identifier_traverse(
    262     int unit,
    263     bcm_mpls_special_label_identifier_traverse_cb cb,
    264     void *user_data_p);
    265 /*
    266  * }
    267  */
    268 /* } */
    269 #endif /* INCLUDE_L3 */
    270 
    271 /**
    272  * \brief Added verification for MPLS tunnel termination.
    273  * See dnx_mpls_tunnel_switch_term_add for more details.
    274  */
    275 shr_error_e dnx_mpls_tunnel_switch_term_add_verify(
    276     int unit,
    277     bcm_mpls_tunnel_switch_t * info);
    278 
    279 
    280 shr_error_e dnx_mpls_tunnel_switch_term_add(
    281     int unit,
    282     bcm_mpls_tunnel_switch_t * info);
    283 
    284 /**
    285 * \brief
    286 *  Get the created MPLS tunnels for mpls termination.
    287 * \par DIRECT INPUT:
    288 *    \param [in] unit -Relevant unit.
    289 *    \param [in] local_inlif - pointer to the in-LIF entry in the inlif table.
    290 *    \param [out] info -A pointer to a struct to be filled according the termination information.
    291 *   info.label - A label according to which the lookup will be done.
    292 *   info.tunnel_id - global_if in case of termination
    293 *   info.port - destination port
    294 * \par INDIRECT INPUT:
    295 *   * \b *info \n
    296 *     See 'info' in DIRECT INPUT above
    297 * \par DIRECT OUTPUT:
    298 *   shr_error_e - Non-zero in case of an error.
    299 * \par INDIRECT OUTPUT:
    300 *   * See \b 'info' in DIRECT INPUT
    301 */
    302 shr_error_e dnx_mpls_tunnel_switch_term_get(
    303     int unit,
    304     int local_inlif,
    305     bcm_mpls_tunnel_switch_t * info);
    306 
    307 /**
    308 * \brief
    309 *  Delete MPLS tunnels for mpls termination.
    310 *   \param [in] unit -Relevant unit.
    311 *   \param [in] local_inlif - pointer to the in-lif to be deleted.
    312 *   \param [in] info  - Ingress MPLS entry to be deleted.
    313 * \return
    314 *   shr_error_e - Non-zero in case of an error.
    315 */
    316 shr_error_e dnx_mpls_tunnel_switch_term_delete(
    317     int unit,
    318     int local_inlif,
    319     bcm_mpls_tunnel_switch_t * info);
    320 
    321 /**
    322  * \brief
    323  *    Delete all MPLS tunnels for mpls termination.
    324  *
    325  * \param [in] unit       -  device unit number.
    326  *
    327  * \return
    328  *   \retval Zero if no error was detected
    329  *   \retval Negative if error was detected. See \ref bcm_error_t
    330  * \remark
    331  *   None.
    332  * \see
    333  *   * None
    334  */
    335 shr_error_e dnx_mpls_tunnel_switch_term_delete_all(
    336     int unit);
    337 
    338 /**
    339  * \brief
    340  *   Extract the match information and criteria from a tunnel switch structure
    341  * \param [in] unit
    342  * \param [in] tunnel - input structure from an API
    343  * \param [out] match - result match criteria and information for dnx_mpls_termination_lookup
    344  */
    345 shr_error_e dnx_mpls_term_match_criteria_from_tunnel_switch_get(
    346     int unit,
    347     bcm_mpls_tunnel_switch_t * tunnel,
    348     dnx_mpls_term_match_t * match);
    349 
    350 /**
    351 * \brief
    352 * Add/get/delete MPLS termination label to either 
    353 * DBAL_TABLE_MPLS_TERMINATION_SINGLE_LABEL_DB or 
    354 * DBAL_TABLE_MPLS_TERMINATION_CONTEXT_SPECIFIC_LABEL_DB table. 
    355 * This function configures ISEM lookup and is done for all cores. 
    356 *   \param [in] unit    -  Relevant unit.
    357 *   \param [in] action - perform SET/GET/DELETE on the table.
    358 *   \param [in] match_info  -  Match struct holding the match criteria and the match information.
    359 *   \param [in] local_in_lif   -  Local lif to be saved or looked up.
    360 * \return
    361 *   shr_error_e - Non-zero in case of an error.
    362 */
    363 shr_error_e dnx_mpls_termination_lookup(
    364     int unit,
    365     dnx_mpls_termination_lookup_action_e action,
    366     dnx_mpls_term_match_t * match_info,
    367     int *local_in_lif);
    368 
    369 /**
    370  * \brief 
    371  * Write to DBAL_TABLE_INGRESS_MPLS_TERMINATION_PROFILE table.
    372  * \param [in] unit - Relevant unit. 
    373  * \param [in] term_profile_info - A pointer to a struct containing relevant information for the Term Profile.
    374  * \param [in] term_profile - Termination Profile number, used as index to the table.
    375  * \return
    376  *   Error indication according to shr_error_e enum
    377  * \remark
    378  *   * None
    379  * \see
    380  *   * None
    381  */
    382 shr_error_e dnx_mpls_termination_profile_hw_set(
    383     int unit,
    384     dnx_mpls_termination_profile_t * term_profile_info,
    385     int term_profile);
    386 
    387 /**
    388  * \brief
    389  * Delete the termination profile entry form the HW
    390  *
    391  * \param [in] unit - Relevant unit. 
    392  * \param [in] term_profile - Termination profile number to be deleted
    393  *
    394  * \return
    395  *   Error indication according to shr_error_e enum
    396  *
    397  * \remark
    398  *   * None
    399  * \see
    400  *   * None
    401  */
    402 shr_error_e dnx_mpls_hw_termination_profile_delete(
    403     int unit,
    404     uint32 term_profile);
    405 
    406 /**
    407  * \brief 
    408  * Check whether the termination profile was already allocated 
    409  * using the template allocation algorithm, if not allocate new 
    410  * profile. 
    411  *
    412  * \param [in] unit - Relevant unit. 
    413  * \param [in] term_profile_info - A struct containing relevant information for the Term Profile.
    414  * \param [out] term_profile                     -  Termination profile used as reference
    415  * \param [in] old_term_profile                     -  Termination profile used as reference - used in case exchange is needed
    416  * \param [out] is_first_term_profile_reference  -  Returns 1 if the profile is the first reference
    417  * \param [out] is_last_term_profile_reference  -  Returns 1 if the profile is the last reference - used in case exchange is needed
    418  * \return
    419  *   Error indication according to shr_error_e enum
    420  *
    421  * \remark
    422  *   * None
    423  * \see
    424  *   * None
    425  */
    426 shr_error_e dnx_mpls_termination_profile_allocation(
    427     int unit,
    428     dnx_mpls_termination_profile_t term_profile_info,
    429     int *term_profile,
    430     int old_term_profile,
    431     uint8 *is_first_term_profile_reference,
    432     uint8 *is_last_term_profile_reference);
    433 
    434 /**
    435  * \brief
    436  * Traverse all MPLS tunnels in the ingress for mpls termination and run a callback function
    437  * provided by the user for each one.
    438  * \param [in] unit - The unit number.
    439  * \param [in] cb   - A pointer to callback function,
    440  *          it receives the value of the user_data variable and
    441  *          all MPLS tunnel objects that were iterated
    442  * \param [in] user_data - user data that will be sent to the callback function
    443  * \return
    444  *   \retval Zero if no error was detected
    445  *   \retval Negative if error was detected. See \ref shr_error_e
    446  * \see
    447  */
    448 shr_error_e dnx_mpls_tunnel_switch_term_traverse(
    449     int unit,
    450     bcm_mpls_tunnel_switch_traverse_cb cb,
    451     void *user_data);
    452 /*
    453  * }
    454  */
    455 #endif/*_MPLS_TUNNEL_TERM_H_INCLUDED__*/