fib: DPO layout add u64 parameter. 49/30149/2
authorNeale Ranns <neale.ranns@cisco.com>
Thu, 26 Nov 2020 09:41:01 +0000 (09:41 +0000)
committerBeno�t Ganne <bganne@cisco.com>
Thu, 26 Nov 2020 13:12:27 +0000 (13:12 +0000)
Type: improvement

Signed-off-by: Neale Ranns <neale.ranns@cisco.com>
Change-Id: Iee04af801814b6360b045cf7dc8bcad6f517229e

src/vnet/dpo/dpo.c
src/vnet/dpo/dpo.h

index d5865d1..1331b55 100644 (file)
@@ -262,13 +262,15 @@ void
 dpo_copy (dpo_id_t *dst,
          const dpo_id_t *src)
 {
-    dpo_id_t tmp = *dst;
+    dpo_id_t tmp = {
+        .as_u64 = dst->as_u64
+    };
 
     /*
      * the destination is written in a single u64 write - hence atomically w.r.t
      * any packets inflight.
      */
-    *((u64*)dst) = *(u64*)src;
+    dst->as_u64 = src->as_u64;
 
     dpo_lock(dst);
     dpo_unlock(&tmp);
@@ -279,6 +281,9 @@ dpo_is_adj (const dpo_id_t *dpo)
 {
     return ((dpo->dpoi_type == DPO_ADJACENCY) ||
            (dpo->dpoi_type == DPO_ADJACENCY_INCOMPLETE) ||
+            (dpo->dpoi_type == DPO_ADJACENCY_GLEAN) ||
+            (dpo->dpoi_type == DPO_ADJACENCY_MCAST) ||
+            (dpo->dpoi_type == DPO_ADJACENCY_MCAST_MIDCHAIN) ||
            (dpo->dpoi_type == DPO_ADJACENCY_MIDCHAIN) ||
            (dpo->dpoi_type == DPO_ADJACENCY_GLEAN));
 }
index e5a9bdc..ee4990d 100644 (file)
@@ -168,23 +168,28 @@ typedef enum dpo_type_t_ {
  * instance number/index of objects of that type
  */
 typedef struct dpo_id_t_ {
-    /**
-     * the type
-     */
-    dpo_type_t dpoi_type;
-    /**
-     * the data-path protocol of the type.
-     */
-    dpo_proto_t dpoi_proto;
-    /**
-     * The next VLIB node to follow.
-     */
-    u16 dpoi_next_node;
-    /**
-     * the index of objects of that type
-     */
-    index_t dpoi_index;
-} __attribute__ ((aligned(sizeof(u64)))) dpo_id_t;
+    union {
+        struct {
+            /**
+             * the type
+             */
+            dpo_type_t dpoi_type;
+            /**
+             * the data-path protocol of the type.
+             */
+            dpo_proto_t dpoi_proto;
+            /**
+             * The next VLIB node to follow.
+             */
+            u16 dpoi_next_node;
+            /**
+             * the index of objects of that type
+             */
+            index_t dpoi_index;
+        };
+        u64 as_u64;
+    };
+} dpo_id_t;
 
 STATIC_ASSERT(sizeof(dpo_id_t) <= sizeof(u64),
              "DPO ID is greater than sizeof u64 "