Skip to content

Commit f394d07

Browse files
TaeheeYookuba-moo
authored andcommitted
netdevsim: add HDS feature
HDS options(tcp-data-split, hds-thresh) have dependencies between other features like XDP. Basic dependencies are checked in the core API. netdevsim is very useful to check basic dependencies. The default tcp-data-split mode is UNKNOWN but netdevsim driver returns ENABLED when ethtool dumps tcp-data-split mode. The default value of HDS threshold is 0 and the maximum value is 1024. ethtool shows like this. ethtool -g eni1np1 Ring parameters for eni1np1: Pre-set maximums: ... HDS thresh: 1024 Current hardware settings: ... TCP data split: on HDS thresh: 0 ethtool -G eni1np1 tcp-data-split on hds-thresh 1024 ethtool -g eni1np1 Ring parameters for eni1np1: Pre-set maximums: ... HDS thresh: 1024 Current hardware settings: ... TCP data split: on HDS thresh: 1024 Signed-off-by: Taehee Yoo <ap420073@gmail.com> Link: https://patch.msgid.link/20250114142852.3364986-10-ap420073@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 6b43673 commit f394d07

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

drivers/net/netdevsim/ethtool.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Copyright (c) 2020 Facebook
33

44
#include <linux/debugfs.h>
5-
#include <linux/ethtool.h>
65
#include <linux/random.h>
76

87
#include "netdevsim.h"
@@ -72,6 +71,12 @@ static void nsim_get_ringparam(struct net_device *dev,
7271
struct netdevsim *ns = netdev_priv(dev);
7372

7473
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;
76+
kernel_ring->hds_thresh_max = NSIM_HDS_THRESHOLD_MAX;
77+
78+
if (kernel_ring->tcp_data_split == ETHTOOL_TCP_DATA_SPLIT_UNKNOWN)
79+
kernel_ring->tcp_data_split = ETHTOOL_TCP_DATA_SPLIT_ENABLED;
7580
}
7681

7782
static int nsim_set_ringparam(struct net_device *dev,
@@ -161,6 +166,8 @@ static int nsim_get_ts_info(struct net_device *dev,
161166

162167
static const struct ethtool_ops nsim_ethtool_ops = {
163168
.supported_coalesce_params = ETHTOOL_COALESCE_ALL_PARAMS,
169+
.supported_ring_params = ETHTOOL_RING_USE_TCP_DATA_SPLIT |
170+
ETHTOOL_RING_USE_HDS_THRS,
164171
.get_pause_stats = nsim_get_pause_stats,
165172
.get_pauseparam = nsim_get_pauseparam,
166173
.set_pauseparam = nsim_set_pauseparam,
@@ -182,6 +189,9 @@ static void nsim_ethtool_ring_init(struct netdevsim *ns)
182189
ns->ethtool.ring.rx_jumbo_max_pending = 4096;
183190
ns->ethtool.ring.rx_mini_max_pending = 4096;
184191
ns->ethtool.ring.tx_max_pending = 4096;
192+
193+
ns->netdev->ethtool->hds_config = ETHTOOL_TCP_DATA_SPLIT_UNKNOWN;
194+
ns->netdev->ethtool->hds_thresh = 0;
185195
}
186196

187197
void nsim_ethtool_init(struct netdevsim *ns)

drivers/net/netdevsim/netdev.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include <linux/debugfs.h>
1717
#include <linux/etherdevice.h>
18+
#include <linux/ethtool_netlink.h>
1819
#include <linux/kernel.h>
1920
#include <linux/module.h>
2021
#include <linux/netdevice.h>
@@ -54,6 +55,7 @@ static int nsim_forward_skb(struct net_device *dev, struct sk_buff *skb,
5455
static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
5556
{
5657
struct netdevsim *ns = netdev_priv(dev);
58+
struct ethtool_netdev_state *ethtool;
5759
struct net_device *peer_dev;
5860
unsigned int len = skb->len;
5961
struct netdevsim *peer_ns;
@@ -74,6 +76,13 @@ static netdev_tx_t nsim_start_xmit(struct sk_buff *skb, struct net_device *dev)
7476
rxq = rxq % peer_dev->num_rx_queues;
7577
rq = peer_ns->rq[rxq];
7678

79+
ethtool = peer_dev->ethtool;
80+
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)))
84+
skb_linearize(skb);
85+
7786
skb_tx_timestamp(skb);
7887
if (unlikely(nsim_forward_skb(peer_dev, skb, rq) == NET_RX_DROP))
7988
goto out_drop_cnt;

drivers/net/netdevsim/netdevsim.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/debugfs.h>
1717
#include <linux/device.h>
1818
#include <linux/ethtool.h>
19+
#include <linux/ethtool_netlink.h>
1920
#include <linux/kernel.h>
2021
#include <linux/list.h>
2122
#include <linux/netdevice.h>
@@ -36,6 +37,8 @@
3637
#define NSIM_IPSEC_VALID BIT(31)
3738
#define NSIM_UDP_TUNNEL_N_PORTS 4
3839

40+
#define NSIM_HDS_THRESHOLD_MAX 1024
41+
3942
struct nsim_sa {
4043
struct xfrm_state *xs;
4144
__be32 ipaddr[4];

0 commit comments

Comments
 (0)