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

vswitch.h (4420B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        vswitch.h
      8  * Purpose:     vswitch internal definitions to the BCM library.
      9  */
     10 
     11 #ifndef   _BCM_INT_DPP_VSWITCH_H_
     12 #define   _BCM_INT_DPP_VSWITCH_H_
     13 
     14 #include <bcm/types.h>
     15 #include <shared/swstate/sw_state.h>
     16 #include <bcm_int/dpp/mim.h>
     17 
     18 typedef struct _bcm_tr_vswitch_bookkeeping_s {
     19     int         initialized;        /* Set to TRUE when VSWITCH module initialized */
     20     PARSER_HINT_ARR SHR_BITDCL      *vsi_usage;
     21     int         vpn_detach_ports;  /* Set to 1 when VSWITCH module initialized */
     22 } _bcm_dpp_vswitch_bookkeeping_t;
     23 
     24 
     25 /*
     26  * vswitch definition
     27  */
     28 #define _BCM_DPP_VPN_ID_MASK           0xffff
     29 #define _BCM_DPP_VPN_BVID_MASK(_unit_) ((SOC_IS_JERICHO_A0(_unit_) | SOC_IS_JERICHO_B0(_unit_) | SOC_IS_QMX(_unit_)) ? 0x7000 : 0xf000)
     30 #define _BCM_DPP_VPN_VID_MASK          0xfff
     31 
     32 #define _BCM_DPP_VPN_IS_SET(_vpn_)    \
     33         ((_vpn_) != 0)
     34 
     35 #define _BCM_DPP_VPN_ID_SET(_vpn_, _id_) \
     36     ((_vpn_) = ((_id_) & _BCM_DPP_VPN_ID_MASK))
     37 
     38 #define _BCM_DPP_VPN_ID_GET(_vpn_) \
     39     ((_vpn_) & _BCM_DPP_VPN_ID_MASK)
     40 
     41 #define _BCM_DPP_VPN_IS_CROSS_CONNECT_VPWS(_vpn) (_vpn == 0)
     42 
     43 
     44 #define _BCM_DPP_VLAN_TO_BVID(_unit_, _vpn_) \
     45     ((_vpn_) | _BCM_DPP_VPN_BVID_MASK(_unit_))
     46 
     47 #define _BCM_DPP_VLAN_IS_BVID(_unit_, _vpn_) \
     48   ((((_vpn_) & _BCM_DPP_VPN_BVID_MASK(_unit_)) == _BCM_DPP_VPN_BVID_MASK(_unit_)) & (MIM_IS_INIT(_unit_) | (!SOC_IS_JERICHO_A0(_unit_) & !SOC_IS_JERICHO_B0(_unit_) & !SOC_IS_QMX(_unit_))))
     49 
     50 #define _BCM_DPP_BVID_TO_VLAN(_vpn_) \
     51     ((_vpn_) & _BCM_DPP_VPN_VID_MASK)
     52 
     53 /*
     54  * given VPN check if it's MP
     55  */
     56 #define _BCM_DDP_IS_MP_VPN(_vpn)  (_BCM_DPP_VPN_IS_SET(_vpn))
     57 #define _BCM_DDP_IS_CROSS_CONNECT_P2P_VPN(_vpn) (_BCM_DPP_VPN_IS_CROSS_CONNECT_VPWS(_vpn))
     58 
     59 /* map from MP VPN to VSI*/
     60 #define _BCM_DDP_VPN_TO_VSI(vpn) ((_BCM_DDP_IS_MP_VPN(vpn))?vpn:SOC_PPC_VSI_P2P_SERVICE)
     61 
     62 typedef enum _bcm_petra_vswitch_unknown_action_e {
     63    _bcm_petra_vswitch_unknown_action_drop=0,/* drop unknown da*/         
     64    _bcm_petra_vswitch_unknown_action_flood,
     65    _bcm_petra_vswitch_unknown_action_flood_per_action
     66 } _bcm_petra_vswitch_unknown_action_t;
     67 
     68 
     69 /* check if the given vsi/vpn exist */
     70 int _bcm_dpp_vlan_check(int unit, int vsi);
     71 
     72 #define _BCM_DPP_VSI_TYPE_NOF_BITS (8)
     73 
     74 typedef enum _bcm_vsi_type_s {
     75     _bcmDppVsiTypeAny=0,       /* Any VPN */
     76     _bcmDppVsiTypeMpls=1,      /* MPLS VPN */
     77     _bcmDppVsiTypeVswitch=2,   /* VSWITCH VSI */
     78     _bcmDppVsiTypeMim=4,   /* MIM VSI */
     79     _bcmDppVsiTypeL2gre=8,   /* L2GRE VSI */
     80     _bcmDppVsiTypeVxlan=0x10,  /* VXLAN */
     81     _bcmDppVsiTypeAll=0x1F,    /* All */
     82     _bcmDppVsiTypeCount
     83 } _bcm_vsi_type_e;
     84 
     85 
     86 extern _bcm_dpp_vswitch_bookkeeping_t  _bcm_dpp_vswitch_bk_info[BCM_MAX_NUM_UNITS];
     87 
     88 /* set/return bitmap of vsi usage */
     89 int _bcm_dpp_vswitch_vsi_usage_get(int unit, int	vsi, _bcm_vsi_type_e *usage);
     90 int _bcm_dpp_vswitch_vsi_usage_set(int unit, int	vsi, _bcm_vsi_type_e vswitch_usage);
     91 
     92 /* check specific usage of the vsi */
     93 int _bcm_dpp_vswitch_vsi_usage_type_set(int unit, int	vsi, _bcm_vsi_type_e type, uint8 used);
     94 int _bcm_dpp_vswitch_vsi_usage_type_check(int unit, int	vsi, _bcm_vsi_type_e type, uint8 *used);
     95 
     96 /* allocate VSI for specific usage
     97    - allocate VSI id if needed 
     98    - set the usage type. 
     99    - calling this API with different types over the same VSI-id should return ok. 
    100    - Remarks: 
    101         - replaced is optional, store if this call replace exist vsi of same type 
    102  */
    103 int _bcm_dpp_vswitch_vsi_usage_alloc(int unit, int flags, _bcm_vsi_type_e type, bcm_vlan_t *vsi, uint8 *replaced);
    104 
    105 /* dellocate VSI from specific usage
    106    - reset the usage type. 
    107    - dealloc if this was last usage of this VSI
    108  */
    109 int _bcm_dpp_vswitch_vsi_usage_dealloc(int unit, _bcm_vsi_type_e type, bcm_vlan_t	vsi);
    110 
    111 
    112 
    113 /* destroy vswitch and delete all ports */
    114 int bcm_petra_vswitch_destroy_internal(int unit, bcm_vlan_t vsi, _bcm_vsi_type_e vsi_type, int is_port_delete);
    115 
    116 
    117 
    118 /*
    119  * set VSI  flooding configuration
    120  */
    121 int
    122 bcm_petra_vswitch_vsi_set(
    123     int    unit,
    124     bcm_vlan_t    vsi,
    125 	_bcm_petra_vswitch_unknown_action_t  action,
    126     int is_clear);
    127 
    128 int
    129 bcm_petra_vswitch_vsi_get(
    130     int    unit,
    131     bcm_vlan_t    vsi,
    132 	_bcm_petra_vswitch_unknown_action_t  *action);
    133 
    134 
    135 #endif /* _BCM_INT_DPP_VSWITCH_H_ */