fib: fib api updates
[vpp.git] / src / vnet / bier / bier_fmask.h
index d5ff459..87845bb 100644 (file)
  * egress towards the next-hop. As such the fmask is part of the rewrite
  * (adj) for that next-hop. It it thus an extension of the next-hop and in
  * no way associated with the bit-position(s) that are reachable through it.
- * Fmasks are thus shared by bit-positions that egress throught the same
+ * Fmasks are thus shared by bit-positions that egress through the same
  * nh (BFR-NBR).
- * Deag fmasks are also shread in the event that a router has local
- * bit-positions. This is necessary to prevent the router recieving two copies
+ * Deag fmasks are also shared in the event that a router has local
+ * bit-positions. This is necessary to prevent the router receiving two copies
  * of each packet. Consequently it also means that they share the same
  * disposition data for the global data.
  */
@@ -54,7 +54,7 @@ typedef struct bier_fmask_bits_t_ {
      * The total number of references to bits set on this mask
      * in effect a count of the number of children.
      */
-    uint32_t bfmb_count;
+    u32 bfmb_count;
 } bier_fmask_bits_t;
 
 /**
@@ -65,12 +65,14 @@ typedef enum bier_fmask_attributes_t_
     BIER_FMASK_ATTR_FIRST,
     BIER_FMASK_ATTR_FORWARDING = BIER_FMASK_ATTR_FIRST,
     BIER_FMASK_ATTR_DISP,
+    BIER_FMASK_ATTR_MPLS,
     BIER_FMASK_ATTR_LAST = BIER_FMASK_ATTR_DISP,
 } bier_fmask_attributes_t;
 
 #define BIER_FMASK_ATTR_NAMES {                         \
      [BIER_FMASK_ATTR_FORWARDING] = "forwarding",       \
      [BIER_FMASK_ATTR_DISP] = "disposition",            \
+     [BIER_FMASK_ATTR_MPLS] = "mpls",                   \
 }
 
 #define FOR_EACH_BIER_FMASK_ATTR(_item)          \
@@ -82,6 +84,7 @@ typedef enum bier_fmask_flags_t_
 {
     BIER_FMASK_FLAG_FORWARDING = (1 << BIER_FMASK_ATTR_FORWARDING),
     BIER_FMASK_FLAG_DISP = (1 << BIER_FMASK_ATTR_DISP),
+    BIER_FMASK_FLAG_MPLS = (1 << BIER_FMASK_ATTR_MPLS),
 } bier_fmask_flags_t;
 
 /**
@@ -94,6 +97,11 @@ typedef enum bier_fmask_flags_t_
  *      for the next lookup
  */
 typedef struct bier_fmask_t_ {
+    /**
+     * Required for pool_get_aligned
+     */
+    CLIB_CACHE_LINE_ALIGN_MARK(cacheline0);
+
     /**
      * The BIER fmask is a child of a FIB entry in the FIB graph.
      */
@@ -110,47 +118,20 @@ typedef struct bier_fmask_t_ {
      */
     bier_fmask_bits_t bfm_bits;
 
-    struct
-    {
-        /**
-         * The key to this fmask - used for store/lookup in the DB
-         */
-        bier_fmask_id_t bfm_id;
-
-        /**
-         * The BIER Table this Fmask is used in
-         */
-        index_t bfm_fib_index;
-    };
-
-    union
-    {
-        /**
-         * For forwarding via a next-hop
-         */
-        struct
-        {
-            /**
-             * The parent fib entry
-             */
-            fib_node_index_t bfm_fei;
-            /**
-             * The MPLS label to paint on the header during forwarding
-             */
-            mpls_label_t bfm_label;
-        };
-
-        /**
-         * For disposition
-         */
-        struct
-        {
-            /**
-             * The parent disposition table object
-             */
-            index_t bfm_disp;
-        };
-    };
+    /**
+     * The key to this fmask - used for store/lookup in the DB
+     */
+    bier_fmask_id_t *bfm_id;
+
+    /**
+     * The MPLS label to paint on the header during forwarding
+     */
+    mpls_label_t bfm_label;
+
+    /**
+     * The path-list
+     */
+    fib_node_index_t bfm_pl;
 
     /**
      * the index of this fmask in the parent's child list.
@@ -170,7 +151,6 @@ extern void bier_fmask_unlock(index_t bfmi);
 extern void bier_fmask_lock(index_t bfmi);
 
 extern index_t bier_fmask_create_and_lock(const bier_fmask_id_t *fmid,
-                                          index_t bti,
                                           const fib_route_path_t *rpath);
 
 extern u8* format_bier_fmask(u8 *s, va_list *ap);
@@ -183,11 +163,15 @@ extern u32 bier_fmask_child_add (fib_node_index_t fib_entry_index,
                                  fib_node_index_t child_index);
 extern void bier_fmask_child_remove (fib_node_index_t fib_entry_index,
                                      u32 sibling_index);
+extern void bier_fmask_get_stats (index_t bfmi, u64 * packets, u64 * bytes);
+extern void bier_fmask_encode (index_t bfmi,
+                               bier_table_id_t *btid,
+                               fib_route_path_t *rpath);
 
 /*
  * provided for fast data-path access
  */
-bier_fmask_t *bier_fmask_pool;
+extern bier_fmask_t *bier_fmask_pool;
 
 static inline bier_fmask_t *
 bier_fmask_get (u32 index)