aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/dpdk/buffer.c2
-rw-r--r--src/plugins/dpdk/device/device.c8
-rw-r--r--src/plugins/dpdk/device/dpdk_priv.h8
-rwxr-xr-xsrc/plugins/dpdk/device/init.c2
-rw-r--r--src/plugins/dpdk/device/node.c32
-rw-r--r--src/plugins/dpdk/hqos/hqos.c16
-rw-r--r--src/plugins/dpdk/ipsec/cli.c8
-rw-r--r--src/plugins/dpdk/ipsec/crypto_node.c4
-rw-r--r--src/plugins/dpdk/ipsec/esp.h4
-rw-r--r--src/plugins/dpdk/ipsec/esp_decrypt.c4
-rw-r--r--src/plugins/dpdk/ipsec/esp_encrypt.c5
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.c2
-rw-r--r--src/plugins/dpdk/ipsec/ipsec.h4
-rw-r--r--src/plugins/dpdk/main.c2
-rw-r--r--src/plugins/flowperpkt/l2_node.c2
-rw-r--r--src/plugins/flowperpkt/node.c2
-rw-r--r--src/plugins/ioam/export-common/ioam_export.h6
-rw-r--r--src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c16
-rw-r--r--src/plugins/ixge/ixge.c2
-rw-r--r--src/plugins/lb/lb.c8
-rw-r--r--src/plugins/lb/node.c22
-rw-r--r--src/plugins/lb/refcount.c8
-rw-r--r--src/plugins/lb/refcount.h4
-rw-r--r--src/plugins/memif/node.c35
-rw-r--r--src/plugins/snat/in2out.c110
-rw-r--r--src/plugins/snat/out2in.c102
-rw-r--r--src/plugins/snat/snat.h10
27 files changed, 216 insertions, 212 deletions
diff --git a/src/plugins/dpdk/buffer.c b/src/plugins/dpdk/buffer.c
index 2765c292..c80b3fa8 100644
--- a/src/plugins/dpdk/buffer.c
+++ b/src/plugins/dpdk/buffer.c
@@ -132,7 +132,7 @@ dpdk_buffer_delete_free_list (vlib_main_t * vm, u32 free_list_index)
u32 merge_index;
int i;
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
f = vlib_buffer_get_free_list (vm, free_list_index);
diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c
index 50b26689..91661246 100644
--- a/src/plugins/dpdk/device/device.c
+++ b/src/plugins/dpdk/device/device.c
@@ -243,7 +243,7 @@ static_always_inline
ASSERT (ring->tx_tail == 0);
n_retry = 16;
- queue_id = vm->cpu_index;
+ queue_id = vm->thread_index;
do
{
@@ -266,7 +266,7 @@ static_always_inline
{
/* no wrap, transmit in one burst */
dpdk_device_hqos_per_worker_thread_t *hqos =
- &xd->hqos_wt[vm->cpu_index];
+ &xd->hqos_wt[vm->thread_index];
ASSERT (hqos->swq != NULL);
@@ -332,7 +332,7 @@ dpdk_buffer_recycle (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_buffer_t * b, u32 bi, struct rte_mbuf **mbp)
{
dpdk_main_t *dm = &dpdk_main;
- u32 my_cpu = vm->cpu_index;
+ u32 my_cpu = vm->thread_index;
struct rte_mbuf *mb_new;
if (PREDICT_FALSE (b->flags & VLIB_BUFFER_RECYCLE) == 0)
@@ -376,7 +376,7 @@ dpdk_interface_tx (vlib_main_t * vm,
tx_ring_hdr_t *ring;
u32 n_on_ring;
- my_cpu = vm->cpu_index;
+ my_cpu = vm->thread_index;
queue_id = my_cpu;
diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h
index dd40ff48..52b4ca4b 100644
--- a/src/plugins/dpdk/device/dpdk_priv.h
+++ b/src/plugins/dpdk/device/dpdk_priv.h
@@ -79,7 +79,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now)
{
vlib_simple_counter_main_t *cm;
vnet_main_t *vnm = vnet_get_main ();
- u32 my_cpu = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u64 rxerrors, last_rxerrors;
/* only update counters for PMD interfaces */
@@ -96,7 +96,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now)
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
VNET_INTERFACE_COUNTER_RX_NO_BUF);
- vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index,
+ vlib_increment_simple_counter (cm, thread_index, xd->vlib_sw_if_index,
xd->stats.rx_nombuf -
xd->last_stats.rx_nombuf);
}
@@ -107,7 +107,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now)
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
VNET_INTERFACE_COUNTER_RX_MISS);
- vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index,
+ vlib_increment_simple_counter (cm, thread_index, xd->vlib_sw_if_index,
xd->stats.imissed -
xd->last_stats.imissed);
}
@@ -119,7 +119,7 @@ dpdk_update_counters (dpdk_device_t * xd, f64 now)
cm = vec_elt_at_index (vnm->interface_main.sw_if_counters,
VNET_INTERFACE_COUNTER_RX_ERROR);
- vlib_increment_simple_counter (cm, my_cpu, xd->vlib_sw_if_index,
+ vlib_increment_simple_counter (cm, thread_index, xd->vlib_sw_if_index,
rxerrors - last_rxerrors);
}
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index 538db6cb..7eaf8da7 100755
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -324,7 +324,7 @@ dpdk_port_setup (dpdk_main_t * dm, dpdk_device_t * xd)
int rv;
int j;
- ASSERT (os_get_cpu_number () == 0);
+ ASSERT (vlib_get_thread_index () == 0);
if (xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP)
{
diff --git a/src/plugins/dpdk/device/node.c b/src/plugins/dpdk/device/node.c
index e740fd18..b10e0fad 100644
--- a/src/plugins/dpdk/device/node.c
+++ b/src/plugins/dpdk/device/node.c
@@ -283,7 +283,7 @@ dpdk_buffer_init_from_template (void *d0, void *d1, void *d2, void *d3,
*/
static_always_inline u32
dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd,
- vlib_node_runtime_t * node, u32 cpu_index, u16 queue_id,
+ vlib_node_runtime_t * node, u32 thread_index, u16 queue_id,
int maybe_multiseg)
{
u32 n_buffers;
@@ -294,7 +294,7 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd,
uword n_rx_bytes = 0;
u32 n_trace, trace_cnt __attribute__ ((unused));
vlib_buffer_free_list_t *fl;
- vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, cpu_index);
+ vlib_buffer_t *bt = vec_elt_at_index (dm->buffer_templates, thread_index);
if ((xd->flags & DPDK_DEVICE_FLAG_ADMIN_UP) == 0)
return 0;
@@ -306,7 +306,7 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd,
return 0;
}
- vec_reset_length (xd->d_trace_buffers[cpu_index]);
+ vec_reset_length (xd->d_trace_buffers[thread_index]);
trace_cnt = n_trace = vlib_get_trace_count (vm, node);
if (n_trace > 0)
@@ -318,7 +318,7 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd,
{
struct rte_mbuf *mb = xd->rx_vectors[queue_id][mb_index++];
vlib_buffer_t *b = vlib_buffer_from_rte_mbuf (mb);
- vec_add1 (xd->d_trace_buffers[cpu_index],
+ vec_add1 (xd->d_trace_buffers[thread_index],
vlib_get_buffer_index (vm, b));
}
}
@@ -546,20 +546,22 @@ dpdk_device_input (dpdk_main_t * dm, dpdk_device_t * xd,
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
- if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[cpu_index]) > 0))
+ if (PREDICT_FALSE (vec_len (xd->d_trace_buffers[thread_index]) > 0))
{
- dpdk_rx_trace (dm, node, xd, queue_id, xd->d_trace_buffers[cpu_index],
- vec_len (xd->d_trace_buffers[cpu_index]));
- vlib_set_trace_count (vm, node, n_trace -
- vec_len (xd->d_trace_buffers[cpu_index]));
+ dpdk_rx_trace (dm, node, xd, queue_id,
+ xd->d_trace_buffers[thread_index],
+ vec_len (xd->d_trace_buffers[thread_index]));
+ vlib_set_trace_count (vm, node,
+ n_trace -
+ vec_len (xd->d_trace_buffers[thread_index]));
}
vlib_increment_combined_counter
(vnet_get_main ()->interface_main.combined_sw_if_counters
+ VNET_INTERFACE_COUNTER_RX,
- cpu_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
+ thread_index, xd->vlib_sw_if_index, mb_index, n_rx_bytes);
- vnet_device_increment_rx_packets (cpu_index, mb_index);
+ vnet_device_increment_rx_packets (thread_index, mb_index);
return mb_index;
}
@@ -630,19 +632,19 @@ dpdk_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * f)
dpdk_device_t *xd;
uword n_rx_packets = 0;
dpdk_device_and_queue_t *dq;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
/*
* Poll all devices on this cpu for input/interrupts.
*/
/* *INDENT-OFF* */
- vec_foreach (dq, dm->devices_by_cpu[cpu_index])
+ vec_foreach (dq, dm->devices_by_cpu[thread_index])
{
xd = vec_elt_at_index(dm->devices, dq->device);
if (xd->flags & DPDK_DEVICE_FLAG_MAYBE_MULTISEG)
- n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, /* maybe_multiseg */ 1);
+ n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 1);
else
- n_rx_packets += dpdk_device_input (dm, xd, node, cpu_index, dq->queue_id, /* maybe_multiseg */ 0);
+ n_rx_packets += dpdk_device_input (dm, xd, node, thread_index, dq->queue_id, /* maybe_multiseg */ 0);
}
/* *INDENT-ON* */
diff --git a/src/plugins/dpdk/hqos/hqos.c b/src/plugins/dpdk/hqos/hqos.c
index a288fca7..8b251beb 100644
--- a/src/plugins/dpdk/hqos/hqos.c
+++ b/src/plugins/dpdk/hqos/hqos.c
@@ -397,7 +397,7 @@ static_always_inline void
dpdk_hqos_thread_internal_hqos_dbg_bypass (vlib_main_t * vm)
{
dpdk_main_t *dm = &dpdk_main;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
u32 dev_pos;
dev_pos = 0;
@@ -405,12 +405,12 @@ dpdk_hqos_thread_internal_hqos_dbg_bypass (vlib_main_t * vm)
{
vlib_worker_thread_barrier_check ();
- u32 n_devs = vec_len (dm->devices_by_hqos_cpu[cpu_index]);
+ u32 n_devs = vec_len (dm->devices_by_hqos_cpu[thread_index]);
if (dev_pos >= n_devs)
dev_pos = 0;
dpdk_device_and_queue_t *dq =
- vec_elt_at_index (dm->devices_by_hqos_cpu[cpu_index], dev_pos);
+ vec_elt_at_index (dm->devices_by_hqos_cpu[thread_index], dev_pos);
dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device);
dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht;
@@ -479,7 +479,7 @@ static_always_inline void
dpdk_hqos_thread_internal (vlib_main_t * vm)
{
dpdk_main_t *dm = &dpdk_main;
- u32 cpu_index = vm->cpu_index;
+ u32 thread_index = vm->thread_index;
u32 dev_pos;
dev_pos = 0;
@@ -487,7 +487,7 @@ dpdk_hqos_thread_internal (vlib_main_t * vm)
{
vlib_worker_thread_barrier_check ();
- u32 n_devs = vec_len (dm->devices_by_hqos_cpu[cpu_index]);
+ u32 n_devs = vec_len (dm->devices_by_hqos_cpu[thread_index]);
if (PREDICT_FALSE (n_devs == 0))
{
dev_pos = 0;
@@ -497,7 +497,7 @@ dpdk_hqos_thread_internal (vlib_main_t * vm)
dev_pos = 0;
dpdk_device_and_queue_t *dq =
- vec_elt_at_index (dm->devices_by_hqos_cpu[cpu_index], dev_pos);
+ vec_elt_at_index (dm->devices_by_hqos_cpu[thread_index], dev_pos);
dpdk_device_t *xd = vec_elt_at_index (dm->devices, dq->device);
dpdk_device_hqos_per_hqos_thread_t *hqos = xd->hqos_ht;
@@ -586,7 +586,7 @@ dpdk_hqos_thread (vlib_worker_thread_t * w)
vm = vlib_get_main ();
- ASSERT (vm->cpu_index == os_get_cpu_number ());
+ ASSERT (vm->thread_index == vlib_get_thread_index ());
clib_time_init (&vm->clib_time);
clib_mem_set_heap (w->thread_mheap);
@@ -595,7 +595,7 @@ dpdk_hqos_thread (vlib_worker_thread_t * w)
while (tm->worker_thread_release == 0)
vlib_worker_thread_barrier_check ();
- if (vec_len (dm->devices_by_hqos_cpu[vm->cpu_index]) == 0)
+ if (vec_len (dm->devices_by_hqos_cpu[vm->thread_index]) == 0)
return
clib_error
("current I/O TX thread does not have any devices assigned to it");
diff --git a/src/plugins/dpdk/ipsec/cli.c b/src/plugins/dpdk/ipsec/cli.c
index cd0a6037..3ae8c9b8 100644
--- a/src/plugins/dpdk/ipsec/cli.c
+++ b/src/plugins/dpdk/ipsec/cli.c
@@ -42,8 +42,8 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
for (i = 0; i < tm->n_vlib_mains; i++)
{
uword key, data;
- u32 cpu_index = vlib_mains[i]->cpu_index;
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ u32 thread_index = vlib_mains[i]->thread_index;
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
u8 *s = 0;
if (skip_master)
@@ -57,7 +57,7 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
i32 last_cdev = -1;
crypto_qp_data_t *qpd;
- s = format (s, "%u\t", cpu_index);
+ s = format (s, "%u\t", thread_index);
/* *INDENT-OFF* */
vec_foreach (qpd, cwm->qp_data)
@@ -95,7 +95,7 @@ dpdk_ipsec_show_mapping (vlib_main_t * vm, u16 detail_display)
cap.sym.auth.algo = p_key->auth_algo;
check_algo_is_supported (&cap, auth_str);
vlib_cli_output (vm, "%u\t%10s\t%15s\t%3s\t%u\t%u\n",
- vlib_mains[i]->cpu_index, cipher_str, auth_str,
+ vlib_mains[i]->thread_index, cipher_str, auth_str,
p_key->is_outbound ? "out" : "in",
cwm->qp_data[data].dev_id,
cwm->qp_data[data].qp_id);
diff --git a/src/plugins/dpdk/ipsec/crypto_node.c b/src/plugins/dpdk/ipsec/crypto_node.c
index dc3452b2..a3c45902 100644
--- a/src/plugins/dpdk/ipsec/crypto_node.c
+++ b/src/plugins/dpdk/ipsec/crypto_node.c
@@ -171,9 +171,9 @@ static uword
dpdk_crypto_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
crypto_qp_data_t *qpd;
u32 n_deq = 0;
diff --git a/src/plugins/dpdk/ipsec/esp.h b/src/plugins/dpdk/ipsec/esp.h
index 320295b1..56f0c756 100644
--- a/src/plugins/dpdk/ipsec/esp.h
+++ b/src/plugins/dpdk/ipsec/esp.h
@@ -170,9 +170,9 @@ static_always_inline int
create_sym_sess (ipsec_sa_t * sa, crypto_sa_session_t * sa_sess,
u8 is_outbound)
{
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
struct rte_crypto_sym_xform cipher_xform = { 0 };
struct rte_crypto_sym_xform auth_xform = { 0 };
struct rte_crypto_sym_xform *xfs;
diff --git a/src/plugins/dpdk/ipsec/esp_decrypt.c b/src/plugins/dpdk/ipsec/esp_decrypt.c
index 286e03f8..bab76e3b 100644
--- a/src/plugins/dpdk/ipsec/esp_decrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_decrypt.c
@@ -88,7 +88,7 @@ dpdk_esp_decrypt_node_fn (vlib_main_t * vm,
{
u32 n_left_from, *from, *to_next, next_index;
ipsec_main_t *im = &ipsec_main;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
dpdk_crypto_main_t * dcm = &dpdk_crypto_main;
dpdk_esp_main_t * em = &dpdk_esp_main;
u32 i;
@@ -104,7 +104,7 @@ dpdk_esp_decrypt_node_fn (vlib_main_t * vm,
return n_left_from;
}
- crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, cpu_index);
+ crypto_worker_main_t *cwm = vec_elt_at_index(dcm->workers_main, thread_index);
u32 n_qps = vec_len(cwm->qp_data);
struct rte_crypto_op ** cops_to_enq[n_qps];
u32 n_cop_qp[n_qps], * bi_to_enq[n_qps];
diff --git a/src/plugins/dpdk/ipsec/esp_encrypt.c b/src/plugins/dpdk/ipsec/esp_encrypt.c
index 5b03de73..f996d7df 100644
--- a/src/plugins/dpdk/ipsec/esp_encrypt.c
+++ b/src/plugins/dpdk/ipsec/esp_encrypt.c
@@ -93,7 +93,7 @@ dpdk_esp_encrypt_node_fn (vlib_main_t * vm,
{
u32 n_left_from, *from, *to_next, next_index;
ipsec_main_t *im = &ipsec_main;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
dpdk_esp_main_t *em = &dpdk_esp_main;
u32 i;
@@ -111,7 +111,8 @@ dpdk_esp_encrypt_node_fn (vlib_main_t * vm,
return n_left_from;
}
- crypto_worker_main_t *cwm = vec_elt_at_index (dcm->workers_main, cpu_index);
+ crypto_worker_main_t *cwm =
+ vec_elt_at_index (dcm->workers_main, thread_index);
u32 n_qps = vec_len (cwm->qp_data);
struct rte_crypto_op **cops_to_enq[n_qps];
u32 n_cop_qp[n_qps], *bi_to_enq[n_qps];
diff --git a/src/plugins/dpdk/ipsec/ipsec.c b/src/plugins/dpdk/ipsec/ipsec.c
index b0aaaaec..5d8f4fba 100644
--- a/src/plugins/dpdk/ipsec/ipsec.c
+++ b/src/plugins/dpdk/ipsec/ipsec.c
@@ -289,7 +289,7 @@ dpdk_ipsec_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
if (!map)
{
clib_warning ("unable to create hash table for worker %u",
- vlib_mains[i]->cpu_index);
+ vlib_mains[i]->thread_index);
goto error;
}
cwm->algo_qp_map = map;
diff --git a/src/plugins/dpdk/ipsec/ipsec.h b/src/plugins/dpdk/ipsec/ipsec.h
index 28bffc80..f0f793c0 100644
--- a/src/plugins/dpdk/ipsec/ipsec.h
+++ b/src/plugins/dpdk/ipsec/ipsec.h
@@ -95,8 +95,8 @@ static_always_inline void
crypto_alloc_cops ()
{
dpdk_crypto_main_t *dcm = &dpdk_crypto_main;
- u32 cpu_index = os_get_cpu_number ();
- crypto_worker_main_t *cwm = &dcm->workers_main[cpu_index];
+ u32 thread_index = vlib_get_thread_index ();
+ crypto_worker_main_t *cwm = &dcm->workers_main[thread_index];
unsigned socket_id = rte_socket_id ();
crypto_qp_data_t *qpd;
diff --git a/src/plugins/dpdk/main.c b/src/plugins/dpdk/main.c
index 7ee2a785..942b8b2d 100644
--- a/src/plugins/dpdk/main.c
+++ b/src/plugins/dpdk/main.c
@@ -39,7 +39,7 @@ rte_delay_us_override (unsigned us)
* thread then do not intercept. (Must not be called from an
* independent pthread).
*/
- if (os_get_cpu_number () == 0)
+ if (vlib_get_thread_index () == 0)
{
/*
* We're in the vlib main thread or a vlib process. Make sure
diff --git a/src/plugins/flowperpkt/l2_node.c b/src/plugins/flowperpkt/l2_node.c
index 1c2f681e..fdaf81d1 100644
--- a/src/plugins/flowperpkt/l2_node.c
+++ b/src/plugins/flowperpkt/l2_node.c
@@ -102,7 +102,7 @@ add_to_flow_record_l2 (vlib_main_t * vm,
u8 * src_mac, u8 * dst_mac,
u16 ethertype, u64 timestamp, u16 length, int do_flush)
{
- u32 my_cpu_number = vm->cpu_index;
+ u32 my_cpu_number = vm->thread_index;
flow_report_main_t *frm = &flow_report_main;
ip4_header_t *ip;
udp_header_t *udp;
diff --git a/src/plugins/flowperpkt/node.c b/src/plugins/flowperpkt/node.c
index f77f087d..0277682d 100644
--- a/src/plugins/flowperpkt/node.c
+++ b/src/plugins/flowperpkt/node.c
@@ -101,7 +101,7 @@ add_to_flow_record_ipv4 (vlib_main_t * vm,
u32 src_address, u32 dst_address,
u8 tos, u64 timestamp, u16 length, int do_flush)
{
- u32 my_cpu_number = vm->cpu_index;
+ u32 my_cpu_number = vm->thread_index;
flow_report_main_t *frm = &flow_report_main;
ip4_header_t *ip;
udp_header_t *udp;
diff --git a/src/plugins/ioam/export-common/ioam_export.h b/src/plugins/ioam/export-common/ioam_export.h
index 2bf3fd54..9de0d13b 100644
--- a/src/plugins/ioam/export-common/ioam_export.h
+++ b/src/plugins/ioam/export-common/ioam_export.h
@@ -477,8 +477,8 @@ do { \
from = vlib_frame_vector_args (F); \
n_left_from = (F)->n_vectors; \
next_index = (N)->cached_next_index; \
- while (__sync_lock_test_and_set ((EM)->lockp[(VM)->cpu_index], 1)); \
- my_buf = ioam_export_get_my_buffer (EM, (VM)->cpu_index); \
+ while (__sync_lock_test_and_set ((EM)->lockp[(VM)->thread_index], 1)); \
+ my_buf = ioam_export_get_my_buffer (EM, (VM)->thread_index); \
my_buf->touched_at = vlib_time_now (VM); \
while (n_left_from > 0) \
{ \
@@ -620,7 +620,7 @@ do { \
} \
vlib_node_increment_counter (VM, export_node.index, \
EXPORT_ERROR_RECORDED, pkts_recorded); \
- *(EM)->lockp[(VM)->cpu_index] = 0; \
+ *(EM)->lockp[(VM)->thread_index] = 0; \
} while(0)
#endif /* __included_ioam_export_h__ */
diff --git a/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c b/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c
index a56dc040..0cf742c9 100644
--- a/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c
+++ b/src/plugins/ioam/ip6/ioam_cache_tunnel_select_node.c
@@ -396,7 +396,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm,
clib_net_to_host_u32
(tcp0->seq_number) + 1,
no_of_responses, now,
- vm->cpu_index, &pool_index0))
+ vm->thread_index, &pool_index0))
{
cache_ts_added++;
}
@@ -419,7 +419,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm,
e2e =
(ioam_e2e_cache_option_t *) ((u8 *) hbh0 +
cm->rewrite_pool_index_offset);
- e2e->pool_id = (u8) vm->cpu_index;
+ e2e->pool_id = (u8) vm->thread_index;
e2e->pool_index = pool_index0;
ioam_e2e_id_rewrite_handler ((ioam_e2e_id_option_t *)
((u8 *) e2e +
@@ -455,7 +455,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm,
clib_net_to_host_u32
(tcp1->seq_number) + 1,
no_of_responses, now,
- vm->cpu_index, &pool_index1))
+ vm->thread_index, &pool_index1))
{
cache_ts_added++;
}
@@ -479,7 +479,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm,
e2e =
(ioam_e2e_cache_option_t *) ((u8 *) hbh1 +
cm->rewrite_pool_index_offset);
- e2e->pool_id = (u8) vm->cpu_index;
+ e2e->pool_id = (u8) vm->thread_index;
e2e->pool_index = pool_index1;
ioam_e2e_id_rewrite_handler ((ioam_e2e_id_option_t *)
((u8 *) e2e +
@@ -562,7 +562,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm,
clib_net_to_host_u32
(tcp0->seq_number) + 1,
no_of_responses, now,
- vm->cpu_index, &pool_index0))
+ vm->thread_index, &pool_index0))
{
cache_ts_added++;
}
@@ -585,7 +585,7 @@ ip6_reset_ts_hbh_node_fn (vlib_main_t * vm,
e2e =
(ioam_e2e_cache_option_t *) ((u8 *) hbh0 +
cm->rewrite_pool_index_offset);
- e2e->pool_id = (u8) vm->cpu_index;
+ e2e->pool_id = (u8) vm->thread_index;
e2e->pool_index = pool_index0;
ioam_e2e_id_rewrite_handler ((ioam_e2e_id_option_t *)
((u8 *) e2e +
@@ -701,7 +701,7 @@ expired_cache_ts_timer_callback (u32 * expired_timers)
ioam_cache_main_t *cm = &ioam_cache_main;
int i;
u32 pool_index;
- u32 thread_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 count = 0;
for (i = 0; i < vec_len (expired_timers); i++)
@@ -724,7 +724,7 @@ ioam_cache_ts_timer_tick_node_fn (vlib_main_t * vm,
vlib_frame_t * f)
{
ioam_cache_main_t *cm = &ioam_cache_main;
- u32 my_thread_index = os_get_cpu_number ();
+ u32 my_thread_index = vlib_get_thread_index ();
struct timespec ts, tsrem;
tw_timer_expire_timers_16t_2w_512sl (&cm->timer_wheels[my_thread_index],
diff --git a/src/plugins/ixge/ixge.c b/src/plugins/ixge/ixge.c
index f3c5cc09..08f5b692 100644
--- a/src/plugins/ixge/ixge.c
+++ b/src/plugins/ixge/ixge.c
@@ -1887,7 +1887,7 @@ done:
vlib_increment_combined_counter (vnet_main.
interface_main.combined_sw_if_counters +
VNET_INTERFACE_COUNTER_RX,
- 0 /* cpu_index */ ,
+ 0 /* thread_index */ ,
xd->vlib_sw_if_index, n_packets,
dq->rx.n_bytes);
diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c
index add81236..addc2a42 100644
--- a/src/plugins/lb/lb.c
+++ b/src/plugins/lb/lb.c
@@ -63,11 +63,11 @@ u8 *format_lb_main (u8 * s, va_list * args)
s = format(s, " #vips: %u\n", pool_elts(lbm->vips));
s = format(s, " #ass: %u\n", pool_elts(lbm->ass) - 1);
- u32 cpu_index;
- for(cpu_index = 0; cpu_index < tm->n_vlib_mains; cpu_index++ ) {
- lb_hash_t *h = lbm->per_cpu[cpu_index].sticky_ht;
+ u32 thread_index;
+ for(thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++ ) {
+ lb_hash_t *h = lbm->per_cpu[thread_index].sticky_ht;
if (h) {
- s = format(s, "core %d\n", cpu_index);
+ s = format(s, "core %d\n", thread_index);
s = format(s, " timeout: %ds\n", h->timeout);
s = format(s, " usage: %d / %d\n", lb_hash_elts(h, lb_hash_time_now(vlib_get_main())), lb_hash_size(h));
}
diff --git a/src/plugins/lb/node.c b/src/plugins/lb/node.c
index 8b763c53..3171148b 100644
--- a/src/plugins/lb/node.c
+++ b/src/plugins/lb/node.c
@@ -60,10 +60,10 @@ format_lb_trace (u8 * s, va_list * args)
return s;
}
-lb_hash_t *lb_get_sticky_table(u32 cpu_index)
+lb_hash_t *lb_get_sticky_table(u32 thread_index)
{
lb_main_t *lbm = &lb_main;
- lb_hash_t *sticky_ht = lbm->per_cpu[cpu_index].sticky_ht;
+ lb_hash_t *sticky_ht = lbm->per_cpu[thread_index].sticky_ht;
//Check if size changed
if (PREDICT_FALSE(sticky_ht && (lbm->per_cpu_sticky_buckets != lb_hash_nbuckets(sticky_ht))))
{
@@ -71,8 +71,8 @@ lb_hash_t *lb_get_sticky_table(u32 cpu_index)
lb_hash_bucket_t *b;
u32 i;
lb_hash_foreach_entry(sticky_ht, b, i) {
- vlib_refcount_add(&lbm->as_refcount, cpu_index, b->value[i], -1);
- vlib_refcount_add(&lbm->as_refcount, cpu_index, 0, 1);
+ vlib_refcount_add(&lbm->as_refcount, thread_index, b->value[i], -1);
+ vlib_refcount_add(&lbm->as_refcount, thread_index, 0, 1);
}
lb_hash_free(sticky_ht);
@@ -81,8 +81,8 @@ lb_hash_t *lb_get_sticky_table(u32 cpu_index)
//Create if necessary
if (PREDICT_FALSE(sticky_ht == NULL)) {
- lbm->per_cpu[cpu_index].sticky_ht = lb_hash_alloc(lbm->per_cpu_sticky_buckets, lbm->flow_timeout);
- sticky_ht = lbm->per_cpu[cpu_index].sticky_ht;
+ lbm->per_cpu[thread_index].sticky_ht = lb_hash_alloc(lbm->per_cpu_sticky_buckets, lbm->flow_timeout);
+ sticky_ht = lbm->per_cpu[thread_index].sticky_ht;
clib_warning("Regenerated sticky table %p", sticky_ht);
}
@@ -153,10 +153,10 @@ lb_node_fn (vlib_main_t * vm,
{
lb_main_t *lbm = &lb_main;
u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
- u32 cpu_index = os_get_cpu_number();
+ u32 thread_index = vlib_get_thread_index();
u32 lb_time = lb_hash_time_now(vm);
- lb_hash_t *sticky_ht = lb_get_sticky_table(cpu_index);
+ lb_hash_t *sticky_ht = lb_get_sticky_table(thread_index);
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
next_index = node->cached_next_index;
@@ -240,9 +240,9 @@ lb_node_fn (vlib_main_t * vm,
//Configuration may be changed, vectors resized, etc...
//Dereference previously used
- vlib_refcount_add(&lbm->as_refcount, cpu_index,
+ vlib_refcount_add(&lbm->as_refcount, thread_index,
lb_hash_available_value(sticky_ht, hash0, available_index0), -1);
- vlib_refcount_add(&lbm->as_refcount, cpu_index,
+ vlib_refcount_add(&lbm->as_refcount, thread_index,
asindex0, 1);
//Add sticky entry
@@ -260,7 +260,7 @@ lb_node_fn (vlib_main_t * vm,
}
vlib_increment_simple_counter(&lbm->vip_counters[counter],
- cpu_index,
+ thread_index,
vnet_buffer (p0)->ip.adj_index[VLIB_TX],
1);
diff --git a/src/plugins/lb/refcount.c b/src/plugins/lb/refcount.c
index 22415c88..6f01ab5a 100644
--- a/src/plugins/lb/refcount.c
+++ b/src/plugins/lb/refcount.c
@@ -31,10 +31,10 @@ u64 vlib_refcount_get(vlib_refcount_t *r, u32 index)
{
u64 count = 0;
vlib_thread_main_t *tm = vlib_get_thread_main ();
- u32 cpu_index;
- for (cpu_index = 0; cpu_index < tm->n_vlib_mains; cpu_index++) {
- if (r->per_cpu[cpu_index].length > index)
- count += r->per_cpu[cpu_index].counters[index];
+ u32 thread_index;
+ for (thread_index = 0; thread_index < tm->n_vlib_mains; thread_index++) {
+ if (r->per_cpu[thread_index].length > index)
+ count += r->per_cpu[thread_index].counters[index];
}
return count;
}
diff --git a/src/plugins/lb/refcount.h b/src/plugins/lb/refcount.h
index 8c26e7be..dcfcb3fe 100644
--- a/src/plugins/lb/refcount.h
+++ b/src/plugins/lb/refcount.h
@@ -45,9 +45,9 @@ typedef struct {
void __vlib_refcount_resize(vlib_refcount_per_cpu_t *per_cpu, u32 size);
static_always_inline
-void vlib_refcount_add(vlib_refcount_t *r, u32 cpu_index, u32 counter_index, i32 v)
+void vlib_refcount_add(vlib_refcount_t *r, u32 thread_index, u32 counter_index, i32 v)
{
- vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[cpu_index];
+ vlib_refcount_per_cpu_t *per_cpu = &r->per_cpu[thread_index];
if (PREDICT_FALSE(counter_index >= per_cpu->length))
__vlib_refcount_resize(per_cpu, clib_max(counter_index + 16, per_cpu->length * 2));
diff --git a/src/plugins/memif/node.c b/src/plugins/memif/node.c
index 659d5dfb..cee1f3d1 100644
--- a/src/plugins/memif/node.c
+++ b/src/plugins/memif/node.c
@@ -94,7 +94,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
u32 n_rx_bytes = 0;
u32 *to_next = 0;
u32 n_free_bufs;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
u32 bi0, bi1;
vlib_buffer_t *b0, *b1;
u16 ring_size = 1 << mif->log2_ring_size;
@@ -105,14 +105,15 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
if (mif->per_interface_next_index != ~0)
next_index = mif->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 < ring_size))
{
- vec_validate (nm->rx_buffers[cpu_index], ring_size + n_free_bufs - 1);
+ vec_validate (nm->rx_buffers[thread_index],
+ ring_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],
ring_size);
- _vec_len (nm->rx_buffers[cpu_index]) = n_free_bufs;
+ _vec_len (nm->rx_buffers[thread_index]) = n_free_bufs;
}
head = ring->head;
@@ -158,15 +159,15 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
CLIB_CACHE_LINE_BYTES, LOAD);
}
/* get empty buffer */
- u32 last_buf = vec_len (nm->rx_buffers[cpu_index]) - 1;
- bi0 = nm->rx_buffers[cpu_index][last_buf];
- bi1 = nm->rx_buffers[cpu_index][last_buf - 1];
- _vec_len (nm->rx_buffers[cpu_index]) -= 2;
+ u32 last_buf = vec_len (nm->rx_buffers[thread_index]) - 1;
+ bi0 = nm->rx_buffers[thread_index][last_buf];
+ bi1 = nm->rx_buffers[thread_index][last_buf - 1];
+ _vec_len (nm->rx_buffers[thread_index]) -= 2;
if (last_buf > 4)
{
- memif_prefetch (vm, nm->rx_buffers[cpu_index][last_buf - 2]);
- memif_prefetch (vm, nm->rx_buffers[cpu_index][last_buf - 3]);
+ memif_prefetch (vm, nm->rx_buffers[thread_index][last_buf - 2]);
+ memif_prefetch (vm, nm->rx_buffers[thread_index][last_buf - 3]);
}
/* enqueue buffer */
@@ -256,9 +257,9 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
while (num_slots && n_left_to_next)
{
/* get empty buffer */
- u32 last_buf = vec_len (nm->rx_buffers[cpu_index]) - 1;
- bi0 = nm->rx_buffers[cpu_index][last_buf];
- _vec_len (nm->rx_buffers[cpu_index]) = last_buf;
+ u32 last_buf = vec_len (nm->rx_buffers[thread_index]) - 1;
+ bi0 = nm->rx_buffers[thread_index][last_buf];
+ _vec_len (nm->rx_buffers[thread_index]) = last_buf;
/* enqueue buffer */
to_next[0] = bi0;
@@ -315,7 +316,7 @@ memif_device_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
ring->tail = head;
vlib_increment_combined_counter (vnm->interface_main.combined_sw_if_counters
- + VNET_INTERFACE_COUNTER_RX, cpu_index,
+ + VNET_INTERFACE_COUNTER_RX, thread_index,
mif->hw_if_index, n_rx_packets,
n_rx_bytes);
@@ -327,7 +328,7 @@ memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
u32 n_rx_packets = 0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
memif_main_t *nm = &memif_main;
memif_if_t *mif;
@@ -337,7 +338,7 @@ memif_input_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
if (mif->flags & MEMIF_IF_FLAG_ADMIN_UP &&
mif->flags & MEMIF_IF_FLAG_CONNECTED &&
(mif->if_index % nm->input_cpu_count) ==
- (cpu_index - nm->input_cpu_first_index))
+ (thread_index - nm->input_cpu_first_index))
{
if (mif->flags & MEMIF_IF_FLAG_IS_SLAVE)
n_rx_packets +=
diff --git a/src/plugins/snat/in2out.c b/src/plugins/snat/in2out.c
index b4961365..e5ee965f 100644
--- a/src/plugins/snat/in2out.c
+++ b/src/plugins/snat/in2out.c
@@ -212,7 +212,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
snat_session_t ** sessionp,
vlib_node_runtime_t * node,
u32 next0,
- u32 cpu_index)
+ u32 thread_index)
{
snat_user_t *u;
snat_user_key_t user_key;
@@ -246,27 +246,27 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
if (clib_bihash_search_8_8 (&sm->user_hash, &kv0, &value0))
{
/* no, make a new one */
- pool_get (sm->per_thread_data[cpu_index].users, u);
+ pool_get (sm->per_thread_data[thread_index].users, u);
memset (u, 0, sizeof (*u));
u->addr = ip0->src_address;
u->fib_index = rx_fib_index0;
- pool_get (sm->per_thread_data[cpu_index].list_pool, per_user_list_head_elt);
+ pool_get (sm->per_thread_data[thread_index].list_pool, per_user_list_head_elt);
u->sessions_per_user_list_head_index = per_user_list_head_elt -
- sm->per_thread_data[cpu_index].list_pool;
+ sm->per_thread_data[thread_index].list_pool;
- clib_dlist_init (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_init (sm->per_thread_data[thread_index].list_pool,
u->sessions_per_user_list_head_index);
- kv0.value = u - sm->per_thread_data[cpu_index].users;
+ kv0.value = u - sm->per_thread_data[thread_index].users;
/* add user */
clib_bihash_add_del_8_8 (&sm->user_hash, &kv0, 1 /* is_add */);
}
else
{
- u = pool_elt_at_index (sm->per_thread_data[cpu_index].users,
+ u = pool_elt_at_index (sm->per_thread_data[thread_index].users,
value0.value);
}
@@ -276,25 +276,25 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
/* Remove the oldest dynamic translation */
do {
oldest_per_user_translation_list_index =
- clib_dlist_remove_head (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove_head (sm->per_thread_data[thread_index].list_pool,
u->sessions_per_user_list_head_index);
ASSERT (oldest_per_user_translation_list_index != ~0);
/* add it back to the end of the LRU list */
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
u->sessions_per_user_list_head_index,
oldest_per_user_translation_list_index);
/* Get the list element */
oldest_per_user_translation_list_elt =
- pool_elt_at_index (sm->per_thread_data[cpu_index].list_pool,
+ pool_elt_at_index (sm->per_thread_data[thread_index].list_pool,
oldest_per_user_translation_list_index);
/* Get the session index from the list element */
session_index = oldest_per_user_translation_list_elt->value;
/* Get the session */
- s = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
session_index);
} while (snat_is_session_static (s));
@@ -346,7 +346,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
}
/* Create a new session */
- pool_get (sm->per_thread_data[cpu_index].sessions, s);
+ pool_get (sm->per_thread_data[thread_index].sessions, s);
memset (s, 0, sizeof (*s));
s->outside_address_index = address_index;
@@ -362,22 +362,22 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
}
/* Create list elts */
- pool_get (sm->per_thread_data[cpu_index].list_pool,
+ pool_get (sm->per_thread_data[thread_index].list_pool,
per_user_translation_list_elt);
- clib_dlist_init (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_init (sm->per_thread_data[thread_index].list_pool,
per_user_translation_list_elt -
- sm->per_thread_data[cpu_index].list_pool);
+ sm->per_thread_data[thread_index].list_pool);
per_user_translation_list_elt->value =
- s - sm->per_thread_data[cpu_index].sessions;
+ s - sm->per_thread_data[thread_index].sessions;
s->per_user_index = per_user_translation_list_elt -
- sm->per_thread_data[cpu_index].list_pool;
+ sm->per_thread_data[thread_index].list_pool;
s->per_user_list_head_index = u->sessions_per_user_list_head_index;
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s->per_user_list_head_index,
per_user_translation_list_elt -
- sm->per_thread_data[cpu_index].list_pool);
+ sm->per_thread_data[thread_index].list_pool);
}
s->in2out = *key0;
@@ -388,12 +388,12 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
/* Add to translation hashes */
kv0.key = s->in2out.as_u64;
- kv0.value = s - sm->per_thread_data[cpu_index].sessions;
+ kv0.value = s - sm->per_thread_data[thread_index].sessions;
if (clib_bihash_add_del_8_8 (&sm->in2out, &kv0, 1 /* is_add */))
clib_warning ("in2out key add failed");
kv0.key = s->out2in.as_u64;
- kv0.value = s - sm->per_thread_data[cpu_index].sessions;
+ kv0.value = s - sm->per_thread_data[thread_index].sessions;
if (clib_bihash_add_del_8_8 (&sm->out2in, &kv0, 1 /* is_add */))
clib_warning ("out2in key add failed");
@@ -403,7 +403,7 @@ static u32 slow_path (snat_main_t *sm, vlib_buffer_t *b0,
worker_by_out_key.port = s->out2in.port;
worker_by_out_key.fib_index = s->out2in.fib_index;
kv0.key = worker_by_out_key.as_u64;
- kv0.value = cpu_index;
+ kv0.value = thread_index;
clib_bihash_add_del_8_8 (&sm->worker_by_out, &kv0, 1);
/* log NAT event */
@@ -465,7 +465,7 @@ snat_in2out_error_t icmp_get_key(icmp46_header_t *icmp0,
*
* @param[in,out] sm SNAT main
* @param[in,out] node SNAT node runtime
- * @param[in] cpu_index CPU index
+ * @param[in] thread_index thread index
* @param[in,out] b0 buffer containing packet to be translated
* @param[out] p_key address and port before NAT translation
* @param[out] p_value address and port after NAT translation
@@ -473,7 +473,7 @@ snat_in2out_error_t icmp_get_key(icmp46_header_t *icmp0,
* @param d optional parameter
*/
u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d)
@@ -524,13 +524,13 @@ u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node,
}
next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0,
- &s0, node, next0, cpu_index);
+ &s0, node, next0, thread_index);
if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP))
goto out;
}
else
- s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value0.value);
out:
@@ -548,7 +548,7 @@ out:
*
* @param[in] sm SNAT main
* @param[in,out] node SNAT node runtime
- * @param[in] cpu_index CPU index
+ * @param[in] thread_index thread index
* @param[in,out] b0 buffer containing packet to be translated
* @param[out] p_key address and port before NAT translation
* @param[out] p_value address and port after NAT translation
@@ -556,7 +556,7 @@ out:
* @param d optional parameter
*/
u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d)
@@ -624,7 +624,7 @@ static inline u32 icmp_in2out (snat_main_t *sm,
u32 rx_fib_index0,
vlib_node_runtime_t * node,
u32 next0,
- u32 cpu_index,
+ u32 thread_index,
void *d)
{
snat_session_key_t key0, sm0;
@@ -641,7 +641,7 @@ static inline u32 icmp_in2out (snat_main_t *sm,
echo0 = (icmp_echo_header_t *)(icmp0+1);
- next0_tmp = sm->icmp_match_in2out_cb(sm, node, cpu_index, b0,
+ next0_tmp = sm->icmp_match_in2out_cb(sm, node, thread_index, b0,
&key0, &sm0, &dont_translate, d);
if (next0_tmp != ~0)
next0 = next0_tmp;
@@ -847,11 +847,11 @@ static inline u32 icmp_in2out_slow_path (snat_main_t *sm,
vlib_node_runtime_t * node,
u32 next0,
f64 now,
- u32 cpu_index,
+ u32 thread_index,
snat_session_t ** p_s0)
{
next0 = icmp_in2out(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
- next0, cpu_index, p_s0);
+ next0, thread_index, p_s0);
snat_session_t * s0 = *p_s0;
if (PREDICT_TRUE(next0 != SNAT_IN2OUT_NEXT_DROP && s0))
{
@@ -862,9 +862,9 @@ static inline u32 icmp_in2out_slow_path (snat_main_t *sm,
/* Per-user LRU list maintenance for dynamic translations */
if (!snat_is_session_static (s0))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s0->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s0->per_user_list_head_index,
s0->per_user_index);
}
@@ -884,7 +884,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
snat_runtime_t * rt = (snat_runtime_t *)node->runtime_data;
f64 now = vlib_time_now (vm);
u32 stats_node_index;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
stats_node_index = is_slow_path ? snat_in2out_slowpath_node.index :
snat_in2out_node.index;
@@ -977,7 +977,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
{
next0 = icmp_in2out_slow_path
(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0,
- node, next0, now, cpu_index, &s0);
+ node, next0, now, thread_index, &s0);
goto trace00;
}
}
@@ -1006,7 +1006,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
goto trace00;
next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0,
- &s0, node, next0, cpu_index);
+ &s0, node, next0, thread_index);
if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP))
goto trace00;
}
@@ -1017,7 +1017,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
}
}
else
- s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value0.value);
old_addr0 = ip0->src_address.as_u32;
@@ -1063,9 +1063,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s0))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s0->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s0->per_user_list_head_index,
s0->per_user_index);
}
@@ -1081,7 +1081,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
t->next_index = next0;
t->session_index = ~0;
if (s0)
- t->session_index = s0 - sm->per_thread_data[cpu_index].sessions;
+ t->session_index = s0 - sm->per_thread_data[thread_index].sessions;
}
pkts_processed += next0 != SNAT_IN2OUT_NEXT_DROP;
@@ -1117,7 +1117,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
{
next1 = icmp_in2out_slow_path
(sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
- next1, now, cpu_index, &s1);
+ next1, now, thread_index, &s1);
goto trace01;
}
}
@@ -1146,7 +1146,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
goto trace01;
next1 = slow_path (sm, b1, ip1, rx_fib_index1, &key1,
- &s1, node, next1, cpu_index);
+ &s1, node, next1, thread_index);
if (PREDICT_FALSE (next1 == SNAT_IN2OUT_NEXT_DROP))
goto trace01;
}
@@ -1157,7 +1157,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
}
}
else
- s1 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s1 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value1.value);
old_addr1 = ip1->src_address.as_u32;
@@ -1203,9 +1203,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s1))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s1->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s1->per_user_list_head_index,
s1->per_user_index);
}
@@ -1220,7 +1220,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
t->next_index = next1;
t->session_index = ~0;
if (s1)
- t->session_index = s1 - sm->per_thread_data[cpu_index].sessions;
+ t->session_index = s1 - sm->per_thread_data[thread_index].sessions;
}
pkts_processed += next1 != SNAT_IN2OUT_NEXT_DROP;
@@ -1292,7 +1292,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
{
next0 = icmp_in2out_slow_path
(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
- next0, now, cpu_index, &s0);
+ next0, now, thread_index, &s0);
goto trace0;
}
}
@@ -1321,7 +1321,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
goto trace0;
next0 = slow_path (sm, b0, ip0, rx_fib_index0, &key0,
- &s0, node, next0, cpu_index);
+ &s0, node, next0, thread_index);
if (PREDICT_FALSE (next0 == SNAT_IN2OUT_NEXT_DROP))
goto trace0;
@@ -1333,7 +1333,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
}
}
else
- s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value0.value);
old_addr0 = ip0->src_address.as_u32;
@@ -1379,9 +1379,9 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s0))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s0->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s0->per_user_list_head_index,
s0->per_user_index);
}
@@ -1397,7 +1397,7 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
t->next_index = next0;
t->session_index = ~0;
if (s0)
- t->session_index = s0 - sm->per_thread_data[cpu_index].sessions;
+ t->session_index = s0 - sm->per_thread_data[thread_index].sessions;
}
pkts_processed += next0 != SNAT_IN2OUT_NEXT_DROP;
@@ -2010,7 +2010,7 @@ snat_in2out_worker_handoff_fn (vlib_main_t * vm,
u32 n_left_to_next_worker = 0, *to_next_worker = 0;
u32 next_worker_index = 0;
u32 current_worker_index = ~0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
ASSERT (vec_len (sm->workers));
@@ -2048,7 +2048,7 @@ snat_in2out_worker_handoff_fn (vlib_main_t * vm,
next_worker_index = sm->worker_in2out_cb(ip0, rx_fib_index0);
- if (PREDICT_FALSE (next_worker_index != cpu_index))
+ if (PREDICT_FALSE (next_worker_index != thread_index))
{
do_handoff = 1;
diff --git a/src/plugins/snat/out2in.c b/src/plugins/snat/out2in.c
index 656e42db..5d308d78 100644
--- a/src/plugins/snat/out2in.c
+++ b/src/plugins/snat/out2in.c
@@ -129,7 +129,7 @@ create_session_for_static_mapping (snat_main_t *sm,
snat_session_key_t in2out,
snat_session_key_t out2in,
vlib_node_runtime_t * node,
- u32 cpu_index)
+ u32 thread_index)
{
snat_user_t *u;
snat_user_key_t user_key;
@@ -146,36 +146,36 @@ create_session_for_static_mapping (snat_main_t *sm,
if (clib_bihash_search_8_8 (&sm->user_hash, &kv0, &value0))
{
/* no, make a new one */
- pool_get (sm->per_thread_data[cpu_index].users, u);
+ pool_get (sm->per_thread_data[thread_index].users, u);
memset (u, 0, sizeof (*u));
u->addr = in2out.addr;
u->fib_index = in2out.fib_index;
- pool_get (sm->per_thread_data[cpu_index].list_pool,
+ pool_get (sm->per_thread_data[thread_index].list_pool,
per_user_list_head_elt);
u->sessions_per_user_list_head_index = per_user_list_head_elt -
- sm->per_thread_data[cpu_index].list_pool;
+ sm->per_thread_data[thread_index].list_pool;
- clib_dlist_init (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_init (sm->per_thread_data[thread_index].list_pool,
u->sessions_per_user_list_head_index);
- kv0.value = u - sm->per_thread_data[cpu_index].users;
+ kv0.value = u - sm->per_thread_data[thread_index].users;
/* add user */
clib_bihash_add_del_8_8 (&sm->user_hash, &kv0, 1 /* is_add */);
/* add non-traslated packets worker lookup */
- kv0.value = cpu_index;
+ kv0.value = thread_index;
clib_bihash_add_del_8_8 (&sm->worker_by_in, &kv0, 1);
}
else
{
- u = pool_elt_at_index (sm->per_thread_data[cpu_index].users,
+ u = pool_elt_at_index (sm->per_thread_data[thread_index].users,
value0.value);
}
- pool_get (sm->per_thread_data[cpu_index].sessions, s);
+ pool_get (sm->per_thread_data[thread_index].sessions, s);
memset (s, 0, sizeof (*s));
s->outside_address_index = ~0;
@@ -183,22 +183,22 @@ create_session_for_static_mapping (snat_main_t *sm,
u->nstaticsessions++;
/* Create list elts */
- pool_get (sm->per_thread_data[cpu_index].list_pool,
+ pool_get (sm->per_thread_data[thread_index].list_pool,
per_user_translation_list_elt);
- clib_dlist_init (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_init (sm->per_thread_data[thread_index].list_pool,
per_user_translation_list_elt -
- sm->per_thread_data[cpu_index].list_pool);
+ sm->per_thread_data[thread_index].list_pool);
per_user_translation_list_elt->value =
- s - sm->per_thread_data[cpu_index].sessions;
+ s - sm->per_thread_data[thread_index].sessions;
s->per_user_index =
- per_user_translation_list_elt - sm->per_thread_data[cpu_index].list_pool;
+ per_user_translation_list_elt - sm->per_thread_data[thread_index].list_pool;
s->per_user_list_head_index = u->sessions_per_user_list_head_index;
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s->per_user_list_head_index,
per_user_translation_list_elt -
- sm->per_thread_data[cpu_index].list_pool);
+ sm->per_thread_data[thread_index].list_pool);
s->in2out = in2out;
s->out2in = out2in;
@@ -206,12 +206,12 @@ create_session_for_static_mapping (snat_main_t *sm,
/* Add to translation hashes */
kv0.key = s->in2out.as_u64;
- kv0.value = s - sm->per_thread_data[cpu_index].sessions;
+ kv0.value = s - sm->per_thread_data[thread_index].sessions;
if (clib_bihash_add_del_8_8 (&sm->in2out, &kv0, 1 /* is_add */))
clib_warning ("in2out key add failed");
kv0.key = s->out2in.as_u64;
- kv0.value = s - sm->per_thread_data[cpu_index].sessions;
+ kv0.value = s - sm->per_thread_data[thread_index].sessions;
if (clib_bihash_add_del_8_8 (&sm->out2in, &kv0, 1 /* is_add */))
clib_warning ("out2in key add failed");
@@ -298,7 +298,7 @@ is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0,
*
* @param[in,out] sm SNAT main
* @param[in,out] node SNAT node runtime
- * @param[in] cpu_index CPU index
+ * @param[in] thread_index thread index
* @param[in,out] b0 buffer containing packet to be translated
* @param[out] p_key address and port before NAT translation
* @param[out] p_value address and port after NAT translation
@@ -306,7 +306,7 @@ is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0,
* @param d optional parameter
*/
u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d)
@@ -366,7 +366,7 @@ u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node,
/* Create session initiated by host from external network */
s0 = create_session_for_static_mapping(sm, b0, sm0, key0,
- node, cpu_index);
+ node, thread_index);
if (!s0)
{
@@ -375,7 +375,7 @@ u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node,
}
}
else
- s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value0.value);
out:
@@ -393,7 +393,7 @@ out:
*
* @param[in] sm SNAT main
* @param[in,out] node SNAT node runtime
- * @param[in] cpu_index CPU index
+ * @param[in] thread_index thread index
* @param[in,out] b0 buffer containing packet to be translated
* @param[out] p_key address and port before NAT translation
* @param[out] p_value address and port after NAT translation
@@ -401,7 +401,7 @@ out:
* @param d optional parameter
*/
u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d)
@@ -460,7 +460,7 @@ static inline u32 icmp_out2in (snat_main_t *sm,
u32 rx_fib_index0,
vlib_node_runtime_t * node,
u32 next0,
- u32 cpu_index,
+ u32 thread_index,
void *d)
{
snat_session_key_t key0, sm0;
@@ -477,7 +477,7 @@ static inline u32 icmp_out2in (snat_main_t *sm,
echo0 = (icmp_echo_header_t *)(icmp0+1);
- next0_tmp = sm->icmp_match_out2in_cb(sm, node, cpu_index, b0,
+ next0_tmp = sm->icmp_match_out2in_cb(sm, node, thread_index, b0,
&key0, &sm0, &dont_translate, d);
if (next0_tmp != ~0)
next0 = next0_tmp;
@@ -589,11 +589,11 @@ static inline u32 icmp_out2in_slow_path (snat_main_t *sm,
u32 rx_fib_index0,
vlib_node_runtime_t * node,
u32 next0, f64 now,
- u32 cpu_index,
+ u32 thread_index,
snat_session_t ** p_s0)
{
next0 = icmp_out2in(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
- next0, cpu_index, p_s0);
+ next0, thread_index, p_s0);
snat_session_t * s0 = *p_s0;
if (PREDICT_TRUE(next0 != SNAT_OUT2IN_NEXT_DROP && s0))
{
@@ -604,9 +604,9 @@ static inline u32 icmp_out2in_slow_path (snat_main_t *sm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s0))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s0->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s0->per_user_list_head_index,
s0->per_user_index);
}
@@ -624,7 +624,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
u32 pkts_processed = 0;
snat_main_t * sm = &snat_main;
f64 now = vlib_time_now (vm);
- u32 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;
@@ -712,7 +712,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
{
next0 = icmp_out2in_slow_path
(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
- next0, now, cpu_index, &s0);
+ next0, now, thread_index, &s0);
goto trace0;
}
@@ -743,7 +743,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* Create session initiated by host from external network */
s0 = create_session_for_static_mapping(sm, b0, sm0, key0, node,
- cpu_index);
+ thread_index);
if (!s0)
{
b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
@@ -752,7 +752,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
}
}
else
- s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value0.value);
old_addr0 = ip0->dst_address.as_u32;
@@ -796,9 +796,9 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s0))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s0->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s0->per_user_list_head_index,
s0->per_user_index);
}
@@ -813,7 +813,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
t->next_index = next0;
t->session_index = ~0;
if (s0)
- t->session_index = s0 - sm->per_thread_data[cpu_index].sessions;
+ t->session_index = s0 - sm->per_thread_data[thread_index].sessions;
}
pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP;
@@ -847,7 +847,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
{
next1 = icmp_out2in_slow_path
(sm, b1, ip1, icmp1, sw_if_index1, rx_fib_index1, node,
- next1, now, cpu_index, &s1);
+ next1, now, thread_index, &s1);
goto trace1;
}
@@ -878,7 +878,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* Create session initiated by host from external network */
s1 = create_session_for_static_mapping(sm, b1, sm1, key1, node,
- cpu_index);
+ thread_index);
if (!s1)
{
b1->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
@@ -887,7 +887,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
}
}
else
- s1 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s1 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value1.value);
old_addr1 = ip1->dst_address.as_u32;
@@ -931,9 +931,9 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s1))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s1->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s1->per_user_list_head_index,
s1->per_user_index);
}
@@ -948,7 +948,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
t->next_index = next1;
t->session_index = ~0;
if (s1)
- t->session_index = s1 - sm->per_thread_data[cpu_index].sessions;
+ t->session_index = s1 - sm->per_thread_data[thread_index].sessions;
}
pkts_processed += next1 != SNAT_OUT2IN_NEXT_DROP;
@@ -1016,7 +1016,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
{
next0 = icmp_out2in_slow_path
(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
- next0, now, cpu_index, &s0);
+ next0, now, thread_index, &s0);
goto trace00;
}
@@ -1048,7 +1048,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* Create session initiated by host from external network */
s0 = create_session_for_static_mapping(sm, b0, sm0, key0, node,
- cpu_index);
+ thread_index);
if (!s0)
{
b0->error = node->errors[SNAT_OUT2IN_ERROR_NO_TRANSLATION];
@@ -1057,7 +1057,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
}
}
else
- s0 = pool_elt_at_index (sm->per_thread_data[cpu_index].sessions,
+ s0 = pool_elt_at_index (sm->per_thread_data[thread_index].sessions,
value0.value);
old_addr0 = ip0->dst_address.as_u32;
@@ -1101,9 +1101,9 @@ snat_out2in_node_fn (vlib_main_t * vm,
/* Per-user LRU list maintenance for dynamic translation */
if (!snat_is_session_static (s0))
{
- clib_dlist_remove (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_remove (sm->per_thread_data[thread_index].list_pool,
s0->per_user_index);
- clib_dlist_addtail (sm->per_thread_data[cpu_index].list_pool,
+ clib_dlist_addtail (sm->per_thread_data[thread_index].list_pool,
s0->per_user_list_head_index,
s0->per_user_index);
}
@@ -1118,7 +1118,7 @@ snat_out2in_node_fn (vlib_main_t * vm,
t->next_index = next0;
t->session_index = ~0;
if (s0)
- t->session_index = s0 - sm->per_thread_data[cpu_index].sessions;
+ t->session_index = s0 - sm->per_thread_data[thread_index].sessions;
}
pkts_processed += next0 != SNAT_OUT2IN_NEXT_DROP;
@@ -1599,7 +1599,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm,
u32 n_left_to_next_worker = 0, *to_next_worker = 0;
u32 next_worker_index = 0;
u32 current_worker_index = ~0;
- u32 cpu_index = os_get_cpu_number ();
+ u32 thread_index = vlib_get_thread_index ();
ASSERT (vec_len (sm->workers));
@@ -1637,7 +1637,7 @@ snat_out2in_worker_handoff_fn (vlib_main_t * vm,
next_worker_index = sm->worker_out2in_cb(ip0, rx_fib_index0);
- if (PREDICT_FALSE (next_worker_index != cpu_index))
+ if (PREDICT_FALSE (next_worker_index != thread_index))
{
do_handoff = 1;
diff --git a/src/plugins/snat/snat.h b/src/plugins/snat/snat.h
index 017825c0..f4e1c5c0 100644
--- a/src/plugins/snat/snat.h
+++ b/src/plugins/snat/snat.h
@@ -221,7 +221,7 @@ struct snat_main_s;
typedef u32 snat_icmp_match_function_t (struct snat_main_s *sm,
vlib_node_runtime_t *node,
- u32 cpu_index,
+ u32 thread_index,
vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
@@ -402,22 +402,22 @@ typedef struct {
} tcp_udp_header_t;
u32 icmp_match_in2out_fast(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d);
u32 icmp_match_in2out_slow(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d);
u32 icmp_match_out2in_fast(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d);
u32 icmp_match_out2in_slow(snat_main_t *sm, vlib_node_runtime_t *node,
- u32 cpu_index, vlib_buffer_t *b0,
+ u32 thread_index, vlib_buffer_t *b0,
snat_session_key_t *p_key,
snat_session_key_t *p_value,
u8 *p_dont_translate, void *d);