From patchwork Thu Jul 22 09:54:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96198 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 18419A0C4E; Thu, 22 Jul 2021 11:54:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5D356410DA; Thu, 22 Jul 2021 11:54:53 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id EB93E40E50; Thu, 22 Jul 2021 11:54:51 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 9AECD7F529; Thu, 22 Jul 2021 12:54:51 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 7173A7F553; Thu, 22 Jul 2021 12:54:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 7173A7F553 Authentication-Results: shelob.oktetlabs.ru/7173A7F553; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Remy Horton , Ivan Malov Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:23 +0300 Message-Id: <20210722095433.1898589-2-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 01/11] net/sfc: fix get xstats by ID callback to use MAC stats lock X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Add MAC stats lock in get xstats by id callback before reading number of supported MAC stats. Fixes: 73280c1e4ff ("net/sfc: support xstats retrieval by ID") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_ethdev.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index 88896db1f8..d4ac61ff76 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -789,12 +789,14 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, int ret; int rc; - if (unlikely(values == NULL) || - unlikely((ids == NULL) && (n < port->mac_stats_nb_supported))) - return port->mac_stats_nb_supported; - rte_spinlock_lock(&port->mac_stats_lock); + if (unlikely(values == NULL) || + unlikely(ids == NULL && n < port->mac_stats_nb_supported)) { + ret = port->mac_stats_nb_supported; + goto unlock; + } + rc = sfc_port_update_mac_stats(sa); if (rc != 0) { SFC_ASSERT(rc > 0); From patchwork Thu Jul 22 09:54:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96199 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6371AA0C4E; Thu, 22 Jul 2021 11:55:01 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C6420410E1; Thu, 22 Jul 2021 11:54:56 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 7B4AA410E4; Thu, 22 Jul 2021 11:54:55 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 52ECF7F6D2; Thu, 22 Jul 2021 12:54:55 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id AC02C7F596; Thu, 22 Jul 2021 12:54:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru AC02C7F596 Authentication-Results: shelob.oktetlabs.ru/AC02C7F596; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Robert Stonehouse , Andrew Lee Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:24 +0300 Message-Id: <20210722095433.1898589-3-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 02/11] net/sfc: fix reading adapter state without locking X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Update MAC stats function reads adapter state with MAC stats locking but without adapter locking. Add adapter locking before calling this function and remove MAC stats locking since there's no point to have it together with adapter locking. The second place MAC stats locking is used is MAC stats reset function. It's called with adapter being already locked so there's no point to use MAC stats locking anymore. Fixes: 1caab2f1e68 ("net/sfc: add basic statistics") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 1 - drivers/net/sfc/sfc_ethdev.c | 28 ++++++++++++++++++++-------- drivers/net/sfc/sfc_port.c | 9 +++------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 546739bd4a..c7b0e5a30d 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -130,7 +130,6 @@ struct sfc_port { unsigned int nb_mcast_addrs; uint8_t *mcast_addrs; - rte_spinlock_t mac_stats_lock; uint64_t *mac_stats_buf; unsigned int mac_stats_nb_supported; efsys_mem_t mac_stats_dma_mem; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index d4ac61ff76..d5417e5e65 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -613,7 +613,7 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) uint64_t *mac_stats; int ret; - rte_spinlock_lock(&port->mac_stats_lock); + sfc_adapter_lock(sa); ret = sfc_port_update_mac_stats(sa); if (ret != 0) @@ -686,7 +686,7 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) } unlock: - rte_spinlock_unlock(&port->mac_stats_lock); + sfc_adapter_unlock(sa); SFC_ASSERT(ret >= 0); return -ret; } @@ -698,12 +698,15 @@ sfc_stats_reset(struct rte_eth_dev *dev) struct sfc_port *port = &sa->port; int rc; + sfc_adapter_lock(sa); + if (sa->state != SFC_ADAPTER_STARTED) { /* * The operation cannot be done if port is not started; it * will be scheduled to be done during the next port start */ port->mac_stats_reset_pending = B_TRUE; + sfc_adapter_unlock(sa); return 0; } @@ -711,6 +714,8 @@ sfc_stats_reset(struct rte_eth_dev *dev) if (rc != 0) sfc_err(sa, "failed to reset statistics (rc = %d)", rc); + sfc_adapter_unlock(sa); + SFC_ASSERT(rc >= 0); return -rc; } @@ -726,7 +731,7 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int i; int nstats = 0; - rte_spinlock_lock(&port->mac_stats_lock); + sfc_adapter_lock(sa); rc = sfc_port_update_mac_stats(sa); if (rc != 0) { @@ -748,7 +753,7 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, } unlock: - rte_spinlock_unlock(&port->mac_stats_lock); + sfc_adapter_unlock(sa); return nstats; } @@ -789,7 +794,7 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, int ret; int rc; - rte_spinlock_lock(&port->mac_stats_lock); + sfc_adapter_lock(sa); if (unlikely(values == NULL) || unlikely(ids == NULL && n < port->mac_stats_nb_supported)) { @@ -819,7 +824,7 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, ret = nb_written; unlock: - rte_spinlock_unlock(&port->mac_stats_lock); + sfc_adapter_unlock(sa); return ret; } @@ -835,9 +840,14 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, unsigned int nb_written = 0; unsigned int i; + sfc_adapter_lock(sa); + if (unlikely(xstats_names == NULL) || - unlikely((ids == NULL) && (size < port->mac_stats_nb_supported))) - return port->mac_stats_nb_supported; + unlikely((ids == NULL) && (size < port->mac_stats_nb_supported))) { + nb_supported = port->mac_stats_nb_supported; + sfc_adapter_unlock(sa); + return nb_supported; + } for (i = 0; (i < EFX_MAC_NSTATS) && (nb_written < size); ++i) { if (!EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) @@ -853,6 +863,8 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, ++nb_supported; } + sfc_adapter_unlock(sa); + return nb_written; } diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index ac117f9c48..cdc0f94f19 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -43,7 +43,7 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa) unsigned int nb_attempts = 0; int rc; - SFC_ASSERT(rte_spinlock_is_locked(&port->mac_stats_lock)); + SFC_ASSERT(sfc_adapter_is_locked(sa)); if (sa->state != SFC_ADAPTER_STARTED) return EINVAL; @@ -103,14 +103,13 @@ sfc_port_reset_sw_stats(struct sfc_adapter *sa) int sfc_port_reset_mac_stats(struct sfc_adapter *sa) { - struct sfc_port *port = &sa->port; int rc; - rte_spinlock_lock(&port->mac_stats_lock); + SFC_ASSERT(sfc_adapter_is_locked(sa)); + rc = efx_mac_stats_clear(sa->nic); if (rc == 0) sfc_port_reset_sw_stats(sa); - rte_spinlock_unlock(&port->mac_stats_lock); return rc; } @@ -416,8 +415,6 @@ sfc_port_attach(struct sfc_adapter *sa) goto fail_mcast_addr_list_buf_alloc; } - 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, From patchwork Thu Jul 22 09:54:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96200 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D3490A0C4E; Thu, 22 Jul 2021 11:55:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3590A410F1; Thu, 22 Jul 2021 11:55:00 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 5D62C410FD; Thu, 22 Jul 2021 11:54:59 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 2695B7F6D3; Thu, 22 Jul 2021 12:54:59 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id E02FD7F5B3; Thu, 22 Jul 2021 12:54:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E02FD7F5B3 Authentication-Results: shelob.oktetlabs.ru/E02FD7F5B3; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Thomas Monjalon , Ferruh Yigit , Kuba Kozak Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:25 +0300 Message-Id: <20210722095433.1898589-4-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 03/11] ethdev: fix docs of functions getting xstats by IDs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Document valid combinations of input arguments in accordance with current implementation in ethdev. Fixes: 79c913a42f0 ("ethdev: retrieve xstats by ID") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- lib/ethdev/rte_ethdev.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h index d2b27c351f..80c42d2f08 100644 --- a/lib/ethdev/rte_ethdev.h +++ b/lib/ethdev/rte_ethdev.h @@ -2872,13 +2872,16 @@ int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, * @param port_id * The port identifier of the Ethernet device. * @param xstats_names - * An rte_eth_xstat_name array of at least *size* elements to - * be filled. If set to NULL, the function returns the required number - * of elements. + * An array of at least @p size elements to be filled in. + * Must not be NULL if @p ids are specified (not NULL) or @p size is not 0. * @param ids - * IDs array given by app to retrieve specific statistics + * IDs array given by app to retrieve specific statistics names. + * May be NULL to retrieve all available statistics names. * @param size - * The size of the xstats_names array (number of elements). + * If @p ids is not NULL, number of elements in the array with requested IDs + * and number of elements in @p xstats_names to put names in. If @p ids is + * NULL, number of elements in @p xstats_names to put all available statistics + * names in. * @return * - A positive value lower or equal to size: success. The return value * is the number of entries filled in the stats table. @@ -2886,7 +2889,7 @@ int rte_eth_xstats_get(uint16_t port_id, struct rte_eth_xstat *xstats, * is too small. The return value corresponds to the size that should * be given to succeed. The entries in the table are not valid and * shall not be used by the caller. - * - A negative value on error (invalid port id). + * - A negative value on error. */ int rte_eth_xstats_get_names_by_id(uint16_t port_id, @@ -2899,14 +2902,15 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, * @param port_id * The port identifier of the Ethernet device. * @param ids - * A pointer to an ids array passed by application. This tells which - * statistics values function should retrieve. This parameter - * can be set to NULL if size is 0. In this case function will retrieve - * all available statistics. + * IDs array given by app to retrieve specific statistics. + * May be NULL to retrieve all available statistics. * @param values - * A pointer to a table to be filled with device statistics values. + * An array of at least @p size elements to be filled in. + * Must not be NULL if @p ids are specified (not NULL) or @p size is not 0. * @param size - * The size of the ids array (number of elements). + * If @p ids is not NULL, number of elements in the array with requested IDs + * and number of elements in values to put statistics in. If @p ids is NULL, + * number of elements in values to put all available statistics in. * @return * - A positive value lower or equal to size: success. The return value * is the number of entries filled in the stats table. @@ -2914,7 +2918,7 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, * is too small. The return value corresponds to the size that should * be given to succeed. The entries in the table are not valid and * shall not be used by the caller. - * - A negative value on error (invalid port id). + * - A negative value on error. */ int rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint64_t *values, unsigned int size); From patchwork Thu Jul 22 09:54:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96201 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9B928A0C4E; Thu, 22 Jul 2021 11:55:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8280A40E78; Thu, 22 Jul 2021 11:55:04 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 1B42A4068B; Thu, 22 Jul 2021 11:55:03 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id CE57D7F6D2; Thu, 22 Jul 2021 12:55:02 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 1E14F7F6BC; Thu, 22 Jul 2021 12:54:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 1E14F7F6BC Authentication-Results: shelob.oktetlabs.ru/1E14F7F6BC; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Thomas Monjalon , Ferruh Yigit , Kuba Kozak Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:26 +0300 Message-Id: <20210722095433.1898589-5-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 04/11] ethdev: fix docs of drivers callbacks getting xstats by IDs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Update xstats by IDs callbacks documentation in accordance with ethdev usage of these callbacks. Document valid combinations of input arguments to make driver implementation simpler. Fixes: 79c913a42f0 ("ethdev: retrieve xstats by ID") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- lib/ethdev/ethdev_driver.h | 43 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h index 40e474aa7e..e934be9285 100644 --- a/lib/ethdev/ethdev_driver.h +++ b/lib/ethdev/ethdev_driver.h @@ -187,11 +187,28 @@ typedef int (*eth_xstats_get_t)(struct rte_eth_dev *dev, struct rte_eth_xstat *stats, unsigned int n); /**< @internal Get extended stats of an Ethernet device. */ +/** + * @internal + * Get extended stats specified by IDs of an Ethernet device. + * + * @param dev + * ethdev handle of port. + * @param ids + * IDs array to retrieve specific statistics. Must not be NULL. + * @param values + * A pointer to a table to be filled with device statistics values. + * Must not be NULL. + * @param n + * Element count in @p ids and @p values + * + * @return + * - A number of filled in stats. + * - A negative value on error. + */ typedef int (*eth_xstats_get_by_id_t)(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n); -/**< @internal Get extended stats of an Ethernet device. */ /** * @internal @@ -218,10 +235,32 @@ typedef int (*eth_xstats_get_names_t)(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, unsigned int size); /**< @internal Get names of extended stats of an Ethernet device. */ +/** + * @internal + * Get names of extended stats specified by IDs of an Ethernet device. + * For name count, set @p xstats_names and @p ids to NULL. + * + * @param dev + * ethdev handle of port. + * @param xstats_names + * An rte_eth_xstat_name array of at least *size* elements to + * be filled. Can be NULL together with @p ids to retrieve number of + * available statistics. + * @param ids + * IDs array to retrieve specific statistics. Can be NULL together + * with @p xstats_names to retrieve number of available statistics. + * @param size + * Size of ids and xstats_names arrays. + * Element count in @p ids and @p xstats_names + * + * @return + * - A number of filled in stats if both xstats_names and ids are not NULL. + * - A number of available stats if both xstats_names and ids are NULL. + * - A negative value on error. + */ typedef int (*eth_xstats_get_names_by_id_t)(struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, const uint64_t *ids, unsigned int size); -/**< @internal Get names of extended stats of an Ethernet device. */ typedef int (*eth_queue_stats_mapping_set_t)(struct rte_eth_dev *dev, uint16_t queue_id, From patchwork Thu Jul 22 09:54:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96202 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6F2B3A0C4E; Thu, 22 Jul 2021 11:55:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 548D041109; Thu, 22 Jul 2021 11:55:11 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 6682040E50; Thu, 22 Jul 2021 11:55:10 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 3DB157F6D4; Thu, 22 Jul 2021 12:55:10 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 519F97F6BF; Thu, 22 Jul 2021 12:54:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 519F97F6BF Authentication-Results: shelob.oktetlabs.ru/519F97F6BF; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Ivan Malov , Remy Horton Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:27 +0300 Message-Id: <20210722095433.1898589-6-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 05/11] net/sfc: fix xstats by ID callbacks according to ethdev X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Fix xstats by ID callbacks according to ethdev usage. Handle combinations of input arguments that are required by ethdev and sanity check and reject other combinations on callback entry. Fixes: 73280c1e4ff ("net/sfc: support xstats retrieval by ID") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_ethdev.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index d5417e5e65..fca3f524a1 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -794,13 +794,10 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, int ret; int rc; - sfc_adapter_lock(sa); + if (unlikely(ids == NULL || values == NULL)) + return -EINVAL; - if (unlikely(values == NULL) || - unlikely(ids == NULL && n < port->mac_stats_nb_supported)) { - ret = port->mac_stats_nb_supported; - goto unlock; - } + sfc_adapter_lock(sa); rc = sfc_port_update_mac_stats(sa); if (rc != 0) { @@ -815,7 +812,7 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, if (!EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) continue; - if ((ids == NULL) || (ids[nb_written] == nb_supported)) + if (ids[nb_written] == nb_supported) values[nb_written++] = mac_stats[i]; ++nb_supported; @@ -840,10 +837,13 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, unsigned int nb_written = 0; unsigned int i; + if (unlikely(xstats_names == NULL && ids != NULL) || + unlikely(xstats_names != NULL && ids == NULL)) + return -EINVAL; + sfc_adapter_lock(sa); - if (unlikely(xstats_names == NULL) || - unlikely((ids == NULL) && (size < port->mac_stats_nb_supported))) { + if (unlikely(xstats_names == NULL && ids == NULL)) { nb_supported = port->mac_stats_nb_supported; sfc_adapter_unlock(sa); return nb_supported; @@ -853,7 +853,7 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, if (!EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) continue; - if ((ids == NULL) || (ids[nb_written] == nb_supported)) { + if (ids[nb_written] == nb_supported) { char *name = xstats_names[nb_written++].name; strlcpy(name, efx_mac_stat_name(sa->nic, i), From patchwork Thu Jul 22 09:54:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96203 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5D417A0C4E; Thu, 22 Jul 2021 11:55:29 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 93EB341136; Thu, 22 Jul 2021 11:55:12 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id CEF43410DD; Thu, 22 Jul 2021 11:55:10 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 9C3AF7F6D6; Thu, 22 Jul 2021 12:55:10 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 8547A7F6C9; Thu, 22 Jul 2021 12:54:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 8547A7F6C9 Authentication-Results: shelob.oktetlabs.ru/8547A7F6C9; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Remy Horton , Ivan Malov Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:28 +0300 Message-Id: <20210722095433.1898589-7-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 06/11] net/sfc: fix accessing xstats by an unsorted list of IDs X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Device may support only some MAC stats. Add mapping from ids to subset of supported MAC stats for each port. Fixes: 73280c1e4ff ("net/sfc: support xstats retrieval by ID") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 2 ++ drivers/net/sfc/sfc_ethdev.c | 44 ++++++++++++++++++------------------ drivers/net/sfc/sfc_port.c | 29 ++++++++++++++++++------ 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index c7b0e5a30d..972d32606d 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -141,6 +141,8 @@ struct sfc_port { uint32_t mac_stats_mask[EFX_MAC_STATS_MASK_NPAGES]; + unsigned int mac_stats_by_id[EFX_MAC_NSTATS]; + uint64_t ipackets; }; diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index fca3f524a1..ae9304f90f 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -788,8 +788,6 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); struct sfc_port *port = &sa->port; uint64_t *mac_stats; - unsigned int nb_supported = 0; - unsigned int nb_written = 0; unsigned int i; int ret; int rc; @@ -808,17 +806,19 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, mac_stats = port->mac_stats_buf; - for (i = 0; (i < EFX_MAC_NSTATS) && (nb_written < n); ++i) { - if (!EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) - continue; - - if (ids[nb_written] == nb_supported) - values[nb_written++] = mac_stats[i]; + SFC_ASSERT(port->mac_stats_nb_supported <= + RTE_DIM(port->mac_stats_by_id)); - ++nb_supported; + for (i = 0; i < n; i++) { + if (ids[i] < port->mac_stats_nb_supported) { + values[i] = mac_stats[port->mac_stats_by_id[ids[i]]]; + } else { + ret = i; + goto unlock; + } } - ret = nb_written; + ret = n; unlock: sfc_adapter_unlock(sa); @@ -833,8 +833,7 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, { struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); struct sfc_port *port = &sa->port; - unsigned int nb_supported = 0; - unsigned int nb_written = 0; + unsigned int nb_supported; unsigned int i; if (unlikely(xstats_names == NULL && ids != NULL) || @@ -849,23 +848,24 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, return nb_supported; } - for (i = 0; (i < EFX_MAC_NSTATS) && (nb_written < size); ++i) { - if (!EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) - continue; - - if (ids[nb_written] == nb_supported) { - char *name = xstats_names[nb_written++].name; + SFC_ASSERT(port->mac_stats_nb_supported <= + RTE_DIM(port->mac_stats_by_id)); - strlcpy(name, efx_mac_stat_name(sa->nic, i), + for (i = 0; i < size; i++) { + if (ids[i] < port->mac_stats_nb_supported) { + strlcpy(xstats_names[i].name, + efx_mac_stat_name(sa->nic, + port->mac_stats_by_id[ids[i]]), sizeof(xstats_names[0].name)); + } else { + sfc_adapter_unlock(sa); + return i; } - - ++nb_supported; } sfc_adapter_unlock(sa); - return nb_written; + return size; } static int diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index cdc0f94f19..bb9e01d96b 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -157,6 +157,27 @@ sfc_port_phy_caps_to_max_link_speed(uint32_t phy_caps) #endif +static void +sfc_port_fill_mac_stats_info(struct sfc_adapter *sa) +{ + unsigned int mac_stats_nb_supported = 0; + struct sfc_port *port = &sa->port; + unsigned int stat_idx; + + efx_mac_stats_get_mask(sa->nic, port->mac_stats_mask, + sizeof(port->mac_stats_mask)); + + for (stat_idx = 0; stat_idx < EFX_MAC_NSTATS; ++stat_idx) { + if (!EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, stat_idx)) + continue; + + port->mac_stats_by_id[mac_stats_nb_supported] = stat_idx; + mac_stats_nb_supported++; + } + + port->mac_stats_nb_supported = mac_stats_nb_supported; +} + int sfc_port_start(struct sfc_adapter *sa) { @@ -165,7 +186,6 @@ sfc_port_start(struct sfc_adapter *sa) uint32_t phy_adv_cap; const uint32_t phy_pause_caps = ((1u << EFX_PHY_CAP_PAUSE) | (1u << EFX_PHY_CAP_ASYM)); - unsigned int i; sfc_log_init(sa, "entry"); @@ -259,12 +279,7 @@ sfc_port_start(struct sfc_adapter *sa) port->mac_stats_reset_pending = B_FALSE; } - efx_mac_stats_get_mask(sa->nic, port->mac_stats_mask, - sizeof(port->mac_stats_mask)); - - for (i = 0, port->mac_stats_nb_supported = 0; i < EFX_MAC_NSTATS; ++i) - if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) - port->mac_stats_nb_supported++; + sfc_port_fill_mac_stats_info(sa); port->mac_stats_update_generation = 0; From patchwork Thu Jul 22 09:54:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96204 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BBC80A0C4E; Thu, 22 Jul 2021 11:55:35 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF108410FE; Thu, 22 Jul 2021 11:55:18 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id D1A4B4068B; Thu, 22 Jul 2021 11:55:17 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 9F6D87F6E1; Thu, 22 Jul 2021 12:55:17 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id BBD547F6CA; Thu, 22 Jul 2021 12:54:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru BBD547F6CA Authentication-Results: shelob.oktetlabs.ru/BBD547F6CA; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Robert Stonehouse , Andrew Lee Cc: David Marchand , Ivan Ilchenko , stable@dpdk.org, Andy Moreton Date: Thu, 22 Jul 2021 12:54:29 +0300 Message-Id: <20210722095433.1898589-8-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 07/11] net/sfc: fix MAC stats update to work for stopped device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Fixes: 1caab2f1e68 ("net/sfc: add basic statistics") Cc: stable@dpdk.org Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 2 +- drivers/net/sfc/sfc_ethdev.c | 6 +++--- drivers/net/sfc/sfc_port.c | 11 +++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 972d32606d..1594f934ba 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -422,7 +422,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); +int sfc_port_update_mac_stats(struct sfc_adapter *sa, boolean_t manual_update); int sfc_port_reset_mac_stats(struct sfc_adapter *sa); int sfc_set_rx_mode(struct sfc_adapter *sa); int sfc_set_rx_mode_unchecked(struct sfc_adapter *sa); diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index ae9304f90f..bbc22723f6 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -615,7 +615,7 @@ sfc_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) sfc_adapter_lock(sa); - ret = sfc_port_update_mac_stats(sa); + ret = sfc_port_update_mac_stats(sa, B_FALSE); if (ret != 0) goto unlock; @@ -733,7 +733,7 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, sfc_adapter_lock(sa); - rc = sfc_port_update_mac_stats(sa); + rc = sfc_port_update_mac_stats(sa, B_FALSE); if (rc != 0) { SFC_ASSERT(rc > 0); nstats = -rc; @@ -797,7 +797,7 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, sfc_adapter_lock(sa); - rc = sfc_port_update_mac_stats(sa); + rc = sfc_port_update_mac_stats(sa, B_FALSE); if (rc != 0) { SFC_ASSERT(rc > 0); ret = -rc; diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index bb9e01d96b..8c432c15f5 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -26,7 +26,8 @@ /** * Update MAC statistics in the buffer. * - * @param sa Adapter + * @param sa Adapter + * @param force_upload Flag to upload MAC stats in any case * * @return Status code * @retval 0 Success @@ -34,7 +35,7 @@ * @retval ENOMEM Memory allocation failure */ int -sfc_port_update_mac_stats(struct sfc_adapter *sa) +sfc_port_update_mac_stats(struct sfc_adapter *sa, boolean_t force_upload) { struct sfc_port *port = &sa->port; efsys_mem_t *esmp = &port->mac_stats_dma_mem; @@ -46,14 +47,14 @@ sfc_port_update_mac_stats(struct sfc_adapter *sa) SFC_ASSERT(sfc_adapter_is_locked(sa)); if (sa->state != SFC_ADAPTER_STARTED) - return EINVAL; + return 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)) { + (port->mac_stats_update_period_ms == 0) || force_upload) { if (port->mac_stats_update_period_ms != 0) { uint64_t timestamp = sfc_get_system_msecs(); @@ -367,6 +368,8 @@ sfc_port_stop(struct sfc_adapter *sa) (void)efx_mac_stats_periodic(sa->nic, &sa->port.mac_stats_dma_mem, 0, B_FALSE); + sfc_port_update_mac_stats(sa, B_TRUE); + efx_port_fini(sa->nic); efx_filter_fini(sa->nic); From patchwork Thu Jul 22 09:54:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96205 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 23797A0C4E; Thu, 22 Jul 2021 11:55:41 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4AFE41135; Thu, 22 Jul 2021 11:55:19 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 2A2544068B for ; Thu, 22 Jul 2021 11:55:18 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id EA8A87F6E1; Thu, 22 Jul 2021 12:55:17 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id E89E67F6CB; Thu, 22 Jul 2021 12:54:45 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E89E67F6CB Authentication-Results: shelob.oktetlabs.ru/E89E67F6CB; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: David Marchand , Ivan Ilchenko , Andy Moreton Date: Thu, 22 Jul 2021 12:54:30 +0300 Message-Id: <20210722095433.1898589-9-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 08/11] net/sfc: simplify getting of available xstats case X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko There is no point to recalculate number of available xstats on each request. The number is calculated once on device start and may be returned on subsequent calls. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_ethdev.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index bbc22723f6..f0567a71d0 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -733,6 +733,11 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, sfc_adapter_lock(sa); + if (unlikely(xstats == NULL)) { + nstats = port->mac_stats_nb_supported; + goto unlock; + } + rc = sfc_port_update_mac_stats(sa, B_FALSE); if (rc != 0) { SFC_ASSERT(rc > 0); @@ -744,7 +749,7 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, 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) { + if (nstats < (int)xstats_count) { xstats[nstats].id = nstats; xstats[nstats].value = mac_stats[i]; } @@ -768,9 +773,16 @@ sfc_xstats_get_names(struct rte_eth_dev *dev, unsigned int i; unsigned int nstats = 0; + if (unlikely(xstats_names == NULL)) { + sfc_adapter_lock(sa); + nstats = port->mac_stats_nb_supported; + sfc_adapter_unlock(sa); + return nstats; + } + 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) + if (nstats < xstats_count) strlcpy(xstats_names[nstats].name, efx_mac_stat_name(sa->nic, i), sizeof(xstats_names[0].name)); From patchwork Thu Jul 22 09:54:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96206 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A5DD9A0C4E; Thu, 22 Jul 2021 11:55:46 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 174A9410DB; Thu, 22 Jul 2021 11:55:23 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 83D014113F for ; Thu, 22 Jul 2021 11:55:21 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 50FC07F6E3; Thu, 22 Jul 2021 12:55:21 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 28B417F6CC; Thu, 22 Jul 2021 12:54:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 28B417F6CC Authentication-Results: shelob.oktetlabs.ru/28B417F6CC; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: David Marchand , Ivan Ilchenko , Andy Moreton Date: Thu, 22 Jul 2021 12:54:31 +0300 Message-Id: <20210722095433.1898589-10-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 09/11] net/sfc: prepare to add more xstats X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Move getting MAC stats code that involves locking to separate functions to simplify addition of new xstats. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc.h | 4 ++ drivers/net/sfc/sfc_ethdev.c | 73 ++++---------------------------- drivers/net/sfc/sfc_port.c | 80 ++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 65 deletions(-) diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 1594f934ba..58b8c2c2ad 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -423,6 +423,10 @@ 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, boolean_t manual_update); +int sfc_port_get_mac_stats(struct sfc_adapter *sa, struct rte_eth_xstat *xstats, + unsigned int xstats_count, unsigned int *nb_written); +int sfc_port_get_mac_stats_by_id(struct sfc_adapter *sa, const uint64_t *ids, + uint64_t *values, unsigned int n); int sfc_port_reset_mac_stats(struct sfc_adapter *sa); int sfc_set_rx_mode(struct sfc_adapter *sa); int sfc_set_rx_mode_unchecked(struct sfc_adapter *sa); diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index f0567a71d0..dd7e5c253a 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -726,41 +726,17 @@ sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, { struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); struct sfc_port *port = &sa->port; - uint64_t *mac_stats; - int rc; - unsigned int i; - int nstats = 0; - - sfc_adapter_lock(sa); + unsigned int nb_written = 0; + unsigned int nb_supp; if (unlikely(xstats == NULL)) { - nstats = port->mac_stats_nb_supported; - goto unlock; - } - - rc = sfc_port_update_mac_stats(sa, B_FALSE); - 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 (nstats < (int)xstats_count) { - xstats[nstats].id = nstats; - xstats[nstats].value = mac_stats[i]; - } - nstats++; - } + sfc_adapter_lock(sa); + nb_supp = port->mac_stats_nb_supported; + sfc_adapter_unlock(sa); + return nb_supp; } -unlock: - sfc_adapter_unlock(sa); - - return nstats; + return sfc_port_get_mac_stats(sa, xstats, xstats_count, &nb_written); } static int @@ -798,44 +774,11 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n) { struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); - struct sfc_port *port = &sa->port; - uint64_t *mac_stats; - unsigned int i; - int ret; - int rc; if (unlikely(ids == NULL || values == NULL)) return -EINVAL; - sfc_adapter_lock(sa); - - rc = sfc_port_update_mac_stats(sa, B_FALSE); - if (rc != 0) { - SFC_ASSERT(rc > 0); - ret = -rc; - goto unlock; - } - - mac_stats = port->mac_stats_buf; - - SFC_ASSERT(port->mac_stats_nb_supported <= - RTE_DIM(port->mac_stats_by_id)); - - for (i = 0; i < n; i++) { - if (ids[i] < port->mac_stats_nb_supported) { - values[i] = mac_stats[port->mac_stats_by_id[ids[i]]]; - } else { - ret = i; - goto unlock; - } - } - - ret = n; - -unlock: - sfc_adapter_unlock(sa); - - return ret; + return sfc_port_get_mac_stats_by_id(sa, ids, values, n); } static int diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 8c432c15f5..f6689a17c0 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -636,3 +636,83 @@ sfc_port_link_mode_to_info(efx_link_mode_t link_mode, link_info->link_autoneg = ETH_LINK_AUTONEG; } + +int +sfc_port_get_mac_stats(struct sfc_adapter *sa, struct rte_eth_xstat *xstats, + unsigned int xstats_count, unsigned int *nb_written) +{ + struct sfc_port *port = &sa->port; + uint64_t *mac_stats; + unsigned int i; + int nstats = 0; + int ret; + + sfc_adapter_lock(sa); + + ret = sfc_port_update_mac_stats(sa, B_FALSE); + if (ret != 0) { + SFC_ASSERT(ret > 0); + ret = -ret; + 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 (nstats < (int)xstats_count) { + xstats[nstats].id = nstats; + xstats[nstats].value = mac_stats[i]; + (*nb_written)++; + } + nstats++; + } + } + ret = nstats; + +unlock: + sfc_adapter_unlock(sa); + + return ret; +} + +int +sfc_port_get_mac_stats_by_id(struct sfc_adapter *sa, const uint64_t *ids, + uint64_t *values, unsigned int n) +{ + struct sfc_port *port = &sa->port; + uint64_t *mac_stats; + unsigned int i; + int ret; + int rc; + + sfc_adapter_lock(sa); + + rc = sfc_port_update_mac_stats(sa, B_FALSE); + if (rc != 0) { + SFC_ASSERT(rc > 0); + ret = -rc; + goto unlock; + } + + mac_stats = port->mac_stats_buf; + + SFC_ASSERT(port->mac_stats_nb_supported <= + RTE_DIM(port->mac_stats_by_id)); + + for (i = 0; i < n; i++) { + if (ids[i] < port->mac_stats_nb_supported) { + values[i] = mac_stats[port->mac_stats_by_id[ids[i]]]; + } else { + ret = i; + goto unlock; + } + } + + ret = n; + +unlock: + sfc_adapter_unlock(sa); + + return ret; +} From patchwork Thu Jul 22 09:54:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96207 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2BF88A0C4E; Thu, 22 Jul 2021 11:55:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3773B41142; Thu, 22 Jul 2021 11:55:24 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 2F322410FC for ; Thu, 22 Jul 2021 11:55:23 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 03B677F6E2; Thu, 22 Jul 2021 12:55:23 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 75F057F6CD; Thu, 22 Jul 2021 12:54:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 75F057F6CD Authentication-Results: shelob.oktetlabs.ru/75F057F6CD; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: David Marchand , Ivan Ilchenko , Andy Moreton Date: Thu, 22 Jul 2021 12:54:32 +0300 Message-Id: <20210722095433.1898589-11-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 10/11] net/sfc: add xstats for Rx/Tx doorbells X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Rx/Tx doorbells statistics are collected in software and available per queue. These stats are useful for performance investigation. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/meson.build | 1 + drivers/net/sfc/sfc.c | 16 + drivers/net/sfc/sfc.h | 9 + drivers/net/sfc/sfc_dp.h | 10 + drivers/net/sfc/sfc_ef10.h | 3 +- drivers/net/sfc/sfc_ef100_rx.c | 1 + drivers/net/sfc/sfc_ef100_tx.c | 1 + drivers/net/sfc/sfc_ef10_essb_rx.c | 3 +- drivers/net/sfc/sfc_ef10_rx.c | 3 +- drivers/net/sfc/sfc_ef10_tx.c | 1 + drivers/net/sfc/sfc_ethdev.c | 124 +++++-- drivers/net/sfc/sfc_port.c | 10 +- drivers/net/sfc/sfc_rx.c | 1 + drivers/net/sfc/sfc_sw_stats.c | 572 +++++++++++++++++++++++++++++ drivers/net/sfc/sfc_sw_stats.h | 49 +++ drivers/net/sfc/sfc_tx.c | 4 +- 16 files changed, 772 insertions(+), 36 deletions(-) create mode 100644 drivers/net/sfc/sfc_sw_stats.c create mode 100644 drivers/net/sfc/sfc_sw_stats.h diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build index 4625859077..a912cdccfa 100644 --- a/drivers/net/sfc/meson.build +++ b/drivers/net/sfc/meson.build @@ -70,6 +70,7 @@ sources = files( 'sfc.c', 'sfc_mcdi.c', 'sfc_sriov.c', + 'sfc_sw_stats.c', 'sfc_intr.c', 'sfc_ev.c', 'sfc_port.c', diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 4097cf39de..274a98e228 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -24,6 +24,7 @@ #include "sfc_tx.h" #include "sfc_kvargs.h" #include "sfc_tweak.h" +#include "sfc_sw_stats.h" int @@ -636,10 +637,17 @@ sfc_configure(struct sfc_adapter *sa) if (rc != 0) goto fail_tx_configure; + rc = sfc_sw_xstats_configure(sa); + if (rc != 0) + goto fail_sw_xstats_configure; + sa->state = SFC_ADAPTER_CONFIGURED; sfc_log_init(sa, "done"); return 0; +fail_sw_xstats_configure: + sfc_tx_close(sa); + fail_tx_configure: sfc_rx_close(sa); @@ -666,6 +674,7 @@ sfc_close(struct sfc_adapter *sa) SFC_ASSERT(sa->state == SFC_ADAPTER_CONFIGURED); sa->state = SFC_ADAPTER_CLOSING; + sfc_sw_xstats_close(sa); sfc_tx_close(sa); sfc_rx_close(sa); sfc_port_close(sa); @@ -891,6 +900,10 @@ sfc_attach(struct sfc_adapter *sa) sfc_flow_init(sa); + rc = sfc_sw_xstats_init(sa); + if (rc != 0) + goto fail_sw_xstats_init; + /* * Create vSwitch to be able to use VFs when PF is not started yet * as DPDK port. VFs should be able to talk to each other even @@ -906,6 +919,9 @@ sfc_attach(struct sfc_adapter *sa) return 0; fail_sriov_vswitch_create: + sfc_sw_xstats_close(sa); + +fail_sw_xstats_init: sfc_flow_fini(sa); sfc_mae_detach(sa); diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h index 58b8c2c2ad..331e06bac6 100644 --- a/drivers/net/sfc/sfc.h +++ b/drivers/net/sfc/sfc.h @@ -217,6 +217,14 @@ struct sfc_counter_rxq { struct rte_mempool *mp; }; +struct sfc_sw_xstats { + uint64_t *reset_vals; + + rte_spinlock_t queues_bitmap_lock; + void *queues_bitmap_mem; + struct rte_bitmap *queues_bitmap; +}; + /* Adapter private data */ struct sfc_adapter { /* @@ -249,6 +257,7 @@ struct sfc_adapter { struct sfc_sriov sriov; struct sfc_intr intr; struct sfc_port port; + struct sfc_sw_xstats sw_xstats; struct sfc_filter filter; struct sfc_mae mae; diff --git a/drivers/net/sfc/sfc_dp.h b/drivers/net/sfc/sfc_dp.h index 61c1a3fbac..7fd8f34b0f 100644 --- a/drivers/net/sfc/sfc_dp.h +++ b/drivers/net/sfc/sfc_dp.h @@ -42,6 +42,16 @@ enum sfc_dp_type { /** Datapath queue run-time information */ struct sfc_dp_queue { + /* + * Typically the structure is located at the end of Rx/Tx queue + * data structure and not used on datapath. So, it is not a + * problem to have extra fields even if not used. However, + * put stats at top of the structure to be closer to fields + * used on datapath or reap to have more chances to be cache-hot. + */ + uint32_t rx_dbells; + uint32_t tx_dbells; + uint16_t port_id; uint16_t queue_id; struct rte_pci_addr pci_addr; diff --git a/drivers/net/sfc/sfc_ef10.h b/drivers/net/sfc/sfc_ef10.h index ad4c1fdbef..e9bb72e28b 100644 --- a/drivers/net/sfc/sfc_ef10.h +++ b/drivers/net/sfc/sfc_ef10.h @@ -99,7 +99,7 @@ sfc_ef10_ev_present(const efx_qword_t ev) static inline void sfc_ef10_rx_qpush(volatile void *doorbell, unsigned int added, - unsigned int ptr_mask) + unsigned int ptr_mask, uint32_t *dbell_counter) { efx_dword_t dword; @@ -118,6 +118,7 @@ sfc_ef10_rx_qpush(volatile void *doorbell, unsigned int added, * operations that follow it (i.e. doorbell write). */ rte_write32(dword.ed_u32[0], doorbell); + (*dbell_counter)++; } static inline void diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c index 10c74aa118..d4cb96881c 100644 --- a/drivers/net/sfc/sfc_ef100_rx.c +++ b/drivers/net/sfc/sfc_ef100_rx.c @@ -119,6 +119,7 @@ sfc_ef100_rx_qpush(struct sfc_ef100_rxq *rxq, unsigned int added) * operations that follow it (i.e. doorbell write). */ rte_write32(dword.ed_u32[0], rxq->doorbell); + rxq->dp.dpq.rx_dbells++; sfc_ef100_rx_debug(rxq, "RxQ pushed doorbell at pidx %u (added=%u)", EFX_DWORD_FIELD(dword, ERF_GZ_RX_RING_PIDX), diff --git a/drivers/net/sfc/sfc_ef100_tx.c b/drivers/net/sfc/sfc_ef100_tx.c index f9ad6f7b73..522e9a0d34 100644 --- a/drivers/net/sfc/sfc_ef100_tx.c +++ b/drivers/net/sfc/sfc_ef100_tx.c @@ -489,6 +489,7 @@ sfc_ef100_tx_qpush(struct sfc_ef100_txq *txq, unsigned int added) * operations that follow it (i.e. doorbell write). */ rte_write32(dword.ed_u32[0], txq->doorbell); + txq->dp.dpq.tx_dbells++; sfc_ef100_tx_debug(txq, "TxQ pushed doorbell at pidx %u (added=%u)", EFX_DWORD_FIELD(dword, ERF_GZ_TX_RING_PIDX), diff --git a/drivers/net/sfc/sfc_ef10_essb_rx.c b/drivers/net/sfc/sfc_ef10_essb_rx.c index 3c246eb149..991329e86f 100644 --- a/drivers/net/sfc/sfc_ef10_essb_rx.c +++ b/drivers/net/sfc/sfc_ef10_essb_rx.c @@ -220,7 +220,8 @@ sfc_ef10_essb_rx_qrefill(struct sfc_ef10_essb_rxq *rxq) SFC_ASSERT(rxq->added != added); rxq->added = added; - sfc_ef10_rx_qpush(rxq->doorbell, added, rxq_ptr_mask); + sfc_ef10_rx_qpush(rxq->doorbell, added, rxq_ptr_mask, + &rxq->dp.dpq.rx_dbells); } static bool diff --git a/drivers/net/sfc/sfc_ef10_rx.c b/drivers/net/sfc/sfc_ef10_rx.c index 2b4393d232..49a7d4fb42 100644 --- a/drivers/net/sfc/sfc_ef10_rx.c +++ b/drivers/net/sfc/sfc_ef10_rx.c @@ -171,7 +171,8 @@ sfc_ef10_rx_qrefill(struct sfc_ef10_rxq *rxq) SFC_ASSERT(rxq->added != added); rxq->added = added; - sfc_ef10_rx_qpush(rxq->doorbell, added, ptr_mask); + sfc_ef10_rx_qpush(rxq->doorbell, added, ptr_mask, + &rxq->dp.dpq.rx_dbells); } static void diff --git a/drivers/net/sfc/sfc_ef10_tx.c b/drivers/net/sfc/sfc_ef10_tx.c index a8d34ead33..ed43adb4ca 100644 --- a/drivers/net/sfc/sfc_ef10_tx.c +++ b/drivers/net/sfc/sfc_ef10_tx.c @@ -248,6 +248,7 @@ sfc_ef10_tx_qpush(struct sfc_ef10_txq *txq, unsigned int added, rte_io_wmb(); *(volatile efsys_uint128_t *)txq->doorbell = oword.eo_u128[0]; + txq->dp.dpq.tx_dbells++; } static unsigned int diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c index dd7e5c253a..2db0d000c3 100644 --- a/drivers/net/sfc/sfc_ethdev.c +++ b/drivers/net/sfc/sfc_ethdev.c @@ -28,6 +28,10 @@ #include "sfc_flow.h" #include "sfc_dp.h" #include "sfc_dp_rx.h" +#include "sfc_sw_stats.h" + +#define SFC_XSTAT_ID_INVALID_VAL UINT64_MAX +#define SFC_XSTAT_ID_INVALID_NAME '\0' uint32_t sfc_logtype_driver; @@ -714,29 +718,49 @@ sfc_stats_reset(struct rte_eth_dev *dev) if (rc != 0) sfc_err(sa, "failed to reset statistics (rc = %d)", rc); + sfc_sw_xstats_reset(sa); + sfc_adapter_unlock(sa); SFC_ASSERT(rc >= 0); return -rc; } +static unsigned int +sfc_xstats_get_nb_supported(struct sfc_adapter *sa) +{ + struct sfc_port *port = &sa->port; + unsigned int nb_supported; + + sfc_adapter_lock(sa); + nb_supported = port->mac_stats_nb_supported + + sfc_sw_xstats_get_nb_supported(sa); + sfc_adapter_unlock(sa); + + return nb_supported; +} + static int sfc_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, unsigned int xstats_count) { struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); - struct sfc_port *port = &sa->port; unsigned int nb_written = 0; - unsigned int nb_supp; + unsigned int nb_supported = 0; + int rc; - if (unlikely(xstats == NULL)) { - sfc_adapter_lock(sa); - nb_supp = port->mac_stats_nb_supported; - sfc_adapter_unlock(sa); - return nb_supp; - } + if (unlikely(xstats == NULL)) + return sfc_xstats_get_nb_supported(sa); + + rc = sfc_port_get_mac_stats(sa, xstats, xstats_count, &nb_written); + if (rc < 0) + return rc; - return sfc_port_get_mac_stats(sa, xstats, xstats_count, &nb_written); + nb_supported = rc; + sfc_sw_xstats_get_vals(sa, xstats, xstats_count, &nb_written, + &nb_supported); + + return nb_supported; } static int @@ -748,24 +772,31 @@ sfc_xstats_get_names(struct rte_eth_dev *dev, struct sfc_port *port = &sa->port; unsigned int i; unsigned int nstats = 0; + unsigned int nb_written = 0; + int ret; - if (unlikely(xstats_names == NULL)) { - sfc_adapter_lock(sa); - nstats = port->mac_stats_nb_supported; - sfc_adapter_unlock(sa); - return nstats; - } + if (unlikely(xstats_names == NULL)) + return sfc_xstats_get_nb_supported(sa); for (i = 0; i < EFX_MAC_NSTATS; ++i) { if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) { - if (nstats < xstats_count) + if (nstats < xstats_count) { strlcpy(xstats_names[nstats].name, efx_mac_stat_name(sa->nic, i), sizeof(xstats_names[0].name)); + nb_written++; + } nstats++; } } + ret = sfc_sw_xstats_get_names(sa, xstats_names, xstats_count, + &nb_written, &nstats); + if (ret != 0) { + SFC_ASSERT(ret < 0); + return ret; + } + return nstats; } @@ -774,11 +805,35 @@ sfc_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, uint64_t *values, unsigned int n) { struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev); + struct sfc_port *port = &sa->port; + unsigned int nb_supported; + unsigned int i; + int rc; if (unlikely(ids == NULL || values == NULL)) return -EINVAL; - return sfc_port_get_mac_stats_by_id(sa, ids, values, n); + /* + * Values array could be filled in nonsequential order. Fill values with + * constant indicating invalid ID first. + */ + for (i = 0; i < n; i++) + values[i] = SFC_XSTAT_ID_INVALID_VAL; + + rc = sfc_port_get_mac_stats_by_id(sa, ids, values, n); + if (rc != 0) + return rc; + + nb_supported = port->mac_stats_nb_supported; + sfc_sw_xstats_get_vals_by_id(sa, ids, values, n, &nb_supported); + + /* Return number of written stats before invalid ID is encountered. */ + for (i = 0; i < n; i++) { + if (values[i] == SFC_XSTAT_ID_INVALID_VAL) + return i; + } + + return n; } static int @@ -790,18 +845,23 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, struct sfc_port *port = &sa->port; unsigned int nb_supported; unsigned int i; + int ret; if (unlikely(xstats_names == NULL && ids != NULL) || unlikely(xstats_names != NULL && ids == NULL)) return -EINVAL; - sfc_adapter_lock(sa); + if (unlikely(xstats_names == NULL && ids == NULL)) + return sfc_xstats_get_nb_supported(sa); - if (unlikely(xstats_names == NULL && ids == NULL)) { - nb_supported = port->mac_stats_nb_supported; - sfc_adapter_unlock(sa); - return nb_supported; - } + /* + * Names array could be filled in nonsequential order. Fill names with + * string indicating invalid ID first. + */ + for (i = 0; i < size; i++) + xstats_names[i].name[0] = SFC_XSTAT_ID_INVALID_NAME; + + sfc_adapter_lock(sa); SFC_ASSERT(port->mac_stats_nb_supported <= RTE_DIM(port->mac_stats_by_id)); @@ -812,14 +872,26 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev, efx_mac_stat_name(sa->nic, port->mac_stats_by_id[ids[i]]), sizeof(xstats_names[0].name)); - } else { - sfc_adapter_unlock(sa); - return i; } } + nb_supported = port->mac_stats_nb_supported; + sfc_adapter_unlock(sa); + ret = sfc_sw_xstats_get_names_by_id(sa, ids, xstats_names, size, + &nb_supported); + if (ret != 0) { + SFC_ASSERT(ret < 0); + return ret; + } + + /* Return number of written names before invalid ID is encountered. */ + for (i = 0; i < size; i++) { + if (xstats_names[i].name[0] == SFC_XSTAT_ID_INVALID_NAME) + return i; + } + return size; } diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index f6689a17c0..adb2b2cb81 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -7,6 +7,8 @@ * for Solarflare) and Solarflare Communications, Inc. */ +#include + #include "efx.h" #include "sfc.h" @@ -701,15 +703,11 @@ sfc_port_get_mac_stats_by_id(struct sfc_adapter *sa, const uint64_t *ids, RTE_DIM(port->mac_stats_by_id)); for (i = 0; i < n; i++) { - if (ids[i] < port->mac_stats_nb_supported) { + if (ids[i] < port->mac_stats_nb_supported) values[i] = mac_stats[port->mac_stats_by_id[ids[i]]]; - } else { - ret = i; - goto unlock; - } } - ret = n; + ret = 0; unlock: sfc_adapter_unlock(sa); diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index f6a8ac68e8..280e8a61f9 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -138,6 +138,7 @@ sfc_efx_rx_qrefill(struct sfc_efx_rxq *rxq) SFC_ASSERT(added != rxq->added); rxq->added = added; efx_rx_qpush(rxq->common, added, &rxq->pushed); + rxq->dp.dpq.rx_dbells++; } static uint64_t diff --git a/drivers/net/sfc/sfc_sw_stats.c b/drivers/net/sfc/sfc_sw_stats.c new file mode 100644 index 0000000000..8489b603f5 --- /dev/null +++ b/drivers/net/sfc/sfc_sw_stats.c @@ -0,0 +1,572 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2021 Xilinx, Inc. + */ +#include +#include + +#include "sfc.h" +#include "sfc_rx.h" +#include "sfc_tx.h" +#include "sfc_sw_stats.h" + +enum sfc_sw_stats_type { + SFC_SW_STATS_RX, + SFC_SW_STATS_TX, +}; + +typedef uint64_t sfc_get_sw_xstat_val_t(struct sfc_adapter *sa, uint16_t qid); + +struct sfc_sw_xstat_descr { + const char *name; + enum sfc_sw_stats_type type; + sfc_get_sw_xstat_val_t *get_val; +}; + +static sfc_get_sw_xstat_val_t sfc_get_sw_xstat_val_rx_dbells; +static uint64_t +sfc_get_sw_xstat_val_rx_dbells(struct sfc_adapter *sa, uint16_t qid) +{ + struct sfc_adapter_shared *sas = sfc_sa2shared(sa); + struct sfc_rxq_info *rxq_info; + + rxq_info = sfc_rxq_info_by_ethdev_qid(sas, qid); + if (rxq_info->state & SFC_RXQ_INITIALIZED) + return rxq_info->dp->dpq.rx_dbells; + return 0; +} + +static sfc_get_sw_xstat_val_t sfc_get_sw_xstat_val_tx_dbells; +static uint64_t +sfc_get_sw_xstat_val_tx_dbells(struct sfc_adapter *sa, uint16_t qid) +{ + struct sfc_adapter_shared *sas = sfc_sa2shared(sa); + struct sfc_txq_info *txq_info; + + txq_info = sfc_txq_info_by_ethdev_qid(sas, qid); + if (txq_info->state & SFC_TXQ_INITIALIZED) + return txq_info->dp->dpq.tx_dbells; + return 0; +} + +struct sfc_sw_xstat_descr sfc_sw_xstats[] = { + { + .name = "dbells", + .type = SFC_SW_STATS_RX, + .get_val = sfc_get_sw_xstat_val_rx_dbells, + }, + { + .name = "dbells", + .type = SFC_SW_STATS_TX, + .get_val = sfc_get_sw_xstat_val_tx_dbells, + } +}; + +static int +sfc_sw_stat_get_name(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat, char *name, + size_t name_size, unsigned int id_off) +{ + const char *prefix; + int ret; + + switch (sw_xstat->type) { + case SFC_SW_STATS_RX: + prefix = "rx"; + break; + case SFC_SW_STATS_TX: + prefix = "tx"; + break; + default: + sfc_err(sa, "%s: unknown software statistics type %d", + __func__, sw_xstat->type); + return -EINVAL; + } + + if (id_off == 0) { + ret = snprintf(name, name_size, "%s_%s", prefix, + sw_xstat->name); + if (ret < 0 || ret >= (int)name_size) { + sfc_err(sa, "%s: failed to fill xstat name %s_%s, err %d", + __func__, prefix, sw_xstat->name, ret); + return ret > 0 ? -EINVAL : ret; + } + } else { + uint16_t qid = id_off - 1; + ret = snprintf(name, name_size, "%s_q%u_%s", prefix, qid, + sw_xstat->name); + if (ret < 0 || ret >= (int)name_size) { + sfc_err(sa, "%s: failed to fill xstat name %s_q%u_%s, err %d", + __func__, prefix, qid, sw_xstat->name, ret); + return ret > 0 ? -EINVAL : ret; + } + } + + return 0; +} + +static unsigned int +sfc_sw_stat_get_queue_count(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat) +{ + struct sfc_adapter_shared *sas = sfc_sa2shared(sa); + + switch (sw_xstat->type) { + case SFC_SW_STATS_RX: + return sas->ethdev_rxq_count; + case SFC_SW_STATS_TX: + return sas->ethdev_txq_count; + default: + sfc_err(sa, "%s: unknown software statistics type %d", + __func__, sw_xstat->type); + return 0; + } +} + +static unsigned int +sfc_sw_xstat_per_queue_get_count(unsigned int nb_queues) +{ + /* Take into account the accumulative xstat of all queues */ + return nb_queues > 0 ? 1 + nb_queues : 0; +} + +static unsigned int +sfc_sw_xstat_get_nb_supported(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat) +{ + unsigned int nb_queues; + + nb_queues = sfc_sw_stat_get_queue_count(sa, sw_xstat); + return sfc_sw_xstat_per_queue_get_count(nb_queues); +} + +static int +sfc_sw_stat_get_names(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat, + struct rte_eth_xstat_name *xstats_names, + unsigned int xstats_names_sz, + unsigned int *nb_written, + unsigned int *nb_supported) +{ + const size_t name_size = sizeof(xstats_names[0].name); + unsigned int id_base = *nb_supported; + unsigned int nb_queues; + unsigned int qid; + int rc; + + nb_queues = sfc_sw_stat_get_queue_count(sa, sw_xstat); + if (nb_queues == 0) + return 0; + *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + + /* + * The order of each software xstat type is the accumulative xstat + * followed by per-queue xstats. + */ + if (*nb_written < xstats_names_sz) { + rc = sfc_sw_stat_get_name(sa, sw_xstat, + xstats_names[*nb_written].name, + name_size, *nb_written - id_base); + if (rc != 0) + return rc; + (*nb_written)++; + } + + for (qid = 0; qid < nb_queues; ++qid) { + if (*nb_written < xstats_names_sz) { + rc = sfc_sw_stat_get_name(sa, sw_xstat, + xstats_names[*nb_written].name, + name_size, *nb_written - id_base); + if (rc != 0) + return rc; + (*nb_written)++; + } + } + + return 0; +} + +static int +sfc_sw_xstat_get_names_by_id(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat, + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size, + unsigned int *nb_supported) +{ + const size_t name_size = sizeof(xstats_names[0].name); + unsigned int id_base = *nb_supported; + unsigned int nb_queues; + unsigned int i; + int rc; + + nb_queues = sfc_sw_stat_get_queue_count(sa, sw_xstat); + if (nb_queues == 0) + return 0; + *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + + /* + * The order of each software xstat type is the accumulative xstat + * followed by per-queue xstats. + */ + for (i = 0; i < size; i++) { + if (id_base <= ids[i] && ids[i] <= id_base + nb_queues) { + rc = sfc_sw_stat_get_name(sa, sw_xstat, + xstats_names[i].name, + name_size, ids[i] - id_base); + if (rc != 0) + return rc; + } + } + + return 0; +} + +static void +sfc_sw_xstat_get_values(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat, + struct rte_eth_xstat *xstats, + unsigned int xstats_size, + unsigned int *nb_written, + unsigned int *nb_supported) +{ + unsigned int qid; + uint64_t value; + struct rte_eth_xstat *accum_xstat; + bool count_accum_value = false; + unsigned int nb_queues; + + nb_queues = sfc_sw_stat_get_queue_count(sa, sw_xstat); + if (nb_queues == 0) + return; + *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + + /* + * The order of each software xstat type is the accumulative xstat + * followed by per-queue xstats. + */ + if (*nb_written < xstats_size) { + count_accum_value = true; + accum_xstat = &xstats[*nb_written]; + xstats[*nb_written].id = *nb_written; + xstats[*nb_written].value = 0; + (*nb_written)++; + } + + for (qid = 0; qid < nb_queues; ++qid) { + value = sw_xstat->get_val(sa, qid); + + if (*nb_written < xstats_size) { + xstats[*nb_written].id = *nb_written; + xstats[*nb_written].value = value; + (*nb_written)++; + } + + if (count_accum_value) + accum_xstat->value += value; + } +} + +static void +sfc_sw_xstat_get_values_by_id(struct sfc_adapter *sa, + const struct sfc_sw_xstat_descr *sw_xstat, + const uint64_t *ids, + uint64_t *values, + unsigned int ids_size, + unsigned int *nb_supported) +{ + rte_spinlock_t *bmp_lock = &sa->sw_xstats.queues_bitmap_lock; + struct rte_bitmap *bmp = sa->sw_xstats.queues_bitmap; + unsigned int id_base = *nb_supported; + bool count_accum_value = false; + unsigned int accum_value_idx; + uint64_t accum_value = 0; + unsigned int i, qid; + unsigned int nb_queues; + + + rte_spinlock_lock(bmp_lock); + rte_bitmap_reset(bmp); + + nb_queues = sfc_sw_stat_get_queue_count(sa, sw_xstat); + if (nb_queues == 0) + goto unlock; + *nb_supported += sfc_sw_xstat_per_queue_get_count(nb_queues); + + /* + * The order of each software xstat type is the accumulative xstat + * followed by per-queue xstats. + */ + for (i = 0; i < ids_size; i++) { + if (id_base <= ids[i] && ids[i] <= (id_base + nb_queues)) { + if (ids[i] == id_base) { /* Accumulative value */ + count_accum_value = true; + accum_value_idx = i; + continue; + } + qid = ids[i] - id_base - 1; + values[i] = sw_xstat->get_val(sa, qid); + accum_value += values[i]; + + rte_bitmap_set(bmp, qid); + } + } + + if (count_accum_value) { + for (qid = 0; qid < nb_queues; ++qid) { + if (rte_bitmap_get(bmp, qid) != 0) + continue; + values[accum_value_idx] += sw_xstat->get_val(sa, qid); + } + values[accum_value_idx] += accum_value; + } + +unlock: + rte_spinlock_unlock(bmp_lock); +} + +unsigned int +sfc_sw_xstats_get_nb_supported(struct sfc_adapter *sa) +{ + unsigned int nb_supported = 0; + unsigned int i; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) { + nb_supported += sfc_sw_xstat_get_nb_supported(sa, + &sfc_sw_xstats[i]); + } + + return nb_supported; +} + +void +sfc_sw_xstats_get_vals(struct sfc_adapter *sa, + struct rte_eth_xstat *xstats, + unsigned int xstats_count, + unsigned int *nb_written, + unsigned int *nb_supported) +{ + uint64_t *reset_vals = sa->sw_xstats.reset_vals; + unsigned int sw_xstats_offset; + unsigned int i; + + sfc_adapter_lock(sa); + + sw_xstats_offset = *nb_supported; + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) { + sfc_sw_xstat_get_values(sa, &sfc_sw_xstats[i], xstats, + xstats_count, nb_written, nb_supported); + } + + for (i = sw_xstats_offset; i < *nb_written; i++) + xstats[i].value -= reset_vals[i - sw_xstats_offset]; + + sfc_adapter_unlock(sa); +} + +int +sfc_sw_xstats_get_names(struct sfc_adapter *sa, + struct rte_eth_xstat_name *xstats_names, + unsigned int xstats_count, + unsigned int *nb_written, + unsigned int *nb_supported) +{ + unsigned int i; + int ret; + + sfc_adapter_lock(sa); + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) { + ret = sfc_sw_stat_get_names(sa, &sfc_sw_xstats[i], + xstats_names, xstats_count, + nb_written, nb_supported); + if (ret != 0) { + sfc_adapter_unlock(sa); + return ret; + } + } + + sfc_adapter_unlock(sa); + + return 0; +} + +void +sfc_sw_xstats_get_vals_by_id(struct sfc_adapter *sa, + const uint64_t *ids, + uint64_t *values, + unsigned int n, + unsigned int *nb_supported) +{ + uint64_t *reset_vals = sa->sw_xstats.reset_vals; + unsigned int sw_xstats_offset; + unsigned int i; + + sfc_adapter_lock(sa); + + sw_xstats_offset = *nb_supported; + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) { + sfc_sw_xstat_get_values_by_id(sa, &sfc_sw_xstats[i], ids, + values, n, nb_supported); + } + + for (i = 0; i < n; i++) { + if (sw_xstats_offset <= ids[i] && ids[i] < *nb_supported) + values[i] -= reset_vals[ids[i] - sw_xstats_offset]; + } + + sfc_adapter_unlock(sa); +} + +int +sfc_sw_xstats_get_names_by_id(struct sfc_adapter *sa, + const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size, + unsigned int *nb_supported) +{ + unsigned int i; + int ret; + + sfc_adapter_lock(sa); + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) { + ret = sfc_sw_xstat_get_names_by_id(sa, &sfc_sw_xstats[i], ids, + xstats_names, size, + nb_supported); + if (ret != 0) { + sfc_adapter_unlock(sa); + SFC_ASSERT(ret < 0); + return ret; + } + } + + sfc_adapter_unlock(sa); + + return 0; +} + +static void +sfc_sw_xstat_reset(struct sfc_adapter *sa, struct sfc_sw_xstat_descr *sw_xstat, + uint64_t *reset_vals) +{ + unsigned int nb_queues; + unsigned int qid; + uint64_t *accum_xstat_reset; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + nb_queues = sfc_sw_stat_get_queue_count(sa, sw_xstat); + if (nb_queues == 0) + return; + + /* + * The order of each software xstat type is the accumulative xstat + * followed by per-queue xstats. + */ + accum_xstat_reset = reset_vals; + *accum_xstat_reset = 0; + reset_vals++; + + for (qid = 0; qid < nb_queues; ++qid) { + reset_vals[qid] = sw_xstat->get_val(sa, qid); + *accum_xstat_reset += reset_vals[qid]; + } +} + +void +sfc_sw_xstats_reset(struct sfc_adapter *sa) +{ + uint64_t *reset_vals = sa->sw_xstats.reset_vals; + struct sfc_sw_xstat_descr *sw_xstat; + unsigned int i; + + SFC_ASSERT(sfc_adapter_is_locked(sa)); + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) { + sw_xstat = &sfc_sw_xstats[i]; + sfc_sw_xstat_reset(sa, sw_xstat, reset_vals); + reset_vals += sfc_sw_xstat_get_nb_supported(sa, sw_xstat); + } +} + +int +sfc_sw_xstats_configure(struct sfc_adapter *sa) +{ + uint64_t **reset_vals = &sa->sw_xstats.reset_vals; + size_t nb_supported = 0; + unsigned int i; + + for (i = 0; i < RTE_DIM(sfc_sw_xstats); i++) + nb_supported += sfc_sw_xstat_get_nb_supported(sa, + &sfc_sw_xstats[i]); + + *reset_vals = rte_realloc(*reset_vals, + nb_supported * sizeof(**reset_vals), 0); + if (*reset_vals == NULL) + return ENOMEM; + + memset(*reset_vals, 0, nb_supported * sizeof(**reset_vals)); + + return 0; +} + +static void +sfc_sw_xstats_free_queues_bitmap(struct sfc_adapter *sa) +{ + rte_bitmap_free(sa->sw_xstats.queues_bitmap); + rte_free(sa->sw_xstats.queues_bitmap_mem); +} + +static int +sfc_sw_xstats_alloc_queues_bitmap(struct sfc_adapter *sa) +{ + struct rte_bitmap **queues_bitmap = &sa->sw_xstats.queues_bitmap; + void **queues_bitmap_mem = &sa->sw_xstats.queues_bitmap_mem; + uint32_t bmp_size; + int rc; + + bmp_size = rte_bitmap_get_memory_footprint(RTE_MAX_QUEUES_PER_PORT); + *queues_bitmap_mem = NULL; + *queues_bitmap = NULL; + + *queues_bitmap_mem = rte_calloc_socket("bitmap_mem", bmp_size, 1, 0, + sa->socket_id); + if (*queues_bitmap_mem == NULL) + return ENOMEM; + + *queues_bitmap = rte_bitmap_init(RTE_MAX_QUEUES_PER_PORT, + *queues_bitmap_mem, bmp_size); + if (*queues_bitmap == NULL) { + rc = EINVAL; + goto fail; + } + + rte_spinlock_init(&sa->sw_xstats.queues_bitmap_lock); + return 0; + +fail: + sfc_sw_xstats_free_queues_bitmap(sa); + return rc; +} + +int +sfc_sw_xstats_init(struct sfc_adapter *sa) +{ + sa->sw_xstats.reset_vals = NULL; + + return sfc_sw_xstats_alloc_queues_bitmap(sa); +} + +void +sfc_sw_xstats_close(struct sfc_adapter *sa) +{ + rte_free(sa->sw_xstats.reset_vals); + sa->sw_xstats.reset_vals = NULL; + + sfc_sw_xstats_free_queues_bitmap(sa); +} diff --git a/drivers/net/sfc/sfc_sw_stats.h b/drivers/net/sfc/sfc_sw_stats.h new file mode 100644 index 0000000000..1abded8018 --- /dev/null +++ b/drivers/net/sfc/sfc_sw_stats.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2021 Xilinx, Inc. + */ +#ifndef _SFC_SW_STATS_H +#define _SFC_SW_STATS_H + +#include + +#include "sfc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void sfc_sw_xstats_get_vals(struct sfc_adapter *sa, + struct rte_eth_xstat *xstats, + unsigned int xstats_count, unsigned int *nb_written, + unsigned int *nb_supported); + +int sfc_sw_xstats_get_names(struct sfc_adapter *sa, + struct rte_eth_xstat_name *xstats_names, + unsigned int xstats_count, unsigned int *nb_written, + unsigned int *nb_supported); + +void sfc_sw_xstats_get_vals_by_id(struct sfc_adapter *sa, const uint64_t *ids, + uint64_t *values, unsigned int n, + unsigned int *nb_supported); + +int sfc_sw_xstats_get_names_by_id(struct sfc_adapter *sa, const uint64_t *ids, + struct rte_eth_xstat_name *xstats_names, + unsigned int size, + unsigned int *nb_supported); + +unsigned int sfc_sw_xstats_get_nb_supported(struct sfc_adapter *sa); + +int sfc_sw_xstats_configure(struct sfc_adapter *sa); + +void sfc_sw_xstats_reset(struct sfc_adapter *sa); + +int sfc_sw_xstats_init(struct sfc_adapter *sa); + +void sfc_sw_xstats_close(struct sfc_adapter *sa); + +#ifdef __cplusplus +} +#endif + +#endif /* _SFC_SW_STATS_H */ diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c index ce2a9a6a4f..49b239f4d2 100644 --- a/drivers/net/sfc/sfc_tx.c +++ b/drivers/net/sfc/sfc_tx.c @@ -980,8 +980,10 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) txq->completed, &txq->added); SFC_ASSERT(rc == 0); - if (likely(pushed != txq->added)) + if (likely(pushed != txq->added)) { efx_tx_qpush(txq->common, txq->added, pushed); + txq->dp.dpq.tx_dbells++; + } } #if SFC_TX_XMIT_PKTS_REAP_AT_LEAST_ONCE From patchwork Thu Jul 22 09:54:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Rybchenko X-Patchwork-Id: 96208 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 89B5CA0C4E; Thu, 22 Jul 2021 11:55:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B4CCC41147; Thu, 22 Jul 2021 11:55:28 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 67D1241147 for ; Thu, 22 Jul 2021 11:55:27 +0200 (CEST) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 389047F6CC; Thu, 22 Jul 2021 12:55:27 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id AC3317F6CE; Thu, 22 Jul 2021 12:54:46 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru AC3317F6CE Authentication-Results: shelob.oktetlabs.ru/AC3317F6CE; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org, Xiaoyun Li Cc: David Marchand , Ivan Ilchenko Date: Thu, 22 Jul 2021 12:54:33 +0300 Message-Id: <20210722095433.1898589-12-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> References: <20210604144225.287678-1-andrew.rybchenko@oktetlabs.ru> <20210722095433.1898589-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 11/11] app/testpmd: add option to display extended statistics X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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 Ilchenko Add 'display-xstats' option for using in accompanying with Rx/Tx statistics (i.e. 'stats-period' option or 'show port stats' interactive command) to display specified list of extended statistics. Signed-off-by: Ivan Ilchenko Signed-off-by: Andrew Rybchenko --- app/test-pmd/cmdline.c | 56 ++++++++++++ app/test-pmd/config.c | 66 ++++++++++++++ app/test-pmd/parameters.c | 18 ++++ app/test-pmd/testpmd.c | 122 ++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 21 +++++ doc/guides/testpmd_app_ug/run_app.rst | 5 ++ 6 files changed, 288 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 8468018cf3..baffef1642 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -3609,6 +3609,62 @@ cmdline_parse_inst_t cmd_stop = { /* *** SET CORELIST and PORTLIST CONFIGURATION *** */ +int +parse_xstats_list(char *in_str, struct rte_eth_xstat_name **xstats, + unsigned int *xstats_num) +{ + int max_names_nb, names_nb; + int stringlen; + char **names; + char *str; + int ret; + int i; + + names = NULL; + str = strdup(in_str); + if (str == NULL) { + ret = ENOMEM; + goto out; + } + stringlen = strlen(str); + + for (i = 0, max_names_nb = 1; str[i] != '\0'; i++) { + if (str[i] == ',') + max_names_nb++; + } + + names = calloc(max_names_nb, sizeof(*names)); + if (names == NULL) { + ret = ENOMEM; + goto out; + } + + names_nb = rte_strsplit(str, stringlen, names, max_names_nb, ','); + printf("max names is %d\n", max_names_nb); + if (names_nb < 0) { + ret = EINVAL; + goto out; + } + + *xstats = calloc(names_nb, sizeof(**xstats)); + if (*xstats == NULL) { + ret = ENOMEM; + goto out; + } + + for (i = 0; i < names_nb; i++) + rte_strscpy((*xstats)[i].name, names[i], + sizeof((*xstats)[i].name)); + + *xstats_num = names_nb; + ret = 0; + +out: + free(names); + free(str); + return ret; +} + unsigned int parse_item_list(const char *str, const char *item_name, unsigned int max_items, unsigned int *parsed_items, int check_unique_values) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 04ae0feb58..6d604145bd 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -173,6 +173,70 @@ print_ethaddr(const char *name, struct rte_ether_addr *eth_addr) printf("%s%s", name, buf); } +static void +nic_xstats_display_periodic(portid_t port_id) +{ + struct xstat_display_info *xstats_info; + uint64_t *prev_values, *curr_values; + uint64_t diff_value, value_rate; + uint64_t *ids, *ids_supp; + struct timespec cur_time; + unsigned int i, i_supp; + size_t ids_supp_sz; + uint64_t diff_ns; + int rc; + + xstats_info = &xstats_per_port[port_id]; + + ids_supp_sz = xstats_info->ids_supp_sz; + if (xstats_display_num == 0 || ids_supp_sz == 0) + return; + + printf("\n"); + + ids = xstats_info->ids; + ids_supp = xstats_info->ids_supp; + prev_values = xstats_info->prev_values; + curr_values = xstats_info->curr_values; + + rc = rte_eth_xstats_get_by_id(port_id, ids_supp, curr_values, + ids_supp_sz); + if (rc != (int)ids_supp_sz) { + fprintf(stderr, "%s: Failed to get values of %zu supported xstats for port %u - return code %d\n", + __func__, ids_supp_sz, port_id, rc); + return; + } + + diff_ns = 0; + if (clock_gettime(CLOCK_TYPE_ID, &cur_time) == 0) { + uint64_t ns; + + ns = cur_time.tv_sec * NS_PER_SEC; + ns += cur_time.tv_nsec; + + if (xstats_info->prev_ns != 0) + diff_ns = ns - xstats_info->prev_ns; + xstats_info->prev_ns = ns; + } + + printf("%-31s%-17s%s\n", " ", "Value", "Rate (since last show)"); + for (i = i_supp = 0; i < xstats_display_num; i++) { + if (ids[i] == XSTAT_ID_INVALID) + continue; + + diff_value = (curr_values[i_supp] > prev_values[i]) ? + (curr_values[i_supp] - prev_values[i]) : 0; + prev_values[i] = curr_values[i_supp]; + value_rate = diff_ns > 0 ? + (double)diff_value / diff_ns * NS_PER_SEC : 0; + + printf(" %-25s%12"PRIu64" %15"PRIu64"\n", + xstats_display[i].name, curr_values[i_supp], value_rate); + + i_supp++; + } +} + void nic_stats_display(portid_t port_id) { @@ -243,6 +307,8 @@ nic_stats_display(portid_t port_id) PRIu64" Tx-bps: %12"PRIu64"\n", mpps_rx, mbps_rx * 8, mpps_tx, mbps_tx * 8); + nic_xstats_display_periodic(port_id); + printf(" %s############################%s\n", nic_stats_border, nic_stats_border); } diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 5e69d2aa8c..d4c032cb56 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -61,6 +61,9 @@ usage(char* progname) "(only if interactive is disabled).\n"); printf(" --stats-period=PERIOD: statistics will be shown " "every PERIOD seconds (only if interactive is disabled).\n"); + printf(" --display-xstats xstat1[,...]: extended statistics to show. " + "Used with --stats-period specified or interactive commands " + "that show Rx/Tx statistics (i.e. 'show port stats').\n"); printf(" --nb-cores=N: set the number of forwarding cores " "(1 <= N <= %d).\n", nb_lcores); printf(" --nb-ports=N: set the number of forwarding ports " @@ -532,6 +535,7 @@ launch_args_parse(int argc, char** argv) #endif { "tx-first", 0, 0, 0 }, { "stats-period", 1, 0, 0 }, + { "display-xstats", 1, 0, 0 }, { "nb-cores", 1, 0, 0 }, { "nb-ports", 1, 0, 0 }, { "coremask", 1, 0, 0 }, @@ -689,6 +693,20 @@ launch_args_parse(int argc, char** argv) stats_period = n; break; } + if (!strcmp(lgopts[opt_idx].name, "display-xstats")) { + char rc; + + rc = parse_xstats_list(optarg, &xstats_display, + &xstats_display_num); + if (rc != 0) + rte_exit(EXIT_FAILURE, + "Failed to fill xstats to display: %d\n", + rc); + + if (alloc_display_xstats_info() != 0) + rte_exit(EXIT_FAILURE, + "Failed to alloc xstats display memory\n"); + } if (!strcmp(lgopts[opt_idx].name, "eth-peers-configfile")) { if (init_peer_eth_addrs(optarg) != 0) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index a48f70962f..aebb1d6135 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -208,6 +208,14 @@ uint32_t param_total_num_mbufs = 0; /**< number of mbufs in all pools - if * specified on command-line. */ uint16_t stats_period; /**< Period to show statistics (disabled by default) */ +/** Extended statistics to show. */ +struct rte_eth_xstat_name *xstats_display; + +unsigned int xstats_display_num; /**< Size of extended statistics to show */ + +/** Helper structures for each port to show extended statistics. */ +struct xstat_display_info xstats_per_port[RTE_MAX_ETHPORTS]; + /* * In container, it cannot terminate the process which running with 'stats-period' * option. Set flag to exit stats period loop after received SIGINT/SIGTERM. @@ -542,6 +550,12 @@ uint16_t gso_max_segment_size = RTE_ETHER_MAX_LEN - RTE_ETHER_CRC_LEN; /* Holds the registered mbuf dynamic flags names. */ char dynf_names[64][RTE_MBUF_DYN_NAMESIZE]; +/** Fill helper structures for specified port to show extended statistics. */ +static void fill_display_xstats_info_for_port(portid_t pi); + +/** Fill helper structures for all ports to show extended statistics. */ +static void fill_display_xstats_info(void); + /* * Helper function to check if socket is already discovered. * If yes, return positive value. If not, return zero. @@ -2673,6 +2687,8 @@ start_port(portid_t pid) } } + fill_display_xstats_info_for_port(pid); + printf("Done\n"); return 0; } @@ -3693,6 +3709,110 @@ force_quit(void) prompt_exit(); } +int +alloc_display_xstats_info(void) +{ + portid_t port; + uint64_t *mem; + size_t mem_size; + + if (xstats_display_num == 0) + return 0; + + memset(xstats_per_port, 0, sizeof(xstats_per_port)); + + for (port = 0; port < RTE_MAX_ETHPORTS; port++) { + uint64_t **ids = &xstats_per_port[port].ids; + uint64_t **ids_supp = &xstats_per_port[port].ids_supp; + uint64_t **prev_values = &xstats_per_port[port].prev_values; + uint64_t **curr_values = &xstats_per_port[port].curr_values; + + if (port == 0) { + mem_size = RTE_MAX_ETHPORTS * xstats_display_num * + (sizeof(**ids) + sizeof(**ids_supp) + + sizeof(**prev_values) + + sizeof(**curr_values)); + + mem = malloc(mem_size); + if (mem == NULL) + return -ENOMEM; + + memset(mem, 0, mem_size); + } + + *ids = mem; + mem += xstats_display_num * sizeof(**ids); + + *ids_supp = mem; + mem += xstats_display_num * sizeof(**ids_supp); + + *prev_values = mem; + mem += xstats_display_num * sizeof(**prev_values); + + *curr_values = mem; + mem += xstats_display_num * sizeof(**curr_values); + } + + return 0; +} + +static void +fill_display_xstats_info_for_port(portid_t pi) +{ + unsigned int stat, stat_supp; + uint64_t *ids, *ids_supp; + const char *xstat_name; + struct rte_port *port; + int rc; + + if (xstats_display_num == 0) + return; + + if (pi == (portid_t)RTE_PORT_ALL) { + fill_display_xstats_info(); + return; + } + + port = &ports[pi]; + if (port->port_status != RTE_PORT_STARTED) + return; + + ids = xstats_per_port[pi].ids; + ids_supp = xstats_per_port[pi].ids_supp; + + for (stat = stat_supp = 0; stat < xstats_display_num; stat++) { + xstat_name = xstats_display[stat].name; + + rc = rte_eth_xstats_get_id_by_name(pi, xstat_name, + ids + stat); + if (rc != 0) { + ids[stat] = XSTAT_ID_INVALID; + printf("No xstat '%s' on port %u - skip it\n", + xstat_name, pi); + continue; + } + ids_supp[stat_supp++] = ids[stat]; + } + + xstats_per_port[pi].ids_supp_sz = stat_supp; +} + +static void +fill_display_xstats_info(void) +{ + portid_t pi; + + if (xstats_display_num == 0) + return; + + RTE_ETH_FOREACH_DEV(pi) { + if (pi == (portid_t)RTE_PORT_ALL) + continue; + + fill_display_xstats_info_for_port(pi); + } +} + static void print_stats(void) { @@ -3893,6 +4013,8 @@ main(int argc, char** argv) } #endif + fill_display_xstats_info(); + #ifdef RTE_LIB_CMDLINE if (strlen(cmdline_filename) != 0) cmdline_read_from_file(cmdline_filename); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index d61a055bdd..d66232dfa4 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -434,6 +434,24 @@ extern uint32_t param_total_num_mbufs; extern uint16_t stats_period; +extern struct rte_eth_xstat_name *xstats_display; +extern unsigned int xstats_display_num; + +#define XSTAT_ID_INVALID UINT64_MAX + +/** Information for an extended statistics to show. */ +struct xstat_display_info { + /** IDs of xstats in the order of xstats_display */ + uint64_t *ids; + /** Supported xstats IDs in the order of xstats_display */ + uint64_t *ids_supp; + size_t ids_supp_sz; + uint64_t *prev_values; + uint64_t *curr_values; + uint64_t prev_ns; +}; +extern struct xstat_display_info xstats_per_port[]; + extern uint16_t hairpin_mode; #ifdef RTE_LIB_LATENCYSTATS @@ -766,6 +784,8 @@ inc_tx_burst_stats(struct fwd_stream *fs, uint16_t nb_tx) unsigned int parse_item_list(const char *str, const char *item_name, unsigned int max_items, unsigned int *parsed_items, int check_unique_values); +int parse_xstats_list(char *in_str, struct rte_eth_xstat_name **xstats, + unsigned int *xstats_num); void launch_args_parse(int argc, char** argv); void cmdline_read_from_file(const char *filename); void prompt(void); @@ -978,6 +998,7 @@ enum print_warning { int port_id_is_invalid(portid_t port_id, enum print_warning warning); void print_valid_ports(void); int new_socket_id(unsigned int socket_id); +int alloc_display_xstats_info(void); queueid_t get_allowed_max_nb_rxq(portid_t *pid); int check_nb_rxq(queueid_t rxq); diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index eb48318353..3e5ba81f18 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -56,6 +56,11 @@ The command line options are: Display statistics every PERIOD seconds, if interactive mode is disabled. The default value is 0, which means that the statistics will not be displayed. +* ``--display-xstats xstat1[,...]`` + + Display extended statistics every PERIOD seconds as specified in ``--stats-period`` + or when used with interactive commands that show Rx/Tx statistics (i.e. 'show port stats'). + * ``--nb-cores=N`` Set the number of forwarding cores,