net/sfc: support extended statistics
authorAndrew Rybchenko <arybchenko@solarflare.com>
Thu, 15 Dec 2016 12:50:55 +0000 (12:50 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 17 Jan 2017 18:40:50 +0000 (19:40 +0100)
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andrew Lee <alee@solarflare.com>
Reviewed-by: Robert Stonehouse <rstonehouse@solarflare.com>
doc/guides/nics/features/sfc_efx.ini
doc/guides/nics/sfc_efx.rst
drivers/net/sfc/efsys.h
drivers/net/sfc/sfc_ethdev.c

index f55a988..698553c 100644 (file)
@@ -8,6 +8,7 @@ Link status          = Y
 L3 checksum offload  = P
 L4 checksum offload  = P
 Basic stats          = Y
+Extended stats       = Y
 BSD nic_uio          = Y
 Linux UIO            = Y
 Linux VFIO           = Y
index cbb51de..eb9d26d 100644 (file)
@@ -50,6 +50,9 @@ SFC EFX PMD has support for:
 
 - Port hardware statistics
 
+- Extended statistics (see Solarflare Server Adapter User's Guide for
+  the statistics description)
+
 
 Non-supported Features
 ----------------------
index fe8615f..0f941e6 100644 (file)
@@ -159,7 +159,7 @@ prefetch_read_once(const volatile void *addr)
 /* Code inclusion options */
 
 
-#define EFSYS_OPT_NAMES 0
+#define EFSYS_OPT_NAMES 1
 
 /* Disable SFN5xxx/SFN6xxx since it requires specific support in the PMD */
 #define EFSYS_OPT_SIENA 0
index 3a92cac..e1125e4 100644 (file)
@@ -391,6 +391,67 @@ unlock:
        rte_spinlock_unlock(&port->mac_stats_lock);
 }
 
+static int
+sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
+              unsigned int xstats_count)
+{
+       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_port *port = &sa->port;
+       uint64_t *mac_stats;
+       int rc;
+       unsigned int i;
+       int nstats = 0;
+
+       rte_spinlock_lock(&port->mac_stats_lock);
+
+       rc = sfc_port_update_mac_stats(sa);
+       if (rc != 0) {
+               SFC_ASSERT(rc > 0);
+               nstats = -rc;
+               goto unlock;
+       }
+
+       mac_stats = port->mac_stats_buf;
+
+       for (i = 0; i < EFX_MAC_NSTATS; ++i) {
+               if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
+                       if (xstats != NULL && nstats < (int)xstats_count) {
+                               xstats[nstats].id = nstats;
+                               xstats[nstats].value = mac_stats[i];
+                       }
+                       nstats++;
+               }
+       }
+
+unlock:
+       rte_spinlock_unlock(&port->mac_stats_lock);
+
+       return nstats;
+}
+
+static int
+sfc_xstats_get_names(struct rte_eth_dev *dev,
+                    struct rte_eth_xstat_name *xstats_names,
+                    unsigned int xstats_count)
+{
+       struct sfc_adapter *sa = dev->data->dev_private;
+       struct sfc_port *port = &sa->port;
+       unsigned int i;
+       unsigned int nstats = 0;
+
+       for (i = 0; i < EFX_MAC_NSTATS; ++i) {
+               if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
+                       if (xstats_names != NULL && nstats < xstats_count)
+                               strncpy(xstats_names[nstats].name,
+                                       efx_mac_stat_name(sa->nic, i),
+                                       sizeof(xstats_names[0].name));
+                       nstats++;
+               }
+       }
+
+       return nstats;
+}
+
 static const struct eth_dev_ops sfc_eth_dev_ops = {
        .dev_configure                  = sfc_dev_configure,
        .dev_start                      = sfc_dev_start,
@@ -398,6 +459,8 @@ static const struct eth_dev_ops sfc_eth_dev_ops = {
        .dev_close                      = sfc_dev_close,
        .link_update                    = sfc_dev_link_update,
        .stats_get                      = sfc_stats_get,
+       .xstats_get                     = sfc_xstats_get,
+       .xstats_get_names               = sfc_xstats_get_names,
        .dev_infos_get                  = sfc_dev_infos_get,
        .rx_queue_setup                 = sfc_rx_queue_setup,
        .rx_queue_release               = sfc_rx_queue_release,