L2 BVI/FIB: Update L2 FIB table when BVI's MAC changes
[vpp.git] / src / vnet / interface.h
index f82cf9d..30023eb 100644 (file)
@@ -69,7 +69,8 @@ typedef clib_error_t *(vnet_subif_add_del_function_t)
 
 /* Interface set mac address callback. */
 typedef clib_error_t *(vnet_interface_set_mac_address_function_t)
-  (struct vnet_hw_interface_t * hi, char *address);
+  (struct vnet_hw_interface_t * hi,
+   const u8 * old_address, const u8 * new_address);
 
 /* Interface set rx mode callback. */
 typedef clib_error_t *(vnet_interface_set_rx_mode_function_t)
@@ -108,6 +109,7 @@ typedef struct _vnet_interface_function_list_elt
   clib_error_t *(*fp) (struct vnet_main_t * vnm, u32 if_index, u32 flags);
 } _vnet_interface_function_list_elt_t;
 
+#ifndef CLIB_MARCH_VARIANT
 #define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p)                    \
                                                                         \
 static void __vnet_interface_function_init_##tag##_##f (void)           \
@@ -146,6 +148,12 @@ static void __vnet_interface_function_deinit_##tag##_##f (void)         \
       next = next->next_interface_function;                             \
     }                                                                   \
 }
+#else
+/* create unused pointer to silence compiler warnings and get whole
+   function optimized out */
+#define _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,p)                    \
+static __clib_unused void * __clib_unused_##f = f;
+#endif
 
 #define _VNET_INTERFACE_FUNCTION_DECL(f,tag)                            \
   _VNET_INTERFACE_FUNCTION_DECL_PRIO(f,tag,VNET_ITF_FUNC_PRIORITY_LOW)
@@ -195,6 +203,9 @@ typedef struct _vnet_device_class
   /* Transmit function. */
   vlib_node_function_t *tx_function;
 
+  /* Transmit function candidate registration with priority */
+  vlib_node_fn_registration_t *tx_fn_registrations;
+
   /* Error strings indexed by error code for this node. */
   char **tx_function_error_strings;
 
@@ -245,6 +256,7 @@ typedef struct _vnet_device_class
   vnet_interface_set_mac_address_function_t *mac_addr_change_function;
 } vnet_device_class_t;
 
+#ifndef CLIB_MARCH_VARIANT
 #define VNET_DEVICE_CLASS(x,...)                                        \
   __VA_ARGS__ vnet_device_class_t x;                                    \
 static void __vnet_add_device_class_registration_##x (void)             \
@@ -264,6 +276,30 @@ static void __vnet_rm_device_class_registration_##x (void)              \
                                   &x, next_class_registration);         \
 }                                                                       \
 __VA_ARGS__ vnet_device_class_t x
+#else
+/* create unused pointer to silence compiler warnings and get whole
+   function optimized out */
+#define VNET_DEVICE_CLASS(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->next_registration = devclass.tx_fn_registrations;                 \
+  devclass.tx_fn_registrations = r;                                    \
+}                                                                      \
+uword CLIB_CPU_OPTIMIZED CLIB_MARCH_SFX (devclass##_tx_fn)
 
 #define VLIB_DEVICE_TX_FUNCTION_CLONE_TEMPLATE(arch, fn, tgt)          \
   uword                                                                        \
@@ -648,32 +684,40 @@ typedef enum
 
 extern vnet_mtu_t vnet_link_to_mtu (vnet_link_t link);
 
-/* Software-interface.  This corresponds to a Ethernet VLAN, ATM vc, a
-   tunnel, etc.  Configuration (e.g. IP address) gets attached to
-   software interface. */
-typedef struct
+typedef enum vnet_sw_interface_flags_t_
 {
-  vnet_sw_interface_type_t type:16;
-
-  u16 flags;
   /* Interface is "up" meaning adminstratively up.
      Up in the sense of link state being up is maintained by hardware interface. */
-#define VNET_SW_INTERFACE_FLAG_ADMIN_UP (1 << 0)
+  VNET_SW_INTERFACE_FLAG_ADMIN_UP = (1 << 0),
 
   /* Interface is disabled for forwarding: punt all traffic to slow-path. */
-#define VNET_SW_INTERFACE_FLAG_PUNT (1 << 1)
+  VNET_SW_INTERFACE_FLAG_PUNT = (1 << 1),
 
-#define VNET_SW_INTERFACE_FLAG_PROXY_ARP (1 << 2)
+  VNET_SW_INTERFACE_FLAG_PROXY_ARP = (1 << 2),
 
-#define VNET_SW_INTERFACE_FLAG_UNNUMBERED (1 << 3)
+  VNET_SW_INTERFACE_FLAG_UNNUMBERED = (1 << 3),
 
-#define VNET_SW_INTERFACE_FLAG_BOND_SLAVE (1 << 4)
+  VNET_SW_INTERFACE_FLAG_BOND_SLAVE = (1 << 4),
 
   /* Interface does not appear in CLI/API */
-#define VNET_SW_INTERFACE_FLAG_HIDDEN (1 << 5)
+  VNET_SW_INTERFACE_FLAG_HIDDEN = (1 << 5),
 
   /* Interface in ERROR state */
-#define VNET_SW_INTERFACE_FLAG_ERROR (1 << 6)
+  VNET_SW_INTERFACE_FLAG_ERROR = (1 << 6),
+
+  /* Interface has IP configured directed broadcast */
+  VNET_SW_INTERFACE_FLAG_DIRECTED_BCAST = (1 << 7),
+
+} __attribute__ ((packed)) vnet_sw_interface_flags_t;
+
+/* Software-interface.  This corresponds to a Ethernet VLAN, ATM vc, a
+   tunnel, etc.  Configuration (e.g. IP address) gets attached to
+   software interface. */
+typedef struct
+{
+  vnet_sw_interface_type_t type:16;
+
+  vnet_sw_interface_flags_t flags;
 
   /* Index for this interface. */
   u32 sw_if_index;