summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2017-04-05 19:18:20 +0200
committerDave Barach <openvpp@barachs.net>2017-04-06 11:31:39 +0000
commit586afd762bfa149f5ca167bd5fd5a0cd59ce94fe (patch)
tree808b57c61e0fe1a181871bb1ad94398c5ba42671 /src/vnet
parentbc799c92d761a2d45105aa6a1685b3663687d2a4 (diff)
Use thread local storage for thread index
This patch deprecates stack-based thread identification, Also removes requirement that thread stacks are adjacent. Finally, possibly annoying for some folks, it renames all occurences of cpu_index and cpu_number with thread index. Using word "cpu" is misleading here as thread can be migrated ti different CPU, and also it is not related to linux cpu index. Change-Id: I68cdaf661e701d2336fc953dcb9978d10a70f7c1 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/adj/adj_l2.c4
-rw-r--r--src/vnet/adj/adj_midchain.c8
-rw-r--r--src/vnet/adj/adj_nsh.c4
-rw-r--r--src/vnet/classify/vnet_classify.c16
-rw-r--r--src/vnet/cop/ip4_whitelist.c8
-rw-r--r--src/vnet/cop/ip6_whitelist.c8
-rw-r--r--src/vnet/devices/af_packet/node.c20
-rw-r--r--src/vnet/devices/devices.c61
-rw-r--r--src/vnet/devices/devices.h18
-rw-r--r--src/vnet/devices/netmap/node.c24
-rw-r--r--src/vnet/devices/ssvm/node.c6
-rw-r--r--src/vnet/devices/virtio/vhost-user.c127
-rw-r--r--src/vnet/dpo/lookup_dpo.c20
-rw-r--r--src/vnet/dpo/replicate_dpo.c12
-rw-r--r--src/vnet/ethernet/arp.c2
-rw-r--r--src/vnet/ethernet/interface.c7
-rwxr-xr-xsrc/vnet/ethernet/node.c14
-rw-r--r--src/vnet/gre/node.c8
-rw-r--r--src/vnet/interface.h2
-rw-r--r--src/vnet/interface_output.c53
-rw-r--r--src/vnet/ip/ip4_forward.c34
-rw-r--r--src/vnet/ip/ip4_input.c8
-rw-r--r--src/vnet/ip/ip6_forward.c24
-rw-r--r--src/vnet/ip/ip6_input.c8
-rw-r--r--src/vnet/ip/ip6_neighbor.c4
-rw-r--r--src/vnet/ipsec/esp.h8
-rw-r--r--src/vnet/ipsec/esp_decrypt.c13
-rw-r--r--src/vnet/ipsec/esp_encrypt.c13
-rw-r--r--src/vnet/ipsec/ikev2.c64
-rw-r--r--src/vnet/ipsec/ipsec.h12
-rw-r--r--src/vnet/ipsec/ipsec_if.c2
-rw-r--r--src/vnet/l2/l2_bvi.h2
-rw-r--r--src/vnet/l2/l2_input.c14
-rw-r--r--src/vnet/l2/l2_output.c6
-rw-r--r--src/vnet/l2tp/decap.c2
-rw-r--r--src/vnet/l2tp/encap.c2
-rw-r--r--src/vnet/l2tp/l2tp.c6
-rw-r--r--src/vnet/lisp-gpe/decap.c16
-rw-r--r--src/vnet/lldp/lldp_input.c2
-rw-r--r--src/vnet/map/ip4_map.c14
-rw-r--r--src/vnet/map/ip4_map_t.c12
-rw-r--r--src/vnet/map/ip6_map.c19
-rw-r--r--src/vnet/map/ip6_map_t.c12
-rw-r--r--src/vnet/mpls/mpls_input.c8
-rw-r--r--src/vnet/mpls/mpls_lookup.c20
-rw-r--r--src/vnet/mpls/mpls_output.c10
-rw-r--r--src/vnet/pg/input.c4
-rw-r--r--src/vnet/replication.c20
-rw-r--r--src/vnet/replication.h2
-rw-r--r--src/vnet/session/node.c2
-rwxr-xr-xsrc/vnet/sr/sr_localsid.c44
-rw-r--r--src/vnet/tcp/builtin_client.c2
-rw-r--r--src/vnet/tcp/tcp.c8
-rw-r--r--src/vnet/tcp/tcp_debug.h2
-rw-r--r--src/vnet/tcp/tcp_input.c10
-rw-r--r--src/vnet/tcp/tcp_output.c20
-rw-r--r--src/vnet/udp/udp_input.c2
-rw-r--r--src/vnet/unix/tapcli.c2
-rw-r--r--src/vnet/unix/tuntap.c4
-rw-r--r--src/vnet/vxlan-gpe/decap.c10
-rw-r--r--src/vnet/vxlan-gpe/encap.c12
-rw-r--r--src/vnet/vxlan/decap.c10
-rw-r--r--src/vnet/vxlan/encap.c12
63 files changed, 470 insertions, 453 deletions
diff --git a/src/vnet/adj/adj_l2.c b/src/vnet/adj/adj_l2.c
index f68e54e0214..20d70dd4cd1 100644
--- a/src/vnet/adj/adj_l2.c
+++ b/src/vnet/adj/adj_l2.c
@@ -52,7 +52,7 @@ adj_l2_rewrite_inline (vlib_main_t * vm,
{
u32 * from = vlib_frame_vector_args (frame);
u32 n_left_from, n_left_to_next, * to_next, next_index;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
ethernet_main_t * em = &ethernet_main;
n_left_from = frame->n_vectors;
@@ -93,7 +93,7 @@ adj_l2_rewrite_inline (vlib_main_t * vm,
vnet_buffer(p0)->sw_if_index[VLIB_TX] = adj0->rewrite_header.sw_if_index;
vlib_increment_combined_counter(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index0,
/* packet increment */ 0,
/* byte increment */ rw_len0);
diff --git a/src/vnet/adj/adj_midchain.c b/src/vnet/adj/adj_midchain.c
index e8087f08d21..5756de4393d 100644
--- a/src/vnet/adj/adj_midchain.c
+++ b/src/vnet/adj/adj_midchain.c
@@ -49,7 +49,7 @@ adj_midchain_tx_inline (vlib_main_t * vm,
u32 next_index;
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
/* Vector of buffer / pkt indices we're supposed to process */
from = vlib_frame_vector_args (frame);
@@ -124,13 +124,13 @@ adj_midchain_tx_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_TX,
- cpu_index,
+ thread_index,
adj0->rewrite_header.sw_if_index,
1,
vlib_buffer_length_in_chain (vm, b0));
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_TX,
- cpu_index,
+ thread_index,
adj1->rewrite_header.sw_if_index,
1,
vlib_buffer_length_in_chain (vm, b1));
@@ -181,7 +181,7 @@ adj_midchain_tx_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_TX,
- cpu_index,
+ thread_index,
adj0->rewrite_header.sw_if_index,
1,
vlib_buffer_length_in_chain (vm, b0));
diff --git a/src/vnet/adj/adj_nsh.c b/src/vnet/adj/adj_nsh.c
index 9a0f9d8b9d6..128570b02a9 100644
--- a/src/vnet/adj/adj_nsh.c
+++ b/src/vnet/adj/adj_nsh.c
@@ -53,7 +53,7 @@ adj_nsh_rewrite_inline (vlib_main_t * vm,
{
u32 * from = vlib_frame_vector_args (frame);
u32 n_left_from, n_left_to_next, * to_next, next_index;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
@@ -94,7 +94,7 @@ adj_nsh_rewrite_inline (vlib_main_t * vm,
vnet_buffer(p0)->ip.save_rewrite_length = rw_len0;
vlib_increment_combined_counter(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index0,
/* packet increment */ 0,
/* byte increment */ rw_len0);
diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c
index 98842a481b8..70a189b08ef 100644
--- a/src/vnet/classify/vnet_classify.c
+++ b/src/vnet/classify/vnet_classify.c
@@ -251,12 +251,12 @@ static inline void make_working_copy
vnet_classify_entry_##size##_t * working_copy##size = 0;
foreach_size_in_u32x4;
#undef _
- u32 cpu_number = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
- if (cpu_number >= vec_len (t->working_copies))
+ if (thread_index >= vec_len (t->working_copies))
{
oldheap = clib_mem_set_heap (t->mheap);
- vec_validate (t->working_copies, cpu_number);
+ vec_validate (t->working_copies, thread_index);
clib_mem_set_heap (oldheap);
}
@@ -265,7 +265,7 @@ static inline void make_working_copy
* updates from multiple threads will not result in sporadic, spurious
* lookup failures.
*/
- working_copy = t->working_copies[cpu_number];
+ working_copy = t->working_copies[thread_index];
t->saved_bucket.as_u64 = b->as_u64;
oldheap = clib_mem_set_heap (t->mheap);
@@ -290,7 +290,7 @@ static inline void make_working_copy
default:
abort();
}
- t->working_copies[cpu_number] = working_copy;
+ t->working_copies[thread_index] = working_copy;
}
_vec_len(working_copy) = (1<<b->log2_pages)*t->entries_per_page;
@@ -318,7 +318,7 @@ static inline void make_working_copy
working_bucket.offset = vnet_classify_get_offset (t, working_copy);
CLIB_MEMORY_BARRIER();
b->as_u64 = working_bucket.as_u64;
- t->working_copies[cpu_number] = working_copy;
+ t->working_copies[thread_index] = working_copy;
}
static vnet_classify_entry_t *
@@ -387,7 +387,7 @@ int vnet_classify_add_del (vnet_classify_table_t * t,
int i;
u64 hash, new_hash;
u32 new_log2_pages;
- u32 cpu_number = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
u8 * key_minus_skip;
ASSERT ((add_v->flags & VNET_CLASSIFY_ENTRY_FREE) == 0);
@@ -498,7 +498,7 @@ int vnet_classify_add_del (vnet_classify_table_t * t,
new_log2_pages = t->saved_bucket.log2_pages + 1;
expand_again:
- working_copy = t->working_copies[cpu_number];
+ working_copy = t->working_copies[thread_index];
new_v = split_and_rehash (t, working_copy, new_log2_pages);
if (new_v == 0)
diff --git a/src/vnet/cop/ip4_whitelist.c b/src/vnet/cop/ip4_whitelist.c
index 6ef3d7d73be..1b5e336b752 100644
--- a/src/vnet/cop/ip4_whitelist.c
+++ b/src/vnet/cop/ip4_whitelist.c
@@ -60,7 +60,7 @@ ip4_cop_whitelist_node_fn (vlib_main_t * vm,
cop_feature_type_t next_index;
cop_main_t *cm = &cop_main;
vlib_combined_counter_main_t * vcm = &load_balance_main.lbm_via_counters;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -177,12 +177,12 @@ ip4_cop_whitelist_node_fn (vlib_main_t * vm,
dpo1 = load_balance_get_bucket_i(lb1, 0);
vlib_increment_combined_counter
- (vcm, cpu_index, lb_index0, 1,
+ (vcm, thread_index, lb_index0, 1,
vlib_buffer_length_in_chain (vm, b0)
+ sizeof(ethernet_header_t));
vlib_increment_combined_counter
- (vcm, cpu_index, lb_index1, 1,
+ (vcm, thread_index, lb_index1, 1,
vlib_buffer_length_in_chain (vm, b1)
+ sizeof(ethernet_header_t));
@@ -273,7 +273,7 @@ ip4_cop_whitelist_node_fn (vlib_main_t * vm,
dpo0 = load_balance_get_bucket_i(lb0, 0);
vlib_increment_combined_counter
- (vcm, cpu_index, lb_index0, 1,
+ (vcm, thread_index, lb_index0, 1,
vlib_buffer_length_in_chain (vm, b0)
+ sizeof(ethernet_header_t));
diff --git a/src/vnet/cop/ip6_whitelist.c b/src/vnet/cop/ip6_whitelist.c
index c2e16ccfe54..f3fe62e35b1 100644
--- a/src/vnet/cop/ip6_whitelist.c
+++ b/src/vnet/cop/ip6_whitelist.c
@@ -61,7 +61,7 @@ ip6_cop_whitelist_node_fn (vlib_main_t * vm,
cop_main_t *cm = &cop_main;
ip6_main_t * im6 = &ip6_main;
vlib_combined_counter_main_t * vcm = &load_balance_main.lbm_via_counters;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -153,12 +153,12 @@ ip6_cop_whitelist_node_fn (vlib_main_t * vm,
dpo1 = load_balance_get_bucket_i(lb1, 0);
vlib_increment_combined_counter
- (vcm, cpu_index, lb_index0, 1,
+ (vcm, thread_index, lb_index0, 1,
vlib_buffer_length_in_chain (vm, b0)
+ sizeof(ethernet_header_t));
vlib_increment_combined_counter
- (vcm, cpu_index, lb_index1, 1,
+ (vcm, thread_index, lb_index1, 1,
vlib_buffer_length_in_chain (vm, b1)
+ sizeof(ethernet_header_t));
@@ -233,7 +233,7 @@ ip6_cop_whitelist_node_fn (vlib_main_t * vm,
dpo0 = load_balance_get_bucket_i(lb0, 0);
vlib_increment_combined_counter
- (vcm, cpu_index, lb_index0, 1,
+ (vcm, thread_index, lb_index0, 1,
vlib_buffer_length_in_chain (vm, b0)
+ sizeof(ethernet_header_t));
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index ba337f3f70b..76980102f71 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -124,7 +124,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_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;
@@ -132,15 +132,15 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
if (apif->per_interface_next_index != ~0)
next_index = apif->per_interface_next_index;
- n_free_bufs = vec_len (apm->rx_buffers[cpu_index]);
+ n_free_bufs = vec_len (apm->rx_buffers[thread_index]);
if (PREDICT_FALSE (n_free_bufs < VLIB_FRAME_SIZE))
{
- vec_validate (apm->rx_buffers[cpu_index],
+ vec_validate (apm->rx_buffers[thread_index],
VLIB_FRAME_SIZE + n_free_bufs - 1);
n_free_bufs +=
- vlib_buffer_alloc (vm, &apm->rx_buffers[cpu_index][n_free_bufs],
+ vlib_buffer_alloc (vm, &apm->rx_buffers[thread_index][n_free_bufs],
VLIB_FRAME_SIZE);
- _vec_len (apm->rx_buffers[cpu_index]) = n_free_bufs;
+ _vec_len (apm->rx_buffers[thread_index]) = n_free_bufs;
}
rx_frame = apif->next_rx_frame;
@@ -163,11 +163,11 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
/* grab free buffer */
u32 last_empty_buffer =
- vec_len (apm->rx_buffers[cpu_index]) - 1;
+ vec_len (apm->rx_buffers[thread_index]) - 1;
prev_bi0 = bi0;
- bi0 = apm->rx_buffers[cpu_index][last_empty_buffer];
+ bi0 = apm->rx_buffers[thread_index][last_empty_buffer];
b0 = vlib_get_buffer (vm, bi0);
- _vec_len (apm->rx_buffers[cpu_index]) = last_empty_buffer;
+ _vec_len (apm->rx_buffers[thread_index]) = last_empty_buffer;
n_free_bufs--;
/* copy data */
@@ -236,9 +236,9 @@ af_packet_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_increment_combined_counter
(vnet_get_main ()->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number (), apif->hw_if_index, n_rx_packets, n_rx_bytes);
+ vlib_get_thread_index (), apif->hw_if_index, n_rx_packets, n_rx_bytes);
- vnet_device_increment_rx_packets (cpu_index, n_rx_packets);
+ vnet_device_increment_rx_packets (thread_index, n_rx_packets);
return n_rx_packets;
}
diff --git a/src/vnet/devices/devices.c b/src/vnet/devices/devices.c
index 4164522099e..5e5e812c48b 100644
--- a/src/vnet/devices/devices.c
+++ b/src/vnet/devices/devices.c
@@ -104,7 +104,7 @@ vnet_device_queue_sort (void *a1, void *a2)
void
vnet_device_input_assign_thread (u32 hw_if_index,
- u16 queue_id, uword cpu_index)
+ u16 queue_id, uword thread_index)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_device_main_t *vdm = &vnet_device_main;
@@ -115,19 +115,19 @@ vnet_device_input_assign_thread (u32 hw_if_index,
ASSERT (hw->input_node_index > 0);
- if (vdm->first_worker_cpu_index == 0)
- cpu_index = 0;
+ if (vdm->first_worker_thread_index == 0)
+ thread_index = 0;
- if (cpu_index != 0 &&
- (cpu_index < vdm->first_worker_cpu_index ||
- cpu_index > vdm->last_worker_cpu_index))
+ if (thread_index != 0 &&
+ (thread_index < vdm->first_worker_thread_index ||
+ thread_index > vdm->last_worker_thread_index))
{
- cpu_index = vdm->next_worker_cpu_index++;
- if (vdm->next_worker_cpu_index > vdm->last_worker_cpu_index)
- vdm->next_worker_cpu_index = vdm->first_worker_cpu_index;
+ thread_index = vdm->next_worker_thread_index++;
+ if (vdm->next_worker_thread_index > vdm->last_worker_thread_index)
+ vdm->next_worker_thread_index = vdm->first_worker_thread_index;
}
- vm = vlib_mains[cpu_index];
+ vm = vlib_mains[thread_index];
rt = vlib_node_get_runtime_data (vm, hw->input_node_index);
vec_add2 (rt->devices_and_queues, dq, 1);
@@ -136,33 +136,33 @@ vnet_device_input_assign_thread (u32 hw_if_index,
dq->queue_id = queue_id;
vec_sort_with_function (rt->devices_and_queues, vnet_device_queue_sort);
- vec_validate (hw->input_node_cpu_index_by_queue, queue_id);
- hw->input_node_cpu_index_by_queue[queue_id] = cpu_index;
+ vec_validate (hw->input_node_thread_index_by_queue, queue_id);
+ hw->input_node_thread_index_by_queue[queue_id] = thread_index;
}
static int
vnet_device_input_unassign_thread (u32 hw_if_index, u16 queue_id,
- uword cpu_index)
+ uword thread_index)
{
vnet_main_t *vnm = vnet_get_main ();
vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
vnet_device_input_runtime_t *rt;
vnet_device_and_queue_t *dq;
- uword old_cpu_index;
+ uword old_thread_index;
- if (hw->input_node_cpu_index_by_queue == 0)
+ if (hw->input_node_thread_index_by_queue == 0)
return VNET_API_ERROR_INVALID_INTERFACE;
- if (vec_len (hw->input_node_cpu_index_by_queue) < queue_id + 1)
+ if (vec_len (hw->input_node_thread_index_by_queue) < queue_id + 1)
return VNET_API_ERROR_INVALID_INTERFACE;
- old_cpu_index = hw->input_node_cpu_index_by_queue[queue_id];
+ old_thread_index = hw->input_node_thread_index_by_queue[queue_id];
- if (old_cpu_index == cpu_index)
+ if (old_thread_index == thread_index)
return 0;
rt =
- vlib_node_get_runtime_data (vlib_mains[old_cpu_index],
+ vlib_node_get_runtime_data (vlib_mains[old_thread_index],
hw->input_node_index);
vec_foreach (dq, rt->devices_and_queues)
@@ -240,7 +240,7 @@ set_device_placement (vlib_main_t * vm, unformat_input_t * input,
vnet_device_main_t *vdm = &vnet_device_main;
u32 hw_if_index = (u32) ~ 0;
u32 queue_id = (u32) 0;
- u32 cpu_index = (u32) ~ 0;
+ u32 thread_index = (u32) ~ 0;
int rv;
if (!unformat_user (input, unformat_line_input, line_input))
@@ -253,10 +253,10 @@ set_device_placement (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (line_input, "queue %d", &queue_id))
;
- else if (unformat (line_input, "main", &cpu_index))
- cpu_index = 0;
- else if (unformat (line_input, "worker %d", &cpu_index))
- cpu_index += vdm->first_worker_cpu_index;
+ else if (unformat (line_input, "main", &thread_index))
+ thread_index = 0;
+ else if (unformat (line_input, "worker %d", &thread_index))
+ thread_index += vdm->first_worker_thread_index;
else
{
error = clib_error_return (0, "parse error: '%U'",
@@ -271,16 +271,17 @@ set_device_placement (vlib_main_t * vm, unformat_input_t * input,
if (hw_if_index == (u32) ~ 0)
return clib_error_return (0, "please specify valid interface name");
- if (cpu_index > vdm->last_worker_cpu_index)
+ if (thread_index > vdm->last_worker_thread_index)
return clib_error_return (0,
"please specify valid worker thread or main");
- rv = vnet_device_input_unassign_thread (hw_if_index, queue_id, cpu_index);
+ rv =
+ vnet_device_input_unassign_thread (hw_if_index, queue_id, thread_index);
if (rv)
return clib_error_return (0, "not found");
- vnet_device_input_assign_thread (hw_if_index, queue_id, cpu_index);
+ vnet_device_input_assign_thread (hw_if_index, queue_id, thread_index);
return 0;
}
@@ -326,9 +327,9 @@ vnet_device_init (vlib_main_t * vm)
tr = p ? (vlib_thread_registration_t *) p[0] : 0;
if (tr && tr->count > 0)
{
- vdm->first_worker_cpu_index = tr->first_index;
- vdm->next_worker_cpu_index = tr->first_index;
- vdm->last_worker_cpu_index = tr->first_index + tr->count - 1;
+ vdm->first_worker_thread_index = tr->first_index;
+ vdm->next_worker_thread_index = tr->first_index;
+ vdm->last_worker_thread_index = tr->first_index + tr->count - 1;
}
return 0;
}
diff --git a/src/vnet/devices/devices.h b/src/vnet/devices/devices.h
index bbb29fe301c..966f8302230 100644
--- a/src/vnet/devices/devices.h
+++ b/src/vnet/devices/devices.h
@@ -50,9 +50,9 @@ typedef struct
typedef struct
{
vnet_device_per_worker_data_t *workers;
- uword first_worker_cpu_index;
- uword last_worker_cpu_index;
- uword next_worker_cpu_index;
+ uword first_worker_thread_index;
+ uword last_worker_thread_index;
+ uword next_worker_thread_index;
} vnet_device_main_t;
typedef struct
@@ -80,7 +80,7 @@ vnet_set_device_input_node (u32 hw_if_index, u32 node_index)
}
void vnet_device_input_assign_thread (u32 hw_if_index, u16 queue_id,
- uword cpu_index);
+ uword thread_index);
static inline u64
vnet_get_aggregate_rx_packets (void)
@@ -95,12 +95,12 @@ vnet_get_aggregate_rx_packets (void)
}
static inline void
-vnet_device_increment_rx_packets (u32 cpu_index, u64 count)
+vnet_device_increment_rx_packets (u32 thread_index, u64 count)
{
vnet_device_main_t *vdm = &vnet_device_main;
vnet_device_per_worker_data_t *pwd;
- pwd = vec_elt_at_index (vdm->workers, cpu_index);
+ pwd = vec_elt_at_index (vdm->workers, thread_index);
pwd->aggregate_rx_packets += count;
}
@@ -117,9 +117,9 @@ vnet_device_input_set_interrupt_pending (vnet_main_t * vnm, u32 hw_if_index,
{
vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, hw_if_index);
- ASSERT (queue_id < vec_len (hw->input_node_cpu_index_by_queue));
- u32 cpu_index = hw->input_node_cpu_index_by_queue[queue_id];
- vlib_node_set_interrupt_pending (vlib_mains[cpu_index],
+ ASSERT (queue_id < vec_len (hw->input_node_thread_index_by_queue));
+ u32 thread_index = hw->input_node_thread_index_by_queue[queue_id];
+ vlib_node_set_interrupt_pending (vlib_mains[thread_index],
hw->input_node_index);
}
diff --git a/src/vnet/devices/netmap/node.c b/src/vnet/devices/netmap/node.c
index 68ea7832614..e120eeaeabd 100644
--- a/src/vnet/devices/netmap/node.c
+++ b/src/vnet/devices/netmap/node.c
@@ -98,22 +98,22 @@ 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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 n_buffer_bytes = vlib_buffer_free_list_buffer_size (vm,
VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
if (nif->per_interface_next_index != ~0)
next_index = nif->per_interface_next_index;
- n_free_bufs = vec_len (nm->rx_buffers[cpu_index]);
+ n_free_bufs = vec_len (nm->rx_buffers[thread_index]);
if (PREDICT_FALSE (n_free_bufs < VLIB_FRAME_SIZE))
{
- vec_validate (nm->rx_buffers[cpu_index],
+ vec_validate (nm->rx_buffers[thread_index],
VLIB_FRAME_SIZE + n_free_bufs - 1);
n_free_bufs +=
- vlib_buffer_alloc (vm, &nm->rx_buffers[cpu_index][n_free_bufs],
+ vlib_buffer_alloc (vm, &nm->rx_buffers[thread_index][n_free_bufs],
VLIB_FRAME_SIZE);
- _vec_len (nm->rx_buffers[cpu_index]) = n_free_bufs;
+ _vec_len (nm->rx_buffers[thread_index]) = n_free_bufs;
}
cur_ring = nif->first_rx_ring;
@@ -163,11 +163,11 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_buffer_t *b0;
/* grab free buffer */
u32 last_empty_buffer =
- vec_len (nm->rx_buffers[cpu_index]) - 1;
+ vec_len (nm->rx_buffers[thread_index]) - 1;
prev_bi0 = bi0;
- bi0 = nm->rx_buffers[cpu_index][last_empty_buffer];
+ bi0 = nm->rx_buffers[thread_index][last_empty_buffer];
b0 = vlib_get_buffer (vm, bi0);
- _vec_len (nm->rx_buffers[cpu_index]) = last_empty_buffer;
+ _vec_len (nm->rx_buffers[thread_index]) = last_empty_buffer;
n_free_bufs--;
/* copy data */
@@ -247,9 +247,9 @@ netmap_device_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_increment_combined_counter
(vnet_get_main ()->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number (), nif->hw_if_index, n_rx_packets, n_rx_bytes);
+ vlib_get_thread_index (), nif->hw_if_index, n_rx_packets, n_rx_bytes);
- vnet_device_increment_rx_packets (cpu_index, n_rx_packets);
+ vnet_device_increment_rx_packets (thread_index, n_rx_packets);
return n_rx_packets;
}
@@ -260,7 +260,7 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
int i;
u32 n_rx_packets = 0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
netmap_main_t *nm = &netmap_main;
netmap_if_t *nmi;
@@ -269,7 +269,7 @@ netmap_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
nmi = vec_elt_at_index (nm->interfaces, i);
if (nmi->is_admin_up &&
(i % nm->input_cpu_count) ==
- (cpu_index - nm->input_cpu_first_index))
+ (thread_index - nm->input_cpu_first_index))
n_rx_packets += netmap_device_input_fn (vm, node, frame, nmi);
}
diff --git a/src/vnet/devices/ssvm/node.c b/src/vnet/devices/ssvm/node.c
index a6c9dfd771d..539b4161d7a 100644
--- a/src/vnet/devices/ssvm/node.c
+++ b/src/vnet/devices/ssvm/node.c
@@ -89,7 +89,7 @@ ssvm_eth_device_input (ssvm_eth_main_t * em,
ethernet_header_t *eh0;
u16 type0;
u32 n_rx_bytes = 0, l3_offset0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 trace_cnt __attribute__ ((unused)) = vlib_get_trace_count (vm, node);
volatile u32 *lock;
u32 *elt_indices;
@@ -284,10 +284,10 @@ out:
vlib_increment_combined_counter
(vnet_get_main ()->interface_main.combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_RX, cpu_index,
+ + VNET_INTERFACE_COUNTER_RX, thread_index,
intfc->vlib_hw_if_index, rx_queue_index, n_rx_bytes);
- vnet_device_increment_rx_packets (cpu_index, rx_queue_index);
+ vnet_device_increment_rx_packets (thread_index, rx_queue_index);
return rx_queue_index;
}
diff --git a/src/vnet/devices/virtio/vhost-user.c b/src/vnet/devices/virtio/vhost-user.c
index 00807dc0398..5e720f6510a 100644
--- a/src/vnet/devices/virtio/vhost-user.c
+++ b/src/vnet/devices/virtio/vhost-user.c
@@ -331,7 +331,7 @@ vhost_user_tx_thread_placement (vhost_user_intf_t * vui)
{
//Let's try to assign one queue to each thread
u32 qid = 0;
- u32 cpu_index = 0;
+ u32 thread_index = 0;
vui->use_tx_spinlock = 0;
while (1)
{
@@ -341,20 +341,21 @@ vhost_user_tx_thread_placement (vhost_user_intf_t * vui)
if (!rxvq->started || !rxvq->enabled)
continue;
- vui->per_cpu_tx_qid[cpu_index] = qid;
- cpu_index++;
- if (cpu_index == vlib_get_thread_main ()->n_vlib_mains)
+ vui->per_cpu_tx_qid[thread_index] = qid;
+ thread_index++;
+ if (thread_index == vlib_get_thread_main ()->n_vlib_mains)
return;
}
//We need to loop, meaning the spinlock has to be used
vui->use_tx_spinlock = 1;
- if (cpu_index == 0)
+ if (thread_index == 0)
{
//Could not find a single valid one
- for (cpu_index = 0;
- cpu_index < vlib_get_thread_main ()->n_vlib_mains; cpu_index++)
+ for (thread_index = 0;
+ thread_index < vlib_get_thread_main ()->n_vlib_mains;
+ thread_index++)
{
- vui->per_cpu_tx_qid[cpu_index] = 0;
+ vui->per_cpu_tx_qid[thread_index] = 0;
}
return;
}
@@ -368,7 +369,7 @@ vhost_user_rx_thread_placement ()
vhost_user_intf_t *vui;
vhost_cpu_t *vhc;
u32 *workers = 0;
- u32 cpu_index;
+ u32 thread_index;
vlib_main_t *vm;
//Let's list all workers cpu indexes
@@ -400,9 +401,9 @@ vhost_user_rx_thread_placement ()
continue;
i %= vec_len (vui_workers);
- cpu_index = vui_workers[i];
+ thread_index = vui_workers[i];
i++;
- vhc = &vum->cpus[cpu_index];
+ vhc = &vum->cpus[thread_index];
iaq.qid = qid;
iaq.vhost_iface_index = vui - vum->vhost_user_interfaces;
@@ -429,14 +430,14 @@ vhost_user_rx_thread_placement ()
vhc->operation_mode = mode;
}
- for (cpu_index = vum->input_cpu_first_index;
- cpu_index < vum->input_cpu_first_index + vum->input_cpu_count;
- cpu_index++)
+ for (thread_index = vum->input_cpu_first_index;
+ thread_index < vum->input_cpu_first_index + vum->input_cpu_count;
+ thread_index++)
{
vlib_node_state_t state = VLIB_NODE_STATE_POLLING;
- vhc = &vum->cpus[cpu_index];
- vm = vlib_mains ? vlib_mains[cpu_index] : &vlib_global_main;
+ vhc = &vum->cpus[thread_index];
+ vm = vlib_mains ? vlib_mains[thread_index] : &vlib_global_main;
switch (vhc->operation_mode)
{
case VHOST_USER_INTERRUPT_MODE:
@@ -532,7 +533,7 @@ vhost_user_set_interrupt_pending (vhost_user_intf_t * vui, u32 ifq)
{
vhost_user_main_t *vum = &vhost_user_main;
vhost_cpu_t *vhc;
- u32 cpu_index;
+ u32 thread_index;
vhost_iface_and_queue_t *vhiq;
vlib_main_t *vm;
u32 ifq2;
@@ -553,8 +554,8 @@ vhost_user_set_interrupt_pending (vhost_user_intf_t * vui, u32 ifq)
if ((vhiq->vhost_iface_index == (ifq >> 8)) &&
(VHOST_VRING_IDX_TX (vhiq->qid) == (ifq & 0xff)))
{
- cpu_index = vhc - vum->cpus;
- vm = vlib_mains ? vlib_mains[cpu_index] : &vlib_global_main;
+ thread_index = vhc - vum->cpus;
+ vm = vlib_mains ? vlib_mains[thread_index] : &vlib_global_main;
/*
* Convert RX virtqueue number in the lower byte to vring
* queue index for the input node process. Top bytes contain
@@ -1592,7 +1593,7 @@ vhost_user_if_input (vlib_main_t * vm,
u32 n_trace = vlib_get_trace_count (vm, node);
u16 qsz_mask;
u32 map_hint = 0;
- u16 cpu_index = os_get_cpu_number ();
+ u16 thread_index = vlib_get_thread_index ();
u16 copy_len = 0;
{
@@ -1651,32 +1652,32 @@ vhost_user_if_input (vlib_main_t * vm,
* in the loop and come back later. This is not an issue as for big packet,
* processing cost really comes from the memory copy.
*/
- if (PREDICT_FALSE (vum->cpus[cpu_index].rx_buffers_len < n_left + 1))
+ if (PREDICT_FALSE (vum->cpus[thread_index].rx_buffers_len < n_left + 1))
{
- u32 curr_len = vum->cpus[cpu_index].rx_buffers_len;
- vum->cpus[cpu_index].rx_buffers_len +=
+ u32 curr_len = vum->cpus[thread_index].rx_buffers_len;
+ vum->cpus[thread_index].rx_buffers_len +=
vlib_buffer_alloc_from_free_list (vm,
- vum->cpus[cpu_index].rx_buffers +
+ vum->cpus[thread_index].rx_buffers +
curr_len,
VHOST_USER_RX_BUFFERS_N - curr_len,
VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX);
if (PREDICT_FALSE
- (vum->cpus[cpu_index].rx_buffers_len <
+ (vum->cpus[thread_index].rx_buffers_len <
VHOST_USER_RX_BUFFER_STARVATION))
{
/* In case of buffer starvation, discard some packets from the queue
* and log the event.
* We keep doing best effort for the remaining packets. */
- u32 flush = (n_left + 1 > vum->cpus[cpu_index].rx_buffers_len) ?
- n_left + 1 - vum->cpus[cpu_index].rx_buffers_len : 1;
+ u32 flush = (n_left + 1 > vum->cpus[thread_index].rx_buffers_len) ?
+ n_left + 1 - vum->cpus[thread_index].rx_buffers_len : 1;
flush = vhost_user_rx_discard_packet (vm, vui, txvq, flush);
n_left -= flush;
vlib_increment_simple_counter (vnet_main.
interface_main.sw_if_counters +
VNET_INTERFACE_COUNTER_DROP,
- os_get_cpu_number (),
+ vlib_get_thread_index (),
vui->sw_if_index, flush);
vlib_error_count (vm, vhost_user_input_node.index,
@@ -1696,7 +1697,7 @@ vhost_user_if_input (vlib_main_t * vm,
u32 desc_data_offset;
vring_desc_t *desc_table = txvq->desc;
- if (PREDICT_FALSE (vum->cpus[cpu_index].rx_buffers_len <= 1))
+ if (PREDICT_FALSE (vum->cpus[thread_index].rx_buffers_len <= 1))
{
/* Not enough rx_buffers
* Note: We yeld on 1 so we don't need to do an additional
@@ -1707,17 +1708,18 @@ vhost_user_if_input (vlib_main_t * vm,
}
desc_current = txvq->avail->ring[txvq->last_avail_idx & qsz_mask];
- vum->cpus[cpu_index].rx_buffers_len--;
- bi_current = (vum->cpus[cpu_index].rx_buffers)
- [vum->cpus[cpu_index].rx_buffers_len];
+ vum->cpus[thread_index].rx_buffers_len--;
+ bi_current = (vum->cpus[thread_index].rx_buffers)
+ [vum->cpus[thread_index].rx_buffers_len];
b_head = b_current = vlib_get_buffer (vm, bi_current);
to_next[0] = bi_current; //We do that now so we can forget about bi_current
to_next++;
n_left_to_next--;
vlib_prefetch_buffer_with_index (vm,
- (vum->cpus[cpu_index].rx_buffers)
- [vum->cpus[cpu_index].
+ (vum->
+ cpus[thread_index].rx_buffers)
+ [vum->cpus[thread_index].
rx_buffers_len - 1], LOAD);
/* Just preset the used descriptor id and length for later */
@@ -1791,7 +1793,7 @@ vhost_user_if_input (vlib_main_t * vm,
(b_current->current_length == VLIB_BUFFER_DATA_SIZE))
{
if (PREDICT_FALSE
- (vum->cpus[cpu_index].rx_buffers_len == 0))
+ (vum->cpus[thread_index].rx_buffers_len == 0))
{
/* Cancel speculation */
to_next--;
@@ -1805,17 +1807,18 @@ vhost_user_if_input (vlib_main_t * vm,
* but valid.
*/
vhost_user_input_rewind_buffers (vm,
- &vum->cpus[cpu_index],
+ &vum->cpus
+ [thread_index],
b_head);
n_left = 0;
goto stop;
}
/* Get next output */
- vum->cpus[cpu_index].rx_buffers_len--;
+ vum->cpus[thread_index].rx_buffers_len--;
u32 bi_next =
- (vum->cpus[cpu_index].rx_buffers)[vum->cpus
- [cpu_index].rx_buffers_len];
+ (vum->cpus[thread_index].rx_buffers)[vum->cpus
+ [thread_index].rx_buffers_len];
b_current->next_buffer = bi_next;
b_current->flags |= VLIB_BUFFER_NEXT_PRESENT;
bi_current = bi_next;
@@ -1823,7 +1826,7 @@ vhost_user_if_input (vlib_main_t * vm,
}
/* Prepare a copy order executed later for the data */
- vhost_copy_t *cpy = &vum->cpus[cpu_index].copy[copy_len];
+ vhost_copy_t *cpy = &vum->cpus[thread_index].copy[copy_len];
copy_len++;
u32 desc_data_l =
desc_table[desc_current].len - desc_data_offset;
@@ -1880,7 +1883,7 @@ vhost_user_if_input (vlib_main_t * vm,
if (PREDICT_FALSE (copy_len >= VHOST_USER_RX_COPY_THRESHOLD))
{
if (PREDICT_FALSE
- (vhost_user_input_copy (vui, vum->cpus[cpu_index].copy,
+ (vhost_user_input_copy (vui, vum->cpus[thread_index].copy,
copy_len, &map_hint)))
{
clib_warning
@@ -1905,7 +1908,7 @@ vhost_user_if_input (vlib_main_t * vm,
/* Do the memory copies */
if (PREDICT_FALSE
- (vhost_user_input_copy (vui, vum->cpus[cpu_index].copy,
+ (vhost_user_input_copy (vui, vum->cpus[thread_index].copy,
copy_len, &map_hint)))
{
clib_warning ("Memory mapping error on interface hw_if_index=%d "
@@ -1933,9 +1936,9 @@ vhost_user_if_input (vlib_main_t * vm,
vlib_increment_combined_counter
(vnet_main.interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number (), vui->sw_if_index, n_rx_packets, n_rx_bytes);
+ vlib_get_thread_index (), vui->sw_if_index, n_rx_packets, n_rx_bytes);
- vnet_device_increment_rx_packets (cpu_index, n_rx_packets);
+ vnet_device_increment_rx_packets (thread_index, n_rx_packets);
return n_rx_packets;
}
@@ -1946,15 +1949,15 @@ vhost_user_input (vlib_main_t * vm,
{
vhost_user_main_t *vum = &vhost_user_main;
uword n_rx_packets = 0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
vhost_iface_and_queue_t *vhiq;
vhost_user_intf_t *vui;
vhost_cpu_t *vhc;
- vhc = &vum->cpus[cpu_index];
+ vhc = &vum->cpus[thread_index];
if (PREDICT_TRUE (vhc->operation_mode == VHOST_USER_POLLING_MODE))
{
- vec_foreach (vhiq, vum->cpus[cpu_index].rx_queues)
+ vec_foreach (vhiq, vum->cpus[thread_index].rx_queues)
{
vui = &vum->vhost_user_interfaces[vhiq->vhost_iface_index];
n_rx_packets += vhost_user_if_input (vm, vum, vui, vhiq->qid, node);
@@ -2096,7 +2099,7 @@ vhost_user_tx (vlib_main_t * vm,
vhost_user_vring_t *rxvq;
u16 qsz_mask;
u8 error;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 map_hint = 0;
u8 retry = 8;
u16 copy_len;
@@ -2116,7 +2119,7 @@ vhost_user_tx (vlib_main_t * vm,
qid =
VHOST_VRING_IDX_RX (*vec_elt_at_index
- (vui->per_cpu_tx_qid, os_get_cpu_number ()));
+ (vui->per_cpu_tx_qid, vlib_get_thread_index ()));
rxvq = &vui->vrings[qid];
if (PREDICT_FALSE (vui->use_tx_spinlock))
vhost_user_vring_lock (vui, qid);
@@ -2143,10 +2146,10 @@ retry:
if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
{
- vum->cpus[cpu_index].current_trace =
+ vum->cpus[thread_index].current_trace =
vlib_add_trace (vm, node, b0,
- sizeof (*vum->cpus[cpu_index].current_trace));
- vhost_user_tx_trace (vum->cpus[cpu_index].current_trace,
+ sizeof (*vum->cpus[thread_index].current_trace));
+ vhost_user_tx_trace (vum->cpus[thread_index].current_trace,
vui, qid / 2, b0, rxvq);
}
@@ -2188,14 +2191,14 @@ retry:
{
// Get a header from the header array
virtio_net_hdr_mrg_rxbuf_t *hdr =
- &vum->cpus[cpu_index].tx_headers[tx_headers_len];
+ &vum->cpus[thread_index].tx_headers[tx_headers_len];
tx_headers_len++;
hdr->hdr.flags = 0;
hdr->hdr.gso_type = 0;
hdr->num_buffers = 1; //This is local, no need to check
// Prepare a copy order executed later for the header
- vhost_copy_t *cpy = &vum->cpus[cpu_index].copy[copy_len];
+ vhost_copy_t *cpy = &vum->cpus[thread_index].copy[copy_len];
copy_len++;
cpy->len = vui->virtio_net_hdr_sz;
cpy->dst = buffer_map_addr;
@@ -2220,7 +2223,7 @@ retry:
else if (vui->virtio_net_hdr_sz == 12) //MRG is available
{
virtio_net_hdr_mrg_rxbuf_t *hdr =
- &vum->cpus[cpu_index].tx_headers[tx_headers_len - 1];
+ &vum->cpus[thread_index].tx_headers[tx_headers_len - 1];
//Move from available to used buffer
rxvq->used->ring[rxvq->last_used_idx & qsz_mask].id =
@@ -2282,7 +2285,7 @@ retry:
}
{
- vhost_copy_t *cpy = &vum->cpus[cpu_index].copy[copy_len];
+ vhost_copy_t *cpy = &vum->cpus[thread_index].copy[copy_len];
copy_len++;
cpy->len = bytes_left;
cpy->len = (cpy->len > buffer_len) ? buffer_len : cpy->len;
@@ -2325,8 +2328,8 @@ retry:
if (PREDICT_FALSE (b0->flags & VLIB_BUFFER_IS_TRACED))
{
- vum->cpus[cpu_index].current_trace->hdr =
- vum->cpus[cpu_index].tx_headers[tx_headers_len - 1];
+ vum->cpus[thread_index].current_trace->hdr =
+ vum->cpus[thread_index].tx_headers[tx_headers_len - 1];
}
n_left--; //At the end for error counting when 'goto done' is invoked
@@ -2336,7 +2339,7 @@ retry:
done:
//Do the memory copies
if (PREDICT_FALSE
- (vhost_user_tx_copy (vui, vum->cpus[cpu_index].copy,
+ (vhost_user_tx_copy (vui, vum->cpus[thread_index].copy,
copy_len, &map_hint)))
{
clib_warning ("Memory mapping error on interface hw_if_index=%d "
@@ -2386,7 +2389,7 @@ done3:
vlib_increment_simple_counter
(vnet_main.interface_main.sw_if_counters
+ VNET_INTERFACE_COUNTER_DROP,
- os_get_cpu_number (), vui->sw_if_index, n_left);
+ vlib_get_thread_index (), vui->sw_if_index, n_left);
}
vlib_buffer_free (vm, vlib_frame_args (frame), frame->n_vectors);
@@ -2773,11 +2776,11 @@ vhost_user_send_interrupt_process (vlib_main_t * vm,
case ~0:
vec_foreach (vhc, vum->cpus)
{
- u32 cpu_index = vhc - vum->cpus;
+ u32 thread_index = vhc - vum->cpus;
f64 next_timeout;
next_timeout = timeout;
- vec_foreach (vhiq, vum->cpus[cpu_index].rx_queues)
+ vec_foreach (vhiq, vum->cpus[thread_index].rx_queues)
{
vui = &vum->vhost_user_interfaces[vhiq->vhost_iface_index];
vhost_user_vring_t *rxvq =
diff --git a/src/vnet/dpo/lookup_dpo.c b/src/vnet/dpo/lookup_dpo.c
index e94e871cd92..97ad0a44cce 100644
--- a/src/vnet/dpo/lookup_dpo.c
+++ b/src/vnet/dpo/lookup_dpo.c
@@ -266,7 +266,7 @@ lookup_dpo_ip4_inline (vlib_main_t * vm,
int table_from_interface)
{
u32 n_left_from, next_index, * from, * to_next;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters;
from = vlib_frame_vector_args (from_frame);
@@ -407,10 +407,10 @@ lookup_dpo_ip4_inline (vlib_main_t * vm,
vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1,
+ (cm, thread_index, lbi1, 1,
vlib_buffer_length_in_chain (vm, b1));
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -511,7 +511,7 @@ lookup_dpo_ip4_inline (vlib_main_t * vm,
vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -606,7 +606,7 @@ lookup_dpo_ip6_inline (vlib_main_t * vm,
{
vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters;
u32 n_left_from, next_index, * from, * to_next;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -749,10 +749,10 @@ lookup_dpo_ip6_inline (vlib_main_t * vm,
vnet_buffer(b1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1,
+ (cm, thread_index, lbi1, 1,
vlib_buffer_length_in_chain (vm, b1));
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -853,7 +853,7 @@ lookup_dpo_ip6_inline (vlib_main_t * vm,
vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -930,7 +930,7 @@ lookup_dpo_mpls_inline (vlib_main_t * vm,
int table_from_interface)
{
u32 n_left_from, next_index, * from, * to_next;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters;
from = vlib_frame_vector_args (from_frame);
@@ -994,7 +994,7 @@ lookup_dpo_mpls_inline (vlib_main_t * vm,
vnet_buffer(b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
diff --git a/src/vnet/dpo/replicate_dpo.c b/src/vnet/dpo/replicate_dpo.c
index a9f334be7cf..e25ceae91fe 100644
--- a/src/vnet/dpo/replicate_dpo.c
+++ b/src/vnet/dpo/replicate_dpo.c
@@ -627,7 +627,7 @@ replicate_inline (vlib_main_t * vm,
vlib_combined_counter_main_t * cm = &replicate_main.repm_counters;
replicate_main_t * rm = &replicate_main;
u32 n_left_from, * from, * to_next, next_index;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -657,12 +657,12 @@ replicate_inline (vlib_main_t * vm,
rep0 = replicate_get(repi0);
vlib_increment_combined_counter(
- cm, cpu_index, repi0, 1,
+ cm, thread_index, repi0, 1,
vlib_buffer_length_in_chain(vm, b0));
- vec_validate (rm->clones[cpu_index], rep0->rep_n_buckets - 1);
+ vec_validate (rm->clones[thread_index], rep0->rep_n_buckets - 1);
- num_cloned = vlib_buffer_clone (vm, bi0, rm->clones[cpu_index], rep0->rep_n_buckets, 128);
+ num_cloned = vlib_buffer_clone (vm, bi0, rm->clones[thread_index], rep0->rep_n_buckets, 128);
if (num_cloned != rep0->rep_n_buckets)
{
@@ -673,7 +673,7 @@ replicate_inline (vlib_main_t * vm,
for (bucket = 0; bucket < num_cloned; bucket++)
{
- ci0 = rm->clones[cpu_index][bucket];
+ ci0 = rm->clones[thread_index][bucket];
c0 = vlib_get_buffer(vm, ci0);
to_next[0] = ci0;
@@ -700,7 +700,7 @@ replicate_inline (vlib_main_t * vm,
vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
}
}
- vec_reset_length (rm->clones[cpu_index]);
+ vec_reset_length (rm->clones[thread_index]);
}
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
diff --git a/src/vnet/ethernet/arp.c b/src/vnet/ethernet/arp.c
index ee757505192..c74a097ec79 100644
--- a/src/vnet/ethernet/arp.c
+++ b/src/vnet/ethernet/arp.c
@@ -1771,7 +1771,7 @@ set_ip4_over_ethernet_rpc_callback (vnet_arp_set_ip4_over_ethernet_rpc_args_t
* a)
{
vnet_main_t *vm = vnet_get_main ();
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
if (a->flags & ETHERNET_ARP_ARGS_REMOVE)
vnet_arp_unset_ip4_over_ethernet_internal (vm, a);
diff --git a/src/vnet/ethernet/interface.c b/src/vnet/ethernet/interface.c
index 9894e3c887b..335e3f9f270 100644
--- a/src/vnet/ethernet/interface.c
+++ b/src/vnet/ethernet/interface.c
@@ -362,7 +362,7 @@ simulated_ethernet_interface_tx (vlib_main_t * vm,
u32 next_index = VNET_SIMULATED_ETHERNET_TX_NEXT_ETHERNET_INPUT;
u32 i, next_node_index, bvi_flag, sw_if_index;
u32 n_pkts = 0, n_bytes = 0;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
vnet_main_t *vnm = vnet_get_main ();
vnet_interface_main_t *im = &vnm->interface_main;
vlib_node_main_t *nm = &vm->node_main;
@@ -420,8 +420,9 @@ simulated_ethernet_interface_tx (vlib_main_t * vm,
/* increment TX interface stat */
vlib_increment_combined_counter (im->combined_sw_if_counters +
- VNET_INTERFACE_COUNTER_TX, cpu_index,
- sw_if_index, n_pkts, n_bytes);
+ VNET_INTERFACE_COUNTER_TX,
+ thread_index, sw_if_index, n_pkts,
+ n_bytes);
}
return n_left_from;
diff --git a/src/vnet/ethernet/node.c b/src/vnet/ethernet/node.c
index b699e381f91..f7787ed21f8 100755
--- a/src/vnet/ethernet/node.c
+++ b/src/vnet/ethernet/node.c
@@ -291,7 +291,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_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 */
@@ -510,7 +510,7 @@ ethernet_input_inline (vlib_main_t * vm,
interface_main.combined_sw_if_counters
+
VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
new_sw_if_index0, 1,
len0);
if (new_sw_if_index1 != old_sw_if_index1
@@ -519,7 +519,7 @@ ethernet_input_inline (vlib_main_t * vm,
interface_main.combined_sw_if_counters
+
VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
new_sw_if_index1, 1,
len1);
@@ -530,7 +530,7 @@ ethernet_input_inline (vlib_main_t * vm,
vlib_increment_combined_counter
(vnm->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
stats_sw_if_index,
stats_n_packets, stats_n_bytes);
stats_n_packets = stats_n_bytes = 0;
@@ -696,13 +696,13 @@ ethernet_input_inline (vlib_main_t * vm,
vlib_increment_combined_counter
(vnm->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index, new_sw_if_index0, 1, len0);
+ thread_index, new_sw_if_index0, 1, len0);
if (stats_n_packets > 0)
{
vlib_increment_combined_counter
(vnm->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
stats_sw_if_index, stats_n_packets, stats_n_bytes);
stats_n_packets = stats_n_bytes = 0;
}
@@ -734,7 +734,7 @@ ethernet_input_inline (vlib_main_t * vm,
vlib_increment_combined_counter
(vnm->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
node->runtime_data[0] = stats_sw_if_index;
}
diff --git a/src/vnet/gre/node.c b/src/vnet/gre/node.c
index 2683586ea8f..acf15f247f0 100644
--- a/src/vnet/gre/node.c
+++ b/src/vnet/gre/node.c
@@ -75,7 +75,7 @@ gre_input (vlib_main_t * vm,
u64 cached_tunnel_key6[4];
u32 cached_tunnel_sw_if_index = 0, tunnel_sw_if_index = 0;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
u32 len;
vnet_interface_main_t *im = &gm->vnet_main->interface_main;
@@ -257,7 +257,7 @@ gre_input (vlib_main_t * vm,
len = vlib_buffer_length_in_chain (vm, b0);
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
tunnel_sw_if_index,
1 /* packets */,
len /* bytes */);
@@ -324,7 +324,7 @@ drop0:
len = vlib_buffer_length_in_chain (vm, b1);
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
tunnel_sw_if_index,
1 /* packets */,
len /* bytes */);
@@ -502,7 +502,7 @@ drop1:
len = vlib_buffer_length_in_chain (vm, b0);
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index,
+ thread_index,
tunnel_sw_if_index,
1 /* packets */,
len /* bytes */);
diff --git a/src/vnet/interface.h b/src/vnet/interface.h
index a1ea2d6184f..08f08b105fc 100644
--- a/src/vnet/interface.h
+++ b/src/vnet/interface.h
@@ -468,7 +468,7 @@ typedef struct vnet_hw_interface_t
u32 input_node_index;
/* input node cpu index by queue */
- u32 *input_node_cpu_index_by_queue;
+ u32 *input_node_thread_index_by_queue;
} vnet_hw_interface_t;
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 03f2cdca7a0..663dc309a22 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -196,7 +196,7 @@ slow_path (vlib_main_t * vm,
*/
static_always_inline void
incr_output_stats (vnet_main_t * vnm,
- u32 cpu_index,
+ u32 thread_index,
u32 length,
u32 sw_if_index,
u32 * last_sw_if_index, u32 * n_packets, u32 * n_bytes)
@@ -216,7 +216,7 @@ incr_output_stats (vnet_main_t * vnm,
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_TX,
- cpu_index,
+ thread_index,
*last_sw_if_index,
*n_packets, *n_bytes);
}
@@ -240,7 +240,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm,
u32 n_left_to_tx, *from, *from_end, *to_tx;
u32 n_bytes, n_buffers, n_packets;
u32 last_sw_if_index;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
n_buffers = frame->n_vectors;
@@ -266,7 +266,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm,
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
VNET_INTERFACE_COUNTER_TX_ERROR);
- vlib_increment_simple_counter (cm, cpu_index,
+ vlib_increment_simple_counter (cm, thread_index,
rt->sw_if_index, n_buffers);
return vlib_error_drop_buffers (vm, node, from,
/* buffer stride */ 1,
@@ -341,18 +341,18 @@ vnet_interface_output_node_flatten (vlib_main_t * vm,
from += 1;
to_tx += n_buffers;
n_left_to_tx -= n_buffers;
- incr_output_stats (vnm, cpu_index, n_slow_bytes,
+ incr_output_stats (vnm, thread_index, n_slow_bytes,
vnet_buffer (b)->sw_if_index[VLIB_TX],
&last_sw_if_index, &n_packets, &n_bytes);
}
}
else
{
- incr_output_stats (vnm, cpu_index,
+ incr_output_stats (vnm, thread_index,
vlib_buffer_length_in_chain (vm, b0),
vnet_buffer (b0)->sw_if_index[VLIB_TX],
&last_sw_if_index, &n_packets, &n_bytes);
- incr_output_stats (vnm, cpu_index,
+ incr_output_stats (vnm, thread_index,
vlib_buffer_length_in_chain (vm, b0),
vnet_buffer (b1)->sw_if_index[VLIB_TX],
&last_sw_if_index, &n_packets, &n_bytes);
@@ -396,7 +396,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm,
to_tx += n_buffers;
n_left_to_tx -= n_buffers;
}
- incr_output_stats (vnm, cpu_index,
+ incr_output_stats (vnm, thread_index,
vlib_buffer_length_in_chain (vm, b0),
vnet_buffer (b0)->sw_if_index[VLIB_TX],
&last_sw_if_index, &n_packets, &n_bytes);
@@ -408,7 +408,7 @@ vnet_interface_output_node_flatten (vlib_main_t * vm,
}
/* Final update of interface stats. */
- incr_output_stats (vnm, cpu_index, 0, ~0, /* ~0 will flush stats */
+ incr_output_stats (vnm, thread_index, 0, ~0, /* ~0 will flush stats */
&last_sw_if_index, &n_packets, &n_bytes);
return n_buffers;
@@ -428,7 +428,7 @@ vnet_interface_output_node (vlib_main_t * vm,
u32 n_left_to_tx, *from, *from_end, *to_tx;
u32 n_bytes, n_buffers, n_packets;
u32 n_bytes_b0, n_bytes_b1, n_bytes_b2, n_bytes_b3;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
vnet_interface_main_t *im = &vnm->interface_main;
u32 next_index = VNET_INTERFACE_OUTPUT_NEXT_TX;
u32 current_config_index = ~0;
@@ -458,7 +458,7 @@ vnet_interface_output_node (vlib_main_t * vm,
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
VNET_INTERFACE_COUNTER_TX_ERROR);
- vlib_increment_simple_counter (cm, cpu_index,
+ vlib_increment_simple_counter (cm, thread_index,
rt->sw_if_index, n_buffers);
return vlib_error_drop_buffers (vm, node, from,
@@ -558,7 +558,7 @@ vnet_interface_output_node (vlib_main_t * vm,
{
vlib_increment_combined_counter (im->combined_sw_if_counters +
VNET_INTERFACE_COUNTER_TX,
- cpu_index, tx_swif0, 1,
+ thread_index, tx_swif0, 1,
n_bytes_b0);
}
@@ -567,7 +567,7 @@ vnet_interface_output_node (vlib_main_t * vm,
vlib_increment_combined_counter (im->combined_sw_if_counters +
VNET_INTERFACE_COUNTER_TX,
- cpu_index, tx_swif1, 1,
+ thread_index, tx_swif1, 1,
n_bytes_b1);
}
@@ -576,7 +576,7 @@ vnet_interface_output_node (vlib_main_t * vm,
vlib_increment_combined_counter (im->combined_sw_if_counters +
VNET_INTERFACE_COUNTER_TX,
- cpu_index, tx_swif2, 1,
+ thread_index, tx_swif2, 1,
n_bytes_b2);
}
if (PREDICT_FALSE (tx_swif3 != rt->sw_if_index))
@@ -584,7 +584,7 @@ vnet_interface_output_node (vlib_main_t * vm,
vlib_increment_combined_counter (im->combined_sw_if_counters +
VNET_INTERFACE_COUNTER_TX,
- cpu_index, tx_swif3, 1,
+ thread_index, tx_swif3, 1,
n_bytes_b3);
}
}
@@ -623,7 +623,7 @@ vnet_interface_output_node (vlib_main_t * vm,
vlib_increment_combined_counter (im->combined_sw_if_counters +
VNET_INTERFACE_COUNTER_TX,
- cpu_index, tx_swif0, 1,
+ thread_index, tx_swif0, 1,
n_bytes_b0);
}
}
@@ -634,7 +634,7 @@ vnet_interface_output_node (vlib_main_t * vm,
/* Update main interface stats. */
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_TX,
- cpu_index,
+ thread_index,
rt->sw_if_index, n_packets, n_bytes);
return n_buffers;
}
@@ -893,7 +893,7 @@ process_drop_punt (vlib_main_t * vm,
u32 current_sw_if_index, n_errors_current_sw_if_index;
u64 current_counter;
vlib_simple_counter_main_t *cm;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
static vlib_error_t memory[VNET_ERROR_N_DISPOSITION];
static char memory_init[VNET_ERROR_N_DISPOSITION];
@@ -965,19 +965,19 @@ process_drop_punt (vlib_main_t * vm,
current_counter -= 2;
n_errors_current_sw_if_index -= 2;
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1);
/* Increment super-interface drop/punt counters for
sub-interfaces. */
sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0);
vlib_increment_simple_counter
- (cm, cpu_index, sw_if0->sup_sw_if_index,
+ (cm, thread_index, sw_if0->sup_sw_if_index,
sw_if0->sup_sw_if_index != sw_if_index0);
sw_if1 = vnet_get_sw_interface (vnm, sw_if_index1);
vlib_increment_simple_counter
- (cm, cpu_index, sw_if1->sup_sw_if_index,
+ (cm, thread_index, sw_if1->sup_sw_if_index,
sw_if1->sup_sw_if_index != sw_if_index1);
em->counters[current_counter_index] = current_counter;
@@ -1013,11 +1013,12 @@ process_drop_punt (vlib_main_t * vm,
sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
/* Increment drop/punt counters. */
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
/* Increment super-interface drop/punt counters for sub-interfaces. */
sw_if0 = vnet_get_sw_interface (vnm, sw_if_index0);
- vlib_increment_simple_counter (cm, cpu_index, sw_if0->sup_sw_if_index,
+ vlib_increment_simple_counter (cm, thread_index,
+ sw_if0->sup_sw_if_index,
sw_if0->sup_sw_if_index != sw_if_index0);
if (PREDICT_FALSE (e0 != current_error))
@@ -1041,12 +1042,12 @@ process_drop_punt (vlib_main_t * vm,
{
vnet_sw_interface_t *si;
- vlib_increment_simple_counter (cm, cpu_index, current_sw_if_index,
+ vlib_increment_simple_counter (cm, thread_index, current_sw_if_index,
n_errors_current_sw_if_index);
si = vnet_get_sw_interface (vnm, current_sw_if_index);
if (si->sup_sw_if_index != current_sw_if_index)
- vlib_increment_simple_counter (cm, cpu_index, si->sup_sw_if_index,
+ vlib_increment_simple_counter (cm, thread_index, si->sup_sw_if_index,
n_errors_current_sw_if_index);
}
diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c
index ee1703e735e..fdfe7f63dfc 100644
--- a/src/vnet/ip/ip4_forward.c
+++ b/src/vnet/ip/ip4_forward.c
@@ -75,7 +75,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -292,19 +292,19 @@ ip4_lookup_inline (vlib_main_t * vm,
vnet_buffer (p3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lb_index0, 1,
+ (cm, thread_index, lb_index0, 1,
vlib_buffer_length_in_chain (vm, p0)
+ sizeof (ethernet_header_t));
vlib_increment_combined_counter
- (cm, cpu_index, lb_index1, 1,
+ (cm, thread_index, lb_index1, 1,
vlib_buffer_length_in_chain (vm, p1)
+ sizeof (ethernet_header_t));
vlib_increment_combined_counter
- (cm, cpu_index, lb_index2, 1,
+ (cm, thread_index, lb_index2, 1,
vlib_buffer_length_in_chain (vm, p2)
+ sizeof (ethernet_header_t));
vlib_increment_combined_counter
- (cm, cpu_index, lb_index3, 1,
+ (cm, thread_index, lb_index3, 1,
vlib_buffer_length_in_chain (vm, p3)
+ sizeof (ethernet_header_t));
@@ -392,7 +392,7 @@ ip4_lookup_inline (vlib_main_t * vm,
vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
from += 1;
to_next += 1;
@@ -479,7 +479,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -584,9 +584,9 @@ ip4_load_balance (vlib_main_t * vm,
vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
+ (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
vlib_validate_buffer_enqueue_x2 (vm, node, next,
to_next, n_left_to_next,
@@ -639,7 +639,7 @@ ip4_load_balance (vlib_main_t * vm,
vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
vlib_validate_buffer_enqueue_x1 (vm, node, next,
to_next, n_left_to_next,
@@ -2330,7 +2330,7 @@ ip4_rewrite_inline (vlib_main_t * vm,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -2379,9 +2379,9 @@ ip4_rewrite_inline (vlib_main_t * vm,
if (do_counters)
{
vlib_prefetch_combined_counter (&adjacency_counters,
- cpu_index, adj_index0);
+ thread_index, adj_index0);
vlib_prefetch_combined_counter (&adjacency_counters,
- cpu_index, adj_index1);
+ thread_index, adj_index1);
}
ip0 = vlib_buffer_get_current (p0);
@@ -2527,13 +2527,13 @@ ip4_rewrite_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index0, 1,
vlib_buffer_length_in_chain (vm, p0) + rw_len0);
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index1, 1,
vlib_buffer_length_in_chain (vm, p1) + rw_len1);
}
@@ -2618,7 +2618,7 @@ ip4_rewrite_inline (vlib_main_t * vm,
if (do_counters)
vlib_prefetch_combined_counter (&adjacency_counters,
- cpu_index, adj_index0);
+ thread_index, adj_index0);
/* Guess we are only writing on simple Ethernet header. */
vnet_rewrite_one_header (adj0[0], ip0, sizeof (ethernet_header_t));
@@ -2637,7 +2637,7 @@ ip4_rewrite_inline (vlib_main_t * vm,
if (do_counters)
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index, adj_index0, 1,
+ thread_index, adj_index0, 1,
vlib_buffer_length_in_chain (vm, p0) + rw_len0);
/* Check MTU of outgoing interface. */
diff --git a/src/vnet/ip/ip4_input.c b/src/vnet/ip/ip4_input.c
index ba200a9fe13..3b08f4b0089 100644
--- a/src/vnet/ip/ip4_input.c
+++ b/src/vnet/ip/ip4_input.c
@@ -85,7 +85,7 @@ ip4_input_inline (vlib_main_t * vm,
vlib_node_runtime_t *error_node =
vlib_node_get_runtime (vm, ip4_input_node.index);
vlib_simple_counter_main_t *cm;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -178,8 +178,8 @@ ip4_input_inline (vlib_main_t * vm,
vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0);
vnet_feature_arc_start (arc1, sw_if_index1, &next1, p1);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1);
/* Punt packets with options or wrong version. */
if (PREDICT_FALSE (ip0->ip_version_and_header_length != 0x45))
@@ -299,7 +299,7 @@ ip4_input_inline (vlib_main_t * vm,
vnet_buffer (p0)->ip.adj_index[VLIB_RX] = ~0;
vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
/* Punt packets with options or wrong version. */
if (PREDICT_FALSE (ip0->ip_version_and_header_length != 0x45))
diff --git a/src/vnet/ip/ip6_forward.c b/src/vnet/ip/ip6_forward.c
index c120f12cfbd..c2fc4f873f2 100644
--- a/src/vnet/ip/ip6_forward.c
+++ b/src/vnet/ip/ip6_forward.c
@@ -74,7 +74,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -185,9 +185,9 @@ ip6_lookup_inline (vlib_main_t * vm,
vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
+ (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
from += 2;
to_next += 2;
@@ -291,7 +291,7 @@ ip6_lookup_inline (vlib_main_t * vm,
vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
from += 1;
to_next += 1;
@@ -703,7 +703,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
ip6_main_t *im = &ip6_main;
from = vlib_frame_vector_args (frame);
@@ -824,9 +824,9 @@ ip6_load_balance (vlib_main_t * vm,
vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
+ (cm, thread_index, lbi1, 1, vlib_buffer_length_in_chain (vm, p1));
vlib_validate_buffer_enqueue_x2 (vm, node, next,
to_next, n_left_to_next,
@@ -886,7 +886,7 @@ ip6_load_balance (vlib_main_t * vm,
}
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
+ (cm, thread_index, lbi0, 1, vlib_buffer_length_in_chain (vm, p0));
vlib_validate_buffer_enqueue_x1 (vm, node, next,
to_next, n_left_to_next,
@@ -1897,7 +1897,7 @@ ip6_rewrite_inline (vlib_main_t * vm,
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -2019,11 +2019,11 @@ ip6_rewrite_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index, adj_index0, 1,
+ thread_index, adj_index0, 1,
vlib_buffer_length_in_chain (vm, p0) + rw_len0);
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index, adj_index1, 1,
+ thread_index, adj_index1, 1,
vlib_buffer_length_in_chain (vm, p1) + rw_len1);
}
@@ -2156,7 +2156,7 @@ ip6_rewrite_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index, adj_index0, 1,
+ thread_index, adj_index0, 1,
vlib_buffer_length_in_chain (vm, p0) + rw_len0);
}
diff --git a/src/vnet/ip/ip6_input.c b/src/vnet/ip/ip6_input.c
index 20306088611..ffdc4727660 100644
--- a/src/vnet/ip/ip6_input.c
+++ b/src/vnet/ip/ip6_input.c
@@ -82,7 +82,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -171,8 +171,8 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0);
vnet_feature_arc_start (arc1, sw_if_index1, &next1, p1);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1);
error0 = error1 = IP6_ERROR_NONE;
@@ -270,7 +270,7 @@ ip6_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
vnet_buffer (p0)->ip.adj_index[VLIB_RX] = ~0;
vnet_feature_arc_start (arc0, sw_if_index0, &next0, p0);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
error0 = IP6_ERROR_NONE;
/* Version != 6? Drop it. */
diff --git a/src/vnet/ip/ip6_neighbor.c b/src/vnet/ip/ip6_neighbor.c
index 5d1fb6f8994..2af546df8de 100644
--- a/src/vnet/ip/ip6_neighbor.c
+++ b/src/vnet/ip/ip6_neighbor.c
@@ -581,7 +581,7 @@ vnet_set_ip6_ethernet_neighbor (vlib_main_t * vm,
u32 next_index;
pending_resolution_t *pr, *mc;
- if (os_get_cpu_number ())
+ if (vlib_get_thread_index ())
{
set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address,
1 /* set new neighbor */ , is_static,
@@ -722,7 +722,7 @@ vnet_unset_ip6_ethernet_neighbor (vlib_main_t * vm,
uword *p;
int rv = 0;
- if (os_get_cpu_number ())
+ if (vlib_get_thread_index ())
{
set_unset_ip6_neighbor_rpc (vm, sw_if_index, a, link_layer_address,
0 /* unset */ , 0, 0);
diff --git a/src/vnet/ipsec/esp.h b/src/vnet/ipsec/esp.h
index 50cac806d14..799003b9e61 100644
--- a/src/vnet/ipsec/esp.h
+++ b/src/vnet/ipsec/esp.h
@@ -282,8 +282,8 @@ hmac_calc (ipsec_integ_alg_t alg,
u8 * data, int data_len, u8 * signature, u8 use_esn, u32 seq_hi)
{
esp_main_t *em = &esp_main;
- u32 cpu_index = os_get_cpu_number ();
- HMAC_CTX *ctx = &(em->per_thread_data[cpu_index].hmac_ctx);
+ u32 thread_index = vlib_get_thread_index ();
+ HMAC_CTX *ctx = &(em->per_thread_data[thread_index].hmac_ctx);
const EVP_MD *md = NULL;
unsigned int len;
@@ -292,10 +292,10 @@ hmac_calc (ipsec_integ_alg_t alg,
if (PREDICT_FALSE (em->esp_integ_algs[alg].md == 0))
return 0;
- if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_integ_alg))
+ if (PREDICT_FALSE (alg != em->per_thread_data[thread_index].last_integ_alg))
{
md = em->esp_integ_algs[alg].md;
- em->per_thread_data[cpu_index].last_integ_alg = alg;
+ em->per_thread_data[thread_index].last_integ_alg = alg;
}
HMAC_Init (ctx, key, key_len, md);
diff --git a/src/vnet/ipsec/esp_decrypt.c b/src/vnet/ipsec/esp_decrypt.c
index 7289b260e22..925d2b4544a 100644
--- a/src/vnet/ipsec/esp_decrypt.c
+++ b/src/vnet/ipsec/esp_decrypt.c
@@ -85,8 +85,8 @@ esp_decrypt_aes_cbc (ipsec_crypto_alg_t alg,
u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv)
{
esp_main_t *em = &esp_main;
- u32 cpu_index = os_get_cpu_number ();
- EVP_CIPHER_CTX *ctx = &(em->per_thread_data[cpu_index].decrypt_ctx);
+ u32 thread_index = vlib_get_thread_index ();
+ EVP_CIPHER_CTX *ctx = &(em->per_thread_data[thread_index].decrypt_ctx);
const EVP_CIPHER *cipher = NULL;
int out_len;
@@ -95,10 +95,11 @@ esp_decrypt_aes_cbc (ipsec_crypto_alg_t alg,
if (PREDICT_FALSE (em->esp_crypto_algs[alg].type == 0))
return;
- if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_decrypt_alg))
+ if (PREDICT_FALSE
+ (alg != em->per_thread_data[thread_index].last_decrypt_alg))
{
cipher = em->esp_crypto_algs[alg].type;
- em->per_thread_data[cpu_index].last_decrypt_alg = alg;
+ em->per_thread_data[thread_index].last_decrypt_alg = alg;
}
EVP_DecryptInit_ex (ctx, cipher, NULL, key, iv);
@@ -117,11 +118,11 @@ esp_decrypt_node_fn (vlib_main_t * vm,
u32 *recycle = 0;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
ipsec_alloc_empty_buffers (vm, im);
- u32 *empty_buffers = im->empty_buffers[cpu_index];
+ u32 *empty_buffers = im->empty_buffers[thread_index];
if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from))
{
diff --git a/src/vnet/ipsec/esp_encrypt.c b/src/vnet/ipsec/esp_encrypt.c
index 44ae22972af..b2bc4e0b448 100644
--- a/src/vnet/ipsec/esp_encrypt.c
+++ b/src/vnet/ipsec/esp_encrypt.c
@@ -88,8 +88,8 @@ esp_encrypt_aes_cbc (ipsec_crypto_alg_t alg,
u8 * in, u8 * out, size_t in_len, u8 * key, u8 * iv)
{
esp_main_t *em = &esp_main;
- u32 cpu_index = os_get_cpu_number ();
- EVP_CIPHER_CTX *ctx = &(em->per_thread_data[cpu_index].encrypt_ctx);
+ u32 thread_index = vlib_get_thread_index ();
+ EVP_CIPHER_CTX *ctx = &(em->per_thread_data[thread_index].encrypt_ctx);
const EVP_CIPHER *cipher = NULL;
int out_len;
@@ -98,10 +98,11 @@ esp_encrypt_aes_cbc (ipsec_crypto_alg_t alg,
if (PREDICT_FALSE (em->esp_crypto_algs[alg].type == IPSEC_CRYPTO_ALG_NONE))
return;
- if (PREDICT_FALSE (alg != em->per_thread_data[cpu_index].last_encrypt_alg))
+ if (PREDICT_FALSE
+ (alg != em->per_thread_data[thread_index].last_encrypt_alg))
{
cipher = em->esp_crypto_algs[alg].type;
- em->per_thread_data[cpu_index].last_encrypt_alg = alg;
+ em->per_thread_data[thread_index].last_encrypt_alg = alg;
}
EVP_EncryptInit_ex (ctx, cipher, NULL, key, iv);
@@ -119,11 +120,11 @@ esp_encrypt_node_fn (vlib_main_t * vm,
n_left_from = from_frame->n_vectors;
ipsec_main_t *im = &ipsec_main;
u32 *recycle = 0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
ipsec_alloc_empty_buffers (vm, im);
- u32 *empty_buffers = im->empty_buffers[cpu_index];
+ u32 *empty_buffers = im->empty_buffers[thread_index];
if (PREDICT_FALSE (vec_len (empty_buffers) < n_left_from))
{
diff --git a/src/vnet/ipsec/ikev2.c b/src/vnet/ipsec/ikev2.c
index 2c1074d814b..3f9978a7520 100644
--- a/src/vnet/ipsec/ikev2.c
+++ b/src/vnet/ipsec/ikev2.c
@@ -303,16 +303,16 @@ static void
ikev2_delete_sa (ikev2_sa_t * sa)
{
ikev2_main_t *km = &ikev2_main;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
uword *p;
ikev2_sa_free_all_vec (sa);
- p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi, sa->rspi);
+ p = hash_get (km->per_thread_data[thread_index].sa_by_rspi, sa->rspi);
if (p)
{
- hash_unset (km->per_thread_data[cpu_index].sa_by_rspi, sa->rspi);
- pool_put (km->per_thread_data[cpu_index].sas, sa);
+ hash_unset (km->per_thread_data[thread_index].sa_by_rspi, sa->rspi);
+ pool_put (km->per_thread_data[thread_index].sas, sa);
}
}
@@ -776,29 +776,31 @@ ikev2_initial_contact_cleanup (ikev2_sa_t * sa)
ikev2_sa_t *tmp;
u32 i, *delete = 0;
ikev2_child_sa_t *c;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
if (!sa->initial_contact)
return;
/* find old IKE SAs with the same authenticated identity */
/* *INDENT-OFF* */
- pool_foreach (tmp, km->per_thread_data[cpu_index].sas, ({
+ pool_foreach (tmp, km->per_thread_data[thread_index].sas, ({
if (tmp->i_id.type != sa->i_id.type ||
vec_len(tmp->i_id.data) != vec_len(sa->i_id.data) ||
memcmp(sa->i_id.data, tmp->i_id.data, vec_len(sa->i_id.data)))
continue;
if (sa->rspi != tmp->rspi)
- vec_add1(delete, tmp - km->per_thread_data[cpu_index].sas);
+ vec_add1(delete, tmp - km->per_thread_data[thread_index].sas);
}));
/* *INDENT-ON* */
for (i = 0; i < vec_len (delete); i++)
{
- tmp = pool_elt_at_index (km->per_thread_data[cpu_index].sas, delete[i]);
- vec_foreach (c, tmp->childs)
- ikev2_delete_tunnel_interface (km->vnet_main, tmp, c);
+ tmp =
+ pool_elt_at_index (km->per_thread_data[thread_index].sas, delete[i]);
+ vec_foreach (c,
+ tmp->childs) ikev2_delete_tunnel_interface (km->vnet_main,
+ tmp, c);
ikev2_delete_sa (tmp);
}
@@ -1922,10 +1924,10 @@ ikev2_retransmit_sa_init (ike_header_t * ike,
{
ikev2_main_t *km = &ikev2_main;
ikev2_sa_t *sa;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
/* *INDENT-OFF* */
- pool_foreach (sa, km->per_thread_data[cpu_index].sas, ({
+ pool_foreach (sa, km->per_thread_data[thread_index].sas, ({
if (sa->ispi == clib_net_to_host_u64(ike->ispi) &&
sa->iaddr.as_u32 == iaddr.as_u32 &&
sa->raddr.as_u32 == raddr.as_u32)
@@ -2036,7 +2038,7 @@ ikev2_node_fn (vlib_main_t * vm,
u32 n_left_from, *from, *to_next;
ikev2_next_t next_index;
ikev2_main_t *km = &ikev2_main;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -2134,11 +2136,14 @@ ikev2_node_fn (vlib_main_t * vm,
if (sa0->state == IKEV2_STATE_SA_INIT)
{
/* add SA to the pool */
- pool_get (km->per_thread_data[cpu_index].sas, sa0);
+ pool_get (km->per_thread_data[thread_index].sas,
+ sa0);
clib_memcpy (sa0, &sa, sizeof (*sa0));
- hash_set (km->per_thread_data[cpu_index].sa_by_rspi,
+ hash_set (km->
+ per_thread_data[thread_index].sa_by_rspi,
sa0->rspi,
- sa0 - km->per_thread_data[cpu_index].sas);
+ sa0 -
+ km->per_thread_data[thread_index].sas);
}
else
{
@@ -2169,11 +2174,11 @@ ikev2_node_fn (vlib_main_t * vm,
if (sa0->state == IKEV2_STATE_SA_INIT)
{
/* add SA to the pool */
- pool_get (km->per_thread_data[cpu_index].sas, sa0);
+ pool_get (km->per_thread_data[thread_index].sas, sa0);
clib_memcpy (sa0, &sa, sizeof (*sa0));
- hash_set (km->per_thread_data[cpu_index].sa_by_rspi,
+ hash_set (km->per_thread_data[thread_index].sa_by_rspi,
sa0->rspi,
- sa0 - km->per_thread_data[cpu_index].sas);
+ sa0 - km->per_thread_data[thread_index].sas);
}
else
{
@@ -2184,12 +2189,13 @@ ikev2_node_fn (vlib_main_t * vm,
else if (ike0->exchange == IKEV2_EXCHANGE_IKE_AUTH)
{
uword *p;
- p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi,
+ p = hash_get (km->per_thread_data[thread_index].sa_by_rspi,
clib_net_to_host_u64 (ike0->rspi));
if (p)
{
- sa0 = pool_elt_at_index (km->per_thread_data[cpu_index].sas,
- p[0]);
+ sa0 =
+ pool_elt_at_index (km->per_thread_data[thread_index].sas,
+ p[0]);
r = ikev2_retransmit_resp (sa0, ike0);
if (r == 1)
@@ -2240,12 +2246,13 @@ ikev2_node_fn (vlib_main_t * vm,
else if (ike0->exchange == IKEV2_EXCHANGE_INFORMATIONAL)
{
uword *p;
- p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi,
+ p = hash_get (km->per_thread_data[thread_index].sa_by_rspi,
clib_net_to_host_u64 (ike0->rspi));
if (p)
{
- sa0 = pool_elt_at_index (km->per_thread_data[cpu_index].sas,
- p[0]);
+ sa0 =
+ pool_elt_at_index (km->per_thread_data[thread_index].sas,
+ p[0]);
r = ikev2_retransmit_resp (sa0, ike0);
if (r == 1)
@@ -2305,12 +2312,13 @@ ikev2_node_fn (vlib_main_t * vm,
else if (ike0->exchange == IKEV2_EXCHANGE_CREATE_CHILD_SA)
{
uword *p;
- p = hash_get (km->per_thread_data[cpu_index].sa_by_rspi,
+ p = hash_get (km->per_thread_data[thread_index].sa_by_rspi,
clib_net_to_host_u64 (ike0->rspi));
if (p)
{
- sa0 = pool_elt_at_index (km->per_thread_data[cpu_index].sas,
- p[0]);
+ sa0 =
+ pool_elt_at_index (km->per_thread_data[thread_index].sas,
+ p[0]);
r = ikev2_retransmit_resp (sa0, ike0);
if (r == 1)
diff --git a/src/vnet/ipsec/ipsec.h b/src/vnet/ipsec/ipsec.h
index 58f0f145a5a..c884e360004 100644
--- a/src/vnet/ipsec/ipsec.h
+++ b/src/vnet/ipsec/ipsec.h
@@ -324,21 +324,21 @@ int ipsec_set_interface_key (vnet_main_t * vnm, u32 hw_if_index,
always_inline void
ipsec_alloc_empty_buffers (vlib_main_t * vm, ipsec_main_t * im)
{
- u32 cpu_index = os_get_cpu_number ();
- uword l = vec_len (im->empty_buffers[cpu_index]);
+ u32 thread_index = vlib_get_thread_index ();
+ uword l = vec_len (im->empty_buffers[thread_index]);
uword n_alloc = 0;
if (PREDICT_FALSE (l < VLIB_FRAME_SIZE))
{
- if (!im->empty_buffers[cpu_index])
+ if (!im->empty_buffers[thread_index])
{
- vec_alloc (im->empty_buffers[cpu_index], 2 * VLIB_FRAME_SIZE);
+ vec_alloc (im->empty_buffers[thread_index], 2 * VLIB_FRAME_SIZE);
}
- n_alloc = vlib_buffer_alloc (vm, im->empty_buffers[cpu_index] + l,
+ n_alloc = vlib_buffer_alloc (vm, im->empty_buffers[thread_index] + l,
2 * VLIB_FRAME_SIZE - l);
- _vec_len (im->empty_buffers[cpu_index]) = l + n_alloc;
+ _vec_len (im->empty_buffers[thread_index]) = l + n_alloc;
}
}
diff --git a/src/vnet/ipsec/ipsec_if.c b/src/vnet/ipsec/ipsec_if.c
index dc882004cea..ed1248942e3 100644
--- a/src/vnet/ipsec/ipsec_if.c
+++ b/src/vnet/ipsec/ipsec_if.c
@@ -99,7 +99,7 @@ static int
ipsec_add_del_tunnel_if_rpc_callback (ipsec_add_del_tunnel_args_t * a)
{
vnet_main_t *vnm = vnet_get_main ();
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
return ipsec_add_del_tunnel_if_internal (vnm, a);
}
diff --git a/src/vnet/l2/l2_bvi.h b/src/vnet/l2/l2_bvi.h
index dd1130a6c29..e21a1616443 100644
--- a/src/vnet/l2/l2_bvi.h
+++ b/src/vnet/l2/l2_bvi.h
@@ -97,7 +97,7 @@ l2_to_bvi (vlib_main_t * vlib_main,
vlib_increment_combined_counter
(vnet_main->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- vlib_main->cpu_index,
+ vlib_main->thread_index,
vnet_buffer (b0)->sw_if_index[VLIB_RX],
1, vlib_buffer_length_in_chain (vlib_main, b0));
return TO_BVI_ERR_OK;
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index 041ff38d131..e5d6878a7ae 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -117,7 +117,7 @@ typedef enum
static_always_inline void
classify_and_dispatch (vlib_main_t * vm,
vlib_node_runtime_t * node,
- u32 cpu_index,
+ u32 thread_index,
l2input_main_t * msm, vlib_buffer_t * b0, u32 * next0)
{
/*
@@ -237,7 +237,7 @@ l2input_node_inline (vlib_main_t * vm,
u32 n_left_from, *from, *to_next;
l2input_next_t next_index;
l2input_main_t *msm = &l2input_main;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors; /* number of packets to process */
@@ -350,10 +350,10 @@ l2input_node_inline (vlib_main_t * vm,
vlib_node_increment_counter (vm, l2input_node.index,
L2INPUT_ERROR_L2INPUT, 4);
- classify_and_dispatch (vm, node, cpu_index, msm, b0, &next0);
- classify_and_dispatch (vm, node, cpu_index, msm, b1, &next1);
- classify_and_dispatch (vm, node, cpu_index, msm, b2, &next2);
- classify_and_dispatch (vm, node, cpu_index, msm, b3, &next3);
+ classify_and_dispatch (vm, node, thread_index, msm, b0, &next0);
+ classify_and_dispatch (vm, node, thread_index, msm, b1, &next1);
+ classify_and_dispatch (vm, node, thread_index, msm, b2, &next2);
+ classify_and_dispatch (vm, node, thread_index, msm, b3, &next3);
/* verify speculative enqueues, maybe switch current next frame */
/* if next0==next1==next_index then nothing special needs to be done */
@@ -393,7 +393,7 @@ l2input_node_inline (vlib_main_t * vm,
vlib_node_increment_counter (vm, l2input_node.index,
L2INPUT_ERROR_L2INPUT, 1);
- classify_and_dispatch (vm, node, cpu_index, msm, b0, &next0);
+ classify_and_dispatch (vm, node, thread_index, msm, b0, &next0);
/* verify speculative enqueue, maybe switch current next frame */
vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
diff --git a/src/vnet/l2/l2_output.c b/src/vnet/l2/l2_output.c
index 00f22571790..e17b2a16675 100644
--- a/src/vnet/l2/l2_output.c
+++ b/src/vnet/l2/l2_output.c
@@ -643,11 +643,11 @@ l2output_create_output_node_mapping (vlib_main_t * vlib_main, vnet_main_t * vnet
hw0 = vnet_get_sup_hw_interface (vnet_main, sw_if_index);
- uword cpu_number;
+ uword thread_index;
- cpu_number = os_get_cpu_number ();
+ thread_index = vlib_get_thread_index ();
- if (cpu_number)
+ if (thread_index)
{
u32 oldflags;
diff --git a/src/vnet/l2tp/decap.c b/src/vnet/l2tp/decap.c
index e8986935e93..4610412954d 100644
--- a/src/vnet/l2tp/decap.c
+++ b/src/vnet/l2tp/decap.c
@@ -149,7 +149,7 @@ last_stage (vlib_main_t * vm, vlib_node_runtime_t * node, u32 bi)
/* per-mapping byte stats include the ethernet header */
vlib_increment_combined_counter (&lm->counter_main,
- os_get_cpu_number (),
+ vlib_get_thread_index (),
counter_index, 1 /* packet_increment */ ,
vlib_buffer_length_in_chain (vm, b) +
sizeof (ethernet_header_t));
diff --git a/src/vnet/l2tp/encap.c b/src/vnet/l2tp/encap.c
index ed7a9580de1..dcdfde4b564 100644
--- a/src/vnet/l2tp/encap.c
+++ b/src/vnet/l2tp/encap.c
@@ -124,7 +124,7 @@ last_stage (vlib_main_t * vm, vlib_node_runtime_t * node, u32 bi)
/* per-mapping byte stats include the ethernet header */
vlib_increment_combined_counter (&lm->counter_main,
- os_get_cpu_number (),
+ vlib_get_thread_index (),
counter_index, 1 /* packet_increment */ ,
vlib_buffer_length_in_chain (vm, b));
diff --git a/src/vnet/l2tp/l2tp.c b/src/vnet/l2tp/l2tp.c
index cb94d7e7287..3dedc447152 100644
--- a/src/vnet/l2tp/l2tp.c
+++ b/src/vnet/l2tp/l2tp.c
@@ -157,7 +157,7 @@ test_counters_command_fn (vlib_main_t * vm,
u32 session_index;
u32 counter_index;
u32 nincr = 0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
/* *INDENT-OFF* */
pool_foreach (session, lm->sessions,
@@ -167,11 +167,11 @@ test_counters_command_fn (vlib_main_t * vm,
session_index_to_counter_index (session_index,
SESSION_COUNTER_USER_TO_NETWORK);
vlib_increment_combined_counter (&lm->counter_main,
- cpu_index,
+ thread_index,
counter_index,
1/*pkt*/, 1111 /*bytes*/);
vlib_increment_combined_counter (&lm->counter_main,
- cpu_index,
+ thread_index,
counter_index+1,
1/*pkt*/, 2222 /*bytes*/);
nincr++;
diff --git a/src/vnet/lisp-gpe/decap.c b/src/vnet/lisp-gpe/decap.c
index d887a95f16c..687697105a4 100644
--- a/src/vnet/lisp-gpe/decap.c
+++ b/src/vnet/lisp-gpe/decap.c
@@ -103,7 +103,7 @@ next_index_to_iface (lisp_gpe_main_t * lgm, u32 next_index)
}
static_always_inline void
-incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length,
+incr_decap_stats (vnet_main_t * vnm, u32 thread_index, u32 length,
u32 sw_if_index, u32 * last_sw_if_index, u32 * n_packets,
u32 * n_bytes)
{
@@ -122,7 +122,7 @@ incr_decap_stats (vnet_main_t * vnm, u32 cpu_index, u32 length,
vlib_increment_combined_counter (im->combined_sw_if_counters +
VNET_INTERFACE_COUNTER_RX,
- cpu_index, *last_sw_if_index,
+ thread_index, *last_sw_if_index,
*n_packets, *n_bytes);
}
*last_sw_if_index = sw_if_index;
@@ -150,11 +150,11 @@ static uword
lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame, u8 is_v4)
{
- u32 n_left_from, next_index, *from, *to_next, cpu_index;
+ u32 n_left_from, next_index, *from, *to_next, thread_index;
u32 n_bytes = 0, n_packets = 0, last_sw_if_index = ~0, drops = 0;
lisp_gpe_main_t *lgm = vnet_lisp_gpe_get_main ();
- cpu_index = os_get_cpu_number ();
+ thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -267,7 +267,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
if (si0)
{
- incr_decap_stats (lgm->vnet_main, cpu_index,
+ incr_decap_stats (lgm->vnet_main, thread_index,
vlib_buffer_length_in_chain (vm, b0), si0[0],
&last_sw_if_index, &n_packets, &n_bytes);
vnet_buffer (b0)->sw_if_index[VLIB_RX] = si0[0];
@@ -282,7 +282,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
if (si1)
{
- incr_decap_stats (lgm->vnet_main, cpu_index,
+ incr_decap_stats (lgm->vnet_main, thread_index,
vlib_buffer_length_in_chain (vm, b1), si1[0],
&last_sw_if_index, &n_packets, &n_bytes);
vnet_buffer (b1)->sw_if_index[VLIB_RX] = si1[0];
@@ -397,7 +397,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
if (si0)
{
- incr_decap_stats (lgm->vnet_main, cpu_index,
+ incr_decap_stats (lgm->vnet_main, thread_index,
vlib_buffer_length_in_chain (vm, b0), si0[0],
&last_sw_if_index, &n_packets, &n_bytes);
vnet_buffer (b0)->sw_if_index[VLIB_RX] = si0[0];
@@ -430,7 +430,7 @@ lisp_gpe_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
}
/* flush iface stats */
- incr_decap_stats (lgm->vnet_main, cpu_index, 0, ~0, &last_sw_if_index,
+ incr_decap_stats (lgm->vnet_main, thread_index, 0, ~0, &last_sw_if_index,
&n_packets, &n_bytes);
vlib_node_increment_counter (vm, lisp_gpe_ip4_input_node.index,
LISP_GPE_ERROR_NO_TUNNEL, drops);
diff --git a/src/vnet/lldp/lldp_input.c b/src/vnet/lldp/lldp_input.c
index 762743d0d8d..e88f6fdba5f 100644
--- a/src/vnet/lldp/lldp_input.c
+++ b/src/vnet/lldp/lldp_input.c
@@ -35,7 +35,7 @@ typedef struct
static void
lldp_rpc_update_peer_cb (const lldp_intf_update_t * a)
{
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
lldp_intf_t *n = lldp_get_intf (&lldp_main, a->hw_if_index);
if (!n)
diff --git a/src/vnet/map/ip4_map.c b/src/vnet/map/ip4_map.c
index 1a20d704732..e39b6f14dba 100644
--- a/src/vnet/map/ip4_map.c
+++ b/src/vnet/map/ip4_map.c
@@ -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 =
diff --git a/src/vnet/map/ip4_map_t.c b/src/vnet/map/ip4_map_t.c
index b63d76bf4f4..5f2bcbf970a 100644
--- a/src/vnet/map/ip4_map_t.c
+++ b/src/vnet/map/ip4_map_t.c
@@ -477,7 +477,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -520,7 +520,7 @@ ip4_map_t_icmp (vlib_main_t * vm,
if (PREDICT_TRUE (error0 == MAP_ERROR_NONE))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
- cpu_index,
+ thread_index,
vnet_buffer (p0)->map_t.
map_domain_index, 1, len0);
}
@@ -1051,7 +1051,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
vlib_combined_counter_main_t *cm = map_main.domain_counters;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -1158,7 +1158,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
(error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
- cpu_index,
+ thread_index,
vnet_buffer (p0)->map_t.
map_domain_index, 1,
clib_net_to_host_u16 (ip40->
@@ -1169,7 +1169,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
(error1 == MAP_ERROR_NONE && next1 != IP4_MAPT_NEXT_MAPT_ICMP))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
- cpu_index,
+ thread_index,
vnet_buffer (p1)->map_t.
map_domain_index, 1,
clib_net_to_host_u16 (ip41->
@@ -1252,7 +1252,7 @@ ip4_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
(error0 == MAP_ERROR_NONE && next0 != IP4_MAPT_NEXT_MAPT_ICMP))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_TX,
- cpu_index,
+ thread_index,
vnet_buffer (p0)->map_t.
map_domain_index, 1,
clib_net_to_host_u16 (ip40->
diff --git a/src/vnet/map/ip6_map.c b/src/vnet/map/ip6_map.c
index f7eb768fa71..63ada962c7e 100644
--- a/src/vnet/map/ip6_map.c
+++ b/src/vnet/map/ip6_map.c
@@ -172,7 +172,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -319,7 +319,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
IP6_MAP_NEXT_IP4_REWRITE : next0;
}
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
map_domain_index0, 1,
clib_net_to_host_u16
(ip40->length));
@@ -352,7 +352,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
IP6_MAP_NEXT_IP4_REWRITE : next1;
}
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
map_domain_index1, 1,
clib_net_to_host_u16
(ip41->length));
@@ -505,7 +505,7 @@ ip6_map (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
IP6_MAP_NEXT_IP4_REWRITE : next0;
}
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
map_domain_index0, 1,
clib_net_to_host_u16
(ip40->length));
@@ -820,7 +820,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 *fragments_to_drop = NULL;
u32 *fragments_to_loopback = NULL;
@@ -958,8 +958,8 @@ ip6_map_ip4_reass (vlib_main_t * vm,
{
if (error0 == MAP_ERROR_NONE)
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index, map_domain_index0,
- 1,
+ thread_index,
+ map_domain_index0, 1,
clib_net_to_host_u16
(ip40->length));
next0 =
@@ -1015,7 +1015,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u16 *fragment_ids, *fid;
from = vlib_frame_vector_args (frame);
@@ -1143,7 +1143,8 @@ ip6_map_icmp_relay (vlib_main_t * vm,
ip_csum_t sum = ip_incremental_checksum (0, new_icmp40, nlen - 20);
new_icmp40->checksum = ~ip_csum_fold (sum);
- vlib_increment_simple_counter (&mm->icmp_relayed, cpu_index, 0, 1);
+ vlib_increment_simple_counter (&mm->icmp_relayed, thread_index, 0,
+ 1);
error:
if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED))
diff --git a/src/vnet/map/ip6_map_t.c b/src/vnet/map/ip6_map_t.c
index eb3996c2467..99151678a5a 100644
--- a/src/vnet/map/ip6_map_t.c
+++ b/src/vnet/map/ip6_map_t.c
@@ -448,7 +448,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -493,7 +493,7 @@ ip6_map_t_icmp (vlib_main_t * vm,
if (PREDICT_TRUE (error0 == MAP_ERROR_NONE))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
vnet_buffer (p0)->
map_t.map_domain_index, 1,
len0);
@@ -1051,7 +1051,7 @@ ip6_map_t (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_map_t_node.index);
vlib_combined_counter_main_t *cm = map_main.domain_counters;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -1218,7 +1218,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
(error0 == MAP_ERROR_NONE && next0 != IP6_MAPT_NEXT_MAPT_ICMP))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
vnet_buffer (p0)->
map_t.map_domain_index, 1,
clib_net_to_host_u16
@@ -1229,7 +1229,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
(error1 == MAP_ERROR_NONE && next1 != IP6_MAPT_NEXT_MAPT_ICMP))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
vnet_buffer (p1)->
map_t.map_domain_index, 1,
clib_net_to_host_u16
@@ -1403,7 +1403,7 @@ ip6_map_t (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
(error0 == MAP_ERROR_NONE && next0 != IP6_MAPT_NEXT_MAPT_ICMP))
{
vlib_increment_combined_counter (cm + MAP_DOMAIN_COUNTER_RX,
- cpu_index,
+ thread_index,
vnet_buffer (p0)->
map_t.map_domain_index, 1,
clib_net_to_host_u16
diff --git a/src/vnet/mpls/mpls_input.c b/src/vnet/mpls/mpls_input.c
index 893c45111d4..1b9bdd05eed 100644
--- a/src/vnet/mpls/mpls_input.c
+++ b/src/vnet/mpls/mpls_input.c
@@ -76,7 +76,7 @@ mpls_input_inline (vlib_main_t * vm,
u32 n_left_from, next_index, * from, * to_next;
mpls_input_runtime_t * rt;
mpls_main_t * mm;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
vlib_simple_counter_main_t * cm;
vnet_main_t * vnm = vnet_get_main();
@@ -151,7 +151,7 @@ mpls_input_inline (vlib_main_t * vm,
next0 = MPLS_INPUT_NEXT_LOOKUP;
vnet_feature_arc_start(mm->input_feature_arc_index,
sw_if_index0, &next0, b0);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
}
if (PREDICT_FALSE(h1[3] == 0))
@@ -164,7 +164,7 @@ mpls_input_inline (vlib_main_t * vm,
next1 = MPLS_INPUT_NEXT_LOOKUP;
vnet_feature_arc_start(mm->input_feature_arc_index,
sw_if_index1, &next1, b1);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index1, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index1, 1);
}
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
@@ -215,7 +215,7 @@ mpls_input_inline (vlib_main_t * vm,
{
next0 = MPLS_INPUT_NEXT_LOOKUP;
vnet_feature_arc_start(mm->input_feature_arc_index, sw_if_index0, &next0, b0);
- vlib_increment_simple_counter (cm, cpu_index, sw_if_index0, 1);
+ vlib_increment_simple_counter (cm, thread_index, sw_if_index0, 1);
}
if (PREDICT_FALSE(b0->flags & VLIB_BUFFER_IS_TRACED))
diff --git a/src/vnet/mpls/mpls_lookup.c b/src/vnet/mpls/mpls_lookup.c
index 475bb20454b..ace6a70fe80 100644
--- a/src/vnet/mpls/mpls_lookup.c
+++ b/src/vnet/mpls/mpls_lookup.c
@@ -67,7 +67,7 @@ mpls_lookup (vlib_main_t * vm,
vlib_combined_counter_main_t * cm = &load_balance_main.lbm_to_counters;
u32 n_left_from, next_index, * from, * to_next;
mpls_main_t * mm = &mpls_main;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -220,16 +220,16 @@ mpls_lookup (vlib_main_t * vm,
vnet_buffer (b3)->ip.adj_index[VLIB_TX] = dpo3->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1,
+ (cm, thread_index, lbi1, 1,
vlib_buffer_length_in_chain (vm, b1));
vlib_increment_combined_counter
- (cm, cpu_index, lbi2, 1,
+ (cm, thread_index, lbi2, 1,
vlib_buffer_length_in_chain (vm, b2));
vlib_increment_combined_counter
- (cm, cpu_index, lbi3, 1,
+ (cm, thread_index, lbi3, 1,
vlib_buffer_length_in_chain (vm, b3));
/*
@@ -351,7 +351,7 @@ mpls_lookup (vlib_main_t * vm,
vnet_buffer (b0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, b0));
/*
@@ -440,7 +440,7 @@ mpls_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;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
u32 next;
from = vlib_frame_vector_args (frame);
@@ -536,10 +536,10 @@ mpls_load_balance (vlib_main_t * vm,
vnet_buffer (p1)->ip.adj_index[VLIB_TX] = dpo1->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, p0));
vlib_increment_combined_counter
- (cm, cpu_index, lbi1, 1,
+ (cm, thread_index, lbi1, 1,
vlib_buffer_length_in_chain (vm, p1));
if (PREDICT_FALSE(p0->flags & VLIB_BUFFER_IS_TRACED))
@@ -597,7 +597,7 @@ mpls_load_balance (vlib_main_t * vm,
vnet_buffer (p0)->ip.adj_index[VLIB_TX] = dpo0->dpoi_index;
vlib_increment_combined_counter
- (cm, cpu_index, lbi0, 1,
+ (cm, thread_index, lbi0, 1,
vlib_buffer_length_in_chain (vm, p0));
vlib_validate_buffer_enqueue_x1 (vm, node, next,
diff --git a/src/vnet/mpls/mpls_output.c b/src/vnet/mpls/mpls_output.c
index 08018fd1685..d90dec21864 100644
--- a/src/vnet/mpls/mpls_output.c
+++ b/src/vnet/mpls/mpls_output.c
@@ -64,12 +64,12 @@ mpls_output_inline (vlib_main_t * vm,
vlib_frame_t * from_frame,
int is_midchain)
{
- u32 n_left_from, next_index, * from, * to_next, cpu_index;
+ u32 n_left_from, next_index, * from, * to_next, thread_index;
vlib_node_runtime_t * error_node;
u32 n_left_to_next;
mpls_main_t *mm;
- cpu_index = os_get_cpu_number();
+ thread_index = vlib_get_thread_index();
error_node = vlib_node_get_runtime (vm, mpls_output_node.index);
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -137,13 +137,13 @@ mpls_output_inline (vlib_main_t * vm,
/* Bump the adj counters for packet and bytes */
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index0,
1,
vlib_buffer_length_in_chain (vm, p0) + rw_len0);
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index1,
1,
vlib_buffer_length_in_chain (vm, p1) + rw_len1);
@@ -245,7 +245,7 @@ mpls_output_inline (vlib_main_t * vm,
vlib_increment_combined_counter
(&adjacency_counters,
- cpu_index,
+ thread_index,
adj_index0,
1,
vlib_buffer_length_in_chain (vm, p0) + rw_len0);
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index 2649798b109..597ae060045 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -893,7 +893,7 @@ pg_generate_set_lengths (pg_main_t * pg,
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number (),
+ vlib_get_thread_index (),
si->sw_if_index, n_buffers, length_sum);
}
@@ -1266,7 +1266,7 @@ pg_stream_fill_helper (pg_main_t * pg,
l += vlib_buffer_index_length_in_chain (vm, buffers[i]);
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number (),
+ vlib_get_thread_index (),
si->sw_if_index, n_alloc, l);
s->current_replay_packet_index += n_alloc;
s->current_replay_packet_index %=
diff --git a/src/vnet/replication.c b/src/vnet/replication.c
index 86d922b5e7a..233a8c2f100 100644
--- a/src/vnet/replication.c
+++ b/src/vnet/replication.c
@@ -31,16 +31,16 @@ replication_prep (vlib_main_t * vm,
{
replication_main_t *rm = &replication_main;
replication_context_t *ctx;
- uword cpu_number = vm->cpu_index;
+ uword thread_index = vm->thread_index;
ip4_header_t *ip;
u32 ctx_id;
/* Allocate a context, reserve context 0 */
- if (PREDICT_FALSE (rm->contexts[cpu_number] == 0))
- pool_get_aligned (rm->contexts[cpu_number], ctx, CLIB_CACHE_LINE_BYTES);
+ if (PREDICT_FALSE (rm->contexts[thread_index] == 0))
+ pool_get_aligned (rm->contexts[thread_index], ctx, CLIB_CACHE_LINE_BYTES);
- pool_get_aligned (rm->contexts[cpu_number], ctx, CLIB_CACHE_LINE_BYTES);
- ctx_id = ctx - rm->contexts[cpu_number];
+ pool_get_aligned (rm->contexts[thread_index], ctx, CLIB_CACHE_LINE_BYTES);
+ ctx_id = ctx - rm->contexts[thread_index];
/* Save state from vlib buffer */
ctx->saved_free_list_index = b0->free_list_index;
@@ -94,11 +94,11 @@ replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last)
{
replication_main_t *rm = &replication_main;
replication_context_t *ctx;
- uword cpu_number = vm->cpu_index;
+ uword thread_index = vm->thread_index;
ip4_header_t *ip;
/* Get access to the replication context */
- ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
+ ctx = pool_elt_at_index (rm->contexts[thread_index], b0->recycle_count);
/* Restore vnet buffer state */
clib_memcpy (vnet_buffer (b0), ctx->vnet_buffer,
@@ -133,7 +133,7 @@ replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last)
b0->flags &= ~VLIB_BUFFER_RECYCLE;
/* Free context back to its pool */
- pool_put (rm->contexts[cpu_number], ctx);
+ pool_put (rm->contexts[thread_index], ctx);
}
return ctx;
@@ -160,7 +160,7 @@ replication_recycle_callback (vlib_main_t * vm, vlib_buffer_free_list_t * fl)
replication_main_t *rm = &replication_main;
replication_context_t *ctx;
u32 feature_node_index = 0;
- uword cpu_number = vm->cpu_index;
+ uword thread_index = vm->thread_index;
/*
* All buffers in the list are destined to the same recycle node.
@@ -172,7 +172,7 @@ replication_recycle_callback (vlib_main_t * vm, vlib_buffer_free_list_t * fl)
{
bi0 = fl->buffers[0];
b0 = vlib_get_buffer (vm, bi0);
- ctx = pool_elt_at_index (rm->contexts[cpu_number], b0->recycle_count);
+ ctx = pool_elt_at_index (rm->contexts[thread_index], b0->recycle_count);
feature_node_index = ctx->recycle_node_index;
}
diff --git a/src/vnet/replication.h b/src/vnet/replication.h
index 5dc554c97b3..ce4b3ff11d0 100644
--- a/src/vnet/replication.h
+++ b/src/vnet/replication.h
@@ -100,7 +100,7 @@ replication_get_ctx (vlib_buffer_t * b0)
replication_main_t *rm = &replication_main;
return replication_is_recycled (b0) ?
- pool_elt_at_index (rm->contexts[os_get_cpu_number ()],
+ pool_elt_at_index (rm->contexts[vlib_get_thread_index ()],
b0->recycle_count) : 0;
}
diff --git a/src/vnet/session/node.c b/src/vnet/session/node.c
index b86e87d9bac..dd211c51a59 100644
--- a/src/vnet/session/node.c
+++ b/src/vnet/session/node.c
@@ -311,7 +311,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
unix_shared_memory_queue_t *q;
application_t *app;
int n_tx_packets = 0;
- u32 my_thread_index = vm->cpu_index;
+ u32 my_thread_index = vm->thread_index;
int i, rv;
f64 now = vlib_time_now (vm);
diff --git a/src/vnet/sr/sr_localsid.c b/src/vnet/sr/sr_localsid.c
index 2e3d56de80b..6d72a506088 100755
--- a/src/vnet/sr/sr_localsid.c
+++ b/src/vnet/sr/sr_localsid.c
@@ -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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -974,26 +974,26 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_increment_combined_counter
(((next0 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b0));
+ &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b0));
vlib_increment_combined_counter
(((next1 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls1 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b1));
+ &(sm->sr_ls_valid_counters)), thread_index, ls1 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b1));
vlib_increment_combined_counter
(((next2 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls2 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b2));
+ &(sm->sr_ls_valid_counters)), thread_index, ls2 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b2));
vlib_increment_combined_counter
(((next3 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls3 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b3));
+ &(sm->sr_ls_valid_counters)), thread_index, ls3 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b3));
vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
n_left_to_next, bi0, bi1, bi2, bi3,
@@ -1062,8 +1062,8 @@ sr_localsid_d_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_increment_combined_counter
(((next0 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b0));
+ &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b0));
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
@@ -1103,7 +1103,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
while (n_left_from > 0)
{
@@ -1205,26 +1205,26 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_increment_combined_counter
(((next0 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b0));
+ &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b0));
vlib_increment_combined_counter
(((next1 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls1 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b1));
+ &(sm->sr_ls_valid_counters)), thread_index, ls1 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b1));
vlib_increment_combined_counter
(((next2 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls2 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b2));
+ &(sm->sr_ls_valid_counters)), thread_index, ls2 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b2));
vlib_increment_combined_counter
(((next3 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls3 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b3));
+ &(sm->sr_ls_valid_counters)), thread_index, ls3 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b3));
vlib_validate_buffer_enqueue_x4 (vm, node, next_index, to_next,
n_left_to_next, bi0, bi1, bi2, bi3,
@@ -1295,8 +1295,8 @@ sr_localsid_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_increment_combined_counter
(((next0 ==
SR_LOCALSID_NEXT_ERROR) ? &(sm->sr_ls_invalid_counters) :
- &(sm->sr_ls_valid_counters)), cpu_index, ls0 - sm->localsids, 1,
- vlib_buffer_length_in_chain (vm, b0));
+ &(sm->sr_ls_valid_counters)), thread_index, ls0 - sm->localsids,
+ 1, vlib_buffer_length_in_chain (vm, b0));
vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next,
n_left_to_next, bi0, next0);
diff --git a/src/vnet/tcp/builtin_client.c b/src/vnet/tcp/builtin_client.c
index e3705060400..c1567aa09c8 100644
--- a/src/vnet/tcp/builtin_client.c
+++ b/src/vnet/tcp/builtin_client.c
@@ -174,7 +174,7 @@ tclient_thread_fn (void *arg)
pthread_sigmask (SIG_SETMASK, &s, 0);
}
- clib_per_cpu_mheaps[os_get_cpu_number ()] = clib_per_cpu_mheaps[0];
+ clib_per_cpu_mheaps[vlib_get_thread_index ()] = clib_per_cpu_mheaps[0];
while (1)
{
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index b2a371e2cd8..b6c348288ec 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -646,10 +646,10 @@ const static transport_proto_vft_t tcp6_proto = {
void
tcp_timer_keep_handler (u32 conn_index)
{
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
tcp_connection_t *tc;
- tc = tcp_connection_get (conn_index, cpu_index);
+ tc = tcp_connection_get (conn_index, thread_index);
tc->timers[TCP_TIMER_KEEP] = TCP_TIMER_HANDLE_INVALID;
tcp_connection_close (tc);
@@ -675,10 +675,10 @@ tcp_timer_establish_handler (u32 conn_index)
void
tcp_timer_waitclose_handler (u32 conn_index)
{
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
tcp_connection_t *tc;
- tc = tcp_connection_get (conn_index, cpu_index);
+ tc = tcp_connection_get (conn_index, thread_index);
tc->timers[TCP_TIMER_WAITCLOSE] = TCP_TIMER_HANDLE_INVALID;
/* Session didn't come back with a close(). Send FIN either way
diff --git a/src/vnet/tcp/tcp_debug.h b/src/vnet/tcp/tcp_debug.h
index 0090e15e581..eaca672c6e1 100644
--- a/src/vnet/tcp/tcp_debug.h
+++ b/src/vnet/tcp/tcp_debug.h
@@ -343,7 +343,7 @@ typedef enum _tcp_dbg_evt
} \
else \
{ \
- u32 _thread_index = os_get_cpu_number (); \
+ u32 _thread_index = vlib_get_thread_index (); \
_tc = tcp_connection_get (_tc_index, _thread_index); \
} \
ELOG_TYPE_DECLARE (_e) = \
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index a8224dc2450..7e9fa47b290 100644
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -1142,7 +1142,7 @@ tcp46_established_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame, int is_ip4)
{
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index, errors = 0;
+ u32 my_thread_index = vm->thread_index, errors = 0;
tcp_main_t *tm = vnet_get_tcp_main ();
from = vlib_frame_vector_args (from_frame);
@@ -1332,7 +1332,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
{
tcp_main_t *tm = vnet_get_tcp_main ();
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index, errors = 0;
+ u32 my_thread_index = vm->thread_index, errors = 0;
u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
from = vlib_frame_vector_args (from_frame);
@@ -1634,7 +1634,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
{
tcp_main_t *tm = vnet_get_tcp_main ();
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index, errors = 0;
+ u32 my_thread_index = vm->thread_index, errors = 0;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -1989,7 +1989,7 @@ tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame, int is_ip4)
{
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index;
+ u32 my_thread_index = vm->thread_index;
tcp_main_t *tm = vnet_get_tcp_main ();
u8 sst = is_ip4 ? SESSION_TYPE_IP4_TCP : SESSION_TYPE_IP6_TCP;
@@ -2243,7 +2243,7 @@ tcp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame, int is_ip4)
{
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index;
+ u32 my_thread_index = vm->thread_index;
tcp_main_t *tm = vnet_get_tcp_main ();
from = vlib_frame_vector_args (from_frame);
diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c
index ea157bd76b7..e18bfad7eb4 100644
--- a/src/vnet/tcp/tcp_output.c
+++ b/src/vnet/tcp/tcp_output.c
@@ -387,8 +387,8 @@ tcp_make_options (tcp_connection_t * tc, tcp_options_t * opts,
#define tcp_get_free_buffer_index(tm, bidx) \
do { \
u32 *my_tx_buffers, n_free_buffers; \
- u32 cpu_index = os_get_cpu_number(); \
- my_tx_buffers = tm->tx_buffers[cpu_index]; \
+ u32 thread_index = vlib_get_thread_index(); \
+ my_tx_buffers = tm->tx_buffers[thread_index]; \
if (PREDICT_FALSE(vec_len (my_tx_buffers) == 0)) \
{ \
n_free_buffers = 32; /* TODO config or macro */ \
@@ -396,7 +396,7 @@ do { \
_vec_len(my_tx_buffers) = vlib_buffer_alloc_from_free_list ( \
tm->vlib_main, my_tx_buffers, n_free_buffers, \
VLIB_BUFFER_DEFAULT_FREE_LIST_INDEX); \
- tm->tx_buffers[cpu_index] = my_tx_buffers; \
+ tm->tx_buffers[thread_index] = my_tx_buffers; \
} \
/* buffer shortage */ \
if (PREDICT_FALSE (vec_len (my_tx_buffers) == 0)) \
@@ -408,8 +408,8 @@ do { \
#define tcp_return_buffer(tm) \
do { \
u32 *my_tx_buffers; \
- u32 cpu_index = os_get_cpu_number(); \
- my_tx_buffers = tm->tx_buffers[cpu_index]; \
+ u32 thread_index = vlib_get_thread_index(); \
+ my_tx_buffers = tm->tx_buffers[thread_index]; \
_vec_len (my_tx_buffers) +=1; \
} while (0)
@@ -942,7 +942,7 @@ tcp_send_ack (tcp_connection_t * tc)
void
tcp_timer_delack_handler (u32 index)
{
- u32 thread_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
tcp_connection_t *tc;
tc = tcp_connection_get (index, thread_index);
@@ -1022,7 +1022,7 @@ tcp_timer_retransmit_handler_i (u32 index, u8 is_syn)
{
tcp_main_t *tm = vnet_get_tcp_main ();
vlib_main_t *vm = vlib_get_main ();
- u32 thread_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
tcp_connection_t *tc;
vlib_buffer_t *b;
u32 bi, snd_space, n_bytes;
@@ -1152,7 +1152,7 @@ tcp_timer_persist_handler (u32 index)
{
tcp_main_t *tm = vnet_get_tcp_main ();
vlib_main_t *vm = vlib_get_main ();
- u32 thread_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
tcp_connection_t *tc;
vlib_buffer_t *b;
u32 bi, n_bytes;
@@ -1313,7 +1313,7 @@ tcp46_output_inline (vlib_main_t * vm,
vlib_frame_t * from_frame, int is_ip4)
{
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index;
+ u32 my_thread_index = vm->thread_index;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
@@ -1524,7 +1524,7 @@ tcp46_send_reset_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame, u8 is_ip4)
{
u32 n_left_from, next_index, *from, *to_next;
- u32 my_thread_index = vm->cpu_index;
+ u32 my_thread_index = vm->thread_index;
from = vlib_frame_vector_args (from_frame);
n_left_from = from_frame->n_vectors;
diff --git a/src/vnet/udp/udp_input.c b/src/vnet/udp/udp_input.c
index 4b22109bc71..810278e618f 100644
--- a/src/vnet/udp/udp_input.c
+++ b/src/vnet/udp/udp_input.c
@@ -70,7 +70,7 @@ udp4_uri_input_node_fn (vlib_main_t * vm,
udp4_uri_input_next_t next_index;
udp_uri_main_t *um = vnet_get_udp_main ();
session_manager_main_t *smm = vnet_get_session_manager_main ();
- u32 my_thread_index = vm->cpu_index;
+ u32 my_thread_index = vm->thread_index;
u8 my_enqueue_epoch;
u32 *session_indices_to_enqueue;
static u32 serial_number;
diff --git a/src/vnet/unix/tapcli.c b/src/vnet/unix/tapcli.c
index fb1a8bac7d4..0fc62f6c061 100644
--- a/src/vnet/unix/tapcli.c
+++ b/src/vnet/unix/tapcli.c
@@ -366,7 +366,7 @@ static uword tapcli_rx_iface(vlib_main_t * vm,
vlib_increment_combined_counter (
vnet_main.interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number(), ti->sw_if_index,
+ vlib_get_thread_index(), ti->sw_if_index,
1, n_bytes_in_packet);
if (PREDICT_FALSE(n_trace > 0)) {
diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c
index 2cfcc92ff8a..ac674653df4 100644
--- a/src/vnet/unix/tuntap.c
+++ b/src/vnet/unix/tuntap.c
@@ -189,7 +189,7 @@ tuntap_tx (vlib_main_t * vm,
/* Update tuntap interface output stats. */
vlib_increment_combined_counter (im->combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_TX,
- vm->cpu_index,
+ vm->thread_index,
tm->sw_if_index, n_packets, n_bytes);
@@ -297,7 +297,7 @@ tuntap_rx (vlib_main_t * vm,
vlib_increment_combined_counter
(vnet_main.interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- os_get_cpu_number(),
+ vlib_get_thread_index(),
tm->sw_if_index,
1, n_bytes_in_packet);
diff --git a/src/vnet/vxlan-gpe/decap.c b/src/vnet/vxlan-gpe/decap.c
index 22ab4b62f66..d4fe423126e 100644
--- a/src/vnet/vxlan-gpe/decap.c
+++ b/src/vnet/vxlan-gpe/decap.c
@@ -115,7 +115,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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
if (is_ip4)
@@ -342,7 +342,7 @@ vxlan_gpe_input (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len0;
stats_sw_if_index = sw_if_index0;
@@ -427,7 +427,7 @@ vxlan_gpe_input (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len1;
stats_sw_if_index = sw_if_index1;
@@ -588,7 +588,7 @@ vxlan_gpe_input (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len0;
stats_sw_if_index = sw_if_index0;
@@ -615,7 +615,7 @@ vxlan_gpe_input (vlib_main_t * vm,
if (stats_n_packets)
{
vlib_increment_combined_counter (
- im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, cpu_index,
+ im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX, thread_index,
stats_sw_if_index, stats_n_packets, stats_n_bytes);
node->runtime_data[0] = stats_sw_if_index;
}
diff --git a/src/vnet/vxlan-gpe/encap.c b/src/vnet/vxlan-gpe/encap.c
index 3a486e5606e..67ed94b433b 100644
--- a/src/vnet/vxlan-gpe/encap.c
+++ b/src/vnet/vxlan-gpe/encap.c
@@ -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 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
from = vlib_frame_vector_args (from_frame);
@@ -253,7 +253,7 @@ vxlan_gpe_encap (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
stats_sw_if_index = sw_if_index0;
stats_n_packets = 2;
stats_n_bytes = len0 + len1;
@@ -262,10 +262,10 @@ vxlan_gpe_encap (vlib_main_t * vm,
{
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, sw_if_index0, 1, len0);
+ thread_index, sw_if_index0, 1, len0);
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, sw_if_index1, 1, len1);
+ thread_index, sw_if_index1, 1, len1);
}
}
@@ -335,7 +335,7 @@ vxlan_gpe_encap (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter (
im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len0;
stats_sw_if_index = sw_if_index0;
@@ -359,7 +359,7 @@ vxlan_gpe_encap (vlib_main_t * vm,
if (stats_n_packets)
{
vlib_increment_combined_counter (
- im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, cpu_index,
+ im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX, thread_index,
stats_sw_if_index, stats_n_packets, stats_n_bytes);
node->runtime_data[0] = stats_sw_if_index;
}
diff --git a/src/vnet/vxlan/decap.c b/src/vnet/vxlan/decap.c
index 514b2c9968e..2acb1f6f20b 100644
--- a/src/vnet/vxlan/decap.c
+++ b/src/vnet/vxlan/decap.c
@@ -81,7 +81,7 @@ vxlan_input (vlib_main_t * vm,
vxlan4_tunnel_key_t last_key4;
vxlan6_tunnel_key_t last_key6;
u32 pkts_decapsulated = 0;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
u32 stats_sw_if_index, stats_n_packets, stats_n_bytes;
if (is_ip4)
@@ -314,7 +314,7 @@ vxlan_input (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index,
+ thread_index, stats_sw_if_index,
stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len0;
@@ -468,7 +468,7 @@ vxlan_input (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index,
+ thread_index, stats_sw_if_index,
stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len1;
@@ -674,7 +674,7 @@ vxlan_input (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index,
+ thread_index, stats_sw_if_index,
stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len0;
@@ -711,7 +711,7 @@ vxlan_input (vlib_main_t * vm,
{
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_RX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
node->runtime_data[0] = stats_sw_if_index;
}
diff --git a/src/vnet/vxlan/encap.c b/src/vnet/vxlan/encap.c
index 5b63064a848..4cfbbc233c0 100644
--- a/src/vnet/vxlan/encap.c
+++ b/src/vnet/vxlan/encap.c
@@ -77,7 +77,7 @@ vxlan_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 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_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;
@@ -301,7 +301,7 @@ vxlan_encap_inline (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, stats_sw_if_index,
+ thread_index, stats_sw_if_index,
stats_n_packets, stats_n_bytes);
stats_sw_if_index = sw_if_index0;
stats_n_packets = 2;
@@ -311,10 +311,10 @@ vxlan_encap_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, sw_if_index0, 1, len0);
+ thread_index, sw_if_index0, 1, len0);
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, sw_if_index1, 1, len1);
+ thread_index, sw_if_index1, 1, len1);
}
}
@@ -464,7 +464,7 @@ vxlan_encap_inline (vlib_main_t * vm,
if (stats_n_packets)
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, stats_sw_if_index,
+ thread_index, stats_sw_if_index,
stats_n_packets, stats_n_bytes);
stats_n_packets = 1;
stats_n_bytes = len0;
@@ -496,7 +496,7 @@ vxlan_encap_inline (vlib_main_t * vm,
{
vlib_increment_combined_counter
(im->combined_sw_if_counters + VNET_INTERFACE_COUNTER_TX,
- cpu_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
+ thread_index, stats_sw_if_index, stats_n_packets, stats_n_bytes);
node->runtime_data[0] = stats_sw_if_index;
}