classify: use 32 bits hash
[vpp.git] / src / vnet / classify / flow_classify_node.c
index 5941b6d..c0a2999 100644 (file)
@@ -97,9 +97,9 @@ flow_classify_inline (vlib_main_t * vm,
        p2 = vlib_get_buffer (vm, from[2]);
 
        vlib_prefetch_buffer_header (p1, STORE);
-       CLIB_PREFETCH (p1->data, CLIB_CACHE_LINE_BYTES, STORE);
+       clib_prefetch_store (p1->data);
        vlib_prefetch_buffer_header (p2, STORE);
-       CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
+       clib_prefetch_store (p2->data);
       }
 
       bi0 = from[0];
@@ -122,13 +122,11 @@ flow_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);
 
@@ -158,8 +156,7 @@ flow_classify_inline (vlib_main_t * vm,
        fcm->classify_table_index_by_sw_if_index[tid][sw_if_index0];
 
       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);
@@ -187,7 +184,7 @@ flow_classify_inline (vlib_main_t * vm,
          u32 table_index0;
          vnet_classify_table_t *t0;
          vnet_classify_entry_t *e0;
-         u64 hash0;
+         u32 hash0;
          u8 *h0;
 
          /* Stride 3 seems to work best */
@@ -196,7 +193,7 @@ flow_classify_inline (vlib_main_t * vm,
              vlib_buffer_t *p1 = vlib_get_buffer (vm, from[3]);
              vnet_classify_table_t *tp1;
              u32 table_index1;
-             u64 phash1;
+             u32 phash1;
 
              table_index1 = vnet_buffer (p1)->l2_classify.table_index;
 
@@ -230,7 +227,7 @@ flow_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)
                {
                  hits++;
@@ -241,7 +238,7 @@ flow_classify_inline (vlib_main_t * vm,
                  vnet_classify_add_del_session (vcm, table_index0,
                                                 h0, ~0, 0, 0, 0, 0, 1);
                  /* increment counter */
-                 vnet_classify_find_entry (t0, (u8 *) h0, hash0, now);
+                 vnet_classify_find_entry (t0, h0, hash0, now);
                }
            }
          if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
@@ -275,16 +272,15 @@ flow_classify_inline (vlib_main_t * vm,
   return frame->n_vectors;
 }
 
-static uword
-ip4_flow_classify (vlib_main_t * vm,
-                  vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip4_flow_classify_node) (vlib_main_t * vm,
+                                      vlib_node_runtime_t * node,
+                                      vlib_frame_t * frame)
 {
   return flow_classify_inline (vm, node, frame, FLOW_CLASSIFY_TABLE_IP4);
 }
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip4_flow_classify_node) = {
-  .function = ip4_flow_classify,
   .name = "ip4-flow-classify",
   .vector_size = sizeof (u32),
   .format_trace = format_flow_classify_trace,
@@ -297,18 +293,15 @@ VLIB_REGISTER_NODE (ip4_flow_classify_node) = {
 };
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip4_flow_classify_node, ip4_flow_classify);
-
-static uword
-ip6_flow_classify (vlib_main_t * vm,
-                  vlib_node_runtime_t * node, vlib_frame_t * frame)
+VLIB_NODE_FN (ip6_flow_classify_node) (vlib_main_t * vm,
+                                      vlib_node_runtime_t * node,
+                                      vlib_frame_t * frame)
 {
   return flow_classify_inline (vm, node, frame, FLOW_CLASSIFY_TABLE_IP6);
 }
 
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (ip6_flow_classify_node) = {
-  .function = ip6_flow_classify,
   .name = "ip6-flow-classify",
   .vector_size = sizeof (u32),
   .format_trace = format_flow_classify_trace,
@@ -322,8 +315,6 @@ VLIB_REGISTER_NODE (ip6_flow_classify_node) = {
 
 /* *INDENT-ON* */
 
-VLIB_NODE_FUNCTION_MULTIARCH (ip6_flow_classify_node, ip6_flow_classify);
-
 
 static clib_error_t *
 flow_classify_init (vlib_main_t * vm)