From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo01.seg.att.com (nbfkord-smmo01.seg.att.com [209.65.160.76]) by dpdk.org (Postfix) with ESMTP id 5A2B7475E for ; Thu, 15 Dec 2016 13:52:12 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO webmail.solarflare.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id cf192585.2b9fc6c3d940.721152.00-2494.1504283.nbfkord-smmo01.seg.att.com (envelope-from ); Thu, 15 Dec 2016 12:52:12 +0000 (UTC) X-MXL-Hash: 585291fc7400d5fc-21368153fb713373dbf8bd838b06e256285a4188 Received: from unknown [12.187.104.26] (EHLO webmail.solarflare.com) by nbfkord-smmo01.seg.att.com(mxl_mta-7.2.4-7) over TLS secured channel with ESMTP id af192585.0.721151.00-2387.1504277.nbfkord-smmo01.seg.att.com (envelope-from ); Thu, 15 Dec 2016 12:52:11 +0000 (UTC) X-MXL-Hash: 585291fb7c631e7e-e44c0813c2d882dfc8d807f866dc9eec2361c94f Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Thu, 15 Dec 2016 04:52:05 -0800 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1044.25 via Frontend Transport; Thu, 15 Dec 2016 04:52:05 -0800 Received: from uklogin.uk.solarflarecom.com (uklogin.uk.solarflarecom.com [10.17.10.10]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uBFCq3gB006351; Thu, 15 Dec 2016 12:52:03 GMT Received: from uklogin.uk.solarflarecom.com (localhost.localdomain [127.0.0.1]) by uklogin.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id uBFCpced010431; Thu, 15 Dec 2016 12:52:03 GMT From: Andrew Rybchenko To: CC: Date: Thu, 15 Dec 2016 12:50:55 +0000 Message-ID: <1481806283-10387-5-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1481806283-10387-1-git-send-email-arybchenko@solarflare.com> References: <1480664691-26561-1-git-send-email-arybchenko@solarflare.com> <1481806283-10387-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=I8xjMYUg c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=n5n_aSjo0skA:10 a=zRKbQ67AAAAA:8 a=1c0Gvsut1gQ0ElyZZ] X-AnalysisOut: [jwA:9 a=PA03WX8tBzeizutn5_OT:22] X-Spam: [F=0.2000000000; CM=0.500; S=0.200(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH v2 04/32] net/sfc: support extended statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2016 12:52:12 -0000 Signed-off-by: Andrew Rybchenko Reviewed-by: Andrew Lee Reviewed-by: Robert Stonehouse --- doc/guides/nics/features/sfc_efx.ini | 1 + doc/guides/nics/sfc_efx.rst | 3 ++ drivers/net/sfc/efsys.h | 2 +- drivers/net/sfc/sfc_ethdev.c | 63 ++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini index f55a988..698553c 100644 --- a/doc/guides/nics/features/sfc_efx.ini +++ b/doc/guides/nics/features/sfc_efx.ini @@ -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 diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index cbb51de..eb9d26d 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -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 ---------------------- diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h index fe8615f..0f941e6 100644 --- a/drivers/net/sfc/efsys.h +++ b/drivers/net/sfc/efsys.h @@ -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 diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index f31330c..d5ae1a0 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -392,6 +392,67 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) 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, @@ -399,6 +460,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, -- 2.5.5