netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Moshe Shemesh <moshe@nvidia.com>
To: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@nvidia.com>,
	<netdev@vger.kernel.org>
Cc: Moshe Shemesh <moshe@nvidia.com>
Subject: [PATCH net-next 09/10] devlink: Move health common function to health file
Date: Mon, 13 Feb 2023 15:14:17 +0200	[thread overview]
Message-ID: <1676294058-136786-10-git-send-email-moshe@nvidia.com> (raw)
In-Reply-To: <1676294058-136786-1-git-send-email-moshe@nvidia.com>

Now that all devlink health callbacks and related code are in file
health.c move common health functions and devlink_health_reporter struct
to be local in health.c file.

Signed-off-by: Moshe Shemesh <moshe@nvidia.com>
---
 net/devlink/devl_internal.h | 47 -------------------------------------
 net/devlink/health.c        | 45 +++++++++++++++++++++++++----------
 2 files changed, 32 insertions(+), 60 deletions(-)

diff --git a/net/devlink/devl_internal.h b/net/devlink/devl_internal.h
index 211f7ea38d6a..e133f423294a 100644
--- a/net/devlink/devl_internal.h
+++ b/net/devlink/devl_internal.h
@@ -200,53 +200,6 @@ int devlink_resources_validate(struct devlink *devlink,
 			       struct devlink_resource *resource,
 			       struct genl_info *info);
 
-/* Health */
-struct devlink_health_reporter {
-	struct list_head list;
-	void *priv;
-	const struct devlink_health_reporter_ops *ops;
-	struct devlink *devlink;
-	struct devlink_port *devlink_port;
-	struct devlink_fmsg *dump_fmsg;
-	struct mutex dump_lock; /* lock parallel read/write from dump buffers */
-	u64 graceful_period;
-	bool auto_recover;
-	bool auto_dump;
-	u8 health_state;
-	u64 dump_ts;
-	u64 dump_real_ts;
-	u64 error_count;
-	u64 recovery_count;
-	u64 last_recovery_ts;
-};
-
-struct devlink_health_reporter *
-devlink_health_reporter_find_by_name(struct devlink *devlink,
-				     const char *reporter_name);
-struct devlink_health_reporter *
-devlink_port_health_reporter_find_by_name(struct devlink_port *devlink_port,
-					  const char *reporter_name);
-struct devlink_health_reporter *
-devlink_health_reporter_get_from_attrs(struct devlink *devlink,
-				       struct nlattr **attrs);
-struct devlink_health_reporter *
-devlink_health_reporter_get_from_info(struct devlink *devlink,
-				      struct genl_info *info);
-int
-devlink_nl_health_reporter_fill(struct sk_buff *msg,
-				struct devlink_health_reporter *reporter,
-				enum devlink_command cmd, u32 portid,
-				u32 seq, int flags);
-int devlink_health_do_dump(struct devlink_health_reporter *reporter,
-			   void *priv_ctx,
-			   struct netlink_ext_ack *extack);
-int devlink_fmsg_dumpit(struct devlink_fmsg *fmsg, struct sk_buff *skb,
-			struct netlink_callback *cb,
-			enum devlink_command cmd);
-
-struct devlink_fmsg *devlink_fmsg_alloc(void);
-void devlink_fmsg_free(struct devlink_fmsg *fmsg);
-
 /* Line cards */
 struct devlink_linecard;
 
diff --git a/net/devlink/health.c b/net/devlink/health.c
index 3ebd531dee8a..1bcc254e38b1 100644
--- a/net/devlink/health.c
+++ b/net/devlink/health.c
@@ -27,7 +27,7 @@ struct devlink_fmsg {
 			      */
 };
 
-struct devlink_fmsg *devlink_fmsg_alloc(void)
+static struct devlink_fmsg *devlink_fmsg_alloc(void)
 {
 	struct devlink_fmsg *fmsg;
 
@@ -40,7 +40,7 @@ struct devlink_fmsg *devlink_fmsg_alloc(void)
 	return fmsg;
 }
 
-void devlink_fmsg_free(struct devlink_fmsg *fmsg)
+static void devlink_fmsg_free(struct devlink_fmsg *fmsg)
 {
 	struct devlink_fmsg_item *item, *tmp;
 
@@ -51,6 +51,25 @@ void devlink_fmsg_free(struct devlink_fmsg *fmsg)
 	kfree(fmsg);
 }
 
