Subject: Re: [PATCH net-next 09/16] net/mlx5e: Extend tx reporter diagnostics output

From: Jiri Pirko <[email-masked]>
Date: Mon, 8 Jul 2019 14:55:53 +0200

Sun, Jul 07, 2019 at 01:53:01PM CEST, [email-masked] wrote:
>From: Aya Levin <[email-masked]>
>
>Enhance tx reporter's diagnostics output to include: information common
>to all SQs: SQ size, SQ stride size.
>In addition add channel ix, cc and pc.
>
>$ devlink health diagnose pci/0000:00:0b.0 reporter tx
>Common config:
>   SQ: stride size: 64 size: 1024
> SQs:
>   channel ix: 0 sqn: 4283 HW state: 1 stopped: false cc: 0 pc: 0
>   channel ix: 1 sqn: 4288 HW state: 1 stopped: false cc: 0 pc: 0
>   channel ix: 2 sqn: 4293 HW state: 1 stopped: false cc: 0 pc: 0
>   channel ix: 3 sqn: 4298 HW state: 1 stopped: false cc: 0 pc: 0
>
>$ devlink health diagnose pci/0000:00:0b.0 reporter tx -jp
>{
>    "Common config": [
>        "SQ": {
>            "stride size": 64,
>            "size": 1024
>        } ],
>    "SQs": [ {
>            "channel ix": 0,
>            "sqn": 4283,
>            "HW state": 1,
>            "stopped": false,
>            "cc": 0,
>            "pc": 0
>        },{
>            "channel ix": 1,
>            "sqn": 4288,
>            "HW state": 1,
>            "stopped": false,
>            "cc": 0,
>            "pc": 0
>        },{
>            "channel ix": 2,
>            "sqn": 4293,
>            "HW state": 1,
>            "stopped": false,
>            "cc": 0,
>            "pc": 0
>        },{
>            "channel ix": 3,
>            "sqn": 4298,
>            "HW state": 1,
>            "stopped": false,
>            "cc": 0,
>            "pc": 0
>         } ]
>}
>
>Signed-off-by: Aya Levin <[email-masked]>
>Signed-off-by: Tariq Toukan <[email-masked]>
>---
> .../net/ethernet/mellanox/mlx5/core/en/health.c    | 30 ++++++++++++++++
> .../net/ethernet/mellanox/mlx5/core/en/health.h    |  3 ++
> .../ethernet/mellanox/mlx5/core/en/reporter_tx.c   | 42 ++++++++++++++++++++++
> 3 files changed, 75 insertions(+)
>
>diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
>index 60166e5432ae..0d44b081259f 100644
>--- a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
>+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
>@@ -4,6 +4,36 @@
> #include "health.h"
> #include "lib/eq.h"
> 
>+int mlx5e_reporter_named_obj_nest_start(struct devlink_fmsg *fmsg, char *name)
>+{
>+	int err;
>+
>+	err = devlink_fmsg_pair_nest_start(fmsg, name);
>+	if (err)
>+		return err;
>+
>+	err = devlink_fmsg_obj_nest_start(fmsg);
>+	if (err)
>+		return err;
>+
>+	return 0;
>+}
>+
>+int mlx5e_reporter_named_obj_nest_end(struct devlink_fmsg *fmsg)
>+{
>+	int err;
>+
>+	err = devlink_fmsg_pair_nest_end(fmsg);

You should end the obj nest first.

>+	if (err)
>+		return err;
>+
>+	err = devlink_fmsg_obj_nest_end(fmsg);
>+	if (err)
>+		return err;
>+
>+	return 0;
>+}
>+
> int mlx5e_health_sq_to_ready(struct mlx5e_channel *channel, u32 sqn)
> {
> 	struct mlx5_core_dev *mdev = channel->mdev;
>diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/health.h b/drivers/net/ethernet/mellanox/mlx5/core/en/health.h
>index 960aa18c425d..0fecad63135c 100644
>--- a/drivers/net/ethernet/mellanox/mlx5/core/en/health.h
>+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/health.h
>@@ -11,6 +11,9 @@
> void mlx5e_reporter_tx_err_cqe(struct mlx5e_txqsq *sq);
> int mlx5e_reporter_tx_timeout(struct mlx5e_txqsq *sq);
> 
>+int mlx5e_reporter_named_obj_nest_start(struct devlink_fmsg *fmsg, char *name);
>+int mlx5e_reporter_named_obj_nest_end(struct devlink_fmsg *fmsg);
>+
> #define MLX5E_REPORTER_PER_Q_MAX_LEN 256
> 
> struct mlx5e_err_ctx {
>diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
>index dd6417930461..c481f7142a12 100644
>--- a/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
>+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/reporter_tx.c
>@@ -153,6 +153,10 @@ static int mlx5e_tx_reporter_recover(struct devlink_health_reporter *reporter,
> 	if (err)
> 		return err;
> 
>+	err = devlink_fmsg_u32_pair_put(fmsg, "channel ix", sq->channel->ix);

"ix" is an attribute of the channel. I think it should be nested under
"channel" here.

>+	if (err)
>+		return err;
>+
> 	err = devlink_fmsg_u32_pair_put(fmsg, "sqn", sq->sqn);
> 	if (err)
> 		return err;
>@@ -165,6 +169,14 @@ static int mlx5e_tx_reporter_recover(struct devlink_health_reporter *reporter,
> 	if (err)
> 		return err;
> 
>+	err = devlink_fmsg_u32_pair_put(fmsg, "cc", sq->cc);
>+	if (err)
>+		return err;
>+
>+	err = devlink_fmsg_u32_pair_put(fmsg, "pc", sq->pc);
>+	if (err)
>+		return err;
>+
> 	err = devlink_fmsg_obj_nest_end(fmsg);
> 	if (err)
> 		return err;
>@@ -176,6 +188,9 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
> 				      struct devlink_fmsg *fmsg)
> {
> 	struct mlx5e_priv *priv = devlink_health_reporter_priv(reporter);
>+	struct mlx5e_txqsq *generic_sq = priv->txq2sq[0];
>+	u32 sq_stride, sq_sz;
>+
> 	int i, err = 0;
> 
> 	mutex_lock(&priv->state_lock);
>@@ -183,6 +198,33 @@ static int mlx5e_tx_reporter_diagnose(struct devlink_health_reporter *reporter,
> 	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
> 		goto unlock;
> 
>+	sq_sz = mlx5_wq_cyc_get_size(&generic_sq->wq);
>+	sq_stride = MLX5_SEND_WQE_BB;
>+
>+	err = devlink_fmsg_arr_pair_nest_start(fmsg, "Common config");
>+	if (err)
>+		goto unlock;
>+
>+	err = mlx5e_reporter_named_obj_nest_start(fmsg, "SQ");
>+	if (err)
>+		goto unlock;
>+
>+	err = devlink_fmsg_u64_pair_put(fmsg, "stride size", sq_stride);
>+	if (err)
>+		goto unlock;
>+
>+	err = devlink_fmsg_u32_pair_put(fmsg, "size", sq_sz);
>+	if (err)
>+		goto unlock;
>+
>+	err = devlink_fmsg_arr_pair_nest_end(fmsg);

Which nest is this supposed to end? Looks like it is extra and
should not be here...

>+	if (err)
>+		goto unlock;
>+
>+	err = mlx5e_reporter_named_obj_nest_end(fmsg);
>+	if (err)
>+		goto unlock;
>+
> 	err = devlink_fmsg_arr_pair_nest_start(fmsg, "SQs");
> 	if (err)
> 		goto unlock;
>-- 
>1.8.3.1
>