span: add tx functionality and support for multiple mirror ports
[vpp.git] / vnet / vnet / interface.h
index 1f5dcf1..b5245e4 100644 (file)
@@ -61,6 +61,13 @@ typedef clib_error_t *(vnet_subif_add_del_function_t)
 typedef clib_error_t *(vnet_interface_set_mac_address_function_t)
   (struct vnet_hw_interface_t * hi, char *address);
 
+typedef enum vnet_interface_function_priority_t_
+{
+  VNET_ITF_FUNC_PRIORITY_LOW,
+  VNET_ITF_FUNC_PRIORITY_HIGH,
+} vnet_interface_function_priority_t;
+#define VNET_ITF_FUNC_N_PRIO ((vnet_interface_function_priority_t)VNET_ITF_FUNC_PRIORITY_HIGH+1)
+
 typedef struct _vnet_interface_function_list_elt
 {
   struct _vnet_interface_function_list_elt *next_interface_function;
@@ -76,8 +83,23 @@ static void __vnet_interface_function_init_##tag##_##f (void)           \
 {                                                                       \
  vnet_main_t * vnm = vnet_get_main();                                   \
  static _vnet_interface_function_list_elt_t init_function;              \
- init_function.next_interface_function = vnm->tag##_functions;          \
- vnm->tag##_functions = &init_function;                                 \
+ init_function.next_interface_function =                                \
+   vnm->tag##_functions[VNET_ITF_FUNC_PRIORITY_LOW];                    \
+ vnm->tag##_functions[VNET_ITF_FUNC_PRIORITY_LOW] = &init_function;     \
+ init_function.fp = (void *) &f;                                        \
+}
+
+#define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p)                    \
+                                                                        \
+static void __vnet_interface_function_init_##tag##_##f (void)           \
+    __attribute__((__constructor__)) ;                                  \
+                                                                        \
+static void __vnet_interface_function_init_##tag##_##f (void)           \
+{                                                                       \
+ vnet_main_t * vnm = vnet_get_main();                                   \
+ static _vnet_interface_function_list_elt_t init_function;              \
+ init_function.next_interface_function = vnm->tag##_functions[p];       \
+ vnm->tag##_functions[p] = &init_function;                              \
  init_function.fp = (void *) &f;                                        \
 }
 
@@ -85,10 +107,14 @@ static void __vnet_interface_function_init_##tag##_##f (void)           \
   _VNET_INTERFACE_FUNCTION_DECL(f,hw_interface_add_del)
 #define VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION(f)             \
   _VNET_INTERFACE_FUNCTION_DECL(f,hw_interface_link_up_down)
+#define VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION_PRIO(f,p)        \
+  _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,hw_interface_link_up_down,p)
 #define VNET_SW_INTERFACE_ADD_DEL_FUNCTION(f)                  \
   _VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_add_del)
 #define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION(f)            \
   _VNET_INTERFACE_FUNCTION_DECL(f,sw_interface_admin_up_down)
+#define VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION_PRIO(f,p)             \
+  _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,sw_interface_admin_up_down, p)
 
 /* A class of hardware interface devices. */
 typedef struct _vnet_device_class
@@ -154,8 +180,8 @@ typedef struct _vnet_device_class
   /* Link-list of all device classes set up by constructors created below */
   struct _vnet_device_class *next_class_registration;
 
-  /* Do not splice vnet_interface_output_node into TX path */
-  u8 no_flatten_output_chains;
+  /* Splice vnet_interface_output_node into TX path */
+  u8 flatten_output_chains;
 
   /* Function to set mac address. */
   vnet_interface_set_mac_address_function_t *mac_addr_change_function;
@@ -477,6 +503,15 @@ typedef struct
   } eth;
 } vnet_sub_interface_t;
 
+typedef enum
+{
+  /* Always flood */
+  VNET_FLOOD_CLASS_NORMAL,
+  VNET_FLOOD_CLASS_TUNNEL_MASTER,
+  /* Does not flood when tunnel master is in the same L2 BD */
+  VNET_FLOOD_CLASS_TUNNEL_NORMAL
+} vnet_flood_class_t;
+
 /* Software-interface.  This corresponds to a Ethernet VLAN, ATM vc, a
    tunnel, etc.  Configuration (e.g. IP address) gets attached to
    software interface. */
@@ -511,8 +546,6 @@ typedef struct
 
   u32 link_speed;
 
-  u32 output_feature_bitmap;
-
   union
   {
     /* VNET_SW_INTERFACE_TYPE_HARDWARE. */
@@ -521,6 +554,8 @@ typedef struct
     /* VNET_SW_INTERFACE_TYPE_SUB. */
     vnet_sub_interface_t sub;
   };
+
+  vnet_flood_class_t flood_class;
 } vnet_sw_interface_t;
 
 typedef enum
@@ -586,6 +621,8 @@ typedef struct
   u32 pcap_pkts_to_capture;
   uword *pcap_drop_filter_hash;
 
+  /* feature_arc_index */
+  u8 output_feature_arc_index;
 } vnet_interface_main_t;
 
 static inline void
@@ -607,30 +644,6 @@ void vnet_pcap_drop_trace_filter_add_del (u32 error_index, int is_add);
 
 int vnet_interface_name_renumber (u32 sw_if_index, u32 new_show_dev_instance);
 
-
-/*
- *  Output features
- */
-
-#define foreach_intf_output_feat \
- _(IPSEC, "ipsec-output")
-
-/* Feature bitmap positions */
-typedef enum
-{
-#define _(sym,str) INTF_OUTPUT_FEAT_##sym,
-  foreach_intf_output_feat
-#undef _
-    INTF_OUTPUT_N_FEAT,
-} intf_output_feat_t;
-
-/* flag that we are done with feature path */
-#define INTF_OUTPUT_FEAT_DONE INTF_OUTPUT_N_FEAT
-
-int vnet_interface_add_del_feature (struct vnet_main_t *vnm, vlib_main_t * vm,
-                                   u32 sw_if_index,
-                                   intf_output_feat_t feature, int is_add);
-
 #endif /* included_vnet_interface_h */
 
 /*