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

failover.h (8278B)


      1 /*
      2  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3  * 
      4  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      5  */
      6 /** \file bcm_int/dnx/failover/failover.h
      7  *
      8  *
      9  * Reserved.$
     10  */
     11 
     12 #ifndef _DNX_FAILOVER_H_INCLUDED_
     13 /*
     14  * {
     15  */
     16 #define _DNX_FAILOVER_H_INCLUDED_
     17 
     18 #ifndef BCM_DNX_SUPPORT
     19 #error "This file is for use by DNX family only!"
     20 #endif
     21 
     22 /*
     23  * Includes
     24  * {
     25  */
     26 #include <bcm/failover.h>
     27 #include <bcm/mpls.h>
     28 #include <bcm/vlan.h>
     29 
     30 #include <soc/dnx/dbal/dbal.h>
     31 
     32 #include <shared/shrextend/shrextend_error.h>
     33 #include <shared/utilex/utilex_bitstream.h>
     34 
     35 /*
     36  * }
     37  * Includes
     38  */
     39 
     40 /*
     41  * MACROs 
     42  * {  
     43  */
     44 /** 
     45  * \brief -  
     46  * Failover types to be used in order to distinguish between failover object types
     47  */
     48 #define DNX_FAILOVER_TYPE_NONE              (0) /* No Failover type */
     49 #define DNX_FAILOVER_TYPE_FEC               (2) /* Failover ID of type FEC (1:1 UC) */
     50 #define DNX_FAILOVER_TYPE_INGRESS           (3) /* Failover ID of type Ingress (1+1) */
     51 #define DNX_FAILOVER_TYPE_ENCAP             (4) /* Failover ID of type Egress (1:1 MC) */
     52 
     53 /**
     54  * \brief - used to enocode-decode failover_ids with id (protection pointer) and type 
     55  */
     56 #define DNX_FAILOVER_TYPE_SHIFT             (29)
     57 #define DNX_FAILOVER_VAL_SHIFT              (0)
     58 #define DNX_FAILOVER_TYPE_MASK              (0x7)
     59 #define DNX_FAILOVER_VAL_MASK               (0x1FFFFFFF)
     60 
     61 /**
     62  * \brief - set failover type (see BCM_FAILOVER_TYPE_XXX) and id (protection pointer)
     63  */
     64 #define DNX_FAILOVER_SET(object_id, failover_id, failover_type)                         \
     65         ((object_id) = (((failover_type) << DNX_FAILOVER_TYPE_SHIFT) |                  \
     66          (((failover_id) & DNX_FAILOVER_VAL_MASK) << DNX_FAILOVER_VAL_SHIFT)))
     67 
     68 /**
     69  * \brief - get failover type - see BCM_FAILOVER_TYPE_XXX
     70  */
     71 #define DNX_FAILOVER_TYPE_GET(failover_type, failover_id)                               \
     72         ((failover_type) = (((failover_id) >> DNX_FAILOVER_TYPE_SHIFT) &                \
     73             DNX_FAILOVER_TYPE_MASK))                  \
     74 
     75 /**
     76  * \brief - get ID (i.e. protection pointer)
     77  */
     78 #define DNX_FAILOVER_ID_GET(failover_id_val, failover_id)                               \
     79         ((failover_id_val) = (((failover_id) >> DNX_FAILOVER_VAL_SHIFT) &               \
     80             DNX_FAILOVER_VAL_MASK))
     81 
     82 /**
     83  * \brief - Defines and MACROs for protection pointer encoding/decoding for usage in In-LIFs
     84  * The protection pointer value written in In-LIFs is 14 bits and should be derived from the Failover ID and encoded in the following way:
     85  * protection_pointer = ((failover_id & (mask nof_msb)) << nof_lsb) | (failover_id >> nof_msb)
     86  * The reason for this is that when the HW wants to check the protection path selected, it is taking the protection pointer from the In-LIF
     87  * and it is using it to determine which entry and field of memory IPPA_VTT_PATH_SELECT to read. In LIF protection pointer is 14 bits, but 
     88  * the HW is expecting 15 bits - the 12 LSB from the protection pointer indicate the entry(0-4095) and the 3 MSB indicate one of the 8 fields (0-7).
     89  * To compensate this difference only fields 0-3 are used and this way.
     90  */
     91 
     92 /**
     93  * \brief - Encode protection pointer for In-LIF
     94  */
     95 #define DNX_FAILOVER_ID_PROTECTION_POINTER_ENCODE(protection_pointer, failover_id)  \
     96 do                              \
     97 {                               \
     98     uint32 failover_arr[1] = {failover_id}; \
     99     protection_pointer = 0;     \
    100     SHR_IF_ERR_EXIT(utilex_bitstream_field_swap(failover_arr, dnx_data_failover.path_select.in_lif_protection_pointer_nof_lsb_get(unit),             \
    101                                                 dnx_data_failover.path_select.in_lif_protection_pointer_nof_msb_get(unit), (uint32 *)&(protection_pointer))); \
    102 } while (0)
    103 
    104 /**
    105  * \brief - Decode protection pointer from In-LIF
    106  */
    107 #define DNX_FAILOVER_ID_PROTECTION_POINTER_DECODE(failover_id, protection_pointer)  \
    108 do                      \
    109 {                       \
    110    uint32 protection_ptr_arr[1] = {protection_pointer}; \
    111    failover_id = 0;     \
    112    SHR_IF_ERR_EXIT(utilex_bitstream_field_swap(protection_ptr_arr, dnx_data_failover.path_select.in_lif_protection_pointer_nof_msb_get(unit),  \
    113                                                dnx_data_failover.path_select.in_lif_protection_pointer_nof_lsb_get(unit), (uint32 *)&(failover_id)));       \
    114 } while (0)
    115 
    116 /**
    117  * \brief - Returns TRUE for standby path.
    118  * A given failover entity (FEC or protection pointer) can be either primary(working) or secondary(standby).
    119  */
    120 #define DNX_FAILOVER_IS_STANDBY(failover_path_select) (failover_path_select == 0)
    121 
    122 /**
    123  * \brief - failover_id value that indicates protection is disabled
    124  */
    125 #define DNX_FAILOVER_PROTECTION_DISABLE_VALUE   0
    126 
    127 /**
    128  * \brief - Returns TRUE if protection is enabled.
    129  * If failover_id (protection pointer) is 0, then protection is not enabled
    130  */
    131 #define DNX_FAILOVER_IS_PROTECTION_ENABLED(failover_id) (failover_id != DNX_FAILOVER_PROTECTION_DISABLE_VALUE)
    132 
    133 /**
    134  * \brief - L2 protection information.
    135  */
    136 typedef struct
    137 {
    138     /** FEC protection indication */
    139     int is_fec_protected;
    140 
    141     /** FEC protection indication */
    142     bcm_failover_t failover_id;
    143 
    144     /** FEC/ingress protection path */
    145     bcm_gport_t failover_port_id;
    146 
    147     /** ingress protection indication */
    148     bcm_failover_t ingress_failover_id;
    149 
    150     /** egress protection indication */
    151     bcm_failover_t egress_failover_id;
    152 
    153     /** egress protection path */
    154     bcm_gport_t egress_failover_port_id;
    155 
    156     /** failover mc group for reverse path indication */
    157     int is_ingress_mc;
    158 
    159     /** reverse path ingress (1+1) protection mc group */
    160     bcm_multicast_t failover_mc_group;
    161 
    162 } dnx_failover_l2_protection_info_t;
    163 
    164 /*
    165  * MACROs
    166  * }
    167  */
    168 /**
    169  * \brief Initialize dnx failover module (protection path select).
    170  *
    171  * \param [in] unit - The unit number.
    172  *
    173  * \return
    174  *   See shr_error_e
    175  * \remark
    176  *   * None
    177  * \see
    178  *   * None
    179  */
    180 shr_error_e dnx_failover_init(
    181     int unit);
    182 
    183 /**
    184  * \brief - verify that the failover ID was allocated to be used for 'expected_type' and 'expected_hierarchy',
    185  *             otherwise throw an error with proper error message.
    186  *
    187  * \param [in] unit - The unit number.
    188  * \param [in] expected_type - DNX_FAILOVER_TYPE_XXX
    189  * \param [in] expected_hierarchy - expected hierarchy for FEC type or 0 for any other,
    190  * \param [in] failover_id - failover_id got from the user to verify.
    191  * \return
    192  *   See shr_error_e
    193  * \remark
    194  *   * None
    195  * \see
    196  *   * None
    197  */
    198 shr_error_e dnx_failover_id_valid_verify(
    199     int unit,
    200     int expected_type,
    201     dbal_enum_value_field_hierarchy_level_e expected_hierarchy,
    202     bcm_failover_t failover_id);
    203 
    204 /**
    205  * \brief - retrieve protection information for L2 objects (either AC or PWE)
    206  *
    207  * \param [in] unit - Unit #
    208  * \param [in] vlan_port - vlan port info.
    209  * \param [in] mpls_port - mpls port info.
    210  * \param [out] protection_info - protection information. /see dnx_failover_l2_protection_info_t.
    211  *
    212  * \return shr_error_e Standard error handling
    213  */
    214 shr_error_e dnx_failover_l2_protection_info_get(
    215     int unit,
    216     bcm_vlan_port_t * vlan_port,
    217     bcm_mpls_port_t * mpls_port,
    218     dnx_failover_l2_protection_info_t * protection_info);
    219 
    220 /**
    221  * \brief - Verify protection information for L2 objects (either AC or PWE)
    222  *
    223  * \param [in] unit - Unit #
    224  * \param [in] vlan_port - vlan port info.
    225  * \param [in] mpls_port - mpls port info.
    226  *
    227  * \return shr_error_e Standard error handling
    228  *
    229  * \remark - L2 protection verification should not verify whether the provided FEC pointer is a valid allocated FEC
    230  *           since the seqeunce requires L2 object creation prior to the FEC creation.
    231  */
    232 shr_error_e dnx_failover_l2_protection_info_verify(
    233     int unit,
    234     bcm_vlan_port_t * vlan_port,
    235     bcm_mpls_port_t * mpls_port);
    236 
    237 /**
    238  * \brief - Verify protection information for L2 objects (either AC or PWE)
    239  *
    240  * \param [in] unit - Unit #
    241  * \param [in] gport - facility port gport (either system port or trunk).
    242  * \param [in] enable - 1 is up, 0 is down.
    243  *
    244  * \return shr_error_e Standard error handling
    245  */
    246 shr_error_e dnx_failover_facility_port_status_set(
    247     int unit,
    248     bcm_gport_t gport,
    249     int enable);
    250 
    251 #endif /*_DNX_FAILOVER_H_INCLUDED_*/