Use thread local storage for thread index
[vpp.git] / src / vnet / map / ip4_map.c
index 1a20d70..e39b6f1 100644 (file)
@@ -248,7 +248,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
   next_index = node->cached_next_index;
   map_main_t *mm = &map_main;
   vlib_combined_counter_main_t *cm = mm->domain_counters;
-  u32 cpu_index = os_get_cpu_number ();
+  u32 thread_index = vlib_get_thread_index ();
 
   while (n_left_from > 0)
     {
@@ -377,7 +377,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
                                               ip40) ?
                    IP4_MAP_NEXT_IP6_REWRITE : next0;
                  vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
-                                                  cpu_index,
+                                                  thread_index,
                                                   map_domain_index0, 1,
                                                   clib_net_to_host_u16
                                                   (ip6h0->payload_length) +
@@ -409,7 +409,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
                                               ip41) ?
                    IP4_MAP_NEXT_IP6_REWRITE : next1;
                  vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
-                                                  cpu_index,
+                                                  thread_index,
                                                   map_domain_index1, 1,
                                                   clib_net_to_host_u16
                                                   (ip6h1->payload_length) +
@@ -520,7 +520,7 @@ ip4_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
                                               ip40) ?
                    IP4_MAP_NEXT_IP6_REWRITE : next0;
                  vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
-                                                  cpu_index,
+                                                  thread_index,
                                                   map_domain_index0, 1,
                                                   clib_net_to_host_u16
                                                   (ip6h0->payload_length) +
@@ -564,7 +564,7 @@ ip4_map_reass (vlib_main_t * vm,
   next_index = node->cached_next_index;
   map_main_t *mm = &map_main;
   vlib_combined_counter_main_t *cm = mm->domain_counters;
-  u32 cpu_index = os_get_cpu_number ();
+  u32 thread_index = vlib_get_thread_index ();
   u32 *fragments_to_drop = NULL;
   u32 *fragments_to_loopback = NULL;
 
@@ -694,8 +694,8 @@ ip4_map_reass (vlib_main_t * vm,
            {
              if (error0 == MAP_ERROR_NONE)
                vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
-                                                cpu_index, map_domain_index0,
-                                                1,
+                                                thread_index,
+                                                map_domain_index0, 1,
                                                 clib_net_to_host_u16
                                                 (ip60->payload_length) + 40);
              next0 =