l2: Add bridge_domain_add_del_v2 to l2 api
[vpp.git] / src / vnet / l2 / l2_bd.h
index 0e07065..082d210 100644 (file)
@@ -2,6 +2,7 @@
  * l2_bd.h : layer 2 bridge domain
  *
  * Copyright (c) 2013 Cisco and/or its affiliates.
+ * Copyright (c) 2022 Nordix Foundation.
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at:
 
 #include <vlib/vlib.h>
 #include <vnet/vnet.h>
+#include <vnet/ip/ip46_address.h>
+#include <vnet/ethernet/mac_address.h>
+
+typedef enum l2_bd_port_type_t_
+{
+  L2_BD_PORT_TYPE_NORMAL = 0,
+  L2_BD_PORT_TYPE_BVI = 1,
+  L2_BD_PORT_TYPE_UU_FWD = 2,
+} l2_bd_port_type_t;
 
 typedef struct
 {
@@ -53,16 +63,23 @@ typedef struct
 
 typedef struct
 {
-  u32 feature_bitmap;
   /*
    * Contains bit enables for flooding, learning, and forwarding.
    * All other feature bits should always be set.
-   *
+   */
+  u32 feature_bitmap;
+  /*
    * identity of the bridge-domain's BVI interface
    * set to ~0 if there is no BVI
    */
   u32 bvi_sw_if_index;
 
+  /*
+   * identity of the bridge-domain's UU flood interface
+   * set to ~0 if there is no such configuration
+   */
+  u32 uu_fwd_sw_if_index;
+
   /* bridge domain id, not to be confused with bd_index */
   u32 bd_id;
 
@@ -78,6 +95,9 @@ typedef struct
   /* Tunnels (Unicast vxlan) are flooded if there are no masters */
   u32 tun_normal_count;
 
+  /* Interface on which packets are not flooded */
+  u32 no_flood_count;
+
   /* hash ip4/ip6 -> mac for arp/nd termination */
   uword *mac_by_ip4;
   uword *mac_by_ip6;
@@ -88,6 +108,15 @@ typedef struct
   /* sequence number for bridge domain based flush of MACs */
   u8 seq_num;
 
+  /* Bridge domain tag (C string NULL terminated) */
+  u8 *bd_tag;
+
+  /* Maximum number of learned entries */
+  u32 learn_limit;
+
+  /* Current number of learned entries */
+  u32 learn_count;
+
 } l2_bridge_domain_t;
 
 /* Limit Bridge Domain ID to 24 bits to match 24-bit VNI range */
@@ -101,7 +130,9 @@ typedef struct
   u8 forward;
   u8 learn;
   u8 arp_term;
+  u8 arp_ufwd;
   u8 mac_age;
+  u8 *bd_tag;
   u8 is_add;
 } l2_bridge_domain_add_del_args_t;
 
@@ -115,23 +146,28 @@ bd_is_valid (l2_bridge_domain_t * bd_config)
 /* Init bridge domain if not done already */
 void bd_validate (l2_bridge_domain_t * bd_config);
 
-
 void
 bd_add_member (l2_bridge_domain_t * bd_config, l2_flood_member_t * member);
 
 u32 bd_remove_member (l2_bridge_domain_t * bd_config, u32 sw_if_index);
 
-
-#define L2_LEARN   (1<<0)
-#define L2_FWD     (1<<1)
-#define L2_FLOOD   (1<<2)
-#define L2_UU_FLOOD (1<<3)
-#define L2_ARP_TERM (1<<4)
-
-u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, u32 flags, u32 enable);
+typedef enum bd_flags_t_
+{
+  L2_NONE = 0,
+  L2_LEARN = (1 << 0),
+  L2_FWD = (1 << 1),
+  L2_FLOOD = (1 << 2),
+  L2_UU_FLOOD = (1 << 3),
+  L2_ARP_TERM = (1 << 4),
+  L2_ARP_UFWD = (1 << 5),
+} bd_flags_t;
+
+u32 bd_set_flags (vlib_main_t * vm, u32 bd_index, bd_flags_t flags,
+                 u32 enable);
 void bd_set_mac_age (vlib_main_t * vm, u32 bd_index, u8 age);
+void bd_set_learn_limit (vlib_main_t *vm, u32 bd_index, u32 learn_limit);
 int bd_add_del (l2_bridge_domain_add_del_args_t * args);
-
+u32 bd_get_unused_id (void);
 /**
  * \brief Get a bridge domain.
  *
@@ -172,8 +208,22 @@ bd_find_or_add_bd_index (bd_main_t * bdm, u32 bd_id)
   return bd_index;
 }
 
+/**
+ * \brief Walk all the input interfaces in the BD
+ */
+typedef walk_rc_t (*bd_input_walk_fn_t) (u32 bd_index, u32 sw_if_index);
+
+u32 bd_input_walk (u32 bd_index, bd_input_walk_fn_t fn, void *data);
+
+l2_bridge_domain_t *bd_get (u32 bd_index);
+l2_bridge_domain_t *bd_get_by_table_id (u32 table_id);
+
 u32 bd_add_del_ip_mac (u32 bd_index,
-                      u8 * ip_addr, u8 * mac_addr, u8 is_ip6, u8 is_add);
+                      ip46_type_t type,
+                      const ip46_address_t * ip_addr,
+                      const mac_address_t * mac, u8 is_add);
+
+void bd_flush_ip_mac (u32 bd_index);
 
 #endif