net/avp: add device statistics operations
authorAllain Legacy <allain.legacy@windriver.com>
Tue, 28 Mar 2017 11:54:05 +0000 (07:54 -0400)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 4 Apr 2017 17:02:18 +0000 (19:02 +0200)
Adds device functions to query and reset statistics.

Signed-off-by: Allain Legacy <allain.legacy@windriver.com>
Acked-by: Vincent Jardin <vincent.jardin@6wind.com>
doc/guides/nics/features/avp.ini
drivers/net/avp/avp_ethdev.c

index e748ea8..0de761c 100644 (file)
@@ -9,5 +9,7 @@ Jumbo frame          = Y
 Scattered Rx         = Y
 Unicast MAC filter   = Y
 VLAN offload         = Y
+Basic stats          = Y
+Stats per queue      = Y
 Linux UIO            = Y
 x86-64               = Y
index e8021e4..e2119df 100644 (file)
@@ -98,6 +98,10 @@ 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)
 
@@ -145,6 +149,8 @@ static const struct eth_dev_ops avp_eth_dev_ops = {
        .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,
@@ -1718,5 +1724,67 @@ avp_vlan_offload_set(struct rte_eth_dev *eth_dev, int mask)
        }
 }
 
+static void
+avp_dev_stats_get(struct rte_eth_dev *eth_dev, struct rte_eth_stats *stats)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       unsigned int i;
+
+       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;
+               }
+       }
+}
+
+static void
+avp_dev_stats_reset(struct rte_eth_dev *eth_dev)
+{
+       struct avp_dev *avp = AVP_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
+       unsigned int 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;
+               }
+       }
+}
+
 RTE_PMD_REGISTER_PCI(net_avp, rte_avp_pmd.pci_drv);
 RTE_PMD_REGISTER_PCI_TABLE(net_avp, pci_id_avp_map);