+struct devlink_health_reporter {
+	struct list_head list;
+	void *priv;
+	const struct devlink_health_reporter_ops *ops;
+	struct devlink *devlink;
+	struct devlink_port *devlink_port;
+	struct devlink_fmsg *dump_fmsg;
+	struct mutex dump_lock; /* lock parallel read/write from dump buffers */
+	u64 graceful_period;
+	bool auto_recover;
+	bool auto_dump;
+	u8 health_state;
+	u64 dump_ts;
+	u64 dump_real_ts;
+	u64 error_count;
+	u64 recovery_count;
+	u64 last_recovery_ts;
+};
+
 void *
 devlink_health_reporter_priv(struct devlink_health_reporter *reporter)
 {
@@ -70,7 +89,7 @@ __devlink_health_reporter_find_by_name(struct list_head *reporter_list,
 	return NULL;
 }
 
-struct devlink_health_reporter *
+static struct devlink_health_reporter *
 devlink_health_reporter_find_by_name(struct devlink *devlink,
 				     const char *reporter_name)
 {
@@ -78,7 +97,7 @@ devlink_health_reporter_find_by_name(struct devlink *devlink,
 						      reporter_name);
 }
 
-struct devlink_health_reporter *
+static struct devlink_health_reporter *
 devlink_port_health_reporter_find_by_name(struct devlink_port *devlink_port,
 					  const char *reporter_name)
 {
@@ -239,7 +258,7 @@ devlink_health_reporter_destroy(struct devlink_health_reporter *reporter)
 }
 EXPORT_SYMBOL_GPL(devlink_health_reporter_destroy);
 
-int
+static int
 devlink_nl_health_reporter_fill(struct sk_buff *msg,
 				struct devlink_health_reporter *reporter,
 				enum devlink_command cmd, u32 portid,
@@ -310,7 +329,7 @@ devlink_nl_health_reporter_fill(struct sk_buff *msg,
 	return -EMSGSIZE;
 }
 
-struct devlink_health_reporter *
+static struct devlink_health_reporter *
 devlink_health_reporter_get_from_attrs(struct devlink *devlink,
 				       struct nlattr **attrs)
 {
@@ -330,7 +349,7 @@ devlink_health_reporter_get_from_attrs(struct devlink *devlink,
 								 reporter_name);
 }
 
-struct devlink_health_reporter *
+static struct devlink_health_reporter *
 devlink_health_reporter_get_from_info(struct devlink *devlink,
 				      struct genl_info *info)
 {
@@ -517,9 +536,9 @@ devlink_health_dump_clear(struct devlink_health_reporter *reporter)
 	reporter->dump_fmsg = NULL;
 }
 
-int devlink_health_do_dump(struct devlink_health_reporter *reporter,
-			   void *priv_ctx,
-			   struct netlink_ext_ack *extack)
+static int devlink_health_do_dump(struct devlink_health_reporter *reporter,
+				  void *priv_ctx,
+				  struct netlink_ext_ack *extack)
 {
 	int err;
 
@@ -1157,9 +1176,9 @@ static int devlink_fmsg_snd(struct devlink_fmsg *fmsg,
 	return err;
 }
 
-int devlink_fmsg_dumpit(struct devlink_fmsg *fmsg, struct sk_buff *skb,
-			struct netlink_callback *cb,
-			enum devlink_command cmd)
+static int devlink_fmsg_dumpit(struct devlink_fmsg *fmsg, struct sk_buff *skb,
+			       struct netlink_callback *cb,
+			       enum devlink_command cmd)
 {
 	struct devlink_nl_dump_state *state = devlink_dump_state(cb);
 	int index = state->idx;
-- 
2.27.0


  parent reply	other threads:[~2023-02-13 13:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13 13:14 [PATCH net-next 00/10] devlink: cleanups and move devlink health functionality to separate file Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 01/10] devlink: Split out health reporter create code Moshe Shemesh
2023-02-14  6:17   ` Jakub Kicinski
2023-02-14 13:18     ` Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 02/10] devlink: health: Fix nla_nest_end in error flow Moshe Shemesh
2023-02-14  6:18   ` Jakub Kicinski
2023-02-14 13:21     ` Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 03/10] devlink: Move devlink health get and set code to health file Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 04/10] devlink: health: Don't try to add trace with NULL msg Moshe Shemesh
2023-02-14  6:22   ` Jakub Kicinski
2023-02-14 13:48     ` Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 05/10] devlink: Move devlink health report and recover to health file Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 06/10] devlink: Move devlink fmsg and health diagnose " Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 07/10] devlink: Move devlink health dump " Moshe Shemesh
2023-02-13 13:14 ` [PATCH net-next 08/10] devlink: Move devlink health test " Moshe Shemesh
2023-02-13 13:14 ` Moshe Shemesh [this message]
2023-02-13 13:14 ` [PATCH net-next 10/10] devlink: Update devlink health documentation Moshe Shemesh
2023-02-13 13:35 ` [PATCH net-next 00/10] devlink: cleanups and move devlink health functionality to separate file Jiri Pirko
2023-02-14  6:23 ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1676294058-136786-10-git-send-email-moshe@nvidia.com \
    --to=moshe@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).