Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp498641ybt; Fri, 10 Jul 2020 05:28:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaejgbRAmkFtWWQvU1XptW4r1c4kf+QizjiqII0Ul+6E6V5VFsPde+T85XpWoTmmdrvFK2 X-Received: by 2002:aa7:d283:: with SMTP id w3mr58432809edq.76.1594384107287; Fri, 10 Jul 2020 05:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594384107; cv=none; d=google.com; s=arc-20160816; b=SRIbi28pCjhXbPJPZAKDnXX3VuPnn/FKmxnw0VOwT7H1qQh4AeZxFAwNqURaLGV0De 9r4j87H1w1zWNUAzCKn7RoZt12ITiJ58fz7cUYVJzFWo/jouBc1kNtuE1fy4VVCWltrg H9m3LVFhsOUZ/dgnamoERn5mjiWK9b06r1W5Kw5R5Yp/O15jWqhnzwLOsofuGeqKbWxb t0611YSTRLhmxPhtr31ZoYaHcy0vpYNdz60ntCwc+50Rl0qpWwQaNTBUDJ+RBHNAB6p5 +86YUUPlqK0L0NZKCYdT5/rIqLs6QmpFcv1dCSwMUdCQ17bFt/CYDeDoA6FbccNTA3L9 jQTQ== 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=C+BjKyef1cpxA5YW0iHYaVGTQC1+AiC+hdoXdXE3szI=; b=fXbq6rv55tiZjZ9VJaZIoXBp32kXXjgP8H3QuvIm3Hpfw4Ar8CpBR1ZoMr65A6TcJc rkhDiFKZ/RzMMutCJqInGkJmdN0QYXK79CkVI3I+ppmNBvmcdNen1ti5bdQnRQi97e4b H6tN/CC8wVUTfdcwntOH/hi5wJPD53LpKZduFTTAm/hx1FEHsVoWlzq316+0KVYKTOy0 JXXnzXbCxmoWLdEO3bA+oE+Qti71cJtZqNReEZVcX+SciXDrAJ692CDfr/RAIM+eA4Se YEj0UA9igY8auLPoyxUE2EFNQL9ftlf/s0/FTHUHmnKJ0kRsEDXZRToEBcvCTvYKnENY KRmA== 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 g2si3610376ejd.657.2020.07.10.05.28.02; Fri, 10 Jul 2020 05:28:27 -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 S1728084AbgGJM0c (ORCPT + 99 others); Fri, 10 Jul 2020 08:26:32 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:51796 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727876AbgGJMZz (ORCPT ); Fri, 10 Jul 2020 08:25:55 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with SMTP; 10 Jul 2020 15:25:49 +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 06ACPmQ4012400; Fri, 10 Jul 2020 15:25:48 +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 06ACPm8V003378; Fri, 10 Jul 2020 15:25:48 +0300 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06ACPmxI003377; Fri, 10 Jul 2020 15:25:48 +0300 From: Moshe Shemesh To: "David S. Miller" , Jakub Kicinski Cc: Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Vladyslav Tarasiuk Subject: [PATCH net-next v3 5/7] devlink: Add devlink health port reporters API Date: Fri, 10 Jul 2020 15:25:11 +0300 Message-Id: <1594383913-3295-6-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1594383913-3295-1-git-send-email-moshe@mellanox.com> References: <1594383913-3295-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 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