misc: deprecate gbp and its dependents
[vpp.git] / src / vnet / l2 / l2_input.h
index 4d6f1a3..7d1dc9c 100644 (file)
 #ifndef included_vnet_l2_input_h
 #define included_vnet_l2_input_h
 
+#include <stdbool.h>
+
 #include <vlib/vlib.h>
 #include <vnet/vnet.h>
 #include <vnet/l2/l2_bd.h>
+#include <vnet/ethernet/ethernet.h>
 #include <vnet/ethernet/packet.h>
-#include <vnet/ip/ip.h>
+#include <vnet/ip/ip4_inlines.h>
+#include <vnet/ip/ip6_inlines.h>
 
-/* Per-subinterface L2 feature configuration */
+/* l2 connection type */
+typedef enum l2_input_flags_t_
+{
+  /* NONE imples L3 mode. */
+  L2_INPUT_FLAG_NONE = 0,
+  L2_INPUT_FLAG_XCONNECT = (1 << 0),
+  L2_INPUT_FLAG_BRIDGE = (1 << 1),
+  L2_INPUT_FLAG_BVI = (1 << 2),
+} __clib_packed l2_input_flags_t;
 
+/* Per-subinterface L2 feature configuration */
 typedef struct
 {
+  u8 __force_u64_alignement[0] __attribute__ ((aligned (8)));
 
   union
   {
-    u16 bd_index;              /* bridge domain id */
-    u32 output_sw_if_index;    /* for xconnect */
+    /* bridge domain id and values cached from the BD */
+    struct
+    {
+      u16 bd_index;
+      u8 bd_seq_num;
+      u8 bd_mac_age;
+    };
+    /* for xconnect */
+    u32 output_sw_if_index;
   };
 
   /* config for which input features are configured on this interface */
   u32 feature_bitmap;
 
+  /* config for which input features are configured on this interface's
+   * BD - this is cahced from the BD struct*/
+  u32 bd_feature_bitmap;
+
   /* split horizon group */
   u8 shg;
 
-  /* Interface mode. If both are 0, this interface is in L3 mode */
-  u8 xconnect;
-  u8 bridge;
+  /* Interface sequence number */
+  u8 seq_num;
 
-  /* this is the bvi interface for the bridge-domain */
-  u8 bvi;
+  /* Flags describing this interface */
+  l2_input_flags_t flags;
 
+  /* A wee bit of spare space */
+  u8 __pad;
 } l2_input_config_t;
 
+/* Ensure a struct is an even multiple of 8 bytes,
+ * so they do not stradle cache lines */
+STATIC_ASSERT_SIZEOF (l2_input_config_t, 2 * sizeof (u64));
 
 typedef struct
 {
@@ -66,6 +95,8 @@ typedef struct
   /* convenience variables */
   vlib_main_t *vlib_main;
   vnet_main_t *vnet_main;
+
+  u16 msg_id_base;
 } l2input_main_t;
 
 extern l2input_main_t l2input_main;
@@ -102,21 +133,19 @@ l2input_bd_config (u32 bd_index)
  _(DROP,          "feature-bitmap-drop")        \
  _(XCONNECT,      "l2-output")                  \
  _(FLOOD,         "l2-flood")                   \
+ _(ARP_UFWD,      "l2-uu-fwd")                  \
  _(ARP_TERM,      "arp-term-l2bd")              \
  _(UU_FLOOD,      "l2-flood")                   \
  _(UU_FWD,        "l2-uu-fwd")                  \
- _(GBP_FWD,       "gbp-fwd")                    \
  _(FWD,           "l2-fwd")                     \
  _(RW,            "l2-rw")                      \
  _(LEARN,         "l2-learn")                   \
- _(L2_EMULATION,  "l2-emulation")               \
- _(GBP_NULL_CLASSIFY, "gbp-null-classify")      \
- _(GBP_SRC_CLASSIFY,  "gbp-src-classify")       \
  _(VTR,           "l2-input-vtr")               \
  _(L2_IP_QOS_RECORD, "l2-ip-qos-record")        \
  _(VPATH,         "vpath-input-l2")             \
  _(ACL,           "l2-input-acl")               \
  _(POLICER_CLAS,  "l2-policer-classify")       \
