summaryrefslogtreecommitdiffstats
path: root/src/vnet/ethernet
diff options
context:
space:
mode:
authorPavel Kotucek <pkotucek@cisco.com>2017-08-15 13:13:28 +0200
committerNeale Ranns <nranns@cisco.com>2017-08-16 12:18:22 +0000
commit4f80b81d4a7ab537b7a6ede88abed26f278c0f26 (patch)
tree4cb235d051ae6b19502eaeb5cdb49de16e330a39 /src/vnet/ethernet
parentf8cd5817442f3a191befb3242a2c0c9bdd927ce0 (diff)
Add missing counters for P2P ethernet interfaces
Change-Id: I9d172d70f645fea5005abced73ca2700e640263a Signed-off-by: Pavel Kotucek <pkotucek@cisco.com>
Diffstat (limited to 'src/vnet/ethernet')
-rw-r--r--src/vnet/ethernet/p2p_ethernet.c25
-rw-r--r--src/vnet/ethernet/p2p_ethernet_input.c15
2 files changed, 40 insertions, 0 deletions
diff --git a/src/vnet/ethernet/p2p_ethernet.c b/src/vnet/ethernet/p2p_ethernet.c
index e3f667b5ffe..cf3c56b5d24 100644
--- a/src/vnet/ethernet/p2p_ethernet.c
+++ b/src/vnet/ethernet/p2p_ethernet.c
@@ -96,6 +96,31 @@ p2p_ethernet_add_del (vlib_main_t * vm, u32 parent_if_index,
if (vnet_create_sw_interface (vnm, &template, &p2pe_sw_if_index))
return VNET_API_ERROR_SUBIF_CREATE_FAILED;
+ /* Allocate counters for this interface. */
+ {
+ u32 i;
+
+ vnet_interface_counter_lock (im);
+
+ for (i = 0; i < vec_len (im->sw_if_counters); i++)
+ {
+ vlib_validate_simple_counter (&im->sw_if_counters[i],
+ p2pe_sw_if_index);
+ vlib_zero_simple_counter (&im->sw_if_counters[i],
+ p2pe_sw_if_index);
+ }
+
+ for (i = 0; i < vec_len (im->combined_sw_if_counters); i++)
+ {
+ vlib_validate_combined_counter (&im->combined_sw_if_counters
+ [i], p2pe_sw_if_index);
+ vlib_zero_combined_counter (&im->combined_sw_if_counters[i],
+ p2pe_sw_if_index);
+ }
+
+ vnet_interface_counter_unlock (im);
+ }
+
vnet_interface_main_t *im = &vnm->interface_main;
sup_and_sub_key =
((u64) (hi->sw_if_index) << 32) | (u64) p2pe_subif_id;
diff --git a/src/vnet/ethernet/p2p_ethernet_input.c b/src/vnet/ethernet/p2p_ethernet_input.c
index a58b832af14..eeff4f06819 100644
--- a/src/vnet/ethernet/p2p_ethernet_input.c
+++ b/src/vnet/ethernet/p2p_ethernet_input.c
@@ -63,10 +63,13 @@ static uword
p2p_ethernet_input_node_fn (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * frame)
{
+ u32 thread_index = vlib_get_thread_index ();
u32 n_trace = vlib_get_trace_count (vm, node);
u32 n_left_from, *from, *to_next;
u32 next_index;
u32 n_p2p_ethernet_packets = 0;
+ vlib_combined_counter_main_t *cm =
+ vnet_get_main ()->interface_main.combined_sw_if_counters;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -126,6 +129,10 @@ p2p_ethernet_input_node_fn (vlib_main_t * vm,
t0->sw_if_index = sw_if_index0;
t0->p2pe_sw_if_index = rx0;
}
+
+ vlib_increment_combined_counter (cm, thread_index, rx0, 1,
+ vlib_buffer_length_in_chain
+ (vm, b0));
}
if (rx1 != ~0)
{
@@ -143,6 +150,10 @@ p2p_ethernet_input_node_fn (vlib_main_t * vm,
t1->sw_if_index = sw_if_index1;
t1->p2pe_sw_if_index = rx1;
}
+
+ vlib_increment_combined_counter (cm, thread_index, rx1, 1,
+ vlib_buffer_length_in_chain
+ (vm, b1));
}
/* verify speculative enqueue, maybe switch current next frame */
@@ -194,6 +205,10 @@ p2p_ethernet_input_node_fn (vlib_main_t * vm,
t0->sw_if_index = sw_if_index0;
t0->p2pe_sw_if_index = rx0;
}
+
+ vlib_increment_combined_counter (cm, thread_index, rx0, 1,
+ vlib_buffer_length_in_chain
+ (vm, b0));
}
else
{