From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org,
michael.chan@broadcom.com, pavan.chebbi@broadcom.com,
ap420073@gmail.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 3/7] net: provide pending ring configuration in net_device
Date: Sat, 18 Jan 2025 18:05:13 -0800 [thread overview]
Message-ID: <20250119020518.1962249-4-kuba@kernel.org> (raw)
In-Reply-To: <20250119020518.1962249-1-kuba@kernel.org>
Record the pending configuration in net_device struct.
ethtool core duplicates the current config and the specific
handlers (for now just ringparam) can modify it.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
v2:
- make sure all dev->cfg changes are under rtnl_lock
---
include/linux/netdevice.h | 6 ++++++
net/core/dev.c | 2 ++
net/ethtool/netlink.c | 21 ++++++++++++++++++---
net/ethtool/rings.c | 8 +++-----
4 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 173a8b3a9eb2..8da4c61f97b9 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2413,6 +2413,12 @@ struct net_device {
/** @cfg: net_device queue-related configuration */
struct netdev_config *cfg;
+ /**
+ * @cfg_pending: same as @cfg but when device is being actively
+ * reconfigured includes any changes to the configuration
+ * requested by the user, but which may or may not be rejected.
+ */
+ struct netdev_config *cfg_pending;
struct ethtool_netdev_state *ethtool;
/* protected by rtnl_lock */
diff --git a/net/core/dev.c b/net/core/dev.c
index 71b3f786a9cd..a7883f1c94a0 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -11543,6 +11543,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
dev->cfg = kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT);
if (!dev->cfg)
goto free_all;
+ dev->cfg_pending = dev->cfg;
napi_config_sz = array_size(maxqs, sizeof(*dev->napi_config));
dev->napi_config = kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT);
@@ -11612,6 +11613,7 @@ void free_netdev(struct net_device *dev)
return;
}
+ WARN_ON(dev->cfg != dev->cfg_pending);
kfree(dev->cfg);
kfree(dev->ethtool);
netif_free_tx_queues(dev);
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index c17d8513d4c1..1d2f62ef6130 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
+#include <net/netdev_queues.h>
#include <net/sock.h>
#include <linux/ethtool_netlink.h>
#include <linux/phy_link_topology.h>
@@ -692,19 +693,33 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
dev = req_info.dev;
rtnl_lock();
+ dev->cfg_pending = kmemdup(dev->cfg, sizeof(*dev->cfg),
+ GFP_KERNEL_ACCOUNT);
+ if (!dev->cfg_pending) {
+ ret = -ENOMEM;
+ goto out_tie_cfg;
+ }
+
ret = ethnl_ops_begin(dev);
if (ret < 0)
- goto out_rtnl;
+ goto out_free_cfg;
ret = ops->set(&req_info, info);
- if (ret <= 0)
+ if (ret < 0)
+ goto out_ops;
+
+ swap(dev->cfg, dev->cfg_pending);
+ if (!ret)
goto out_ops;
ethtool_notify(dev, ops->set_ntf_cmd, NULL);
ret = 0;
out_ops:
ethnl_ops_complete(dev);
-out_rtnl:
+out_free_cfg:
+ kfree(dev->cfg_pending);
+out_tie_cfg:
+ dev->cfg_pending = dev->cfg;
rtnl_unlock();
out_dev:
ethnl_parse_header_dev_put(&req_info);
diff --git a/net/ethtool/rings.c b/net/ethtool/rings.c
index 7a3c2a2dff12..5e8ba81fbb3e 100644
--- a/net/ethtool/rings.c
+++ b/net/ethtool/rings.c
@@ -294,13 +294,11 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
return -EINVAL;
}
+ dev->cfg_pending->hds_config = kernel_ringparam.tcp_data_split;
+ dev->cfg_pending->hds_thresh = kernel_ringparam.hds_thresh;
+
ret = dev->ethtool_ops->set_ringparam(dev, &ringparam,
&kernel_ringparam, info->extack);
- if (!ret) {
- dev->cfg->hds_config = kernel_ringparam.tcp_data_split;
- dev->cfg->hds_thresh = kernel_ringparam.hds_thresh;
- }
-
return ret < 0 ? ret : 1;
}
--
2.48.1
next prev parent reply other threads:[~2025-01-19 2:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-19 2:05 [PATCH net-next v2 0/7] net: ethtool: fixes for HDS threshold Jakub Kicinski
2025-01-19 2:05 ` [PATCH net-next v2 1/7] net: move HDS config from ethtool state Jakub Kicinski
2025-01-19 2:05 ` [PATCH net-next v2 2/7] net: ethtool: store netdev in a temp variable in ethnl_default_set_doit() Jakub Kicinski
2025-01-19 2:05 ` Jakub Kicinski [this message]
2025-01-19 2:05 ` [PATCH net-next v2 4/7] eth: bnxt: apply hds_thrs settings correctly Jakub Kicinski
2025-01-19 2:05 ` [PATCH net-next v2 5/7] net: ethtool: populate the default HDS params in the core Jakub Kicinski
2025-01-23 16:15 ` Eric Dumazet
2025-01-23 16:22 ` Jakub Kicinski
2025-01-23 16:32 ` Eric Dumazet
2025-01-19 2:05 ` [PATCH net-next v2 6/7] eth: bnxt: allocate enough buffer space to meet HDS threshold Jakub Kicinski
2025-01-19 2:05 ` [PATCH net-next v2 7/7] eth: bnxt: update header sizing defaults Jakub Kicinski
2025-01-19 5:14 ` [PATCH net-next v2 0/7] net: ethtool: fixes for HDS threshold Michael Chan
2025-01-20 20:00 ` patchwork-bot+netdevbpf
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=20250119020518.1962249-4-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ap420073@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@broadcom.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.