interface: fix rx-placement api/cli for new infra
[vpp.git] / src / vnet / ethernet / ethernet.h
index 821a576..a83b0f3 100644 (file)
@@ -132,20 +132,38 @@ typedef u32 (ethernet_flag_change_function_t)
 #define ETHERNET_MIN_PACKET_BYTES  64
 #define ETHERNET_MAX_PACKET_BYTES  9216
 
+/* ethernet dataplane loads mac address as u64 for efficiency */
+typedef union ethernet_interface_address
+{
+  struct
+  {
+    mac_address_t mac;
+    u16 zero;
+  };
+  u64 as_u64;
+} ethernet_interface_address_t;
+
 /* Ethernet interface instance. */
 typedef struct ethernet_interface
 {
   u32 flags;
 
-  /* Accept all packets (promiscuous mode). */
-#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL (1 << 0)
-#define ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC(flags) \
-  (((flags) & ~ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) == 0)
+  /* Top 16 bits for status and bottom 16 bits for set operation */
+#define ETHERNET_INTERFACE_FLAGS_STATUS_MASK  (0xffff0000)
+#define ETHERNET_INTERFACE_FLAGS_SET_OPN_MASK (0x0000ffff)
+
+  /* Interface driver/hw is in L3/non-promiscuous mode so packet DMAC
+     would already be filtered */
+#define ETHERNET_INTERFACE_FLAG_STATUS_L3 (1 << 16)
+
+  /* Set interface to default L3 mode */
+#define ETHERNET_INTERFACE_FLAG_DEFAULT_L3 0
+
+  /* Set interface to accept all packets (promiscuous mode). */
+#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL 1
 
   /* Change MTU on interface from hw interface structure */
-#define ETHERNET_INTERFACE_FLAG_MTU (1 << 1)
-#define ETHERNET_INTERFACE_FLAG_CONFIG_MTU(flags) \
-  ((flags) & ETHERNET_INTERFACE_FLAG_MTU)
+#define ETHERNET_INTERFACE_FLAG_MTU        2
 
   /* Callback, e.g. to turn on/off promiscuous mode */
   ethernet_flag_change_function_t *flag_change;
@@ -153,10 +171,10 @@ typedef struct ethernet_interface
   u32 driver_instance;
 
   /* Ethernet (MAC) address for this interface. */
-  u8 address[6];
+  ethernet_interface_address_t address;
 
   /* Secondary MAC addresses for this interface */
-  mac_address_t *secondary_addrs;
+  ethernet_interface_address_t *secondary_addrs;
 } ethernet_interface_t;
 
 extern vnet_hw_interface_class_t ethernet_hw_interface_class;
@@ -257,7 +275,18 @@ typedef struct
   u32 input_next_mpls;
 } next_by_ethertype_t;
 
+struct ethernet_main_t_;
+
+typedef void (ethernet_address_change_function_t)
+  (struct ethernet_main_t_ * im, u32 sw_if_index, uword opaque);
+
 typedef struct
+{
+  ethernet_address_change_function_t *function;
+  uword function_opaque;
+} ethernet_address_change_ctx_t;
+
+typedef struct ethernet_main_t_
 {
   vlib_main_t *vlib_main;
 
@@ -300,6 +329,13 @@ typedef struct
 
   /* Allocated loopback instances */
   uword *bm_loopback_instances;
+
+  /** Functions to call when interface hw address changes. */
+  ethernet_address_change_ctx_t *address_change_callbacks;
+
+  /** Default interface MTU */
+  u32 default_mtu;
+
 } ethernet_main_t;
 
 extern ethernet_main_t ethernet_main;
@@ -445,6 +481,9 @@ clib_error_t *next_by_ethertype_register (next_by_ethertype_t * l3_next,
 int vnet_create_loopback_interface (u32 * sw_if_indexp, u8 * mac_address,
                                    u8 is_specified, u32 user_instance);
 int vnet_delete_loopback_interface (u32 sw_if_index);
+int vnet_create_sub_interface (u32 sw_if_index, u32 id,
+                              u32 flags, u16 inner_vlan_id,
+                              u16 outer_vlan_id, u32 * sub_sw_if_index);
 int vnet_delete_sub_interface (u32 sw_if_index);
 
 // Perform ethernet subinterface classification table lookups given
@@ -549,8 +588,6 @@ void ethernet_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai);
 u8 *ethernet_build_rewrite (vnet_main_t * vnm,
                            u32 sw_if_index,
                            vnet_link_t link_type, const void *dst_address);
-const u8 *ethernet_ip4_mcast_dst_addr (void);
-const u8 *ethernet_ip6_mcast_dst_addr (void);
 void ethernet_input_init (vlib_main_t * vm, ethernet_main_t * em);
 
 extern vlib_node_registration_t ethernet_input_node;