vpn.h (3446B)
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-2019 Broadcom Inc. All rights reserved. 6 * 7 * This file contains generic VPN definitions internal to the BCM library. 8 */ 9 10 #ifndef _BCM_INT_VPN_H 11 #define _BCM_INT_VPN_H 12 13 #define _BCM_VPN_TYPE_L3 BCM_VPN_TYPE_MPLS_L3 14 #define _BCM_VPN_TYPE_VPWS BCM_VPN_TYPE_MPLS_VPWS 15 #define _BCM_VPN_TYPE_VFI BCM_VPN_TYPE_MPLS_VPLS 16 17 #define _BCM_VPN_SET(_vpn_, _type_, _id_) \ 18 do { \ 19 if (BCM_VPN_TYPE_MPLS_L3 == (_type_)) { \ 20 BCM_VPN_MPLS_L3_VPN_ID_SET(_vpn_, _id_); \ 21 } else if (BCM_VPN_TYPE_MPLS_VPWS == (_type_)) { \ 22 BCM_VPN_MPLS_VPWS_VPN_ID_SET(_vpn_, _id_); \ 23 } else if (BCM_VPN_TYPE_MPLS_VPLS == (_type_)) { \ 24 BCM_VPN_MPLS_VPLS_VPN_ID_SET(_vpn_, _id_); \ 25 } else if (BCM_VPN_TYPE_VXLAN == (_type_)) { \ 26 BCM_VPN_VXLAN_VPN_ID_SET(_vpn_, _id_); \ 27 } else if (BCM_VPN_TYPE_L2GRE == (_type_)) { \ 28 BCM_VPN_L2GRE_VPN_ID_SET(_vpn_, _id_); \ 29 } else if (BCM_VPN_TYPE_MIM == (_type_)) { \ 30 BCM_VPN_MIM_VPN_ID_SET(_vpn_, _id_); \ 31 } \ 32 } while (0) 33 34 #define _BCM_VPN_GET(_id_, _type_, _vpn_) \ 35 do { \ 36 if (BCM_VPN_TYPE_MPLS_L3 == (_type_)) { \ 37 BCM_VPN_MPLS_L3_VPN_ID_GET(_vpn_, _id_); \ 38 } else if (BCM_VPN_TYPE_MPLS_VPWS == (_type_)) { \ 39 BCM_VPN_MPLS_VPWS_VPN_ID_GET(_vpn_, _id_); \ 40 } else if (BCM_VPN_TYPE_MPLS_VPLS == (_type_)) { \ 41 BCM_VPN_MPLS_VPLS_VPN_ID_GET(_vpn_, _id_); \ 42 } else if (BCM_VPN_TYPE_VXLAN == (_type_)) { \ 43 BCM_VPN_VXLAN_VPN_ID_GET(_vpn_, _id_); \ 44 } else if (BCM_VPN_TYPE_L2GRE == (_type_)) { \ 45 BCM_VPN_L2GRE_VPN_ID_GET(_vpn_, _id_); \ 46 } else if (BCM_VPN_TYPE_MIM == (_type_)) { \ 47 BCM_VPN_MIM_VPN_ID_GET(_vpn_, _id_); \ 48 } \ 49 } while (0) 50 51 #define _BCM_VPN_IS_L3(_vpn_) \ 52 (((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_MPLS_L3) \ 53 && ((((_vpn_) >> 12) & 0xf) < BCM_VPN_TYPE_MPLS_VPWS)) 54 55 #define _BCM_VPN_IS_VPLS(_vpn_) \ 56 ((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_MPLS_VPLS) 57 58 #define _BCM_VPN_IS_VPWS(_vpn_) \ 59 (((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_MPLS_VPWS) \ 60 && ((((_vpn_) >> 12) & 0xf) < BCM_VPN_TYPE_MPLS_VPLS)) 61 62 #define _BCM_VPN_IS_MIM(_vpn_) \ 63 ((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_MIM) 64 65 #define _BCM_VPN_IS_L2GRE_ELINE(_vpn_) \ 66 ((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_L2GRE) 67 68 #define _BCM_VPN_IS_L2GRE_ELAN(_vpn_) \ 69 ((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_L2GRE) 70 71 #define _BCM_VPN_IS_VXLAN_ELINE(_vpn_) \ 72 ((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_VXLAN) 73 74 #define _BCM_VPN_IS_VXLAN_ELAN(_vpn_) \ 75 ((((_vpn_) >> 12) & 0xf) >= BCM_VPN_TYPE_VXLAN) 76 77 #define _BCM_VPN_VFI_IS_SET(_vpn_) \ 78 (_BCM_VPN_IS_VPLS(_vpn_) \ 79 || _BCM_VPN_IS_MIM(_vpn_) \ 80 || _BCM_VPN_IS_L2GRE_ELINE(_vpn_) \ 81 || _BCM_VPN_IS_L2GRE_ELAN(_vpn_) \ 82 || _BCM_VPN_IS_VXLAN_ELINE(_vpn_) \ 83 || _BCM_VPN_IS_VXLAN_ELAN(_vpn_)) 84 85 #define _BCM_VPN_IS_SET(_vpn_) \ 86 (_BCM_VPN_IS_L3(_vpn_) \ 87 || _BCM_VPN_IS_VPWS(_vpn_) \ 88 || _BCM_VPN_VFI_IS_SET(_vpn_)) 89 90 #endif /* !_BCM_INT_VPN_H */