Skip to content

Commit 3c83645

Browse files
committed
net: move HDS config from ethtool state
Separate the HDS config from the ethtool state struct. The HDS config contains just simple parameters, not state. Having it as a separate struct will make it easier to clone / copy and also long term potentially make it per-queue. Reviewed-by: Michael Chan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent e81fdf7 commit 3c83645

File tree

10 files changed

+43
-24
lines changed

10 files changed

+43
-24
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,7 +4610,7 @@ void bnxt_set_tpa_flags(struct bnxt *bp)
46104610
static void bnxt_init_ring_params(struct bnxt *bp)
46114611
{
46124612
bp->rx_copybreak = BNXT_DEFAULT_RX_COPYBREAK;
4613-
bp->dev->ethtool->hds_thresh = BNXT_DEFAULT_RX_COPYBREAK;
4613+
bp->dev->cfg->hds_thresh = BNXT_DEFAULT_RX_COPYBREAK;
46144614
}
46154615

46164616
/* bp->rx_ring_size, bp->tx_ring_size, dev->mtu, BNXT_FLAG_{G|L}RO flags must
@@ -6585,7 +6585,7 @@ static void bnxt_hwrm_update_rss_hash_cfg(struct bnxt *bp)
65856585

65866586
static int bnxt_hwrm_vnic_set_hds(struct bnxt *bp, struct bnxt_vnic_info *vnic)
65876587
{
6588-
u16 hds_thresh = (u16)bp->dev->ethtool->hds_thresh;
6588+
u16 hds_thresh = (u16)bp->dev->cfg->hds_thresh;
65896589
struct hwrm_vnic_plcmodes_cfg_input *req;
65906590
int rc;
65916591

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/ptp_clock_kernel.h>
2525
#include <linux/net_tstamp.h>
2626
#include <linux/timecounter.h>
27+
#include <net/netdev_queues.h>
2728
#include <net/netlink.h>
2829
#include "bnxt_hsi.h"
2930
#include "bnxt.h"
@@ -834,7 +835,7 @@ static void bnxt_get_ringparam(struct net_device *dev,
834835
ering->rx_jumbo_pending = bp->rx_agg_ring_size;
835836
ering->tx_pending = bp->tx_ring_size;
836837

837-
kernel_ering->hds_thresh = dev->ethtool->hds_thresh;
838+
kernel_ering->hds_thresh = dev->cfg->hds_thresh;
838839
kernel_ering->hds_thresh_max = BNXT_HDS_THRESHOLD_MAX;
839840
}
840841

@@ -852,7 +853,7 @@ static int bnxt_set_ringparam(struct net_device *dev,
852853
(ering->tx_pending < BNXT_MIN_TX_DESC_CNT))
853854
return -EINVAL;
854855

855-
hds_config_mod = tcp_data_split != dev->ethtool->hds_config;
856+
hds_config_mod = tcp_data_split != dev->cfg->hds_config;
856857
if (tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_DISABLED && hds_config_mod)
857858
return -EINVAL;
858859

drivers/net/netdevsim/ethtool.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/debugfs.h>
55
#include <linux/random.h>
6+
#include <net/netdev_queues.h>
67

78
#include "netdevsim.h"
89

@@ -71,8 +72,8 @@ static void nsim_get_ringparam(struct net_device *dev,
7172
struct netdevsim *ns = netdev_priv(dev);
7273

7374
memcpy(ring, &ns->ethtool.ring, sizeof(ns->ethtool.ring));
74-
kernel_ring->tcp_data_split = dev->ethtool->hds_config;
75-
kernel_ring->hds_thresh = dev->ethtool->hds_thresh;
75+
kernel_ring->tcp_data_split = dev->cfg->hds_config;
76+
kernel_ring->hds_thresh = dev->cfg->hds_thresh;
7677
kernel_ring->hds_thresh_max = NSIM_HDS_THRESHOLD_MAX;
7778

7879
if (kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN)
@@ -190,8 +191,8 @@ static void nsim_ethtool_ring_init(struct netdevsim *ns)
190191
ns->ethtool.ring.rx_mini_max_pending = 4096;
191192
ns->ethtool.ring.tx_max_pending = 4096;
192193

193-
ns->netdev->ethtool->hds_config = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN;
194-
ns->netdev->ethtool->hds_thresh = 0;
194+
ns->netdev->cfg->hds_config = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN;
195+
ns->netdev->cfg->hds_thresh = 0;
195196
}
196197

197198
void nsim_ethtool_init(struct netdevsim *ns)

drivers/net/netdevsim/netdev.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ static int nsim_forward_skb(struct net_device *dev, struct sk_buff *skb,
5555
static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
5656
{
5757
struct netdevsim *ns = netdev_priv(dev);
58-
struct ethtool_netdev_state *ethtool;
5958
struct net_device *peer_dev;
6059
unsigned int len = skb->len;
6160
struct netdevsim *peer_ns;
61+
struct netdev_config *cfg;
6262
struct nsim_rq *rq;
6363
int rxq;
6464

@@ -76,11 +76,11 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
7676
rxq = rxq % peer_dev->num_rx_queues;
7777
rq = peer_ns->rq[rxq];
7878

79-
ethtool = peer_dev->ethtool;
79+
cfg = peer_dev->cfg;
8080
if (skb_is_nonlinear(skb) &&
81-
(ethtool->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED ||
82-
(ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
83-
ethtool->hds_thresh > len)))
81+
(cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED ||
82+
(cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
83+
cfg->hds_thresh > len)))
8484
skb_linearize(skb);
8585

8686
skb_tx_timestamp(skb);

include/linux/ethtool.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,16 +1171,12 @@ int ethtool_virtdev_set_link_ksettings(struct net_device *dev,
11711171
* @rss_ctx: XArray of custom RSS contexts
11721172
* @rss_lock: Protects entries in @rss_ctx. May be taken from
11731173
* within RTNL.
1174-
* @hds_thresh: HDS Threshold value.
1175-
* @hds_config: HDS value from userspace.
11761174
* @wol_enabled: Wake-on-LAN is enabled
11771175
* @module_fw_flash_in_progress: Module firmware flashing is in progress.
11781176
*/
11791177
struct ethtool_netdev_state {
11801178
struct xarray rss_ctx;
11811179
struct mutex rss_lock;
1182-
u32 hds_thresh;
1183-
u8 hds_config;
11841180
unsigned wol_enabled:1;
11851181
unsigned module_fw_flash_in_progress:1;
11861182
};

