From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com, tariqt@nvidia.com, moshe@nvidia.com,
saeedm@nvidia.com, linux-rdma@vger.kernel.org
Subject: [patch net-next v2 11/13] net: devlink: use devlink_port pointer instead of ndo_get_devlink_port
Date: Mon, 3 Oct 2022 12:52:02 +0200 [thread overview]
Message-ID: <20221003105204.3315337-12-jiri@resnulli.us> (raw)
In-Reply-To: <20221003105204.3315337-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
Use newly introduced devlink_port pointer instead of getting it calling
to ndo_get_devlink_port op.
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
net/core/devlink.c | 12 ++----------
net/core/net-sysfs.c | 4 ++--
net/ethtool/ioctl.c | 11 ++---------
3 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c
index cac0c7852159..2a42e49f6a4e 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -12505,14 +12505,6 @@ static void __devlink_compat_running_version(struct devlink *devlink,
nlmsg_free(msg);
}
-static struct devlink_port *netdev_to_devlink_port(struct net_device *dev)
-{
- if (!dev->netdev_ops->ndo_get_devlink_port)
- return NULL;
-
- return dev->netdev_ops->ndo_get_devlink_port(dev);
-}
-
void devlink_compat_running_version(struct devlink *devlink,
char *buf, size_t len)
{
@@ -12558,7 +12550,7 @@ int devlink_compat_phys_port_name_get(struct net_device *dev,
*/
ASSERT_RTNL();
- devlink_port = netdev_to_devlink_port(dev);
+ devlink_port = dev->devlink_port;
if (!devlink_port)
return -EOPNOTSUPP;
@@ -12574,7 +12566,7 @@ int devlink_compat_switch_id_get(struct net_device *dev,
* devlink_port instance cannot disappear in the middle. No need to take
* any devlink lock as only permanent values are accessed.
*/
- devlink_port = netdev_to_devlink_port(dev);
+ devlink_port = dev->devlink_port;
if (!devlink_port || !devlink_port->switch_port)
return -EOPNOTSUPP;
diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 8409d41405df..679b84cc8794 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -532,7 +532,7 @@ static ssize_t phys_port_name_show(struct device *dev,
* returning early without hitting the trylock/restart below.
*/
if (!netdev->netdev_ops->ndo_get_phys_port_name &&
- !netdev->netdev_ops->ndo_get_devlink_port)
+ !netdev->devlink_port)
return -EOPNOTSUPP;
if (!rtnl_trylock())
@@ -562,7 +562,7 @@ static ssize_t phys_switch_id_show(struct device *dev,
* because recurse is false when calling dev_get_port_parent_id.
*/
if (!netdev->netdev_ops->ndo_get_port_parent_id &&
- !netdev->netdev_ops->ndo_get_devlink_port)
+ !netdev->devlink_port)
return -EOPNOTSUPP;
if (!rtnl_trylock())
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 57e7238a4136..b6835136c53f 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -44,16 +44,9 @@ struct ethtool_devlink_compat {
static struct devlink *netdev_to_devlink_get(struct net_device *dev)
{
- struct devlink_port *devlink_port;
-
- if (!dev->netdev_ops->ndo_get_devlink_port)
- return NULL;
-
- devlink_port = dev->netdev_ops->ndo_get_devlink_port(dev);
- if (!devlink_port)
+ if (!dev->devlink_port)
return NULL;
-
- return devlink_try_get(devlink_port->devlink);
+ return devlink_try_get(dev->devlink_port->devlink);
}
/*
--
2.37.1
next prev parent reply other threads:[~2022-10-03 10:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-03 10:51 [patch net-next v2 00/13] net: fix netdev to devlink_port linkage and expose to user Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 01/13] net: devlink: convert devlink port type-specific pointers to union Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 02/13] net: devlink: move port_type_warn_schedule() call to __devlink_port_type_set() Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 03/13] net: devlink: move port_type_netdev_checks() " Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 04/13] net: devlink: take RTNL in port_fill() function only if it is not held Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 05/13] net: devlink: track netdev with devlink_port assigned Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 06/13] net: make drivers to use SET_NETDEV_DEVLINK_PORT to set devlink_port Jiri Pirko
2022-10-03 16:46 ` Jakub Kicinski
2022-10-03 10:51 ` [patch net-next v2 07/13] net: devlink: remove netdev arg from devlink_port_type_eth_set() Jiri Pirko
2022-10-03 10:51 ` [patch net-next v2 08/13] net: devlink: remove net namespace check from devlink_nl_port_fill() Jiri Pirko
2022-10-03 10:52 ` [patch net-next v2 09/13] net: devlink: store copy netdevice ifindex and ifname to allow port_fill() without RTNL held Jiri Pirko
2022-10-03 10:52 ` [patch net-next v2 10/13] net: devlink: add not cleared type warning to port unregister Jiri Pirko
2022-10-03 10:52 ` Jiri Pirko [this message]
2022-10-03 10:52 ` [patch net-next v2 12/13] net: remove unused ndo_get_devlink_port Jiri Pirko
2022-10-03 10:52 ` [patch net-next v2 13/13] net: expose devlink port over rtnetlink Jiri Pirko
2022-10-03 16:45 ` [patch net-next v2 00/13] net: fix netdev to devlink_port linkage and expose to user Jakub Kicinski
2022-10-04 6:56 ` 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=20221003105204.3315337-12-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=moshe@nvidia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--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;
as well as URLs for NNTP newsgroup(s).