avoid using thread local storage for thread index 20/13420/3
authorDamjan Marion <damarion@cisco.com>
Wed, 11 Jul 2018 10:47:43 +0000 (12:47 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 11 Jul 2018 15:13:41 +0000 (15:13 +0000)
It is cheaper to get thread index from vlib_main_t if available...

Change-Id: I4582e160d06d9d7fccdc54271912f0635da79b50
Signed-off-by: Damjan Marion <damarion@cisco.com>
57 files changed:
src/plugins/avf/output.c
src/plugins/lb/node.c
src/plugins/map/ip4_map.c
src/plugins/map/ip4_map_t.c
src/plugins/map/ip6_map.c
src/plugins/map/ip6_map_t.c
src/plugins/marvell/pp2/input.c
src/plugins/marvell/pp2/output.c
src/plugins/memif/device.c
src/plugins/memif/node.c
src/plugins/nat/dslite_in2out.c
src/plugins/nat/dslite_out2in.c
src/plugins/nat/in2out.c
src/plugins/nat/nat64.c
src/plugins/nat/nat64_in2out.c
src/plugins/nat/nat64_out2in.c
src/plugins/nat/nat66_in2out.c
src/plugins/nat/nat66_out2in.c
src/plugins/nat/out2in.c
src/plugins/srv6-ad/node.c
src/plugins/srv6-am/node.c
src/vnet/bier/bier_output.c
src/vnet/bonding/device.c
src/vnet/bonding/node.c
src/vnet/devices/af_packet/node.c
src/vnet/devices/netmap/node.c
src/vnet/devices/virtio/node.c
src/vnet/devices/virtio/vhost_user_input.c
src/vnet/devices/virtio/vhost_user_output.c
src/vnet/dpo/interface_rx_dpo.c
src/vnet/ethernet/node.c
src/vnet/ethernet/p2p_ethernet_input.c
src/vnet/geneve/decap.c
src/vnet/geneve/encap.c
src/vnet/gre/node.c
src/vnet/ip/ip4_forward.c
src/vnet/ip/ip4_forward.h
src/vnet/ip/ip4_input.c
src/vnet/ip/ip6_forward.c
src/vnet/ip/ip6_forward.h
src/vnet/ip/ip6_input.c
src/vnet/ip/ping.c
src/vnet/ipip/node.c
src/vnet/ipsec/esp_encrypt.c
src/vnet/ipsec/ipsec.h
src/vnet/ipsec/ipsec_if.c
src/vnet/ipsec/ipsec_if_in.c
src/vnet/l2tp/l2tp.c
src/vnet/lisp-gpe/decap.c
src/vnet/lisp-gpe/interface.c
src/vnet/srv6/sr_localsid.c
src/vnet/udp/udp.c
src/vnet/udp/udp_encap_node.c
src/vnet/unix/tapcli.c
src/vnet/unix/tuntap.c
src/vnet/vxlan-gpe/decap.c
src/vnet/vxlan-gpe/encap.c

index 2722c99..4eec79b 100644 (file)
@@ -42,7 +42,7 @@ CLIB_MULTIARCH_FN (avf_interface_tx) (vlib_main_t * vm,
   avf_main_t *am = &avf_main;
   vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
   avf_device_t *ad = pool_elt_at_index (am->devices, rd->dev_instance);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u8 qid = thread_index;
   avf_txq_t *txq = vec_elt_at_index (ad->txqs, qid % ad->num_queue_pairs);
   avf_tx_desc_t *d0, *d1, *d2, *d3;
index 44c7781..b33ea22 100644 (file)
@@ -220,7 +220,7 @@ lb_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame,
 {
   lb_main_t *lbm = &lb_main;
   u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 lb_time = lb_hash_time_now (vm);
 
   lb_hash_t *sticky_ht = lb_get_sticky_table (thread_index);
index 1bb33b0..715cdef 100644 (file)
@@ -203,7 +203,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 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
@@ -519,7 +519,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 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 *fragments_to_drop = NULL;
   u32 *fragments_to_loopback = NULL;
 
index ab4b46c..0a9903a 100644 (file)
@@ -177,7 +177,7 @@ ip4_map_t_icmp (vlib_main_t * vm,
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
   vlib_combined_counter_main_t *cm = map_main.domain_counters;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
@@ -541,7 +541,7 @@ ip4_map_t (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 = map_main.domain_counters;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
index 5cdd9d9..01b2d87 100644 (file)
@@ -174,7 +174,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
     vlib_node_get_runtime (vm, ip6_map_node.index);
   map_main_t *mm = &map_main;
   vlib_combined_counter_main_t *cm = mm->domain_counters;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -825,7 +825,7 @@ ip6_map_ip4_reass (vlib_main_t * vm,
     vlib_node_get_runtime (vm, ip6_map_ip4_reass_node.index);
   map_main_t *mm = &map_main;
   vlib_combined_counter_main_t *cm = mm->domain_counters;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 *fragments_to_drop = NULL;
   u32 *fragments_to_loopback = NULL;
 
@@ -1018,7 +1018,7 @@ ip6_map_icmp_relay (vlib_main_t * vm,
   vlib_node_runtime_t *error_node =
     vlib_node_get_runtime (vm, ip6_map_icmp_relay_node.index);
   map_main_t *mm = &map_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u16 *fragment_ids, *fid;
 
   from = vlib_frame_vector_args (frame);
index 852b127..01ed810 100644 (file)
@@ -204,7 +204,7 @@ ip6_map_t_icmp (vlib_main_t * vm,
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
   vlib_combined_counter_main_t *cm = map_main.domain_counters;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
@@ -637,7 +637,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
     vlib_node_get_runtime (vm, ip6_map_t_node.index);
   map_main_t *mm = &map_main;
   vlib_combined_counter_main_t *cm = map_main.domain_counters;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
index 6329e3b..72c1fe0 100644 (file)
@@ -162,7 +162,7 @@ mrvl_pp2_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 {
   vnet_main_t *vnm = vnet_get_main ();
   mrvl_pp2_main_t *ppm = &mrvl_pp2_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   mrvl_pp2_inq_t *inq = vec_elt_at_index (ppif->inqs, qid);
   uword n_trace = vlib_get_trace_count (vm, node);
   mrvl_pp2_per_thread_data_t *ptd =
index 6452994..16efae5 100644 (file)
@@ -34,7 +34,7 @@ mrvl_pp2_interface_tx (vlib_main_t * vm,
   mrvl_pp2_main_t *ppm = &mrvl_pp2_main;
   vnet_interface_output_runtime_t *rd = (void *) node->runtime_data;
   mrvl_pp2_if_t *ppif = pool_elt_at_index (ppm->interfaces, rd->dev_instance);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   mrvl_pp2_per_thread_data_t *ptd =
     vec_elt_at_index (ppm->per_thread_data, thread_index);
   u8 qid = thread_index;
index 87c9404..5c8eb3f 100644 (file)
@@ -409,7 +409,7 @@ CLIB_MULTIARCH_FN (memif_interface_tx) (vlib_main_t * vm,
   vnet_interface_output_runtime_t *rund = (void *) node->runtime_data;
   memif_if_t *mif = pool_elt_at_index (nm->interfaces, rund->dev_instance);
   memif_queue_t *mq;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   memif_per_thread_data_t *ptd = vec_elt_at_index (memif_main.per_thread_data,
                                                   thread_index);
   u8 tx_queues = vec_len (mif->tx_queues);
index 6e2807a..2b8c4f2 100644 (file)
@@ -187,7 +187,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left, *to_next = 0;
   u32 bi0, bi1, bi2, bi3;
   vlib_buffer_t *b0, *b1, *b2, *b3;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   memif_per_thread_data_t *ptd = vec_elt_at_index (mm->per_thread_data,
                                                   thread_index);
   vlib_buffer_t *bt = &ptd->buffer_template;
@@ -542,7 +542,7 @@ memif_device_input_zc_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   u16 s0, s1, s2, s3;
   memif_desc_t *d0, *d1, *d2, *d3;
   vlib_buffer_t *b0, *b1, *b2, *b3;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   memif_per_thread_data_t *ptd = vec_elt_at_index (mm->per_thread_data,
                                                   thread_index);
   u16 cur_slot, last_slot, ring_size, n_slots, mask, head;
index ab0055c..991d6ed 100644 (file)
@@ -228,7 +228,7 @@ dslite_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   dslite_in2out_next_t next_index;
   u32 node_index;
   vlib_node_runtime_t *error_node;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   f64 now = vlib_time_now (vm);
   dslite_main_t *dm = &dslite_main;
 
index 6bfc6e9..798367d 100644 (file)
@@ -101,7 +101,7 @@ dslite_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_from, *from, *to_next;
   dslite_out2in_next_t next_index;
   vlib_node_runtime_t *error_node;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   f64 now = vlib_time_now (vm);
   dslite_main_t *dm = &dslite_main;
 
index ae9c836..be1ddb3 100755 (executable)
@@ -1100,7 +1100,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
   snat_main_t * sm = &snat_main;
   f64 now = vlib_time_now (vm);
   u32 stats_node_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   stats_node_index = is_slow_path ? snat_in2out_slowpath_node.index :
     snat_in2out_node.index;
@@ -2066,7 +2066,7 @@ nat44_in2out_reass_node_fn (vlib_main_t * vm,
   u32 pkts_processed = 0;
   snat_main_t *sm = &snat_main;
   f64 now = vlib_time_now (vm);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   snat_main_per_thread_data_t *per_thread_data =
     &sm->per_thread_data[thread_index];
   u32 *fragments_to_drop = 0;
@@ -2985,7 +2985,7 @@ nat44_ed_in2out_node_fn_inline (vlib_main_t * vm,
   snat_in2out_next_t next_index;
   snat_main_t *sm = &snat_main;
   f64 now = vlib_time_now (vm);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
 
   stats_node_index = is_slow_path ? nat44_ed_in2out_slowpath_node.index :
@@ -3793,7 +3793,7 @@ snat_det_in2out_node_fn (vlib_main_t * vm,
   u32 pkts_processed = 0;
   snat_main_t * sm = &snat_main;
   u32 now = (u32) vlib_time_now (vm);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -4558,7 +4558,7 @@ snat_in2out_worker_handoff_fn_inline (vlib_main_t * vm,
   u32 n_left_to_next_worker = 0, *to_next_worker = 0;
   u32 next_worker_index = 0;
   u32 current_worker_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 fq_index;
   u32 to_node_index;
   vlib_frame_t *d = 0;
index 53c2cab..1ca5e36 100644 (file)
@@ -573,7 +573,7 @@ nat64_static_bib_worker_fn (vlib_main_t * vm, vlib_node_runtime_t * rt,
                            vlib_frame_t * f)
 {
   nat64_main_t *nm = &nat64_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   nat64_db_t *db = &nm->db[thread_index];
   nat64_static_bib_to_update_t *static_bib;
   nat64_db_bib_entry_t *bibe;
@@ -1155,7 +1155,7 @@ nat64_expire_worker_walk_fn (vlib_main_t * vm, vlib_node_runtime_t * rt,
                             vlib_frame_t * f)
 {
   nat64_main_t *nm = &nat64_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   nat64_db_t *db = &nm->db[thread_index];
   u32 now = (u32) vlib_time_now (vm);
 
index 6ff428b..cdfe9b8 100644 (file)
@@ -922,7 +922,7 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   nat64_in2out_next_t next_index;
   u32 pkts_processed = 0;
   u32 stats_node_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   stats_node_index =
     is_slow_path ? nat64_in2out_slowpath_node.index : nat64_in2out_node.index;
@@ -1316,7 +1316,7 @@ nat64_in2out_reass_node_fn (vlib_main_t * vm,
   u32 *fragments_to_drop = 0;
   u32 *fragments_to_loopback = 0;
   nat64_main_t *nm = &nat64_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -1644,7 +1644,7 @@ nat64_in2out_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_to_next_worker = 0, *to_next_worker = 0;
   u32 next_worker_index = 0;
   u32 current_worker_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 fq_index;
   u32 to_node_index;
 
index f43d3e0..f7d4dd4 100644 (file)
@@ -408,7 +408,7 @@ nat64_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_from, *from, *to_next;
   nat64_out2in_next_t next_index;
   u32 pkts_processed = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -650,7 +650,7 @@ nat64_out2in_reass_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 *fragments_to_drop = 0;
   u32 *fragments_to_loopback = 0;
   nat64_main_t *nm = &nat64_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -930,7 +930,7 @@ nat64_out2in_handoff_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_to_next_worker = 0, *to_next_worker = 0;
   u32 next_worker_index = 0;
   u32 current_worker_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 fq_index;
   u32 to_node_index;
 
index d606bf4..6bcf6ec 100644 (file)
@@ -116,7 +116,7 @@ nat66_in2out_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_from, *from, *to_next;
   nat66_in2out_next_t next_index;
   u32 pkts_processed = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   nat66_main_t *nm = &nat66_main;
 
   from = vlib_frame_vector_args (frame);
index a28a4c3..f264765 100644 (file)
@@ -76,7 +76,7 @@ nat66_out2in_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_from, *from, *to_next;
   nat66_out2in_next_t next_index;
   u32 pkts_processed = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   nat66_main_t *nm = &nat66_main;
 
   from = vlib_frame_vector_args (frame);
index 1a1a1f1..ecfabc9 100755 (executable)
@@ -653,7 +653,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
   u32 pkts_processed = 0;
   snat_main_t * sm = &snat_main;
   f64 now = vlib_time_now (vm);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -1256,7 +1256,7 @@ nat44_out2in_reass_node_fn (vlib_main_t * vm,
   u32 pkts_processed = 0;
   snat_main_t *sm = &snat_main;
   f64 now = vlib_time_now (vm);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   snat_main_per_thread_data_t *per_thread_data =
     &sm->per_thread_data[thread_index];
   u32 *fragments_to_drop = 0;
@@ -2038,7 +2038,7 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm,
   nat44_ed_out2in_next_t next_index;
   snat_main_t *sm = &snat_main;
   f64 now = vlib_time_now (vm);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
 
   stats_node_index = is_slow_path ? nat44_ed_out2in_slowpath_node.index :
@@ -2837,7 +2837,7 @@ snat_det_out2in_node_fn (vlib_main_t * vm,
   snat_out2in_next_t next_index;
   u32 pkts_processed = 0;
   snat_main_t * sm = &snat_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -3473,7 +3473,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm,
   u32 n_left_to_next_worker = 0, *to_next_worker = 0;
   u32 next_worker_index = 0;
   u32 current_worker_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   vlib_frame_t *d = 0;
 
   ASSERT (vec_len (sm->workers));
index e2111d6..2985196 100644 (file)
@@ -194,7 +194,7 @@ srv6_ad_localsid_fn (vlib_main_t * vm,
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
 
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
index 8643aa4..84014c5 100644 (file)
@@ -148,7 +148,7 @@ srv6_am_localsid_fn (vlib_main_t * vm,
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
 
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
index 7f513fc..16c1d8e 100644 (file)
@@ -69,7 +69,7 @@ bier_output (vlib_main_t * vm,
     u32 n_left_from, next_index, * from, * to_next;
     u32 thread_index;
 
-    thread_index = vlib_get_thread_index ();
+    thread_index = vm->thread_index;
     from = vlib_frame_vector_args (from_frame);
     n_left_from = from_frame->n_vectors;
 
index 1ade1c2..53123dd 100644 (file)
@@ -140,7 +140,7 @@ bond_load_balance_broadcast (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 *to_next = 0;
   u32 sw_if_index;
   vlib_frame_t *f;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
 
   for (port = 1; port < slave_count; port++)
     {
@@ -403,7 +403,7 @@ bond_tx_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 sw_if_index, sw_if_index1, sw_if_index2, sw_if_index3;
   bond_packet_trace_t *t0;
   uword n_trace = vlib_get_trace_count (vm, node);
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   vnet_main_t *vnm = vnet_get_main ();
   u32 *to_next;
   u32 sif_if_index, sif_if_index1, sif_if_index2, sif_if_index3;
index 5842da3..7abd7b0 100644 (file)
@@ -138,7 +138,7 @@ bond_update_next (vlib_main_t * vm, vlib_node_runtime_t * node,
                  u32 * bond_sw_if_index, vlib_buffer_t * b,
                  u32 * next_index, vlib_error_t * error)
 {
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   slave_if_t *sif;
   bond_if_t *bif;
 
@@ -176,7 +176,7 @@ VLIB_NODE_FN (bond_input_node) (vlib_main_t * vm,
                                vlib_node_runtime_t * node,
                                vlib_frame_t * frame)
 {
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   u32 *from, n_left;
   vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
   u32 sw_if_indices[VLIB_FRAME_SIZE], *sw_if_index;
index d74e56f..8dbd855 100644 (file)
@@ -191,7 +191,7 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 frame_num = apif->rx_req->tp_frame_nr;
   u8 *block_start = apif->rx_ring + block * block_size;
   uword n_trace = vlib_get_trace_count (vm, node);
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm,
                                                          VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
   u32 min_bufs = apif->rx_req->tp_frame_size / n_buffer_bytes;
index 67ddce5..e541700 100644 (file)
@@ -98,7 +98,7 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_free_bufs;
   struct netmap_ring *ring;
   int cur_ring;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm,
                                                          VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
 
@@ -260,7 +260,7 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
 {
   int i;
   u32 n_rx_packets = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   netmap_main_t *nm = &netmap_main;
   netmap_if_t *nmi;
 
index 9477a1c..339c48c 100644 (file)
@@ -128,7 +128,7 @@ virtio_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
                            vlib_frame_t * frame, virtio_if_t * vif, u16 qid)
 {
   vnet_main_t *vnm = vnet_get_main ();
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   uword n_trace = vlib_get_trace_count (vm, node);
   virtio_vring_t *vring = vec_elt_at_index (vif->vrings, 0);
   u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
index 3db4473..3f2b402 100644 (file)
@@ -256,7 +256,7 @@ vhost_user_if_input (vlib_main_t * vm,
   u32 next_index = VNET_DEVICE_INPUT_NEXT_ETHERNET_INPUT;
   u32 n_trace = vlib_get_trace_count (vm, node);
   u32 map_hint = 0;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   u16 copy_len = 0;
 
   {
index f400f18..b415837 100644 (file)
@@ -238,7 +238,7 @@ CLIB_MULTIARCH_FN (vhost_user_tx) (vlib_main_t * vm,
   u32 qid = ~0;
   vhost_user_vring_t *rxvq;
   u8 error;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 map_hint = 0;
   u8 retry = 8;
   u16 copy_len;
index 4e5b1a5..82767e7 100644 (file)
@@ -239,7 +239,7 @@ interface_rx_dpo_inline (vlib_main_t * vm,
                         u8 is_l2)
 {
     u32 n_left_from, next_index, * from, * to_next;
-    u32 thread_index = vlib_get_thread_index ();
+    u32 thread_index = vm->thread_index;
     vnet_interface_main_t *im;
 
     im = &vnet_get_main ()->interface_main;
index 8667667..3b5542e 100755 (executable)
@@ -297,7 +297,7 @@ ethernet_input_inline (vlib_main_t * vm,
   vlib_node_runtime_t *error_node;
   u32 n_left_from, next_index, *from, *to_next;
   u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 cached_sw_if_index = ~0;
   u32 cached_is_l2 = 0;                /* shut up gcc */
   vnet_hw_interface_t *hi = NULL;      /* used for main interface only */
index eeff4f0..74e3bb8 100644 (file)
@@ -63,7 +63,7 @@ static uword
 p2p_ethernet_input_node_fn (vlib_main_t * vm,
                            vlib_node_runtime_t * node, vlib_frame_t * frame)
 {
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 n_trace = vlib_get_trace_count (vm, node);
   u32 n_left_from, *from, *to_next;
   u32 next_index;
index 2e6e9c5..b17c6da 100644 (file)
@@ -82,7 +82,7 @@ geneve_input (vlib_main_t * vm,
   geneve4_tunnel_key_t last_key4;
   geneve6_tunnel_key_t last_key6;
   u32 pkts_decapsulated = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
 
   if (is_ip4)
index e9e7e5b..9774323 100644 (file)
@@ -79,7 +79,7 @@ geneve_encap_inline (vlib_main_t * vm,
   vnet_interface_main_t *im = &vnm->interface_main;
   u32 pkts_encapsulated = 0;
   u16 old_l0 = 0, old_l1 = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
   u32 sw_if_index0 = 0, sw_if_index1 = 0;
   u32 next0 = 0, next1 = 0;
index ee32e60..056d00b 100644 (file)
@@ -77,7 +77,7 @@ gre_input (vlib_main_t * vm,
 
   u32 cached_tunnel_sw_if_index = ~0, tunnel_sw_if_index = ~0;
 
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 len;
   vnet_interface_main_t *im = &gm->vnet_main->interface_main;
 
index d556f0a..fd8559d 100644 (file)
@@ -121,7 +121,7 @@ ip4_load_balance (vlib_main_t * vm,
   vlib_combined_counter_main_t *cm = &load_balance_main.lbm_via_counters;
   u32 n_left_from, n_left_to_next, *from, *to_next;
   ip_lookup_next_t next;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -2082,7 +2082,7 @@ ip4_rewrite_inline (vlib_main_t * vm,
 
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
index 553a053..b1294fd 100644 (file)
@@ -60,7 +60,7 @@ ip4_lookup_inline (vlib_main_t * vm,
   vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters;
   u32 n_left_from, n_left_to_next, *from, *to_next;
   ip_lookup_next_t next;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
index 1ecd43b..15c2ebf 100644 (file)
@@ -90,7 +90,8 @@ ip4_input_set_next (u32 sw_if_index, vlib_buffer_t * b, int arc_enabled)
 }
 
 static_always_inline void
-ip4_input_check_sw_if_index (vlib_simple_counter_main_t * cm, u32 sw_if_index,
+ip4_input_check_sw_if_index (vlib_main_t * vm,
+                            vlib_simple_counter_main_t * cm, u32 sw_if_index,
                             u32 * last_sw_if_index, u32 * cnt,
                             int *arc_enabled)
 {
@@ -103,7 +104,7 @@ ip4_input_check_sw_if_index (vlib_simple_counter_main_t * cm, u32 sw_if_index,
       return;
     }
 
-  thread_index = vlib_get_thread_index ();
+  thread_index = vm->thread_index;
   if (*cnt)
     vlib_increment_simple_counter (cm, thread_index, *last_sw_if_index, *cnt);
   *cnt = 1;
@@ -125,7 +126,7 @@ ip4_input_inline (vlib_main_t * vm,
 {
   vnet_main_t *vnm = vnet_get_main ();
   u32 n_left_from, *from;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   vlib_node_runtime_t *error_node =
     vlib_node_get_runtime (vm, ip4_input_node.index);
   vlib_simple_counter_main_t *cm;
@@ -206,14 +207,14 @@ ip4_input_inline (vlib_main_t * vm,
        }
       else
        {
-         ip4_input_check_sw_if_index (cm, sw_if_index[0], &last_sw_if_index,
-                                      &cnt, &arc_enabled);
-         ip4_input_check_sw_if_index (cm, sw_if_index[1], &last_sw_if_index,
-                                      &cnt, &arc_enabled);
-         ip4_input_check_sw_if_index (cm, sw_if_index[2], &last_sw_if_index,
-                                      &cnt, &arc_enabled);
-         ip4_input_check_sw_if_index (cm, sw_if_index[3], &last_sw_if_index,
-                                      &cnt, &arc_enabled);
+         ip4_input_check_sw_if_index (vm, cm, sw_if_index[0],
+                                      &last_sw_if_index, &cnt, &arc_enabled);
+         ip4_input_check_sw_if_index (vm, cm, sw_if_index[1],
+                                      &last_sw_if_index, &cnt, &arc_enabled);
+         ip4_input_check_sw_if_index (vm, cm, sw_if_index[2],
+                                      &last_sw_if_index, &cnt, &arc_enabled);
+         ip4_input_check_sw_if_index (vm, cm, sw_if_index[3],
+                                      &last_sw_if_index, &cnt, &arc_enabled);
 
          next[0] = ip4_input_set_next (sw_if_index[0], b[0], 1);
          next[1] = ip4_input_set_next (sw_if_index[1], b[1], 1);
@@ -238,7 +239,7 @@ ip4_input_inline (vlib_main_t * vm,
       u32 next0;
       vnet_buffer (b[0])->ip.adj_index[VLIB_RX] = ~0;
       sw_if_index[0] = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
-      ip4_input_check_sw_if_index (cm, sw_if_index[0], &last_sw_if_index,
+      ip4_input_check_sw_if_index (vm, cm, sw_if_index[0], &last_sw_if_index,
                                   &cnt, &arc_enabled);
       next0 = ip4_input_set_next (sw_if_index[0], b[0], arc_enabled);
       ip[0] = vlib_buffer_get_current (b[0]);
index 343d348..41f5b15 100644 (file)
@@ -529,7 +529,7 @@ ip6_load_balance (vlib_main_t * vm,
   vlib_combined_counter_main_t *cm = &load_balance_main.lbm_via_counters;
   u32 n_left_from, n_left_to_next, *from, *to_next;
   ip_lookup_next_t next;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   ip6_main_t *im = &ip6_main;
 
   from = vlib_frame_vector_args (frame);
@@ -1594,7 +1594,7 @@ ip6_rewrite_inline (vlib_main_t * vm,
 
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
index fcdcabd..44744c0 100644 (file)
@@ -59,7 +59,7 @@ ip6_lookup_inline (vlib_main_t * vm,
   vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters;
   u32 n_left_from, n_left_to_next, *from, *to_next;
   ip_lookup_next_t next;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
index 3b38d34..6a7669d 100644 (file)
@@ -73,7 +73,7 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
   vlib_node_runtime_t *error_node =
     vlib_node_get_runtime (vm, ip6_input_node.index);
   vlib_simple_counter_main_t *cm;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
index a929a0c..096b2eb 100755 (executable)
@@ -577,7 +577,7 @@ run_ping_ip46_address (vlib_main_t * vm, u32 table_id, ip4_address_t * pa4,
   pool_get (pm->ping_runs, pr);
   ping_run_index = pr - pm->ping_runs;
   pr->cli_process_id = curr_proc;
-  pr->cli_thread_index = vlib_get_thread_index ();
+  pr->cli_thread_index = vm->thread_index;
   pr->icmp_id = icmp_id;
   hash_set (pm->ping_run_by_icmp_id, icmp_id, ping_run_index);
   for (i = 1; i <= ping_repeat; i++)
index f24ea97..d55b91a 100644 (file)
@@ -65,7 +65,7 @@ ipip_input (vlib_main_t * vm, vlib_node_runtime_t * node,
   ipip_main_t *gm = &ipip_main;
   u32 n_left_from, next_index, *from, *to_next, n_left_to_next;
   u32 tunnel_sw_if_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 len;
   vnet_interface_main_t *im = &gm->vnet_main->interface_main;
 
index 5f63301..4291e94 100644 (file)
@@ -88,11 +88,11 @@ format_esp_encrypt_trace (u8 * s, va_list * args)
 }
 
 always_inline void
-esp_encrypt_cbc (ipsec_crypto_alg_t alg,
+esp_encrypt_cbc (vlib_main_t * vm, ipsec_crypto_alg_t alg,
                 u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv)
 {
   ipsec_proto_main_t *em = &ipsec_proto_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 #if OPENSSL_VERSION_NUMBER >= 0x10100000L
   EVP_CIPHER_CTX *ctx = em->per_thread_data[thread_index].encrypt_ctx;
 #else
@@ -130,7 +130,7 @@ esp_encrypt_node_fn (vlib_main_t * vm,
   ipsec_main_t *im = &ipsec_main;
   ipsec_proto_main_t *em = &ipsec_proto_main;
   u32 *recycle = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   ipsec_alloc_empty_buffers (vm, im);
 
@@ -361,7 +361,7 @@ esp_encrypt_node_fn (vlib_main_t * vm,
                           em->ipsec_proto_main_crypto_algs[sa0->
                                                            crypto_alg].iv_size);
 
-             esp_encrypt_cbc (sa0->crypto_alg,
+             esp_encrypt_cbc (vm, sa0->crypto_alg,
                               (u8 *) vlib_buffer_get_current (i_b0),
                               (u8 *) vlib_buffer_get_current (o_b0) +
                               ip_udp_hdr_size + sizeof (esp_header_t) +
index e457e33..d1aedb1 100644 (file)
@@ -355,7 +355,7 @@ int ipsec_set_interface_sa (vnet_main_t * vnm, u32 hw_if_index, u32 sa_id,
 always_inline void
 ipsec_alloc_empty_buffers (vlib_main_t * vm, ipsec_main_t * im)
 {
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   uword l = vec_len (im->empty_buffers[thread_index]);
   uword n_alloc = 0;
 
index e950a5e..82c2394 100644 (file)
@@ -78,7 +78,7 @@ ipsec_if_tx_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   vnet_interface_main_t *vim = &vnm->interface_main;
   u32 *from, *to_next = 0, next_index;
   u32 n_left_from, sw_if_index0, last_sw_if_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 n_bytes = 0, n_packets = 0;
 
   from = vlib_frame_vector_args (from_frame);
index 655668a..bc10f7f 100644 (file)
@@ -69,7 +69,7 @@ ipsec_if_input_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   ipsec_proto_main_t *em = &ipsec_proto_main;
   u32 *from, *to_next = 0, next_index;
   u32 n_left_from, last_sw_if_index = ~0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u64 n_bytes = 0, n_packets = 0;
   u8 icv_len;
   ipsec_tunnel_if_t *last_t = NULL;
index 3dedc44..a59c789 100644 (file)
@@ -157,7 +157,7 @@ test_counters_command_fn (vlib_main_t * vm,
   u32 session_index;
   u32 counter_index;
   u32 nincr = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   /* *INDENT-OFF* */
   pool_foreach (session, lm->sessions,
index e59a353..fd3f175 100644 (file)
@@ -154,7 +154,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_bytes = 0, n_packets = 0, last_sw_if_index = ~0, drops = 0;
   lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
 
-  thread_index = vlib_get_thread_index ();
+  thread_index = vm->thread_index;
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
 
index 84933ec..1275083 100644 (file)
@@ -239,7 +239,7 @@ l2_lisp_gpe_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node,
 {
   u32 n_left_from, next_index, *from, *to_next;
   lisp_gpe_main_t *lgm = &lisp_gpe_main;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   vlib_combined_counter_main_t *cm = &load_balance_main.lbm_to_counters;
 
   from = vlib_frame_vector_args (from_frame);
index 09c336e..6b1724d 100755 (executable)
@@ -887,7 +887,7 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
   next_index = node->cached_next_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
@@ -1190,7 +1190,7 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
   from = vlib_frame_vector_args (from_frame);
   n_left_from = from_frame->n_vectors;
   next_index = node->cached_next_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   while (n_left_from > 0)
     {
index 888a6cb..9618936 100644 (file)
@@ -265,7 +265,7 @@ udp_open_connection (transport_endpoint_t * rmt)
 {
   udp_main_t *um = vnet_get_udp_main ();
   vlib_main_t *vm = vlib_get_main ();
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   udp_connection_t *uc;
   ip46_address_t lcl_addr;
   u32 node_index;
index 2d37d8b..abf19fa 100644 (file)
@@ -67,7 +67,7 @@ udp_encap_inline (vlib_main_t * vm,
   vlib_combined_counter_main_t *cm = &udp_encap_counters;
   u32 *from = vlib_frame_vector_args (frame);
   u32 n_left_from, n_left_to_next, *to_next, next_index;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
 
   n_left_from = frame->n_vectors;
   next_index = node->cached_next_index;
index e61c91a..4a5628e 100644 (file)
@@ -175,7 +175,7 @@ tapcli_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
   tapcli_main_t *tm = &tapcli_main;
   tapcli_interface_t *ti;
   int i;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
 
   for (i = 0; i < n_packets; i++)
     {
@@ -271,7 +271,7 @@ tapcli_rx_iface (vlib_main_t * vm,
   const uword buffer_size = VLIB_BUFFER_DATA_SIZE;
   u32 n_trace = vlib_get_trace_count (vm, node);
   u8 set_trace = 0;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
   vnet_main_t *vnm;
   vnet_sw_interface_t *si;
   u8 admin_down;
index 5d785ac..fc1ecb2 100644 (file)
@@ -153,7 +153,7 @@ tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
   vnet_interface_main_t *im = &vnm->interface_main;
   u32 n_bytes = 0;
   int i;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
 
   for (i = 0; i < n_packets; i++)
     {
@@ -243,7 +243,7 @@ tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
   vlib_buffer_t *b;
   u32 bi;
   const uword buffer_size = VLIB_BUFFER_DATA_SIZE;
-  u16 thread_index = vlib_get_thread_index ();
+  u16 thread_index = vm->thread_index;
 
   /** Make sure we have some RX buffers. */
   {
index cb7c525..29a043f 100644 (file)
@@ -117,7 +117,7 @@ vxlan_gpe_input (vlib_main_t * vm,
   vxlan4_gpe_tunnel_key_t last_key4;
   vxlan6_gpe_tunnel_key_t last_key6;
   u32 pkts_decapsulated = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
 
   if (is_ip4)
index 71faac5..c97972b 100644 (file)
@@ -151,7 +151,7 @@ vxlan_gpe_encap (vlib_main_t * vm,
   vnet_main_t *vnm = ngm->vnet_main;
   vnet_interface_main_t *im = &vnm->interface_main;
   u32 pkts_encapsulated = 0;
-  u32 thread_index = vlib_get_thread_index ();
+  u32 thread_index = vm->thread_index;
   u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
 
   from = vlib_frame_vector_args (from_frame);