DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>,
	Ivan Malov <ivan.malov@oktetlabs.ru>
Subject: [dpdk-dev] [PATCH v2 3/6] net/sfc: poll MAC stats if periodic DMA is not supported
Date: Thu, 9 Mar 2017 17:23:00 +0000	[thread overview]
Message-ID: <1489080183-21467-4-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1489080183-21467-1-git-send-email-arybchenko@solarflare.com>

From: Ivan Malov <ivan.malov@oktetlabs.ru>

If periodic DMA statistics feature is absent (particularly,
while running over VF), the PMD must provide an ability to
cope with it using explicit update requests which are kept
restrained according to 'stats_update_period_ms' parameter

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@solarflare.com>
---
 drivers/net/sfc/sfc.h      |  9 +++++++++
 drivers/net/sfc/sfc_port.c | 27 ++++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index f634f92..96cd38c 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -156,6 +156,8 @@ struct sfc_port {
 	boolean_t			mac_stats_reset_pending;
 	uint16_t			mac_stats_update_period_ms;
 	uint32_t			mac_stats_update_generation;
+	boolean_t			mac_stats_periodic_dma_supported;
+	uint64_t			mac_stats_last_request_timestamp;
 
 	uint32_t		mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES];
 };
@@ -255,6 +257,13 @@ sfc_adapter_lock_fini(__rte_unused struct sfc_adapter *sa)
 	/* Just for symmetry of the API */
 }
 
+/** Get the number of milliseconds since boot from the default timer */
+static inline uint64_t
+sfc_get_system_msecs(void)
+{
+	return rte_get_timer_cycles() * MS_PER_S / rte_get_timer_hz();
+}
+
 int sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id,
 		  size_t len, int socket_id, efsys_mem_t *esmp);
 void sfc_dma_free(const struct sfc_adapter *sa, efsys_mem_t *esmp);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 84dde76..2276131 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -67,8 +67,23 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa)
 	if (sa->state != SFC_ADAPTER_STARTED)
 		return EINVAL;
 
-	/* If periodic statistics DMA'ing is off, request explicitly */
-	if (port->mac_stats_update_period_ms == 0) {
+	/*
+	 * If periodic statistics DMA'ing is off or if not supported,
+	 * make a manual request and keep an eye on timer if need be
+	 */
+	if (!port->mac_stats_periodic_dma_supported ||
+	    (port->mac_stats_update_period_ms == 0)) {
+		if (port->mac_stats_update_period_ms != 0) {
+			uint64_t timestamp = sfc_get_system_msecs();
+
+			if ((timestamp -
+			     port->mac_stats_last_request_timestamp) <
+			    port->mac_stats_update_period_ms)
+				return 0;
+
+			port->mac_stats_last_request_timestamp = timestamp;
+		}
+
 		rc = efx_mac_stats_upload(sa->nic, esmp);
 		if (rc != 0)
 			return rc;
@@ -209,8 +224,14 @@ sfc_port_start(struct sfc_adapter *sa)
 		rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem,
 					    port->mac_stats_update_period_ms,
 					    B_FALSE);
-		if (rc != 0)
+		if (rc == 0) {
+			port->mac_stats_periodic_dma_supported = B_TRUE;
+		} else if (rc == EOPNOTSUPP) {
+			port->mac_stats_periodic_dma_supported = B_FALSE;
+			port->mac_stats_last_request_timestamp = 0;
+		} else {
 			goto fail_mac_stats_periodic;
+		}
 	}
 
 	sfc_log_init(sa, "disable MAC drain");
-- 
2.9.3

  parent reply	other threads:[~2017-03-09 17:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02 15:46 [dpdk-dev] [PATCH 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 1/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-06 10:10   ` Ferruh Yigit
2017-03-06 14:00     ` Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 2/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 3/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 4/6] net/sfc: port HW stats must work if periodic DMA is absent Andrew Rybchenko
2017-03-02 15:46 ` [dpdk-dev] [PATCH 5/6] net/sfc: port must not fail to start if Rx mode is rejected Andrew Rybchenko
2017-03-06 10:24   ` Ferruh Yigit
2017-03-02 15:46 ` [dpdk-dev] [PATCH 6/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
2017-03-09 17:22 ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs Andrew Rybchenko
2017-03-09 17:22   ` [dpdk-dev] [PATCH v2 1/6] net/sfc/base: don't ignore requested MAC stats update period Andrew Rybchenko
2017-03-09 17:22   ` [dpdk-dev] [PATCH v2 2/6] net/sfc: add kvarg control for MAC statistics " Andrew Rybchenko
2017-03-09 17:23   ` Andrew Rybchenko [this message]
2017-03-09 17:23   ` [dpdk-dev] [PATCH v2 4/6] net/sfc: avoid failure on port start if Rx mode is rejected Andrew Rybchenko
2017-03-09 17:23   ` [dpdk-dev] [PATCH v2 5/6] net/sfc: add support for MCDI proxy Andrew Rybchenko
2017-03-15 11:13     ` Ferruh Yigit
2017-03-09 17:23   ` [dpdk-dev] [PATCH v2 6/6] net/sfc: add VFs to the table of PCI IDs for supported NICs Andrew Rybchenko
2017-03-15 11:11   ` [dpdk-dev] [PATCH v2 0/6] Support running Solarflare PMD over PCI VFs 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=1489080183-21467-4-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=ivan.malov@oktetlabs.ru \
    /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).