diff options
author | Vladyslav Tarasiuk <vladyslavt@mellanox.com> | 2020-07-10 15:25:11 +0300 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-07-10 14:32:02 -0700 |
commit | 15c724b997a8fe1a677cf11797fb29c0bdecc63f (patch) | |
tree | 28f195db469d2b3fc11d88210a8a67bed2d87a8e /net/core | |
parent | f4f541660121aeb91a1b462ab3f3c5a86ab7c3dd (diff) | |
download | linux-15c724b997a8fe1a677cf11797fb29c0bdecc63f.tar.gz linux-15c724b997a8fe1a677cf11797fb29c0bdecc63f.tar.bz2 linux-15c724b997a8fe1a677cf11797fb29c0bdecc63f.zip |
devlink: Add devlink health port reporters API
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/devlink.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c index b4a231ca7135..20a83aace642 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5372,6 +5372,42 @@ __devlink_health_reporter_create(struct devlink *devlink, } /** + * 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 @@ devlink_health_reporter_destroy(struct devlink_health_reporter *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, |