classify: Layout classify entry to group data-plane accessed fields on
[vpp.git] / src / vnet / classify / ip_classify.c
index 1a8e1dd..5a5cfed 100644 (file)
@@ -37,9 +37,6 @@ format_ip_classify_trace (u8 * s, va_list * args)
   return s;
 }
 
-vlib_node_registration_t ip4_classify_node;
-vlib_node_registration_t ip6_classify_node;
-
 #define foreach_ip_classify_error               \
 _(MISS, "Classify misses")                      \
 _(HIT, "Classify hits")                         \
@@ -112,13 +109,11 @@ ip_classify_inline (vlib_main_t * vm,
 
       bi0 = from[0];
       b0 = vlib_get_buffer (vm, bi0);
-      h0 = (void *) vlib_buffer_get_current (b0) -
-       ethernet_buffer_header_size (b0);
+      h0 = vlib_buffer_get_current (b0) - ethernet_buffer_header_size (b0);
 
       bi1 = from[1];
       b1 = vlib_get_buffer (vm, bi1);
-      h1 = (void *) vlib_buffer_get_current (b1) -
-       ethernet_buffer_header_size (b1);
+      h1 = vlib_buffer_get_current (b1) - ethernet_buffer_header_size (b1);
 
       cd_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
       cd0 = classify_dpo_get (cd_index0);
@@ -132,13 +127,11 @@ ip_classify_inline (vlib_main_t * vm,
 
       t1 = pool_elt_at_index (vcm->tables, table_index1);
 
-      vnet_buffer (b0)->l2_classify.hash =
-       vnet_classify_hash_packet (t0, (u8 *) h0);
+      vnet_buffer (b0)->l2_classify.hash = vnet_classify_hash_packet (t0, h0);
 
       vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash);
 
-      vnet_buffer (b1)->l2_classify.hash =
-       vnet_classify_hash_packet (t1, (u8 *) h1);
+      vnet_buffer (b1)->l2_classify.hash = vnet_classify_hash_packet (t1, h1);
 
       vnet_classify_prefetch_bucket (t1, vnet_buffer (b1)->l2_classify.hash);
 
@@ -162,16 +155,14 @@ ip_classify_inline (vlib_main_t * vm,
 
       bi0 = from[0];
       b0 = vlib_get_buffer (vm, bi0);
-      h0 = (void *) vlib_buffer_get_current (b0) -
-       ethernet_buffer_header_size (b0);
+      h0 = vlib_buffer_get_current (b0) - ethernet_buffer_header_size (b0);
 
       cd_index0 = vnet_buffer (b0)->ip.adj_index[VLIB_TX];
       cd0 = classify_dpo_get (cd_index0);
       table_index0 = cd0->cd_table_index;
 
       t0 = pool_elt_at_index (vcm->tables, table_index0);
-      vnet_buffer (b0)->l2_classify.hash =
-       vnet_classify_hash_packet (t0, (u8 *) h0);
+      vnet_buffer (b0)->l2_classify.hash = vnet_classify_hash_packet (t0, h0);
 
       vnet_buffer (b0)->l2_classify.table_index = table_index0;
       vnet_classify_prefetch_bucket (t0, vnet_buffer (b0)->l2_classify.hash);
@@ -240,7 +231,7 @@ ip_classify_inline (vlib_main_t * vm,
              hash0 = vnet_buffer (b0)->l2_classify.hash;
              t0 = pool_elt_at_index (vcm->tables, table_index0);
 
-             e0 = vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
+             e0 = vnet_classify_find_entry (t0, h0, hash0, now);
              if (e0)
                {
                  vnet_buffer (b0)->l2_classify.opaque_index
@@ -265,9 +256,8 @@ ip_classify_inline (vlib_main_t * vm,
                          break;
                        }
 
-                     hash0 = vnet_classify_hash_packet (t0, (u8 *) h0);
-                     e0 = vnet_classify_find_entry
-                       (t0, (u8 *) h0, hash0, now);
+                     hash0 = vnet_classify_hash_packet (t0, h0);
+                     e0 = vnet_classify_find_entry (t0, h0, hash0, now);
                      if (e0)
                        {
                          vnet_buffer (b0)->l2_classify.opaque_index
@@ -290,7 +280,7 @@ ip_classify_inline (vlib_main_t * vm,
                vlib_add_trace (vm, node, b0, sizeof (*t));
              t->next_index = next0;
              t->table_index = t0 ? t0 - vcm->tables : ~0;
-             t->entry_index = e0 ? e0 - t0->entries : ~0;
+             t->entry_index = e0 ? e0->opaque_index : ~0;
            }
 
          /* verify speculative enqueue, maybe switch current next frame */
@@ -311,9 +301,9 @@ ip_classify_inline (vlib_main_t * vm,
   return frame->n_vectors;
 }
 
-static uword
-ip4_classify (vlib_main_t * vm,
-             vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip4_classify_node) (vlib_main_t * vm,
+                                 vlib_node_runtime_t * node,
+                                 vlib_frame_t * frame)
 {
   return ip_classify_inline (vm, node, frame, 1 /* is_ip4 */ );
 }
@@ -321,7 +311,6 @@ ip4_classify (vlib_main_t * vm,
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip4_classify_node) = {
-  .function = ip4_classify,
   .name = "ip4-classify",
   .vector_size = sizeof (u32),
   .sibling_of = "ip4-lookup",
@@ -333,10 +322,9 @@ VLIB_REGISTER_NODE (ip4_classify_node) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_classify_node, ip4_classify)
-     static uword
-       ip6_classify (vlib_main_t * vm,
-                    vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip6_classify_node) (vlib_main_t * vm,
+                                 vlib_node_runtime_t * node,
+                                 vlib_frame_t * frame)
 {
   return ip_classify_inline (vm, node, frame, 0 /* is_ip4 */ );
 }
@@ -344,7 +332,6 @@ VLIB_NODE_FUNCTION_MULTIARCH (ip4_classify_node, ip4_classify)
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip6_classify_node) = {
-  .function = ip6_classify,
   .name = "ip6-classify",
   .vector_size = sizeof (u32),
   .sibling_of = "ip6-lookup",
@@ -356,13 +343,15 @@ VLIB_REGISTER_NODE (ip6_classify_node) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_classify_node, ip6_classify)
-     static clib_error_t *ip_classify_init (vlib_main_t * vm)
+#ifndef CLIB_MARCH_VARIANT
+static clib_error_t *
+ip_classify_init (vlib_main_t * vm)
 {
   return 0;
 }
 
 VLIB_INIT_FUNCTION (ip_classify_init);
+#endif /* CLIB_MARCH_VARIANT */
 
 /*
  * fd.io coding-style-patch-verification: ON