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_encap.h (8964B)


      1 /** \file mpls_tunnel_encap.h
      2  *  MPLS functionality for DNX tunnel encapsulation.
      3  */
      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_TUNNEL_ENCAP_INCLUDED__
     11 /*
     12  * {
     13  */
     14 #define _MPLS_TUNNEL_ENCAP_INCLUDED__
     15 
     16 #ifndef BCM_DNX_SUPPORT
     17 #error "This file is for use by DNX (JR2) family only!"
     18 #endif /* BCM_DNX_SUPPORT */
     19 
     20 #include <bcm_int/dnx/algo/mpls/algo_mpls.h>
     21 #include <bcm_int/dnx/lif/lif_table_mngr_lib.h>
     22 
     23 /*
     24  * }
     25  */
     26 
     27 /*
     28  * MPLS labels case
     29  */
     30  /**
     31  * mpls tunnel encapsulation type - based on the number of MPLS labels to encapsulate.
     32  */
     33 typedef enum
     34 {
     35     FIRST_DNX_MPLS_TUNNEL_ENCAP_TYPE = 0,
     36     DNX_MPLS_TUNNEL_ENCAP_NO_LABEL = FIRST_DNX_MPLS_TUNNEL_ENCAP_TYPE,
     37     DNX_MPLS_TUNNEL_ENCAP_ONE_LABELS,
     38     DNX_MPLS_TUNNEL_ENCAP_TWO_LABELS,
     39     NUM_DNX_MPLS_TUNNEL_ENCAP_TYPE
     40 } dnx_mpls_tunnel_encap_type_e;
     41 /**
     42  * Minimal and maximal number of labels supported for push action. used by mpls_tunnel APIs
     43  */
     44 #define DNX_MPLS_PUSH_MIN_NUM_LABELS 1
     45 #define DNX_MPLS_PUSH_MAX_NUM_LABELS 2
     46 
     47 /*
     48   * default invalid lif value.
     49   * must be same as CFG_LIF_NULL_VALUE HW register, used as local define as no get/set API for that register supported.
     50   */
     51 
     52 #define DNX_MPLS_CFG_LIF_NULL_VALUE 0
     53 
     54 /*
     55  * {
     56  */
     57 /**
     58  * \brief
     59  *   Generic parameter container for mpls encap set/get
     60  */
     61 typedef struct
     62 {
     63     /**
     64      * \brief
     65      *   Number of labels in the EEDB entry
     66      */
     67     int labels_nof;
     68     /**
     69      * \brief
     70      *   Label values array
     71      */
     72     bcm_mpls_egress_label_t *label_array;
     73     /**
     74      * \brief
     75      *   TTL PIPE profile
     76      *   Used only in case TTL is in pipe mode
     77      */
     78     int ttl_pipe_profile;
     79     /**
     80      * \brief
     81      *   ESEM extraction command.
     82      */
     83     int esem_command_profile;
     84     /**
     85      * \brief
     86      *   Network QOS ID
     87      */
     88     int nwk_qos_id;
     89     /**
     90      * \brief
     91      *   has control word.
     92      */
     93     int has_cw;
     94     /**
     95      * \brief
     96      *   indication for evpn iml.
     97      */
     98     int is_iml;
     99     /**
    100      * \brief
    101      *   outlif profile
    102      */
    103     int out_lif_profile;
    104     /**
    105      * \brief
    106      *   outlif llvp profile
    107      */
    108     int out_lif_llvp_profile;
    109     /**
    110      * \brief
    111      *   Phase of EEDB access
    112      */
    113     int outlif_phase;
    114     /**
    115      * \brief
    116      *   protection pointer
    117      */
    118     int protection_pointer;
    119     /**
    120      * \brief
    121      *   protection path
    122      */
    123     int protection_path;
    124     /**
    125      * \brief
    126      *   require esem_name_space in the entry
    127      */
    128     int require_name_space;
    129 } dnx_mpls_encap_t;
    130 
    131 /*
    132  * }
    133  */
    134 
    135 /**
    136  * \brief
    137  *   Initializes the input/output structure for mpls encap set/get functions.
    138  * \param [in] unit - Unit #
    139  * \param [in] encap_info - Designated param
    140  * \remark
    141  *   * None
    142  * \see
    143  *   * None
    144  */
    145 void dnx_mpls_encap_t_init(
    146     int unit,
    147     dnx_mpls_encap_t * encap_info);
    148 
    149 /**
    150 * \brief
    151 * Fill MPLS encap info according to local outlif
    152 *   \param [in] unit         -  Relevant unit.
    153 *   \param [in] entry_handle_id -  DBAL handle id of type superset
    154 *   \param [in] outlif_info  - Local Outlif Information.
    155 *   \param [out] encap_info  - MPLS encapsulation information.
    156 *
    157 * \return
    158 *   Negative in case of an error. See \ref shr_error_e
    159 * \remark
    160  */
    161 shr_error_e dnx_mpls_lif_table_manager_to_encap_info(
    162     int unit,
    163     uint32 entry_handle_id,
    164     lif_table_mngr_outlif_info_t * outlif_info,
    165     dnx_mpls_encap_t * encap_info);
    166 
    167 /**
    168 * \brief
    169 * Fill MPLS outlif info. This will be input to result type decision
    170 *   \param [in] unit         -  Relevant unit.
    171 *   \param [in] entry_handle_id -  DBAL handle id of type superset
    172 *   \param [in] encap_info   - MPLS/MPLS PORT encapsulation information.
    173 *   \param [out] outlif_info  - Local Outlif Information.
    174 *
    175 * \return
    176 *   Negative in case of an error. See \ref shr_error_e
    177 * \remark
    178  */
    179 shr_error_e dnx_mpls_encap_to_lif_table_manager_info(
    180     int unit,
    181     uint32 entry_handle_id,
    182     dnx_mpls_encap_t * encap_info,
    183     lif_table_mngr_outlif_info_t * outlif_info);
    184 
    185 /**
    186 * \brief
    187 *  Calculates the number of additional headers required .
    188 *   \param [in] has_cw     -  whether cw is resent.
    189 *   \param [in] flags         -  label flags, whether EL or ELI required.
    190 * \return
    191 *   number of additional headers used, 0 if non used.
    192 */
    193 int dnx_mpls_nof_additional_headers(
    194     int has_cw,
    195     uint32 flags);
    196 
    197 /**
    198 * \brief
    199 *  Calculate the required result type to be used for the EEDB entry based on label flags and nof labels.
    200 *   \param [in] unit     -  Relevant unit.
    201 *   \param [in] flags     -  Label flags.
    202 *   \param [in] tunnel_type     -  Tunnel type indicating on number of labels to be defined for the current EEDB entry (0, 1 or 2)
    203 * \return
    204 *   the relevant result type to be used
    205 */
    206 dbal_enum_value_result_type_eedb_mpls_tunnel_e dnx_mpls_tunnel_egress_result_type_get(
    207     int unit,
    208     uint32 flags,
    209     int tunnel_type);
    210 
    211 /**
    212 * \brief
    213 *  Set lif, TTL and QoS profiles on 'encap_info'.
    214 *  In case REPLACE is set, update the old profiles from 'encap_info_orig' with new ones.
    215 *   \param [in] unit -Relevant unit.
    216 *   \param [in] update -if set perform REPLACE
    217 *   \param [in] network_group_id - Split Horizon network group identifier.
    218 *   \param [in] dbal_table_id - dbal table id indicating the application - PWE/MPLS/EVPN.
    219 *   \param [in] encap_info_orig - original encapsulation information, used in case REPLACE flag is set
    220 *   \param [out] encap_info - encapsulation parameters.
    221 *   \param [out] ttl_pipe_profile_first_reference - indicate if the new ttl_pipe_profile is the first reference.
    222 *   \param [out] ttl_pipe_profile_last_reference - indicate if the old ttl_pipe_profile is the last reference.
    223 *   \param [out] qos_pipe_profile_first_reference - indicate if the new qos_pipe_profile is the first reference.
    224 *   \param [out] qos_pipe_profile_last_reference - indicate if the old qos_pipe_profile is the last reference.
    225 * \return
    226 *   shr_error_e
    227 */
    228 shr_error_e dnx_mpls_egress_lif_ttl_qos_profiles_sw_allocate(
    229     int unit,
    230     int update,
    231     bcm_switch_network_group_t network_group_id,
    232     dbal_tables_e dbal_table_id,
    233     dnx_mpls_encap_t encap_info_orig,
    234     dnx_mpls_encap_t * encap_info,
    235     uint8 *ttl_pipe_profile_first_reference,
    236     uint8 *ttl_pipe_profile_last_reference,
    237     uint8 *qos_pipe_profile_first_reference,
    238     uint8 *qos_pipe_profile_last_reference);
    239 
    240 /**
    241  * \brief
    242  * Fill the dnx_jr_mode_mpls_push_profile_t structure
    243  * According to the information in bcm_mpls_tunnel_switch_t
    244  *
    245  * \param [in] unit - Relevant unit.
    246  * \param [in] label_entry - A pointer to a struct containing relevant
    247  *        information for the egress label.
    248  * \param [in] has_cw - Ctrl word.
    249  * \param [out] push_profile_info  -  A pointer to the struct representing the tunnel push profile entry.
    250  * \return
    251  *   Error indication according to shr_error_e enum
    252  *
    253  * \remark
    254  *   * None
    255  * \see
    256  *   * None
    257  */
    258 shr_error_e dnx_mpls_label_info_to_push_profile(
    259     int unit,
    260     bcm_mpls_egress_label_t * label_entry,
    261     uint8 has_cw,
    262     dnx_jr_mode_mpls_push_profile_t * push_profile_info);
    263 
    264 /**
    265  * \brief
    266  * convert push profile to mpls label entry information.
    267  *
    268  * \param [in] unit - Relevant unit.
    269  * \param [in] push_cmd - push profile ID
    270  * \param [out] mpls_port - mpls label entry
    271  *
    272  * \return
    273  *   Error indication according to shr_error_e enum
    274  *
    275  * \remark
    276  *   * None
    277  * \see
    278  *   * None
    279  */
    280 shr_error_e dnx_push_profile_to_mpls_label_info(
    281     int unit,
    282     int push_cmd,
    283     bcm_mpls_port_t * mpls_port);
    284 /**
    285 * \brief
    286 *  Create MPLS tunnels in the egress for push with EEI.
    287 * \param [in] unit         - Relevant unit.
    288 * \param [in] label_entry  - mpls push information.
    289 * \param [in] has_cw       - whether carry control word
    290 * \param [in] is_replace - exchange operation.
    291 * \param [out] push_cmd  - push profile id used by EEI.
    292 * \return
    293 *   shr_error_e - Error Type
    294 * \remark
    295 *   * None
    296 * \see
    297 *   * None
    298 */
    299 shr_error_e dnx_mpls_tunnel_create_push_entry_from_eei(
    300     int unit,
    301     bcm_mpls_egress_label_t * label_entry,
    302     uint8 has_cw,
    303     uint8 is_replace,
    304     int *push_cmd);
    305 
    306 /**
    307 * \brief
    308 *  Delete MPLS tunnels in the egress for push with EEI.
    309 * \param [in] unit         - Relevant unit.
    310 * \param [in] push_cmd  - push profile id used by EEI.
    311 * \return
    312 *   shr_error_e - Error Type
    313 * \remark
    314 *   * None
    315 * \see
    316 *   * None
    317 */
    318 shr_error_e dnx_mpls_tunnel_delete_push_entry_from_eei(
    319     int unit,
    320     int push_cmd);
    321 
    322 /**
    323 * \brief
    324 *  Retrieve encap information from push command
    325 * \param [in] unit         - Relevant unit.
    326 * \param [in] push_cmd  - push profile id used by EEI.
    327 * \param [out] encap_info  - mpls encapsulation information.
    328 * \return
    329 *   shr_error_e - Error Type
    330 * \remark
    331 *   * None
    332 * \see
    333 *   * None
    334 */
    335 shr_error_e dnx_mpls_encap_get_from_push_cmd(
    336     int unit,
    337     int push_cmd,
    338     dnx_mpls_encap_t * encap_info);
    339 #endif  /*_MPLS_TUNNEL_ENCAP_INCLUDED__*/