[dpdk-dev] [PATCH 13/16] net/avp: device statistics operations
Allain Legacy
allain.legacy at windriver.com
Sat Feb 25 02:23:12 CET 2017
Adds support for device get/set operations against an AVP device so that an
application can query and reset statistics on an AVP device.
Signed-off-by: Allain Legacy <allain.legacy at windriver.com>
Signed-off-by: Matt Peters <matt.peters at windriver.com>
---
config/common_base | 1 +
drivers/net/avp/avp_ethdev.c | 81 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
diff --git a/config/common_base b/config/common_base
index fe8363d..02dac41 100644
--- a/config/common_base
+++ b/config/common_base
@@ -355,6 +355,7 @@ CONFIG_RTE_LIBRTE_AVP_DEBUG_RX=n
CONFIG_RTE_LIBRTE_AVP_DEBUG_TX=n
CONFIG_RTE_LIBRTE_AVP_DEBUG_DRIVER=y
CONFIG_RTE_LIBRTE_AVP_DEBUG_BUFFERS=n
+CONFIG_RTE_LIBRTE_AVP_STATS=y
#
# Compile the TAP PMD
diff --git a/drivers/net/avp/avp_ethdev.c b/drivers/net/avp/avp_ethdev.c
index ffb6eeb..61861fc 100644
--- a/drivers/net/avp/avp_ethdev.c
+++ b/drivers/net/avp/avp_ethdev.c
@@ -103,6 +103,12 @@ static uint16_t avp_xmit_pkts(void *tx_queue,
static void avp_dev_rx_queue_release(void *rxq);
static void avp_dev_tx_queue_release(void *txq);
+
+static void avp_dev_stats_get(struct rte_eth_dev *dev,
+ struct rte_eth_stats *stats);
+static void avp_dev_stats_reset(struct rte_eth_dev *dev);
+
+
#define AVP_DEV_TO_PCI(eth_dev) RTE_DEV_TO_PCI((eth_dev)->device)
@@ -149,6 +155,8 @@ static uint16_t avp_xmit_pkts(void *tx_queue,
.dev_configure = avp_dev_configure,
.dev_infos_get = avp_dev_info_get,
.vlan_offload_set = avp_vlan_offload_set,
+ .stats_get = avp_dev_stats_get,
+ .stats_reset = avp_dev_stats_reset,
.link_update = avp_dev_link_update,
.rx_queue_setup = avp_dev_rx_queue_setup,
.rx_queue_release = avp_dev_rx_queue_release,
@@ -2095,6 +2103,79 @@ struct avp_queue {
}
}
+static void
+avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats)
+{
+#ifdef RTE_LIBRTE_AVP_STATS
+ struct avp_dev *avp =
+ RTE_AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+ unsigned i;
+
+ memset(stats, 0, sizeof(*stats));
+ for (i = 0; i < avp->num_rx_queues; i++) {
+ struct avp_queue *rxq = avp->dev_data->rx_queues[i];
+
+ if (rxq) {
+ stats->ipackets += rxq->packets;
+ stats->ibytes += rxq->bytes;
+ stats->ierrors += rxq->errors;
+
+ stats->q_ipackets[i] += rxq->packets;
+ stats->q_ibytes[i] += rxq->bytes;
+ stats->q_errors[i] += rxq->errors;
+ }
+ }
+
+ for (i = 0; i < avp->num_tx_queues; i++) {
+ struct avp_queue *txq = avp->dev_data->tx_queues[i];
+
+ if (txq) {
+ stats->opackets += txq->packets;
+ stats->obytes += txq->bytes;
+ stats->oerrors += txq->errors;
+
+ stats->q_opackets[i] += txq->packets;
+ stats->q_obytes[i] += txq->bytes;
+ stats->q_errors[i] += txq->errors;
+ }
+ }
+#else
+ (void)eth_dev;
+ (void)stats;
+#endif
+}
+
+static void
+avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+#ifdef RTE_LIBRTE_AVP_STATS
+ struct avp_dev *avp =
+ RTE_AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+ unsigned i;
+
+ for (i = 0; i < avp->num_rx_queues; i++) {
+ struct avp_queue *rxq = avp->dev_data->rx_queues[i];
+
+ if (rxq) {
+ rxq->bytes = 0;
+ rxq->packets = 0;
+ rxq->errors = 0;
+ }
+ }
+
+ for (i = 0; i < avp->num_tx_queues; i++) {
+ struct avp_queue *txq = avp->dev_data->tx_queues[i];
+
+ if (txq) {
+ txq->bytes = 0;
+ txq->packets = 0;
+ txq->errors = 0;
+ }
+ }
+#else
+ (void)eth_dev;
+#endif
+}
RTE_PMD_REGISTER_PCI(rte_avp, rte_avp_pmd.pci_drv);
RTE_PMD_REGISTER_PCI_TABLE(rte_avp, pci_id_avp_map);
--
1.8.3.1
More information about the dev
mailing list