summaryrefslogtreecommitdiffstats
path: root/src/vnet/interface_output.c
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/interface_output.c
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/interface_output.c')
-rw-r--r--src/vnet/interface_output.c53
1 files changed, 27 insertions, 26 deletions
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);
}