From: Moshe Shemesh <moshe@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>
Cc: Jiri Pirko <jiri@mellanox.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Vladyslav Tarasiuk <vladyslavt@mellanox.com>
Subject: [PATCH net-next v3 5/7] devlink: Add devlink health port reporters API
Date: Fri, 10 Jul 2020 15:25:11 +0300 [thread overview]
Message-ID: <1594383913-3295-6-git-send-email-moshe@mellanox.com> (raw)
In-Reply-To: <1594383913-3295-1-git-send-email-moshe@mellanox.com>
From: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
In order to use new devlink port health reporters infrastructure, add
corresponding constructor and destructor functions.
Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com>
Reviewed-by: Moshe Shemesh <moshe@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
---
include/net/devlink.h | 9 +++++++++
net/core/devlink.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index bb11397..913e867 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -1338,9 +1338,18 @@ struct devlink_health_reporter *
devlink_health_reporter_create(struct devlink *devlink,
const struct devlink_health_reporter_ops *ops,
u64 graceful_period, void *priv);
+
+struct devlink_health_reporter *
+devlink_port_health_reporter_create(struct devlink_port *port,
+ const struct devlink_health_reporter_ops *ops,
+ u64 graceful_period, void *priv);
+
void
devlink_health_reporter_destroy(struct devlink_health_reporter *reporter);
+void
+devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter);
+
void *
devlink_health_reporter_priv(struct devlink_health_reporter *reporter);
int devlink_health_report(struct devlink_health_reporter *reporter,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index b4a231c..20a83aa 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -5372,6 +5372,42 @@ struct devlink_health_reporter {
}
/**
+ * devlink_port_health_reporter_create - create devlink health reporter for
+ * specified port instance
+ *
+ * @port: devlink_port which should contain the new reporter
+ * @ops: ops
+ * @graceful_period: to avoid recovery loops, in msecs
+ * @priv: priv
+ */
+struct devlink_health_reporter *
+devlink_port_health_reporter_create(struct devlink_port *port,
+ const struct devlink_health_reporter_ops *ops,
+ u64 graceful_period, void *priv)
+{
+ struct devlink_health_reporter *reporter;
+
+ mutex_lock(&port->reporters_lock);
+ if (__devlink_health_reporter_find_by_name(&port->reporter_list,
+ &port->reporters_lock, ops->name)) {
+ reporter = ERR_PTR(-EEXIST);
+ goto unlock;
+ }
+
+ reporter = __devlink_health_reporter_create(port->devlink, ops,
+ graceful_period, priv);
+ if (IS_ERR(reporter))
+ goto unlock;
+
+ reporter->devlink_port = port;
+ list_add_tail(&reporter->list, &port->reporter_list);
+unlock:
+ mutex_unlock(&port->reporters_lock);
+ return reporter;
+}
+EXPORT_SYMBOL_GPL(devlink_port_health_reporter_create);
+
+/**
* devlink_health_reporter_create - create devlink health reporter
*
* @devlink: devlink
@@ -5441,6 +5477,20 @@ struct devlink_health_reporter *
}
EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy);
+/**
+ * devlink_port_health_reporter_destroy - destroy devlink port health reporter
+ *
+ * @reporter: devlink health reporter to destroy
+ */
+void
+devlink_port_health_reporter_destroy(struct devlink_health_reporter *reporter)
+{
+ mutex_lock(&reporter->devlink_port->reporters_lock);
+ __devlink_health_reporter_destroy(reporter);
+ mutex_unlock(&reporter->devlink_port->reporters_lock);
+}
+EXPORT_SYMBOL_GPL(devlink_port_health_reporter_destroy);
+
static int
devlink_nl_health_reporter_fill(struct sk_buff *msg,
struct devlink *devlink,
--
1.8.3.1
next prev parent reply other threads:[~2020-07-10 12:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-10 12:25 [PATCH net-next v3 0/7] Add devlink-health support for devlink ports Moshe Shemesh
2020-07-10 12:25 ` [PATCH net-next v3 1/7] devlink: Refactor devlink health reporter constructor Moshe Shemesh
2020-07-10 12:25 ` [PATCH net-next v3 2/7] devlink: Rework devlink health reporter destructor Moshe Shemesh
2020-07-10 12:25 ` [PATCH net-next v3 3/7] devlink: Create generic devlink health reporter search function Moshe Shemesh
2020-07-10 12:25 ` [PATCH net-next v3 4/7] devlink: Implement devlink health reporters on per-port basis Moshe Shemesh
2020-07-10 12:25 ` Moshe Shemesh [this message]
2020-07-13 13:18 ` [PATCH net-next v3 5/7] devlink: Add devlink health port reporters API Qian Cai
2020-07-13 14:07 ` Ido Schimmel
2020-07-10 12:25 ` [PATCH net-next v3 6/7] net/mlx5e: Move devlink port register and unregister calls Moshe Shemesh
2020-07-10 12:25 ` [PATCH net-next v3 7/7] net/mlx5e: Move devlink-health rx and tx reporters to devlink port Moshe Shemesh
2020-07-10 21:11 ` [PATCH net-next v3 0/7] Add devlink-health support for devlink ports Jakub Kicinski
2020-07-10 21:32 ` David Miller
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=1594383913-3295-6-git-send-email-moshe@mellanox.com \
--to=moshe@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vladyslavt@mellanox.com \
/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).