From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nbfkord-smmo02.seg.att.com (nbfkord-smmo02.seg.att.com [209.65.160.78]) by dpdk.org (Postfix) with ESMTP id 33E632B9D for ; Thu, 2 Mar 2017 16:48:29 +0100 (CET) Received: from unknown [12.187.104.26] (EHLO nbfkord-smmo02.seg.att.com) by nbfkord-smmo02.seg.att.com(mxl_mta-7.2.4-7) with ESMTP id dce38b85.2ae02e04f940.1022335.00-2463.2821092.nbfkord-smmo02.seg.att.com (envelope-from ); Thu, 02 Mar 2017 15:48:29 +0000 (UTC) X-MXL-Hash: 58b83ecd03e22587-020885acdfae26b4f42dab192b9eeca59c2040b8 Received: from unknown [12.187.104.26] by nbfkord-smmo02.seg.att.com(mxl_mta-7.2.4-7) with SMTP id 9ce38b85.0.1022304.00-2246.2821057.nbfkord-smmo02.seg.att.com (envelope-from ); Thu, 02 Mar 2017 15:48:28 +0000 (UTC) X-MXL-Hash: 58b83ecc3bbcb15f-ed1cb7150893d64c969f90707ec68387b6edc25e 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, 2 Mar 2017 07:48:14 -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, 2 Mar 2017 07:48:14 -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 v22FmDr4032346; Thu, 2 Mar 2017 15:48:13 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 v22FmCJf002456; Thu, 2 Mar 2017 15:48:13 GMT From: Andrew Rybchenko To: CC: Ivan Malov Date: Thu, 2 Mar 2017 15:46:45 +0000 Message-ID: <1488469608-2252-4-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <1488469608-2252-1-git-send-email-arybchenko@solarflare.com> References: <1488469608-2252-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-AnalysisOut: [v=2.1 cv=T6yKOq+Q c=1 sm=1 tr=0 a=8BlWFWvVlq5taO8ncb8nKg==] X-AnalysisOut: [:17 a=6Iz7jQTuP9IA:10 a=pK7X0mNQAAAA:8 a=zRKbQ67AAAAA:8 a=] X-AnalysisOut: [BVsDaDFzZcIpo7YqzuoA:9 a=yL-r7lOIc7wiYzxd:21 a=a5I1t-YzKeE] X-AnalysisOut: [FubWI:21 a=5HA-qpC1VU4iIGLgRoNS:22 a=PA03WX8tBzeizutn5_OT:] X-AnalysisOut: [22] X-Spam: [F=0.5003378547; CM=0.500; S=0.500(2015072901)] X-MAIL-FROM: X-SOURCE-IP: [12.187.104.26] Subject: [dpdk-dev] [PATCH 3/6] net/sfc: add kvarg control for MAC statistics update period 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, 02 Mar 2017 15:48:29 -0000 From: Ivan Malov The patch is to make MAC statistics update interval tunable by means of 'stats_update_period_ms' kvarg parameter making it possible to use values different from 1000 ms in case of SFN8xxx boards provided that firmware version is 6.2.1.1033 Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andrew Lee --- doc/guides/nics/sfc_efx.rst | 9 +++++ drivers/net/sfc/sfc.h | 2 ++ drivers/net/sfc/sfc_ethdev.c | 1 + drivers/net/sfc/sfc_kvargs.c | 20 +++++++++++ drivers/net/sfc/sfc_kvargs.h | 5 +++ drivers/net/sfc/sfc_port.c | 86 +++++++++++++++++++++++++++++++++++++------- 6 files changed, 110 insertions(+), 13 deletions(-) diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst index 0a05a0a..0130290 100644 --- a/doc/guides/nics/sfc_efx.rst +++ b/doc/guides/nics/sfc_efx.rst @@ -197,3 +197,12 @@ boolean parameters value. Enable extra logging of the communication with the NIC's management CPU. The logging is done using RTE_LOG() with INFO level and PMD type. The format is consumed by the Solarflare netlogdecode cross-platform tool. + +- ``stats_update_period_ms`` [long] (default **1000**) + + Adjust period in milliseconds to update port hardware statistics. + The accepted range is 0 to 65535. The value of **0** may be used + to disable periodic statistics update. One should note that it's + only possible to set an arbitrary value on SFN8xxx provided that + firmware version is 6.2.1.1033 or higher, otherwise any positive + value will select a fixed update period of **1000** milliseconds diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 8c6c02f..8e094e0 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -153,6 +153,8 @@ struct sfc_port { rte_spinlock_t mac_stats_lock; uint64_t *mac_stats_buf; efsys_mem_t mac_stats_dma_mem; + uint16_t mac_stats_update_period_ms; + uint32_t mac_stats_update_generation; uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES]; }; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index be19453..07f126f 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -1362,5 +1362,6 @@ RTE_PMD_REGISTER_PCI_TABLE(net_sfc_efx, pci_id_sfc_efx_map); RTE_PMD_REGISTER_KMOD_DEP(net_sfc_efx, "* igb_uio | uio_pci_generic | vfio"); RTE_PMD_REGISTER_PARAM_STRING(net_sfc_efx, SFC_KVARG_PERF_PROFILE "=" SFC_KVARG_VALUES_PERF_PROFILE " " + SFC_KVARG_STATS_UPDATE_PERIOD_MS "= " SFC_KVARG_MCDI_LOGGING "=" SFC_KVARG_VALUES_BOOL " " SFC_KVARG_DEBUG_INIT "=" SFC_KVARG_VALUES_BOOL); diff --git a/drivers/net/sfc/sfc_kvargs.c b/drivers/net/sfc/sfc_kvargs.c index 227a8db..60a7ac1 100644 --- a/drivers/net/sfc/sfc_kvargs.c +++ b/drivers/net/sfc/sfc_kvargs.c @@ -42,6 +42,7 @@ sfc_kvargs_parse(struct sfc_adapter *sa) struct rte_eth_dev *eth_dev = (sa)->eth_dev; struct rte_devargs *devargs = eth_dev->device->devargs; const char **params = (const char *[]){ + SFC_KVARG_STATS_UPDATE_PERIOD_MS, SFC_KVARG_DEBUG_INIT, SFC_KVARG_MCDI_LOGGING, SFC_KVARG_PERF_PROFILE, @@ -110,3 +111,22 @@ sfc_kvarg_bool_handler(__rte_unused const char *key, return 0; } + +int +sfc_kvarg_long_handler(__rte_unused const char *key, + const char *value_str, void *opaque) +{ + long value; + char *endptr; + + if (!value_str || !opaque) + return -EINVAL; + + value = strtol(value_str, &endptr, 0); + if (endptr == value_str) + return -EINVAL; + + *(long *)opaque = value; + + return 0; +} diff --git a/drivers/net/sfc/sfc_kvargs.h b/drivers/net/sfc/sfc_kvargs.h index 2fea9c7..6c6003a 100644 --- a/drivers/net/sfc/sfc_kvargs.h +++ b/drivers/net/sfc/sfc_kvargs.h @@ -52,6 +52,8 @@ extern "C" { SFC_KVARG_PERF_PROFILE_THROUGHPUT "|" \ SFC_KVARG_PERF_PROFILE_LOW_LATENCY "]" +#define SFC_KVARG_STATS_UPDATE_PERIOD_MS "stats_update_period_ms" + struct sfc_adapter; int sfc_kvargs_parse(struct sfc_adapter *sa); @@ -63,6 +65,9 @@ int sfc_kvargs_process(struct sfc_adapter *sa, const char *key_match, int sfc_kvarg_bool_handler(const char *key, const char *value_str, void *opaque); +int sfc_kvarg_long_handler(const char *key, const char *value_str, + void *opaque); + #ifdef __cplusplus } #endif diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 5998a99..07a61c4 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -31,6 +31,16 @@ #include "sfc.h" #include "sfc_log.h" +#include "sfc_kvargs.h" + +/** Default MAC statistics update period is 1 second */ +#define SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF MS_PER_S + +/** The number of microseconds to sleep on attempt to get statistics update */ +#define SFC_MAC_STATS_UPDATE_RETRY_INTERVAL_US 10 + +/** The number of attempts to await arrival of freshly generated statistics */ +#define SFC_MAC_STATS_UPDATE_NB_ATTEMPTS 50 /** * Update MAC statistics in the buffer. @@ -46,6 +56,10 @@ int sfc_port_update_mac_stats(struct sfc_adapter *sa) { struct sfc_port *port = &sa->port; + efsys_mem_t *esmp = &port->mac_stats_dma_mem; + uint32_t *genp = NULL; + uint32_t gen_old; + unsigned int nb_attempts = 0; int rc; SFC_ASSERT(rte_spinlock_is_locked(&port->mac_stats_lock)); @@ -53,10 +67,27 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa) 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; + /* If periodic statistics DMA'ing is off, request explicitly */ + if (port->mac_stats_update_period_ms == 0) { + rc = efx_mac_stats_upload(sa->nic, esmp); + if (rc != 0) + return rc; + + genp = &port->mac_stats_update_generation; + gen_old = *genp; + } + + do { + if (nb_attempts > 0) + rte_delay_us(SFC_MAC_STATS_UPDATE_RETRY_INTERVAL_US); + + rc = efx_mac_stats_update(sa->nic, esmp, + port->mac_stats_buf, genp); + if (rc != 0) + return rc; + + } while ((genp != NULL) && (*genp == gen_old) && + (++nb_attempts < SFC_MAC_STATS_UPDATE_NB_ATTEMPTS)); return 0; } @@ -143,15 +174,22 @@ sfc_port_start(struct sfc_adapter *sa) 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; + port->mac_stats_update_generation = 0; + + if (port->mac_stats_update_period_ms != 0) { + /* + * Update MAC stats using periodic DMA; + * any positive update interval different from + * 1000 ms can be set only on SFN8xxx provided + * that FW version is 6.2.1.1033 or higher + */ + sfc_log_init(sa, "request MAC stats DMA'ing"); + rc = efx_mac_stats_periodic(sa->nic, &port->mac_stats_dma_mem, + port->mac_stats_update_period_ms, + 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); @@ -210,6 +248,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; + long kvarg_stats_update_period_ms; int rc; sfc_log_init(sa, "entry"); @@ -237,9 +276,30 @@ sfc_port_init(struct sfc_adapter *sa) if (rc != 0) goto fail_mac_stats_dma_alloc; + kvarg_stats_update_period_ms = SFC_MAC_STATS_UPDATE_PERIOD_MS_DEF; + + rc = sfc_kvargs_process(sa, SFC_KVARG_STATS_UPDATE_PERIOD_MS, + sfc_kvarg_long_handler, + &kvarg_stats_update_period_ms); + if ((rc == 0) && + ((kvarg_stats_update_period_ms < 0) || + (kvarg_stats_update_period_ms > UINT16_MAX))) { + sfc_err(sa, "wrong '" SFC_KVARG_STATS_UPDATE_PERIOD_MS "' " + "was set (%ld);", kvarg_stats_update_period_ms); + sfc_err(sa, "it must not be less than 0 " + "or greater than %" PRIu16, UINT16_MAX); + rc = EINVAL; + goto fail_kvarg_stats_update_period_ms; + } else if (rc != 0) { + goto fail_kvarg_stats_update_period_ms; + } + + port->mac_stats_update_period_ms = kvarg_stats_update_period_ms; + sfc_log_init(sa, "done"); return 0; +fail_kvarg_stats_update_period_ms: fail_mac_stats_dma_alloc: rte_free(port->mac_stats_buf); fail_mac_stats_buf_alloc: -- 2.9.3