Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1553633ybt; Thu, 2 Jul 2020 08:10:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOVO2O0YiD+nnTZNwY/VQH/Ax2NkLjYpAH/6KfEXcrKc9e1mkdx6hdeIf386rEmC9i3D2C X-Received: by 2002:a50:f086:: with SMTP id v6mr36253780edl.199.1593702653871; Thu, 02 Jul 2020 08:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593702653; cv=none; d=google.com; s=arc-20160816; b=bOeb8P/qmhVVfFOjoPNLeYMq89fJWtgpDJ3plgIZWqUR7PAHMSsYtLkOYpSCH5rS76 WaGYUEk/WOR/JbZvgkbddA7hpBLNubTOuR6+Y7PL21NhqRbtlxIkuAusW7vhciMbDZuz 1xGv3tQyyKAAqsGug1c+R+l+MpgVSzB3VVajFQhiIlPUNgMclww/lTd8Vqhj7G9UYOHj UZB5wAnh/dB8x/Cw7kdekYzgAZ3d5MXAGqkws1ugpnIsLmXQ86J5nhzQOh22lslwdIdx 4yGpovRuPz11LiitTmG/EVbYSGhj7CKi06PaLcpTanz0Os/QUKh8wTOZcPVR5m3JB3US PpsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=iYn8HToQ1upZyhmEpCuMuV7u8t+3ppBL110hw8nR/9I=; b=KZCcHCW+iLfPn+dnen63OM4Mk67/Q0oZSb+7ylIgZHewn3FiIFLFk82fNlSzD8gB8E tPpsc11LztkXgM1H4IXz6lglzD3LJCzNeE3biRq3CP2mA4R0an4swfvLmMrnTQbri4jz FxSeBVf4w5dH5tgqX5ZNYyWmFTyokmPByc04mj1RwaXzs7In7qrllz9dwtH505uEqpW8 3aJsq58UEjvoGkwUgA/gCY3cL47xFcByQ4N3qHftsyP6i8mRGlTsrKjPT+QoDWj6+tyk GY5hswCMyo0h6VEahCaw2CAxM0hTUXmAbJrPihUUJpBFRqw1o4udYtj/gO4aIrJ7XNa0 COFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w3si5959673edx.581.2020.07.02.08.10.30; Thu, 02 Jul 2020 08:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730184AbgGBPJg (ORCPT + 99 others); Thu, 2 Jul 2020 11:09:36 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:39747 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730057AbgGBPJQ (ORCPT ); Thu, 2 Jul 2020 11:09:16 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 2 Jul 2020 18:09:09 +0300 Received: from dev-l-vrt-136.mtl.labs.mlnx (dev-l-vrt-136.mtl.labs.mlnx [10.234.136.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 062F99u3020270; Thu, 2 Jul 2020 18:09:09 +0300 Received: from dev-l-vrt-136.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 062F99XQ015413; Thu, 2 Jul 2020 18:09:09 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 062F99r4015412; Thu, 2 Jul 2020 18:09:09 +0300 From: Moshe Shemesh To: "David S. Miller" Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladyslav Tarasiuk Subject: [PATCH net-next 5/7] devlink: Add devlink health port reporters API Date: Thu, 2 Jul 2020 18:08:11 +0300 Message-Id: <1593702493-15323-6-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1593702493-15323-1-git-send-email-moshe@mellanox.com> References: <1593702493-15323-1-git-send-email-moshe@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladyslav Tarasiuk In order to use new devlink port health reporters infrastructure, add corresponding constructor and destructor functions. Signed-off-by: Vladyslav Tarasiuk Reviewed-by: Moshe Shemesh Reviewed-by: Jiri Pirko --- include/net/devlink.h | 9 +++++++++ net/core/devlink.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/include/net/devlink.h b/include/net/devlink.h index d3ac152..2082062 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1336,9 +1336,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 8aedd20..e0bb045 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -5346,6 +5346,42 @@ struct devlink_health_reporter { } /** + * devlink_port_health_reporter_create - create devlink health reporter for + * specified port instance + * + * @devlink_port: devlink_port + * @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 @@ -5415,6 +5451,21 @@ struct devlink_health_reporter * } EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy); +/** + * devlink_port_health_reporter_destroy - destroy devlink port health reporter + * + * @port: devlink_port which should contain specified 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