+ _(INPUT_FEAT_ARC, "l2-input-feat-arc")         \
  _(INPUT_CLASSIFY, "l2-input-classify")         \
  _(SPAN,          "span-l2-input")
 
@@ -134,6 +163,7 @@ STATIC_ASSERT (L2INPUT_N_FEAT <= 32, "too many l2 input features");
 /* Feature bit masks */
 typedef enum
 {
+  L2INPUT_FEAT_NONE = 0,
 #define _(sym,str) L2INPUT_FEAT_##sym = (1<<L2INPUT_FEAT_##sym##_BIT),
   foreach_l2input_feat
 #undef _
@@ -149,8 +179,10 @@ STATIC_ASSERT ((u64) L2INPUT_VALID_MASK == (1ull << L2INPUT_N_FEAT) - 1, "");
 /** Return an array of strings containing graph node names of each feature */
 char **l2input_get_feat_names (void);
 
-/* arg0 - u32 feature_bitmap */
+/* arg0 - u32 feature_bitmap, arg1 - u32 verbose */
+u8 *format_l2_input_feature_bitmap (u8 * s, va_list * args);
 u8 *format_l2_input_features (u8 * s, va_list * args);
+u8 *format_l2_input (u8 * s, va_list * args);
 
 static_always_inline u8
 bd_feature_flood (l2_bridge_domain_t * bd_config)
@@ -186,6 +218,42 @@ bd_feature_arp_term (l2_bridge_domain_t * bd_config)
          L2INPUT_FEAT_ARP_TERM);
 }
 
+static_always_inline u8
+bd_feature_arp_ufwd (l2_bridge_domain_t * bd_config)
+{
+  return ((bd_config->feature_bitmap & L2INPUT_FEAT_ARP_UFWD) ==
+         L2INPUT_FEAT_ARP_UFWD);
+}
+
+static inline bool
+l2_input_is_bridge (const l2_input_config_t * input)
+{
+  return (input->flags & L2_INPUT_FLAG_BRIDGE);
+}
+
+static inline bool
+l2_input_is_xconnect (const l2_input_config_t * input)
+{
+  return (input->flags & L2_INPUT_FLAG_XCONNECT);
+}
+
+static inline bool
+l2_input_is_bvi (const l2_input_config_t * input)
+{
+  return (input->flags & L2_INPUT_FLAG_BVI);
+}
+
+static_always_inline u8
+l2_input_seq_num (u32 sw_if_index)
+{
+  l2_input_config_t *input;
+
+  input = vec_elt_at_index (l2input_main.configs, sw_if_index);
+
+  return input->seq_num;
+}
+
+
 /** Masks for eliminating features that do not apply to a packet */
 
 /** Get a pointer to the config for the given interface */
@@ -193,7 +261,8 @@ l2_input_config_t *l2input_intf_config (u32 sw_if_index);
 
 /* Enable (or disable) the feature in the bitmap for the given interface */
 u32 l2input_intf_bitmap_enable (u32 sw_if_index,
-                               u32 feature_bitmap, u32 enable);
+                               l2input_feat_masks_t feature_bitmap,
+                               u32 enable);
 
 /* Sets modifies flags from a bridge domain */
 u32 l2input_set_bridge_features (u32 bd_index, u32 feat_mask, u32 feat_value);
@@ -202,6 +271,9 @@ void l2input_interface_mac_change (u32 sw_if_index,
                                   const u8 * old_address,
                                   const u8 * new_address);
 
+void l2_input_seq_num_inc (u32 sw_if_index);
+walk_rc_t l2input_recache (u32 bd_index, u32 sw_if_index);
+
 #define MODE_L3        0
 #define MODE_L2_BRIDGE 1
 #define MODE_L2_XC     2
@@ -217,8 +289,8 @@ u32 set_int_l2_mode (vlib_main_t * vm,
                     u32 bd_index, l2_bd_port_type_t port_type,
                     u32 shg, u32 xc_sw_if_index);
 
-static inline void
-vnet_update_l2_len (vlib_buffer_t * b)
+static inline u16
+vnet_update_l2_len (vlib_buffer_t *b)
 {
   ethernet_header_t *eth;
   u16 ethertype;
@@ -249,6 +321,8 @@ vnet_update_l2_len (vlib_buffer_t * b)
        }
     }
   ethernet_buffer_set_vlan_count (b, vlan_count);
+
+  return (ethertype);
 }
 
 /*