include/linux/netdevice.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct dsa_port;
6363
struct ip_tunnel_parm_kern;
6464
struct macsec_context;
6565
struct macsec_ops;
66+
struct netdev_config;
6667
struct netdev_name_node;
6768
struct sd_flow_limit;
6869
struct sfp_bus;
@@ -2410,6 +2411,8 @@ struct net_device {
24102411
const struct udp_tunnel_nic_info *udp_tunnel_nic_info;
24112412
struct udp_tunnel_nic *udp_tunnel_nic;
24122413

2414+
/** @cfg: net_device queue-related configuration */
2415+
struct netdev_config *cfg;
24132416
struct ethtool_netdev_state *ethtool;
24142417

24152418
/* protected by rtnl_lock */

include/net/netdev_queues.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44

55
#include <linux/netdevice.h>
66

7+
/**
8+
* struct netdev_config - queue-related configuration for a netdev
9+
* @hds_thresh: HDS Threshold value.
10+
* @hds_config: HDS value from userspace.
11+
*/
12+
struct netdev_config {
13+
u32 hds_thresh;
14+
u8 hds_config;
15+
};
16+
717
/* See the netdev.yaml spec for definition of each statistic */
818
struct netdev_queue_stats_rx {
919
u64 bytes;

net/core/dev.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#include <net/dst.h>
107107
#include <net/dst_metadata.h>
108108
#include <net/gro.h>
109+
#include <net/netdev_queues.h>
109110
#include <net/pkt_sched.h>
110111
#include <net/pkt_cls.h>
111112
#include <net/checksum.h>
@@ -9719,7 +9720,7 @@ int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf)
97199720
if (!dev->netdev_ops->ndo_bpf)
97209721
return -EOPNOTSUPP;
97219722

9722-
if (dev->ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
9723+
if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
97239724
bpf->command == XDP_SETUP_PROG &&
97249725
bpf->prog && !bpf->prog->aux->xdp_has_frags) {
97259726
NL_SET_ERR_MSG(bpf->extack,
@@ -9764,7 +9765,7 @@ static int dev_xdp_install(struct net_device *dev, enum bpf_xdp_mode mode,
97649765
struct netdev_bpf xdp;
97659766
int err;
97669767

9767-
if (dev->ethtool->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
9768+
if (dev->cfg->hds_config == ETHTOOL_TCP_DATA_SPLIT_ENABLED &&
97689769
prog && !prog->aux->xdp_has_frags) {
97699770
NL_SET_ERR_MSG(extack, "unable to install XDP to device using tcp-data-split");
97709771
return -EBUSY;
@@ -11542,6 +11543,10 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
1154211543
if (!dev->ethtool)
1154311544
goto free_all;
1154411545

11546+
dev->cfg = kzalloc(sizeof(*dev->cfg), GFP_KERNEL_ACCOUNT);
11547+
if (!dev->cfg)
11548+
goto free_all;
11549+
1154511550
napi_config_sz = array_size(maxqs, sizeof(*dev->napi_config));
1154611551
dev->napi_config = kvzalloc(napi_config_sz, GFP_KERNEL_ACCOUNT);
1154711552
if (!dev->napi_config)
@@ -11610,6 +11615,7 @@ void free_netdev(struct net_device *dev)
1161011615
return;
1161111616
}
1161211617

11618+
kfree(dev->cfg);
1161311619
kfree(dev->ethtool);
1161411620
netif_free_tx_queues(dev);
1161511621
netif_free_rx_queues(dev);

net/core/devmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,12 @@ int net_devmem_bind_dmabuf_to_queue(struct net_device *dev, u32 rxq_idx,
141141
return -ERANGE;
142142
}
143143

144-
if (dev->ethtool->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
144+
if (dev->cfg->hds_config != ETHTOOL_TCP_DATA_SPLIT_ENABLED) {
145145
NL_SET_ERR_MSG(extack, "tcp-data-split is disabled");
146146
return -EINVAL;
147147
}
148148

149-
if (dev->ethtool->hds_thresh) {
149+
if (dev->cfg->hds_thresh) {
150150
NL_SET_ERR_MSG(extack, "hds-thresh is not zero");
151151
return -EINVAL;
152152
}

net/ethtool/rings.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22

3+
#include <net/netdev_queues.h>
4+
35
#include "netlink.h"
46
#include "common.h"
57

@@ -219,7 +221,7 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
219221

220222
dev->ethtool_ops->get_ringparam(dev, &ringparam,
221223
&kernel_ringparam, info->extack);
222-
kernel_ringparam.tcp_data_split = dev->ethtool->hds_config;
224+
kernel_ringparam.tcp_data_split = dev->cfg->hds_config;
223225

224226
ethnl_update_u32(&ringparam.rx_pending, tb[ETHTOOL_A_RINGS_RX], &mod);
225227
ethnl_update_u32(&ringparam.rx_mini_pending,
@@ -295,8 +297,8 @@ ethnl_set_rings(struct ethnl_req_info *req_info, struct genl_info *info)
295297
ret = dev->ethtool_ops->set_ringparam(dev, &ringparam,
296298
&kernel_ringparam, info->extack);
297299
if (!ret) {
298-
dev->ethtool->hds_config = kernel_ringparam.tcp_data_split;
299-
dev->ethtool->hds_thresh = kernel_ringparam.hds_thresh;
300+
dev->cfg->hds_config = kernel_ringparam.tcp_data_split;
301+
dev->cfg->hds_thresh = kernel_ringparam.hds_thresh;
300302
}
301303

302304
return ret < 0 ? ret : 1;

0 commit comments

Comments
 (0)