From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3017DA0545; Wed, 15 Jul 2020 12:51:01 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A1F331BED3; Wed, 15 Jul 2020 12:50:59 +0200 (CEST) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 167801BEBF; Wed, 15 Jul 2020 12:50:58 +0200 (CEST) From: Shy Shyman To: dev@dpdk.org Cc: viacheslavo@mellanox.com, stable@dpdk.org Date: Wed, 15 Jul 2020 13:50:55 +0300 Message-Id: <20200715105055.80089-1-shys@mellanox.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When debugging performance of a DPDK application the user may need to view the different statistics of DPDK(for example out_of_buffer) This can be enabled by using testpmd command 'show port xstats ' for example. The current implementation assumes legacy mode in which the counters are at //hw_counters/. In switchdev mode the counters file is located right after the device name, hence resides at /hw_counters. The fix tries to open the path in the second location after a failure to open the file from the first location. Fixes: 9c0a9eed37f1 ("net/mlx5: switch to the names in the shared IB context") Cc: stable@dpdk.org Cc: viacheslavo@mellanox.com Signed-off-by: Shy Shyman --- drivers/net/mlx5/linux/mlx5_os.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 2dc57b20ef..0edc96299c 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1948,10 +1948,20 @@ mlx5_os_read_dev_stat(struct mlx5_priv *priv, const char *ctr_name, if (priv->sh) { MKSTR(path, "%s/ports/%d/hw_counters/%s", - priv->sh->ibdev_path, - priv->dev_port, - ctr_name); + priv->sh->ibdev_path, + priv->dev_port, + ctr_name); fd = open(path, O_RDONLY); + /* + * in switchdev the file location is not per port + * but rather in /hw_counters/. + */ + if (fd == -1) { + MKSTR(path1, "%s/hw_counters/%s", + priv->sh->ibdev_path, + ctr_name); + fd = open(path1, O_RDONLY); + } if (fd != -1) { char buf[21] = {'\0'}; ssize_t n = read(fd, buf, sizeof(buf)); -- 2.21.0