vswitch.h (5943B)
1 /* 2 * 3 * 4 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 * 6 * Copyright 2007-2020 Broadcom Inc. All rights reserved. 7 * 8 */ 9 10 #ifndef __BCM_VSWITCH_H__ 11 #define __BCM_VSWITCH_H__ 12 13 #include <bcm/types.h> 14 #include <bcm/policer.h> 15 #include <bcm/port.h> 16 17 #ifndef BCM_HIDE_DISPATCHABLE 18 19 /* Initialize vswitch module. */ 20 extern int bcm_vswitch_init( 21 int unit); 22 23 /* Detach vswitch module. */ 24 extern int bcm_vswitch_detach( 25 int unit); 26 27 /* Create a Virtual Switching Instance. */ 28 extern int bcm_vswitch_create( 29 int unit, 30 bcm_vlan_t *vsi); 31 32 /* Create a Virtual Switching Instance, with a specified ID. */ 33 extern int bcm_vswitch_create_with_id( 34 int unit, 35 bcm_vlan_t vsi); 36 37 /* Destroy a Virtual Switching Instance. */ 38 extern int bcm_vswitch_destroy( 39 int unit, 40 bcm_vlan_t vsi); 41 42 #endif /* BCM_HIDE_DISPATCHABLE */ 43 44 /* Vswitch callback function prototype */ 45 typedef int (*bcm_vswitch_port_traverse_cb)( 46 int unit, 47 bcm_vlan_t vsi, 48 bcm_gport_t port, 49 void *user_data); 50 51 #ifndef BCM_HIDE_DISPATCHABLE 52 53 /* Traverse existing ports on vswitch */ 54 extern int bcm_vswitch_port_traverse( 55 int unit, 56 bcm_vlan_t vsi, 57 bcm_vswitch_port_traverse_cb cb, 58 void *user_data); 59 60 /* Add a logical port to the specified virtual switching instance. */ 61 extern int bcm_vswitch_port_add( 62 int unit, 63 bcm_vlan_t vsi, 64 bcm_gport_t port); 65 66 /* Remove a logical port from the specified virtual switching instance. */ 67 extern int bcm_vswitch_port_delete( 68 int unit, 69 bcm_vlan_t vsi, 70 bcm_gport_t port); 71 72 /* 73 * Remove all logical port members from the specified virtual switching 74 * instance. 75 */ 76 extern int bcm_vswitch_port_delete_all( 77 int unit, 78 bcm_vlan_t vsi); 79 80 /* 81 * Get the virtual switching instance of which the specified logical port 82 * is a member. 83 */ 84 extern int bcm_vswitch_port_get( 85 int unit, 86 bcm_gport_t port, 87 bcm_vlan_t *vsi); 88 89 #endif /* BCM_HIDE_DISPATCHABLE */ 90 91 /* bcm_vswitch_cross_connect_* flags */ 92 #define BCM_VSWITCH_CROSS_CONNECT_DIRECTIONAL 0x00000001 /* connect gport1 to 93 gport2 */ 94 95 /* L3 tunneling initiator. */ 96 typedef struct bcm_vswitch_cross_connect_s { 97 bcm_gport_t port1; /* First gport in cross connect. */ 98 bcm_gport_t port2; /* Second gport in cross connect. */ 99 int encap1; /* First gport encap id. */ 100 int encap2; /* Second gport encap id. */ 101 uint32 flags; /* BCM_VSWITCH_CROSS_CONNECT_XXX flags. */ 102 } bcm_vswitch_cross_connect_t; 103 104 /* Initialize the bcm_vswitch_cross_connect_t struct. */ 105 extern void bcm_vswitch_cross_connect_t_init( 106 bcm_vswitch_cross_connect_t *cross_connect); 107 108 #ifndef BCM_HIDE_DISPATCHABLE 109 110 /* Attach two given logical ports in a point-to-point service. */ 111 extern int bcm_vswitch_cross_connect_add( 112 int unit, 113 bcm_vswitch_cross_connect_t *gports); 114 115 /* Remove attachment between the given logical ports. */ 116 extern int bcm_vswitch_cross_connect_delete( 117 int unit, 118 bcm_vswitch_cross_connect_t *gports); 119 120 /* Delete all point-to-point services. */ 121 extern int bcm_vswitch_cross_connect_delete_all( 122 int unit); 123 124 /* 125 * Return peer, if protected return primary port, invalid gport is 126 * populated. 127 */ 128 extern int bcm_vswitch_cross_connect_get( 129 int unit, 130 bcm_vswitch_cross_connect_t *gports); 131 132 #endif /* BCM_HIDE_DISPATCHABLE */ 133 134 /* Vswitch callback function prototype */ 135 typedef int (*bcm_vswitch_cross_connect_traverse_cb)( 136 int unit, 137 bcm_vswitch_cross_connect_t *gports, 138 void *user_data); 139 140 #ifndef BCM_HIDE_DISPATCHABLE 141 142 /* Traverse all existing point-to-point services. */ 143 extern int bcm_vswitch_cross_connect_traverse( 144 int unit, 145 bcm_vswitch_cross_connect_traverse_cb cb, 146 void *user_data); 147 148 /* Destroy all Virtual Switching Instances. */ 149 extern int bcm_vswitch_destroy_all( 150 int unit); 151 152 #endif /* BCM_HIDE_DISPATCHABLE */ 153 154 /* bcm_vswitch_flexible_connect_* flags */ 155 #define BCM_VSWITCH_FLEXIBLE_CONNECT_UPDATE 0x00000001 /* Update existing 156 connection */ 157 158 /* Vswitch flexible cross connect forwarding information. */ 159 typedef struct bcm_vswitch_flexible_connect_fwd_s { 160 bcm_gport_t forward_port; /* gport to be used as forward destination. */ 161 int forward_encap; /* forward encap id */ 162 } bcm_vswitch_flexible_connect_fwd_t; 163 164 /* Initialize the vswitch_flexible_connect_fwd_t struct. */ 165 extern void bcm_vswitch_flexible_connect_fwd_t_init( 166 bcm_vswitch_flexible_connect_fwd_t *vswitch_flexible_connect_fwd); 167 168 /* Vswitch flexible cross connect match information. */ 169 typedef struct bcm_vswitch_flexible_connect_match_s { 170 bcm_port_match_t match; /* Match criteria */ 171 bcm_gport_t match_port; /* Match port */ 172 bcm_vlan_t match_vlan; /* Match vlan */ 173 bcm_vlan_t match_inner_vlan; /* Match inner vlan */ 174 } bcm_vswitch_flexible_connect_match_t; 175 176 /* Initialize the vswitch_flexible_connect_match_t struct. */ 177 extern void bcm_vswitch_flexible_connect_match_t_init( 178 bcm_vswitch_flexible_connect_match_t *flexible_connect_match); 179 180 #ifndef BCM_HIDE_DISPATCHABLE 181 182 /* Attach given match port to forward destination. */ 183 extern int bcm_vswitch_flexible_connect_add( 184 int unit, 185 uint32 flags, 186 bcm_vswitch_flexible_connect_match_t *port_match, 187 bcm_vswitch_flexible_connect_fwd_t *port_fwd); 188 189 /* Remove flexible connection. */ 190 extern int bcm_vswitch_flexible_connect_delete( 191 int unit, 192 bcm_vswitch_flexible_connect_match_t *port_match); 193 194 /* Return forwarding information for given match peer */ 195 extern int bcm_vswitch_flexible_connect_get( 196 int unit, 197 uint32 flags, 198 bcm_vswitch_flexible_connect_match_t *port_match, 199 bcm_vswitch_flexible_connect_fwd_t *port_fwd); 200 201 #endif /* BCM_HIDE_DISPATCHABLE */ 202 203 #endif /* __BCM_VSWITCH_H__ */