From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Subject: [dpdk-dev] [PATCH 03/31] net/sfc: implement ethdev hook to get basic statistics
Date: Fri, 2 Dec 2016 07:44:23 +0000 [thread overview]
Message-ID: <1480664691-26561-4-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1480664691-26561-1-git-send-email-arybchenko@solarflare.com>
Does not implement any deprecated statistics.
No per-queue statistics yet.
Reviewed-by: Andrew Lee <alee@solarflare.com>
Reviewed-by: Robert Stonehouse <rstonehouse@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
doc/guides/nics/features/sfc_efx.ini | 1 +
doc/guides/nics/sfc_efx.rst | 2 +
drivers/net/sfc/efsys.h | 2 +-
drivers/net/sfc/sfc.h | 7 ++++
drivers/net/sfc/sfc_ethdev.c | 69 +++++++++++++++++++++++++++++++++
drivers/net/sfc/sfc_port.c | 75 ++++++++++++++++++++++++++++++++++++
6 files changed, 155 insertions(+), 1 deletion(-)
diff --git a/doc/guides/nics/features/sfc_efx.ini b/doc/guides/nics/features/sfc_efx.ini
index 67df1c6..f55a988 100644
--- a/doc/guides/nics/features/sfc_efx.ini
+++ b/doc/guides/nics/features/sfc_efx.ini
@@ -7,6 +7,7 @@
Link status = Y
L3 checksum offload = P
L4 checksum offload = P
+Basic 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 36d0974..cbb51de 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -48,6 +48,8 @@ SFC EFX PMD has support for:
- IPv4/IPv6 TCP/UDP transmit checksum offload
+- Port hardware statistics
+
Non-supported Features
----------------------
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index d48eb4c..fe8615f 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -178,7 +178,7 @@ prefetch_read_once(const volatile void *addr)
#define EFSYS_OPT_MCDI_LOGGING 1
#define EFSYS_OPT_MCDI_PROXY_AUTH 0
-#define EFSYS_OPT_MAC_STATS 0
+#define EFSYS_OPT_MAC_STATS 1
#define EFSYS_OPT_LOOPBACK 0
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index d0aafa3..1189283 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -122,6 +122,12 @@ struct sfc_port {
unsigned int flow_ctrl;
boolean_t flow_ctrl_autoneg;
size_t pdu;
+
+ rte_spinlock_t mac_stats_lock;
+ uint64_t *mac_stats_buf;
+ efsys_mem_t mac_stats_dma_mem;
+
+ uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES];
};
/* Adapter private data */
@@ -229,6 +235,7 @@ int sfc_port_start(struct sfc_adapter *sa);
void sfc_port_stop(struct sfc_adapter *sa);
void sfc_port_link_mode_to_info(efx_link_mode_t link_mode,
struct rte_eth_link *link_info);
+int sfc_port_update_mac_stats(struct sfc_adapter *sa);
#ifdef __cplusplus
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 1df227e..f31330c 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -324,12 +324,81 @@ sfc_tx_queue_release(void *queue)
sfc_adapter_unlock(sa);
}
+static void
+sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
+{
+ struct sfc_adapter *sa = dev->data->dev_private;
+ struct sfc_port *port = &sa->port;
+ uint64_t *mac_stats;
+
+ rte_spinlock_lock(&port->mac_stats_lock);
+
+ if (sfc_port_update_mac_stats(sa) != 0)
+ goto unlock;
+
+ mac_stats = port->mac_stats_buf;
+
+ if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask,
+ EFX_MAC_VADAPTER_RX_UNICAST_PACKETS)) {
+ stats->ipackets =
+ mac_stats[EFX_MAC_VADAPTER_RX_UNICAST_PACKETS] +
+ mac_stats[EFX_MAC_VADAPTER_RX_MULTICAST_PACKETS] +
+ mac_stats[EFX_MAC_VADAPTER_RX_BROADCAST_PACKETS];
+ stats->opackets =
+ mac_stats[EFX_MAC_VADAPTER_TX_UNICAST_PACKETS] +
+ mac_stats[EFX_MAC_VADAPTER_TX_MULTICAST_PACKETS] +
+ mac_stats[EFX_MAC_VADAPTER_TX_BROADCAST_PACKETS];
+ stats->ibytes =
+ mac_stats[EFX_MAC_VADAPTER_RX_UNICAST_BYTES] +
+ mac_stats[EFX_MAC_VADAPTER_RX_MULTICAST_BYTES] +
+ mac_stats[EFX_MAC_VADAPTER_RX_BROADCAST_BYTES];
+ stats->obytes =
+ mac_stats[EFX_MAC_VADAPTER_TX_UNICAST_BYTES] +
+ mac_stats[EFX_MAC_VADAPTER_TX_MULTICAST_BYTES] +
+ mac_stats[EFX_MAC_VADAPTER_TX_BROADCAST_BYTES];
+ stats->imissed = mac_stats[EFX_MAC_VADAPTER_RX_OVERFLOW];
+ stats->ierrors = mac_stats[EFX_MAC_VADAPTER_RX_BAD_PACKETS];
+ stats->oerrors = mac_stats[EFX_MAC_VADAPTER_TX_BAD_PACKETS];
+ } else {
+ stats->ipackets = mac_stats[EFX_MAC_RX_PKTS];
+ stats->opackets = mac_stats[EFX_MAC_TX_PKTS];
+ stats->ibytes = mac_stats[EFX_MAC_RX_OCTETS];
+ stats->obytes = mac_stats[EFX_MAC_TX_OCTETS];
+ /*
+ * Take into account stats which are whenever supported
+ * on EF10. If some stat is not supported by current
+ * firmware variant or HW revision, it is guaranteed
+ * to be zero in mac_stats.
+ */
+ stats->imissed =
+ mac_stats[EFX_MAC_RX_NODESC_DROP_CNT] +
+ mac_stats[EFX_MAC_PM_TRUNC_BB_OVERFLOW] +
+ mac_stats[EFX_MAC_PM_DISCARD_BB_OVERFLOW] +
+ mac_stats[EFX_MAC_PM_TRUNC_VFIFO_FULL] +
+ mac_stats[EFX_MAC_PM_DISCARD_VFIFO_FULL] +
+ mac_stats[EFX_MAC_PM_TRUNC_QBB] +
+ mac_stats[EFX_MAC_PM_DISCARD_QBB] +
+ mac_stats[EFX_MAC_PM_DISCARD_MAPPING] +
+ mac_stats[EFX_MAC_RXDP_Q_DISABLED_PKTS] +
+ mac_stats[EFX_MAC_RXDP_DI_DROPPED_PKTS];
+ stats->ierrors =
+ mac_stats[EFX_MAC_RX_FCS_ERRORS] +
+ mac_stats[EFX_MAC_RX_ALIGN_ERRORS] +
+ mac_stats[EFX_MAC_RX_JABBER_PKTS];
+ /* no oerrors counters supported on EF10 */
+ }
+
+unlock:
+ rte_spinlock_unlock(&port->mac_stats_lock);
+}
+
static const struct eth_dev_ops sfc_eth_dev_ops = {
.dev_configure = sfc_dev_configure,
.dev_start = sfc_dev_start,
.dev_stop = sfc_dev_stop,
.dev_close = sfc_dev_close,
.link_update = sfc_dev_link_update,
+ .stats_get = sfc_stats_get,
.dev_infos_get = sfc_dev_infos_get,
.rx_queue_setup = sfc_rx_queue_setup,
.rx_queue_release = sfc_rx_queue_release,
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index c124181..d8ff097 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -32,6 +32,34 @@
#include "sfc.h"
#include "sfc_log.h"
+/**
+ * Update MAC statistics in the buffer.
+ *
+ * @param sa Adapter
+ *
+ * @return Status code
+ * @retval 0 Success
+ * @retval EAGAIN Try again
+ * @retval ENOMEM Memory allocation failure
+ */
+int
+sfc_port_update_mac_stats(struct sfc_adapter *sa)
+{
+ struct sfc_port *port = &sa->port;
+ int rc;
+
+ SFC_ASSERT(rte_spinlock_is_locked(&port->mac_stats_lock));
+
+ if (sa->state != SFC_ADAPTER_STARTED)
+ return EINVAL;
+
+ rc = efx_mac_stats_update(sa->nic, &port->mac_stats_dma_mem,
+ port->mac_stats_buf, NULL);
+ if (rc != 0)
+ return rc;
+
+ return 0;
+}
int
sfc_port_start(struct sfc_adapter *sa)
@@ -67,6 +95,19 @@ sfc_port_start(struct sfc_adapter *sa)
if (rc != 0)
goto fail_mac_filter_set;
+ efx_mac_stats_get_mask(sa->nic, port->mac_stats_mask,
+ sizeof(port->mac_stats_mask));
+
+ /* Update MAC stats using periodic DMA.
+ * Common code always uses 1000ms update period, so period_ms
+ * parameter only needs to be non-zero to start updates.
+ */
+ sfc_log_init(sa, "request MAC stats DMA'ing");
+ rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
+ 1000, B_FALSE);
+ if (rc != 0)
+ goto fail_mac_stats_periodic;
+
sfc_log_init(sa, "disable MAC drain");
rc = efx_mac_drain(sa->nic, B_FALSE);
if (rc != 0)
@@ -76,6 +117,10 @@ sfc_port_start(struct sfc_adapter *sa)
return 0;
fail_mac_drain:
+ (void)efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
+ 0, B_FALSE);
+
+fail_mac_stats_periodic:
fail_mac_filter_set:
fail_mac_addr_set:
fail_mac_pdu_set:
@@ -95,6 +140,10 @@ sfc_port_stop(struct sfc_adapter *sa)
sfc_log_init(sa, "entry");
efx_mac_drain(sa->nic, B_TRUE);
+
+ (void)efx_mac_stats_periodic(sa->nic, &sa->port.mac_stats_dma_mem,
+ 0, B_FALSE);
+
efx_port_fini(sa->nic);
efx_filter_fini(sa->nic);
@@ -106,6 +155,7 @@ sfc_port_init(struct sfc_adapter *sa)
{
const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
struct sfc_port *port = &sa->port;
+ int rc;
sfc_log_init(sa, "entry");
@@ -118,15 +168,40 @@ sfc_port_init(struct sfc_adapter *sa)
else
port->pdu = EFX_MAC_PDU(dev_data->mtu);
+ rte_spinlock_init(&port->mac_stats_lock);
+
+ rc = ENOMEM;
+ port->mac_stats_buf = rte_calloc_socket("mac_stats_buf", EFX_MAC_NSTATS,
+ sizeof(uint64_t), 0,
+ sa->socket_id);
+ if (port->mac_stats_buf == NULL)
+ goto fail_mac_stats_buf_alloc;
+
+ rc = sfc_dma_alloc(sa, "mac_stats", 0, EFX_MAC_STATS_SIZE,
+ sa->socket_id, &port->mac_stats_dma_mem);
+ if (rc != 0)
+ goto fail_mac_stats_dma_alloc;
+
sfc_log_init(sa, "done");
return 0;
+
+fail_mac_stats_dma_alloc:
+ rte_free(port->mac_stats_buf);
+fail_mac_stats_buf_alloc:
+ sfc_log_init(sa, "failed %d", rc);
+ return rc;
}
void
sfc_port_fini(struct sfc_adapter *sa)
{
+ struct sfc_port *port = &sa->port;
+
sfc_log_init(sa, "entry");
+ sfc_dma_free(sa, &port->mac_stats_dma_mem);
+ rte_free(port->mac_stats_buf);
+
sfc_log_init(sa, "done");
}
--
2.5.5
next prev parent reply other threads:[~2016-12-02 7:45 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-02 7:44 [dpdk-dev] [PATCH 00/31] Support more features in Solarflare PMD Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 01/31] net/sfc: implement MCDI logging callback Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 02/31] net/sfc: support parameter to choose performance profile Andrew Rybchenko
2016-12-02 7:44 ` Andrew Rybchenko [this message]
2016-12-02 7:44 ` [dpdk-dev] [PATCH 04/31] net/sfc: support extended statistics Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 05/31] net/sfc: support flow control settings get/set Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 06/31] net/sfc: support link status change interrupt Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 07/31] net/sfc: implement device operation to change MTU Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 08/31] net/sfc: support link speed and duplex settings Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 09/31] net/sfc: support link up/down Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 10/31] net/sfc: support promiscuous and all-multicast control Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 11/31] net/sfc: support main (the first) MAC address change Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 12/31] net/sfc: support multicast addresses list controls Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 13/31] net/sfc: support checksum offloads on receive Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 14/31] net/sfc: handle received packet type info provided by HW Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 15/31] net/sfc: support callback to get receive queue information Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 16/31] net/sfc: support Rx free threshold Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 17/31] net/sfc: add callback to get RxQ pending descriptors count Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 18/31] net/sfc: add RxQ descriptor done callback Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 19/31] net/sfc: support scattered Rx DMA Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 20/31] net/sfc: support deferred start of receive queues Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 21/31] net/sfc: add callback to get transmit queue information Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 22/31] net/sfc: support Tx free threshold Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 23/31] net/sfc: support deferred start of transmit queues Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 24/31] net/sfc: support VLAN offload on transmit path Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 25/31] net/sfc: add basic stubs for RSS support on driver attach Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 26/31] net/sfc: support RSS hash offload Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 27/31] net/sfc: add callback to query RSS key and hash types config Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 28/31] net/sfc: add callback to set " Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 29/31] net/sfc: add callback to query RSS redirection table Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 30/31] net/sfc: add callback to update " Andrew Rybchenko
2016-12-02 7:44 ` [dpdk-dev] [PATCH 31/31] net/sfc: support firmware-assisted TSOv2 Andrew Rybchenko
2016-12-09 17:34 ` [dpdk-dev] [PATCH 00/31] Support more features in Solarflare PMD Ferruh Yigit
2016-12-15 12:50 ` Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 00/32] " Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 01/32] net/sfc: implement MCDI logging callback Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 02/32] net/sfc: support parameter to choose performance profile Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 03/32] net/sfc: implement ethdev hook to get basic statistics Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 04/32] net/sfc: support extended statistics Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 05/32] net/sfc: support flow control settings get/set Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 06/32] net/sfc: support link status change interrupt Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 07/32] net/sfc: implement device operation to change MTU Andrew Rybchenko
2016-12-15 12:50 ` [dpdk-dev] [PATCH v2 08/32] net/sfc: support link speed and duplex settings Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 09/32] net/sfc: support link up/down Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 10/32] net/sfc: support promiscuous and all-multicast control Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 11/32] net/sfc: support main (the first) MAC address change Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 12/32] net/sfc: support multicast addresses list controls Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 13/32] net/sfc: support checksum offloads on receive Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 14/32] net/sfc: handle received packet type info provided by HW Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 15/32] net/sfc: support callback to get receive queue information Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 16/32] net/sfc: support Rx free threshold Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 17/32] net/sfc: add callback to get RxQ pending descriptors count Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 18/32] net/sfc: add RxQ descriptor done callback Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 19/32] net/sfc: support scattered Rx DMA Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 20/32] net/sfc: support deferred start of receive queues Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 21/32] net/sfc: add callback to get transmit queue information Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 22/32] net/sfc: support Tx free threshold Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 23/32] net/sfc: support deferred start of transmit queues Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 24/32] net/sfc: support VLAN offload on transmit path Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 25/32] net/sfc/base: do not use enum type when values are bitmask Andrew Rybchenko
2017-01-18 11:30 ` Ferruh Yigit
2017-01-18 11:52 ` Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 26/32] net/sfc: add basic stubs for RSS support on driver attach Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 27/32] net/sfc: support RSS hash offload Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 28/32] net/sfc: add callback to query RSS key and hash types config Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 29/32] net/sfc: add callback to set " Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 30/32] net/sfc: add callback to query RSS redirection table Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 31/32] net/sfc: add callback to update " Andrew Rybchenko
2016-12-15 12:51 ` [dpdk-dev] [PATCH v2 32/32] net/sfc: support firmware-assisted TSOv2 Andrew Rybchenko
2016-12-16 9:57 ` [dpdk-dev] [PATCH v2 00/32] Support more features in Solarflare PMD Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1480664691-26561-4-git-send-email-arybchenko@solarflare.com \
--to=arybchenko@solarflare.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).