Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp875321pxk; Mon, 31 Aug 2020 03:50:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyx06lSr6+MbvSMuRmcTKeZUZkWGDvKbwOv1uHDL2k9ctSVJxKPBZl6yJNKuQUURxC2ap5 X-Received: by 2002:a50:d809:: with SMTP id o9mr635961edj.12.1598871011895; Mon, 31 Aug 2020 03:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598871011; cv=none; d=google.com; s=arc-20160816; b=vAcSrjlMemaqv5IotarSbOANrYETNm05/0rJv+MA/g9GVwZ8A8Omq5o3LFRIBC4OKk zutoFKpbvnEP24JNoxWnQMtFtG1mQBjF8UXKdc9U8YY5mflrEw0qP2KOYiMMVGnp1ux3 OiL+q5eUZR+v8moORqtjSXBL25vqWo2W/HckL7lyajtSyfxrp9SctrvyhPY0RoPOojvm t0nbgRm7C3fu2Y2SjM9dACd3o1gUMDJxpGVL+ycOEynoFHcyc7Hro0mFNKv8hdtWfjiZ G9LMP638EgtZUYIMjteFRxDh4oDvClTxcjVoVnjoMaYgCxDLtds7wEVEWUPIUnYGqp31 vHXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oko5+c/dibPeBB6wBwJp/K5eZaK7OHUWNL23/h49n1s=; b=Q23b3N//UT3BA6XFCNqw9VWPxdL8++K6HWBGMszjPRreLlMknUTXw42liuSKXQATbo Hg/KAQv+3CAnqbxjhVgw0P365IcHoV/RjS25xm8r4Qd76MftnEDR1EbhWIaH63KBfvRR 0I/4e5QBYLTxLaaoQbYZlY8DzsDZDDNNcylUP1MYlEV0CYyTywSMFvXUiQApJH1Hn0gi 7YsJFMWR9TkA07N6NHrqX53tUDKNBsefzt50rLgXgXbQzbfKbsYW5XX6QY1XDP6t9yCa MJFZtWuhaeKlJoMgpGJQ3Nnp0o/P0iCdSif/Wt66FHtQfmdsKMbx68+gQ2PmwjvJvKlF gfRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=mbe2O9q7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si4745805eds.116.2020.08.31.03.49.49; Mon, 31 Aug 2020 03:50:11 -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; dkim=pass header.i=@resnulli-us.20150623.gappssmtp.com header.s=20150623 header.b=mbe2O9q7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbgHaKsq (ORCPT + 99 others); Mon, 31 Aug 2020 06:48:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726503AbgHaKsb (ORCPT ); Mon, 31 Aug 2020 06:48:31 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55476C061575 for ; Mon, 31 Aug 2020 03:48:30 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id v4so4120996wmj.5 for ; Mon, 31 Aug 2020 03:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=oko5+c/dibPeBB6wBwJp/K5eZaK7OHUWNL23/h49n1s=; b=mbe2O9q7cQpGUCXxyyPedwG7vr9ZHbbh2URFehbp1STci1Q+vxWAiQm+3ZeTdRT1JI BPrKM7510MtndMOtf7oUosMazslwYYlv05sFqzwy4pwAbCnY6KFwzX4iWiXhmA/MBvwC 3N+cbQbkWoBKaRFGVrXSyWJrmRve8+Y2Fv2XN6e9zJpkj+yOkqrSFuR1eH2EjOGvIdaz iT4ZdhMyXpNuKY3GBqTgpnVGZN6oi2vXbbhwmFxCyHsD9zGtW3jt4XHaTSPUTtNP98Ax t+a6Rb5HzOtZIS5wb47oBVUmLkSnR4WGUJTRfVqIRcGzhV/uWv4F6rx5ELcYwg0VuHx8 rt5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=oko5+c/dibPeBB6wBwJp/K5eZaK7OHUWNL23/h49n1s=; b=K+qv0A1AlJT83jcZNnH1tYV3QGEPUCnZ7tfLT3Ku+Kb1ZznaKojwG5LkClfUzPkGn4 r70Ubj+NGcQIt+fkSFEfdr9EKFFYmhrU7kZG3Z68CcAoaxSiO7W1+22vLkvLRLtdB5gM 6XWia4yITMdgIo0bxIUb8zKwsaNBv9aYkNR1my6wjpciLnUQ1g9Re0sko9gF4MwM4L77 us1ghhvvL48ncJ6faD/TAr4GxqlneCGJ19TKm7WAozc32C8OTm5yiAiBzvpqH9ldlF68 KgS5QJzieoMAisTIBvGpLdPM/vy/Wyu7b0HKjlct/tKNEROoGAbpz7L0wDGeFZXluCEP DYAQ== X-Gm-Message-State: AOAM533ZEBboB8AugqNiWXlZFYnW/2yoNo2bh2o43hMjts25bVa03Wl3 u1kFKoCwmPnXyjBdaMH/7N/iwg== X-Received: by 2002:a7b:cf13:: with SMTP id l19mr763110wmg.115.1598870908729; Mon, 31 Aug 2020 03:48:28 -0700 (PDT) Received: from localhost ([86.61.181.4]) by smtp.gmail.com with ESMTPSA id g9sm11837912wrw.63.2020.08.31.03.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Aug 2020 03:48:28 -0700 (PDT) Date: Mon, 31 Aug 2020 12:48:27 +0200 From: Jiri Pirko To: Moshe Shemesh Cc: "David S. Miller" , Jakub Kicinski , Jiri Pirko , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next RFC v3 02/14] devlink: Add reload actions counters Message-ID: <20200831104827.GB3794@nanopsycho.orion> References: <1598801254-27764-1-git-send-email-moshe@mellanox.com> <1598801254-27764-3-git-send-email-moshe@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1598801254-27764-3-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 Sun, Aug 30, 2020 at 05:27:22PM CEST, moshe@mellanox.com wrote: >Add reload actions counters to hold the history per reload action type. >For example, the number of times fw_activate has been done on this >device since the driver module was added or if the firmware activation >was done with or without reset. >The function devlink_reload_actions_cnts_update() is exported to enable >also drivers update on reload actions done, for example in case firmware >activation with reset finished successfully but was initiated by remote >host. > >Signed-off-by: Moshe Shemesh >--- >v2 -> v3: >- New patch >--- > include/net/devlink.h | 2 ++ > net/core/devlink.c | 24 +++++++++++++++++++++--- > 2 files changed, 23 insertions(+), 3 deletions(-) > >diff --git a/include/net/devlink.h b/include/net/devlink.h >index b8f0152a1fff..0547f0707d92 100644 >--- a/include/net/devlink.h >+++ b/include/net/devlink.h >@@ -38,6 +38,7 @@ struct devlink { > struct list_head trap_policer_list; > const struct devlink_ops *ops; > struct xarray snapshot_ids; >+ u32 reload_actions_cnts[DEVLINK_RELOAD_ACTION_MAX]; > struct device *dev; > possible_net_t _net; > struct mutex lock; /* Serializes access to devlink instance specific objects such as >@@ -1372,6 +1373,7 @@ void > devlink_health_reporter_recovery_done(struct devlink_health_reporter *reporter); > > bool devlink_is_reload_failed(const struct devlink *devlink); >+void devlink_reload_actions_cnts_update(struct devlink *devlink, unsigned long actions_done); > > void devlink_flash_update_begin_notify(struct devlink *devlink); > void devlink_flash_update_end_notify(struct devlink *devlink); >diff --git a/net/core/devlink.c b/net/core/devlink.c >index 8d4137ad40db..20a29c34ff71 100644 >--- a/net/core/devlink.c >+++ b/net/core/devlink.c >@@ -2969,10 +2969,23 @@ bool devlink_is_reload_failed(const struct devlink *devlink) > } > EXPORT_SYMBOL_GPL(devlink_is_reload_failed); > >+void devlink_reload_actions_cnts_update(struct devlink *devlink, unsigned long actions_done) >+{ >+ int action; >+ >+ for (action = 0; action < DEVLINK_RELOAD_ACTION_MAX; action++) { >+ if (!test_bit(action, &actions_done)) >+ continue; >+ devlink->reload_actions_cnts[action]++; >+ } >+} >+EXPORT_SYMBOL_GPL(devlink_reload_actions_cnts_update); I don't follow why this is an exported symbol if you only use it from this .c. Looks like a leftover... >+ > static int devlink_reload(struct devlink *devlink, struct net *dest_net, > enum devlink_reload_action action, struct netlink_ext_ack *extack, >- unsigned long *actions_done) >+ unsigned long *actions_done_out) > { >+ unsigned long actions_done; > int err; > > if (!devlink->reload_enabled) >@@ -2985,9 +2998,14 @@ static int devlink_reload(struct devlink *devlink, struct net *dest_net, > if (dest_net && !net_eq(dest_net, devlink_net(devlink))) > devlink_reload_netns_change(devlink, dest_net); > >- err = devlink->ops->reload_up(devlink, action, extack, actions_done); >+ err = devlink->ops->reload_up(devlink, action, extack, &actions_done); > devlink_reload_failed_set(devlink, !!err); >- return err; >+ if (err) >+ return err; >+ devlink_reload_actions_cnts_update(devlink, actions_done); >+ if (actions_done_out) >+ *actions_done_out = actions_done; Why don't you just use the original actions_done directly without having extra local variable? >+ return 0; > } > > static int >-- >2.17.1 >