Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1991084ybt; Thu, 2 Jul 2020 20:31:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHxrjcxdZ0htfSLfiAH0xn8PF7ljRjVRYM1wgnIjjYznrraNOivB1EbT4CF4CL7NmxpSlj X-Received: by 2002:a17:906:d79c:: with SMTP id pj28mr29024117ejb.397.1593747105526; Thu, 02 Jul 2020 20:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593747105; cv=none; d=google.com; s=arc-20160816; b=cRdsSLTBGhQmDTTR2cWjZyliU3TrJ+tCc1tItriEF0stw7r3veX7PgXM/6ma1q/qC+ tnC3kyjOS2wt5VW+Wa7FbtI3SkEFfTyGCU1pVaHUquxVcWyc0XQ8H61oLaZ2MmvAR2iD tfgEAh1mc8ibuPBglS+GW4RqgT+Juw1ZdJe3U1OHWXH1oc0I9Ooc5byDXg7LWB8qx9yU VP2vrXuACRMFNFIxjbUnZ1AKtySBDtx3KUbVqE7oBIdPBWZ9FW62NXcbGNWTBH0rv/mp C2WGETMx6YVHQButLFjeDA7Dl+dumK6fXvflqMB2MWZbU46OP3wl9S1iO3yJRdhnRoo+ 9T5A== 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=P/e6mk00cpJij/DHBObbZiCDuYQOsDLoqyfEk7Xm9Ws=; b=Fg1RYIrwuyO4n7tZWZWoKp99bGvzXQFhkfR8eWVi8zEW7a6imtF8ohmIKirepPISr9 u9GVe7GCU1YuywMZHbIDAzf861u3Y2vX38Ac0eDAoOgyPKl0mCQpEIjR7FmHc9IZNZv6 R55BJpcUJyajktCA8woio9YwVKQWv+mKA4btoCAlz5QseV+AwWqiUOf3zqbEzw8d2XZ1 3jqCxaYB776LVTy9h6gXCC6MaA5ItdrgikKBm4gupVcZeNcP6HXSYNJ4OPlHRpGMQMAp WfV9EIwiK0hFu6EkE7MXXRST0yIsCGy1KQtN8VQFz244xAeVIZCt/cZzKik9/hCpJ0KP UdRA== 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 dt5si9481328ejc.335.2020.07.02.20.31.22; Thu, 02 Jul 2020 20:31:45 -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 S1726247AbgGCD2Y (ORCPT + 99 others); Thu, 2 Jul 2020 23:28:24 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:33621 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726140AbgGCD2W (ORCPT ); Thu, 2 Jul 2020 23:28:22 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 3 Jul 2020 06:28:15 +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 0633SFIQ006796; Fri, 3 Jul 2020 06:28:15 +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 0633SFto006665; Fri, 3 Jul 2020 06:28:15 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 0633SFq1006664; Fri, 3 Jul 2020 06:28:15 +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 v2 5/7] devlink: Add devlink health port reporters API Date: Fri, 3 Jul 2020 06:27:36 +0300 Message-Id: <1593746858-6548-6-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1593746858-6548-1-git-send-email-moshe@mellanox.com> References: <1593746858-6548-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 | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 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..b7aa194 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 + * + * @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 @@ -5415,6 +5451,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