From patchwork Thu Mar 2 15:46:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 21135 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 7AE3CF923; Thu, 2 Mar 2017 16:49:07 +0100 (CET) Received: from nbfkord-smmo02.seg.att.com (nbfkord-smmo02.seg.att.com [209.65.160.78]) by dpdk.org (Postfix) with ESMTP id EAEF06787 for ; Thu, 2 Mar 2017 16:48:27 +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 cce38b85.2ae020e3a940.1022332.00-2460.2821074.nbfkord-smmo02.seg.att.com (envelope-from ); Thu, 02 Mar 2017 15:48:28 +0000 (UTC) X-MXL-Hash: 58b83ecc7813d77c-596e4f9de024a0519f1b6c251ec0d93dd5ba71b2 Received: from unknown [12.187.104.26] by nbfkord-smmo02.seg.att.com(mxl_mta-7.2.4-7) with SMTP id 7ce38b85.0.1022304.00-2358.2821047.nbfkord-smmo02.seg.att.com (envelope-from ); Thu, 02 Mar 2017 15:48:25 +0000 (UTC) X-MXL-Hash: 58b83ec956015d48-f0afc2fc7397dd164a6d3f8ee74ef73f4551b95d 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 v22FmDLo032349; 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 v22FmCJg002456; Thu, 2 Mar 2017 15:48:13 GMT From: Andrew Rybchenko To: CC: Ivan Malov Date: Thu, 2 Mar 2017 15:46:46 +0000 Message-ID: <1488469608-2252-5-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 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: [m7LxttVNNeC-zAxGtXEA:9 a=5HA-qpC1VU4iIGLgRoNS:22 a=PA03WX8] X-AnalysisOut: [tBzeizutn5_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 4/6] net/sfc: port HW stats must work if periodic DMA is absent 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ivan Malov 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 Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- 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 8e094e0..204a054 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -155,6 +155,8 @@ struct sfc_port { efsys_mem_t mac_stats_dma_mem; 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]; }; @@ -254,6 +256,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 07a61c4..5a9740c 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; @@ -187,8 +202,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");