netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Eran Ben Elisha <eranbe@mellanox.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@mellanox.com>,
	"David S. Miller" <davem@davemloft.net>,
	Ariel Almog <ariela@mellanox.com>, Aya Levin <ayal@mellanox.com>,
	Moshe Shemesh <moshe@mellanox.com>
Subject: Re: [PATCH net-next v2 07/11] devlink: Add health diagnose command
Date: Sun, 20 Jan 2019 12:38:29 +0100	[thread overview]
Message-ID: <20190120113829.GK2730@nanopsycho> (raw)
In-Reply-To: <1547762360-7075-8-git-send-email-eranbe@mellanox.com>

Thu, Jan 17, 2019 at 10:59:16PM CET, eranbe@mellanox.com wrote:
>Add devlink health diagnose command, in order to run a diagnose
>operation over a specific reporter.
>
>It is expected from driver's callback for diagnose command to fill it
>via the buffer descriptors API. Devlink will parse it and convert it to
>netlink nla API in order to pass it to the user.
>
>Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
>Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
>---
> include/uapi/linux/devlink.h |  1 +
> net/core/devlink.c           | 51 ++++++++++++++++++++++++++++++++++++
> 2 files changed, 52 insertions(+)
>
>diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
>index 1c186fd77343..51b4d7612cf8 100644
>--- a/include/uapi/linux/devlink.h
>+++ b/include/uapi/linux/devlink.h
>@@ -92,6 +92,7 @@ enum devlink_command {
> 	DEVLINK_CMD_HEALTH_REPORTER_GET,
> 	DEVLINK_CMD_HEALTH_REPORTER_SET,
> 	DEVLINK_CMD_HEALTH_REPORTER_RECOVER,
>+	DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
> 
> 	/* add new commands above here */
> 	__DEVLINK_CMD_MAX,
>diff --git a/net/core/devlink.c b/net/core/devlink.c
>index b224d0d31c0c..57252ca31e1e 100644
>--- a/net/core/devlink.c
>+++ b/net/core/devlink.c
>@@ -4500,6 +4500,50 @@ static int devlink_nl_cmd_health_reporter_recover_doit(struct sk_buff *skb,
> 	return devlink_health_reporter_recover(reporter, NULL);
> }
> 
>+static int devlink_nl_cmd_health_reporter_diagnose_doit(struct sk_buff *skb,
>+							struct genl_info *info)
>+{
>+	struct devlink *devlink = info->user_ptr[0];
>+	struct devlink_health_reporter *reporter;
>+	u64 num_of_buffers;
>+	int err;
>+
>+	reporter = devlink_health_reporter_get_from_info(devlink, info);
>+	if (!reporter)
>+		return -EINVAL;
>+
>+	if (!reporter->ops->diagnose)
>+		return -EOPNOTSUPP;
>+
>+	num_of_buffers =
>+		DEVLINK_HEALTH_SIZE_TO_BUFFERS(reporter->ops->diagnose_size);

This is odd. You need to convert to number of "buffers" the magic value
the driver provided. And then couple lines below....


>+
>+	mutex_lock(&reporter->diagnose_lock);
>+	devlink_health_buffers_reset(reporter->diagnose_buffers_array,
>+				     num_of_buffers);
>+
>+	err = reporter->ops->diagnose(reporter,
>+				      reporter->diagnose_buffers_array,
>+				      DEVLINK_HEALTH_BUFFER_SIZE,
>+				      num_of_buffers);

....you call the driver with "buffers array", buffer size and number of
buffers. It should be just:

	struct devlink_msg_ctx msg_ctx;

	err = reporter->ops->diagnose(reporter, &msg_ctx);

and then;

	err = devlink_health_buffer_snd(info,
					devlink_cmd_health_reporter_diagnose,
					0, &msg_ctx);


>+	if (err)
>+		goto out;
>+
>+	err = devlink_health_buffer_snd(info,
>+					devlink_cmd_health_reporter_diagnose,
>+					0, reporter->diagnose_buffers_array,
>+					num_of_buffers);
>+	if (err)
>+		goto out;
>+
>+	mutex_unlock(&reporter->diagnose_lock);
>+	return 0;
>+
>+out:
>+	mutex_unlock(&reporter->diagnose_lock);
>+	return err;
>+}
>+
> static const struct nla_policy devlink_nl_policy[DEVLINK_ATTR_MAX + 1] = {
> 	[DEVLINK_ATTR_BUS_NAME] = { .type = NLA_NUL_STRING },
> 	[DEVLINK_ATTR_DEV_NAME] = { .type = NLA_NUL_STRING },
>@@ -4770,6 +4814,13 @@ static const struct genl_ops devlink_nl_ops[] = {
> 		.flags = GENL_ADMIN_PERM,
> 		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK,
> 	},
>+	{
>+		.cmd = DEVLINK_CMD_HEALTH_REPORTER_DIAGNOSE,
>+		.doit = devlink_nl_cmd_health_reporter_diagnose_doit,
>+		.policy = devlink_nl_policy,
>+		.flags = GENL_ADMIN_PERM,
>+		.internal_flags = DEVLINK_NL_FLAG_NEED_DEVLINK,
>+	},
> };
> 
> static struct genl_family devlink_nl_family __ro_after_init = {
>-- 
>2.17.1
>

  reply	other threads:[~2019-01-20 11:47 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-17 21:59 [PATCH net-next v2 00/11] Devlink health reporting and recovery system Eran Ben Elisha
2019-01-17 21:59 ` [PATCH net-next v2 01/11] devlink: Add health buffer support Eran Ben Elisha
2019-01-20 10:03   ` Jiri Pirko
2019-01-20 11:06     ` Eran Ben Elisha
2019-01-20 11:08       ` Jiri Pirko
2019-01-20 18:45         ` David Miller
2019-01-21 11:07           ` Eran Ben Elisha
2019-01-21 12:08             ` Jiri Pirko
2019-01-20 11:20   ` Jiri Pirko
2019-01-17 21:59 ` [PATCH net-next v2 02/11] devlink: Add health reporter create/destroy functionality Eran Ben Elisha
2019-01-20 11:49   ` Jiri Pirko
2019-01-17 21:59 ` [PATCH net-next v2 03/11] devlink: Add health report functionality Eran Ben Elisha
2019-01-20 11:27   ` Jiri Pirko
2019-01-21 11:12     ` Eran Ben Elisha
2019-01-17 21:59 ` [PATCH net-next v2 04/11] devlink: Add health get command Eran Ben Elisha
2019-01-20 11:31   ` Jiri Pirko
2019-01-17 21:59 ` [PATCH net-next v2 05/11] devlink: Add health set command Eran Ben Elisha
2019-01-20 11:32   ` Jiri Pirko
2019-01-17 21:59 ` [PATCH net-next v2 06/11] devlink: Add health recover command Eran Ben Elisha
2019-01-20 11:33   ` Jiri Pirko
2019-01-17 21:59 ` [PATCH net-next v2 07/11] devlink: Add health diagnose command Eran Ben Elisha
2019-01-20 11:38   ` Jiri Pirko [this message]
2019-01-17 21:59 ` [PATCH net-next v2 08/11] devlink: Add health dump {get,clear} commands Eran Ben Elisha
2019-01-17 21:59 ` [PATCH net-next v2 09/11] net/mlx5e: Add TX reporter support Eran Ben Elisha
2019-01-20 11:06   ` Jiri Pirko
2019-01-21 11:32     ` Eran Ben Elisha
2019-01-21 12:11       ` Jiri Pirko
2019-01-21 13:06         ` Eran Ben Elisha
2019-01-21 13:45           ` Jiri Pirko
2019-01-17 21:59 ` [PATCH net-next v2 10/11] net/mlx5e: Add TX timeout support for mlx5e TX reporter Eran Ben Elisha
2019-01-17 21:59 ` [PATCH net-next v2 11/11] devlink: Add Documentation/networking/devlink-health.txt Eran Ben Elisha
2019-01-18 22:59 ` [PATCH net-next v2 00/11] Devlink health reporting and recovery system David Miller
2019-01-20  9:27 ` [PATCH iproute2-next v2] devlink: Add health command support Aya Levin
2019-01-23  3:37   ` David Ahern
2019-01-23 11:27     ` Aya Levin
2019-01-24  0:27       ` David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190120113829.GK2730@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=ariela@mellanox.com \
    --cc=ayal@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=eranbe@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=moshe@mellanox.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).