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

switch.h (5203B)


      1 /** \file bcm_int/dnx/switch/switch.h
      2  *
      3  * Internal DNX SWITCH 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 SWITCH_H_INCLUDED
     11 /* { */
     12 #define SWITCH_H_INCLUDED
     13 
     14 #ifndef BCM_DNX_SUPPORT
     15 #error "This file is for use by DNX (JR2) family only!"
     16 #endif
     17 
     18 /*
     19  * Include files.
     20  * {
     21  */
     22 #include <soc/dnx/dbal/auto_generated/dbal_defines_fields.h>
     23 #include <bcm_int/dnx/algo/port/algo_port_mgmt.h>
     24 
     25 /*
     26  * }
     27  */
     28 
     29 /*
     30  * DEFINES
     31  * {
     32  */
     33 /** Port header type index for both directions - IN and OUT */
     34 #define DNX_SWITCH_PORT_HEADER_TYPE_INDEX_BOTH 0
     35 /** Port header type index IN */
     36 #define DNX_SWITCH_PORT_HEADER_TYPE_INDEX_IN 1
     37 /** Port header type index OUT */
     38 #define DNX_SWITCH_PORT_HEADER_TYPE_INDEX_OUT 2
     39 
     40 #define DNX_SWITCH_INTR_BLOCK_MAX_NUM       2048
     41 #define DNX_SWITCH_INTR_BLOCK_WIDTH         BITS2WORDS(DNX_SWITCH_INTR_BLOCK_MAX_NUM)
     42 
     43 /*
     44  * }
     45  */
     46 
     47 /*
     48  * MACROs
     49  * {
     50  */
     51 
     52 /*
     53  * This MACRO is used for running verification function only if their verification mode is enable.
     54  * unit                     -> The unit number
     55  * _expr                    -> The verification function with all the required values.
     56  * _module_verification_id  -> the bcm_switch_module_verify_t value of the calling module.
     57  */
     58 #define DNX_SWITCH_VERIFY_IF_ENABLE_DNX(_unit,_expr,_module_verification_id)                    \
     59 do                                                                                              \
     60 {                                                                                               \
     61   uint8 enable;                                                                                 \
     62   SHR_IF_ERR_EXIT(switch_db.module_verification.get(_unit, _module_verification_id, &enable));  \
     63   if (enable)                                                                                   \
     64   {                                                                                             \
     65        SHR_INVOKE_VERIFY_DNX(_expr);                                                            \
     66   }                                                                                             \
     67 } while (0)
     68 
     69 /*
     70  * }
     71  */
     72 
     73 /**
     74  * \brief
     75  * Verify network_group_id range
     76 */
     77 shr_error_e dnx_switch_network_group_id_verify(
     78     int unit,
     79     int is_ingress,
     80     bcm_switch_network_group_t network_group_id);
     81 
     82 /**
     83  * \brief - Get routed learning mode for supported applications according to input flags
     84  *
     85  * \param [in] unit - unit Id
     86  * \param [out] arg - output flags (BCM_SWITCH_CONTROL_L3_LEARN_XXX)
     87  *
     88  * \return
     89  *   shr_error_e - Error type
     90  *
     91  * \remark
     92  *   * None
     93  * \see
     94  *   * None
     95  */
     96 shr_error_e dnx_switch_control_routed_learn_get(
     97     int unit,
     98     int *arg);
     99 
    100 /**
    101  * \brief - Retrieve the switch header type according to port and port direction
    102  *
    103  * \param [in] unit - Relevant unit
    104  * \param [in] port - Port
    105  * \param [in] direction - Port direction
    106  * \param [out] switch_header_type - Switch Header Type
    107  *
    108  * Port direction can be 0, 1 and 2. 0 means both directions (in and out), 1 means 'in' and 2 means 'out'.
    109  *
    110  * \return
    111  *   int
    112  *
    113  * \remark
    114  *   * None
    115  * \see
    116  *   * None
    117  */
    118 int dnx_switch_header_type_get(
    119     int unit,
    120     bcm_port_t port,
    121     int direction,
    122     int *switch_header_type);
    123 
    124 /**
    125  * \brief - convert BCM header types to DNX header types
    126  *
    127  * \param [in] unit - unit Id
    128  * \param [in] bcm_header_type - BCM header type (BCM_SWITCH_PORT_HEADER_TYPE_...)
    129  * \param [out] dnx_header_type - DNX header type (DNX_ALGO_PORT_HEADER_MODE_...)
    130  *
    131  * \return
    132  *   shr_error_e - Error type
    133  *
    134  * \remark
    135  *   * None
    136  * \see
    137  *   * None
    138  */
    139 shr_error_e dnx_switch_bcm_to_dnx_header_type_convert(
    140     int unit,
    141     int bcm_header_type,
    142     dnx_algo_port_header_mode_e * dnx_header_type);
    143 
    144 /**
    145  * \brief - Get the prt profile and the switch header type of in port
    146  *
    147  * \param [in] unit - Relevant unit
    148  * \param [in] port - Port
    149  * \param [out] switch_header_type - Switch port header type
    150  *
    151  * \return
    152  *   shr_error_e
    153  *
    154  * \remark
    155  *   * None
    156  * \see
    157  *   * None
    158  */
    159 shr_error_e dnx_switch_header_type_in_get(
    160     int unit,
    161     bcm_port_t port,
    162     int *switch_header_type);
    163 /**
    164  * \brief - initialize the switch module
    165  *
    166  * \param [in] unit - Relevant unit
    167  *
    168  * \return
    169  *   shr_error_e
    170  *
    171  * \remark
    172  *   * None
    173  * \see
    174  *   * None
    175  */
    176 int dnx_switch_init(
    177     int unit);
    178 
    179 /**
    180  * \brief - initialize the switch PP module.
    181  * \param [in] unit -  Unit-ID
    182  * \return
    183  *   shr_error_e
    184  * \remarks
    185  *   * None
    186  */
    187 int dnx_switch_pp_init(
    188     int unit);
    189 
    190 /**
    191  * \brief - Return invalid destination information in case that invalid destination interrupr occurs
    192  *
    193  * \param [in] unit - Relevant unit
    194  * \param [in] block_instance - Block instance id
    195  * \param [in] msg - Message that will be printed in case that invalid destination interrupt occurs
    196  *
    197  * \return
    198  *   shr_error_e
    199  *
    200  * \remark
    201  *   * None
    202  * \see
    203  *   * None
    204  */
    205 shr_error_e dnx_switch_interrupt_handles_corrective_action_invalid_destination(
    206     int unit,
    207     int block_instance,
    208     char *msg);
    209 /* } */
    210 #endif /* SWITCH_H_INCLUDED */