vlib: refactor node function variants
[vpp.git] / src / vnet / interface.h
index e9e7462..9c58442 100644 (file)
@@ -313,24 +313,24 @@ __VA_ARGS__ vnet_device_class_t x
 static __clib_unused vnet_device_class_t __clib_unused_##x
 #endif
 
-#define VNET_DEVICE_CLASS_TX_FN(devclass)                              \
-uword CLIB_MARCH_SFX (devclass##_tx_fn)();                             \
-static vlib_node_fn_registration_t                                     \
-  CLIB_MARCH_SFX(devclass##_tx_fn_registration) =                      \
-  { .function = &CLIB_MARCH_SFX (devclass##_tx_fn), };                 \
-                                                                       \
-static void __clib_constructor                                         \
-CLIB_MARCH_SFX (devclass##_tx_fn_multiarch_register) (void)            \
-{                                                                      \
-  extern vnet_device_class_t devclass;                                 \
-  vlib_node_fn_registration_t *r;                                      \
-  r = &CLIB_MARCH_SFX (devclass##_tx_fn_registration);                 \
-  r->priority = CLIB_MARCH_FN_PRIORITY();                              \
-  r->name = CLIB_MARCH_VARIANT_STR;                                    \
-  r->next_registration = devclass.tx_fn_registrations;                 \
-  devclass.tx_fn_registrations = r;                                    \
-}                                                                      \
-uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn)
+#define VNET_DEVICE_CLASS_TX_FN(devclass)                                     \
+  uword CLIB_MARCH_SFX (devclass##_tx_fn) ();                                 \
+  static vlib_node_fn_registration_t CLIB_MARCH_SFX (                         \
+    devclass##_tx_fn_registration) = {                                        \
+    .function = &CLIB_MARCH_SFX (devclass##_tx_fn),                           \
+  };                                                                          \
+                                                                              \
+  static void __clib_constructor CLIB_MARCH_SFX (                             \
+    devclass##_tx_fn_multiarch_register) (void)                               \
+  {                                                                           \
+    extern vnet_device_class_t devclass;                                      \
+    vlib_node_fn_registration_t *r;                                           \
+    r = &CLIB_MARCH_SFX (devclass##_tx_fn_registration);                      \
+    r->march_variant = CLIB_MARCH_SFX (CLIB_MARCH_VARIANT_TYPE);              \
+    r->next_registration = devclass.tx_fn_registrations;                      \
+    devclass.tx_fn_registrations = r;                                         \
+  }                                                                           \
+  uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn)
 
 /**
  * Link Type: A description of the protocol of packets on the link.
@@ -365,11 +365,17 @@ typedef enum vnet_link_t_
        _link <= VNET_LINK_NSH;       \
        _link++)
 
+#define FOR_EACH_VNET_IP_LINK(_link)    \
+  for (_link = VNET_LINK_IP4;           \
+       _link <= VNET_LINK_IP6;          \
+       _link++)
+
 /**
- * @brief Number of link types. Not part of the enum so it does not have to be included in
- * switch statements
+ * @brief Number of link types. Not part of the enum so it does not have to be
+ * included in switch statements
  */
 #define VNET_LINK_NUM (VNET_LINK_NSH+1)
+#define VNET_N_LINKS VNET_LINK_NUM
 
 /**
  * @brief Convert a link to to an Ethertype
@@ -956,8 +962,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);
 
-vlib_node_function_t *vnet_interface_output_node_get (vlib_main_t * vm);
-
 void vnet_register_format_buffer_opaque_helper
   (vnet_buffer_opquae_formatter_t fn);
 
@@ -982,6 +986,8 @@ typedef struct
 
 int vnet_pcap_dispatch_trace_configure (vnet_pcap_dispatch_trace_args_t *);
 
+extern vlib_node_registration_t vnet_interface_output_node;
+
 #endif /* included_vnet_interface_h */
 
 /*