ip: Move the IP6 fib into ip6_[m]fib.c
[vpp.git] / src / vnet / mfib / ip6_mfib.h
index d91af46..67a821c 100644 (file)
 #ifndef __IP6_MFIB_H__
 #define __IP6_MFIB_H__
 
+#include <vppinfra/bihash_40_8.h>
+#include <vppinfra/bihash_template.h>
+
 #include <vlib/vlib.h>
 #include <vnet/ip/ip.h>
 
 #include <vnet/mfib/mfib_table.h>
 
+/*
+ * Default size of the ip6 fib hash table
+ */
+#define IP6_MFIB_DEFAULT_HASH_NUM_BUCKETS (64 * 1024)
+#define IP6_MFIB_DEFAULT_HASH_MEMORY_SIZE (32<<20)
+
+
+/**
+ * A representation of a single IP6 mfib table
+ */
+typedef struct ip6_mfib_table_instance_t_
+{
+  /* The hash table */
+  clib_bihash_40_8_t ip6_mhash;
+
+  /* bitmap / refcounts / vector of mask widths to search */
+  uword *non_empty_dst_address_length_bitmap;
+  u16 *prefix_lengths_in_search_order;
+  i32 dst_address_length_refcounts[257];
+} ip6_mfib_table_instance_t;
+
+/**
+ * the single MFIB table
+ */
+extern ip6_mfib_table_instance_t ip6_mfib_table;
+
 extern fib_node_index_t ip6_mfib_table_lookup(const ip6_mfib_t *fib,
                                               const ip6_address_t *src,
                                               const ip6_address_t *grp,
                                               u32 len);
+extern fib_node_index_t ip6_mfib_table_fwd_lookup(const ip6_mfib_t *fib,
+                                                  const ip6_address_t *src,
+                                                  const ip6_address_t *grp);
 extern fib_node_index_t ip6_mfib_table_lookup_exact_match(const ip6_mfib_t *fib,
                                                           const ip6_address_t *grp,
                                                           const ip6_address_t *src,
                                                           u32 len);
+extern fib_node_index_t ip6_mfib_table_get_less_specific (const ip6_mfib_t *mfib,
+                                                          const ip6_address_t *src,
+                                                          const ip6_address_t *grp,
+                                                          u32 len);
 
 extern void ip6_mfib_table_entry_remove(ip6_mfib_t *fib,
                                         const ip6_address_t *grp,
@@ -79,8 +115,9 @@ ip6_mfib_get (u32 index)
  * @returns A pointer to the retrieved or created fib.
  *
  */
-extern u32 ip6_mfib_table_find_or_create_and_lock(u32 table_id);
-extern u32 ip6_mfib_table_create_and_lock(void);
+extern u32 ip6_mfib_table_find_or_create_and_lock(u32 table_id,
+                                                  mfib_source_t src);
+extern u32 ip6_mfib_table_create_and_lock(mfib_source_t src);
 
 
 static inline
@@ -105,5 +142,21 @@ extern fib_node_index_t ip6_mfib_table_lookup2(const ip6_mfib_t *mfib,
                                                const ip6_address_t *src,
                                                const ip6_address_t *grp);
 
+/**
+ * @brief Walk the IP6 mfib table.
+ *
+ * @param mfib the table to walk
+ * @param fn The function to invoke on each entry visited
+ * @param ctx A context passed in the visit function
+ */
+extern void ip6_mfib_table_walk (ip6_mfib_t *mfib,
+                                 mfib_table_walk_fn_t fn,
+                                 void *ctx);
+
+/**
+ * @brief format (display) ipv6 MFIB mempry usage
+ */
+extern u8 *format_ip6_mfib_table_memory(u8 * s, va_list * args);
+
 #endif