dev: add port and queue counter clear operation
Type: feature
Change-Id: Ibd876c5251fc2f9d87816d235fff2de22be4b21c
Signed-off-by: Monendra Singh Kushwaha <kmonendra@marvell.com>
diff --git a/src/vnet/dev/dev.h b/src/vnet/dev/dev.h
index bbf2f9d..eb06eeb 100644
--- a/src/vnet/dev/dev.h
+++ b/src/vnet/dev/dev.h
@@ -115,6 +115,7 @@
vnet_dev_rx_queue_op_t *start;
vnet_dev_rx_queue_op_no_rv_t *stop;
vnet_dev_rx_queue_op_no_rv_t *free;
+ vnet_dev_rx_queue_op_no_rv_t *clear_counters;
format_function_t *format_info;
} vnet_dev_rx_queue_ops_t;
@@ -124,6 +125,7 @@
vnet_dev_tx_queue_op_t *start;
vnet_dev_tx_queue_op_no_rv_t *stop;
vnet_dev_tx_queue_op_no_rv_t *free;
+ vnet_dev_tx_queue_op_no_rv_t *clear_counters;
format_function_t *format_info;
} vnet_dev_tx_queue_ops_t;
@@ -245,6 +247,7 @@
vnet_dev_port_op_no_rv_t *stop;
vnet_dev_port_op_no_rv_t *deinit;
vnet_dev_port_op_no_rv_t *free;
+ vnet_dev_port_op_no_rv_t *clear_counters;
format_function_t *format_status;
format_function_t *format_flow;
} vnet_dev_port_ops_t;
diff --git a/src/vnet/dev/port.c b/src/vnet/dev/port.c
index 8a6df54..5b4b8cd 100644
--- a/src/vnet/dev/port.c
+++ b/src/vnet/dev/port.c
@@ -733,16 +733,26 @@
void
vnet_dev_port_clear_counters (vlib_main_t *vm, vnet_dev_port_t *port)
{
- if (port->counter_main)
+ if (port->port_ops.clear_counters)
+ port->port_ops.clear_counters (vm, port);
+ else if (port->counter_main)
vnet_dev_counters_clear (vm, port->counter_main);
foreach_vnet_dev_port_rx_queue (q, port)
- if (q->counter_main)
- vnet_dev_counters_clear (vm, q->counter_main);
+ {
+ if (port->rx_queue_ops.clear_counters)
+ port->rx_queue_ops.clear_counters (vm, q);
+ else if (q->counter_main)
+ vnet_dev_counters_clear (vm, q->counter_main);
+ }
foreach_vnet_dev_port_tx_queue (q, port)
- if (q->counter_main)
- vnet_dev_counters_clear (vm, q->counter_main);
+ {
+ if (port->tx_queue_ops.clear_counters)
+ port->tx_queue_ops.clear_counters (vm, q);
+ else if (q->counter_main)
+ vnet_dev_counters_clear (vm, q->counter_main);
+ }
log_notice (port->dev, "counters cleared on port %u", port->port_id);
}