From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, horms@kernel.org, donald.hunter@gmail.com,
corbet@lwn.net, skhan@linuxfoundation.org, saeedm@nvidia.com,
leon@kernel.org, tariqt@nvidia.com, mbloch@nvidia.com,
przemyslaw.kitszel@intel.com, mschmidt@redhat.com,
andrew+netdev@lunn.ch, rostedt@goodmis.org, mhiramat@kernel.org,
mathieu.desnoyers@efficios.com, chuck.lever@oracle.com,
matttbe@kernel.org, cjubran@nvidia.com, daniel.zahka@gmail.com,
Jiri Pirko <jiri@nvidia.com>
Subject: [PATCH net-next 06/10] devlink: add devlink_dev_driver_name() helper and use it in trace events
Date: Mon, 23 Feb 2026 15:55:53 +0100 [thread overview]
Message-ID: <20260223145557.248679-7-jiri@resnulli.us> (raw)
In-Reply-To: <20260223145557.248679-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
In preparation to dev-less devlinks, add devlink_dev_driver_name()
that safely returns the driver name or NULL, and use it in all trace
events. The trace __string() macro handles NULL via __string_src(),
recording "(null)".
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
include/net/devlink.h | 1 +
include/trace/events/devlink.h | 12 ++++++------
net/devlink/core.c | 7 +++++++
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 0afb0958b910..45dec7067a8e 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -1613,6 +1613,7 @@ struct devlink *priv_to_devlink(void *priv);
struct device *devlink_to_dev(const struct devlink *devlink);
const char *devlink_bus_name(const struct devlink *devlink);
const char *devlink_dev_name(const struct devlink *devlink);
+const char *devlink_dev_driver_name(const struct devlink *devlink);
/* Devlink instance explicit locking */
void devl_lock(struct devlink *devlink);
diff --git a/include/trace/events/devlink.h b/include/trace/events/devlink.h
index 32304ce9ad15..4f8edf77dfbe 100644
--- a/include/trace/events/devlink.h
+++ b/include/trace/events/devlink.h
@@ -23,7 +23,7 @@ TRACE_EVENT(devlink_hwmsg,
TP_STRUCT__entry(
__string(bus_name, devlink_bus_name(devlink))
__string(dev_name, devlink_dev_name(devlink))
- __string(driver_name, devlink_to_dev(devlink)->driver->name)
+ __string(driver_name, devlink_dev_driver_name(devlink))
__field(bool, incoming)
__field(unsigned long, type)
__dynamic_array(u8, buf, len)
@@ -57,7 +57,7 @@ TRACE_EVENT(devlink_hwerr,
TP_STRUCT__entry(
__string(bus_name, devlink_bus_name(devlink))
__string(dev_name, devlink_dev_name(devlink))
- __string(driver_name, devlink_to_dev(devlink)->driver->name)
+ __string(driver_name, devlink_dev_driver_name(devlink))
__field(int, err)
__string(msg, msg)
),
@@ -87,7 +87,7 @@ TRACE_EVENT(devlink_health_report,
TP_STRUCT__entry(
__string(bus_name, devlink_bus_name(devlink))
__string(dev_name, devlink_dev_name(devlink))
- __string(driver_name, devlink_to_dev(devlink)->driver->name)
+ __string(driver_name, devlink_dev_driver_name(devlink))
__string(reporter_name, reporter_name)
__string(msg, msg)
),
@@ -118,7 +118,7 @@ TRACE_EVENT(devlink_health_recover_aborted,
TP_STRUCT__entry(
__string(bus_name, devlink_bus_name(devlink))
__string(dev_name, devlink_dev_name(devlink))
- __string(driver_name, devlink_to_dev(devlink)->driver->name)
+ __string(driver_name, devlink_dev_driver_name(devlink))
__string(reporter_name, reporter_name)
__field(bool, health_state)
__field(u64, time_since_last_recover)
@@ -152,7 +152,7 @@ TRACE_EVENT(devlink_health_reporter_state_update,
TP_STRUCT__entry(
__string(bus_name, devlink_bus_name(devlink))
__string(dev_name, devlink_dev_name(devlink))
- __string(driver_name, devlink_to_dev(devlink)->driver->name)
+ __string(driver_name, devlink_dev_driver_name(devlink))
__string(reporter_name, reporter_name)
__field(u8, new_state)
),
@@ -183,7 +183,7 @@ TRACE_EVENT(devlink_trap_report,
TP_STRUCT__entry(
__string(bus_name, devlink_bus_name(devlink))
__string(dev_name, devlink_dev_name(devlink))
- __string(driver_name, devlink_to_dev(devlink)->driver->name)
+ __string(driver_name, devlink_dev_driver_name(devlink))
__string(trap_name, metadata->trap_name)
__string(trap_group_name, metadata->trap_group_name)
__array(char, input_dev_name, IFNAMSIZ)
diff --git a/net/devlink/core.c b/net/devlink/core.c
index 2dd6d45bec18..85e83a3b082a 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -260,6 +260,13 @@ const char *devlink_dev_name(const struct devlink *devlink)
}
EXPORT_SYMBOL_GPL(devlink_dev_name);
+const char *devlink_dev_driver_name(const struct devlink *devlink)
+{
+ struct device *dev = devlink->dev;
+
+ return dev ? dev->driver->name : NULL;
+}
+
struct net *devlink_net(const struct devlink *devlink)
{
return read_pnet(&devlink->_net);
--
2.51.1
next prev parent reply other threads:[~2026-02-23 14:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 14:55 [PATCH net-next 00/10] devlink: introduce shared devlink instance for PFs on same chip Jiri Pirko
2026-02-23 14:55 ` [PATCH net-next 01/10] devlink: expose devlink instance index over netlink Jiri Pirko
2026-02-23 14:55 ` [PATCH net-next 02/10] devlink: store bus_name and dev_name pointers in struct devlink Jiri Pirko
2026-02-23 14:55 ` [PATCH net-next 03/10] devlink: avoid extra iterations when found devlink is not registered Jiri Pirko
2026-02-23 14:55 ` [PATCH net-next 04/10] devlink: allow to use devlink index as a command handle Jiri Pirko
2026-02-23 14:55 ` [PATCH net-next 05/10] devlink: support index-based lookup via bus_name/dev_name handle Jiri Pirko
2026-02-25 2:22 ` Jakub Kicinski
2026-02-25 2:23 ` [net-next,05/10] " Jakub Kicinski
2026-02-23 14:55 ` Jiri Pirko [this message]
2026-02-25 2:23 ` [net-next,06/10] devlink: add devlink_dev_driver_name() helper and use it in trace events Jakub Kicinski
2026-02-23 14:55 ` [PATCH net-next 07/10] devlink: allow devlink instance allocation without a backing device Jiri Pirko
2026-02-25 2:23 ` [net-next,07/10] " Jakub Kicinski
2026-02-23 14:55 ` [PATCH net-next 08/10] devlink: introduce shared devlink instance for PFs on same chip Jiri Pirko
2026-02-25 2:23 ` [net-next,08/10] " Jakub Kicinski
2026-02-23 14:55 ` [PATCH net-next 09/10] documentation: networking: add shared devlink documentation Jiri Pirko
2026-02-25 2:23 ` [net-next,09/10] " Jakub Kicinski
2026-02-23 14:55 ` [PATCH net-next 10/10] net/mlx5: Add a shared devlink instance for PFs on same chip Jiri Pirko
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=20260223145557.248679-7-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=andrew+netdev@lunn.ch \
--cc=chuck.lever@oracle.com \
--cc=cjubran@nvidia.com \
--cc=corbet@lwn.net \
--cc=daniel.zahka@gmail.com \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=matttbe@kernel.org \
--cc=mbloch@nvidia.com \
--cc=mhiramat@kernel.org \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=przemyslaw.kitszel@intel.com \
--cc=rostedt@goodmis.org \
--cc=saeedm@nvidia.com \
--cc=skhan@linuxfoundation.org \
--cc=tariqt@nvidia.com \
/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