DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters
@ 2020-07-15 10:50 Shy Shyman
  2020-07-15 10:54 ` Slava Ovsiienko
  2020-07-20  7:20 ` Raslan Darawsheh
  0 siblings, 2 replies; 4+ messages in thread
From: Shy Shyman @ 2020-07-15 10:50 UTC (permalink / raw)
  To: dev; +Cc: viacheslavo, stable

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
<port_id>' for example.

The current implementation assumes legacy mode in which the
counters
are at <ibdev_path>/<port_id>/hw_counters/<file_name>.
In switchdev mode the counters file is located right after the device
name, hence resides at <ibdev_path>/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 <shys@mellanox.com>
---
 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 <ibdev_path>/hw_counters/<file_name>.
+		*/
+		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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters
  2020-07-15 10:50 [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters Shy Shyman
@ 2020-07-15 10:54 ` Slava Ovsiienko
  2020-07-20  7:20 ` Raslan Darawsheh
  1 sibling, 0 replies; 4+ messages in thread
From: Slava Ovsiienko @ 2020-07-15 10:54 UTC (permalink / raw)
  To: Shy Shyman, dev; +Cc: stable

> -----Original Message-----
> From: Shy Shyman <shys@mellanox.com>
> Sent: Wednesday, July 15, 2020 13:51
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; stable@dpdk.org
> Subject: [PATCH] net/mlx5: fix file path location of HW counters
> 
> 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 <port_id>' for
> example.
> 
> The current implementation assumes legacy mode in which the counters are
> at <ibdev_path>/<port_id>/hw_counters/<file_name>.
> In switchdev mode the counters file is located right after the device name,
> hence resides at <ibdev_path>/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 <shys@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters
  2020-07-15 10:50 [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters Shy Shyman
  2020-07-15 10:54 ` Slava Ovsiienko
@ 2020-07-20  7:20 ` Raslan Darawsheh
  1 sibling, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2020-07-20  7:20 UTC (permalink / raw)
  To: Shy Shyman, dev; +Cc: Slava Ovsiienko, stable

Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Shy Shyman
> Sent: Wednesday, July 15, 2020 1:51 PM
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters
> 
> 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
> <port_id>' for example.
> 
> The current implementation assumes legacy mode in which the
> counters
> are at <ibdev_path>/<port_id>/hw_counters/<file_name>.
> In switchdev mode the counters file is located right after the device
> name, hence resides at <ibdev_path>/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 <shys@mellanox.com>
> ---
>  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 <ibdev_path>/hw_counters/<file_name>.
> +		*/
> +		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

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters
@ 2020-07-15 10:40 Shy Shyman
  0 siblings, 0 replies; 4+ messages in thread
From: Shy Shyman @ 2020-07-15 10:40 UTC (permalink / raw)
  To: dev; +Cc: viacheslavo, stable

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
<port_id>' for example.

The current implementation assumes legacy mode in which the
counters
are at <ibdev_path>/<port_id>/hw_counters/<file_name>.
In switchdev mode the counters file is located right after the device
name, hence resides at <ibdev_path>/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 <shys@mellanox.com>
---
 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 <ibdev_path>/hw_counters/<file_name>.
+		*/
+		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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-07-20  7:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 10:50 [dpdk-dev] [PATCH] net/mlx5: fix file path location of HW counters Shy Shyman
2020-07-15 10:54 ` Slava Ovsiienko
2020-07-20  7:20 ` Raslan Darawsheh
  -- strict thread matches above, loose matches on Subject: below --
2020-07-15 10:40 Shy Shyman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).