mirror of
https://github.com/torvalds/linux.git
synced 2026-05-31 02:24:24 +02:00
Merge branch 'netdevsim-support-ets-offload'
Davide Caratti says: ==================== netdevsim: support ETS offload - patch 1 moves netdevsim tc offloads to a dedicated file - patch 2 enables ETS offload on netdevsim - patch 3 is a tdc test for ets offload on netdevsim ==================== Link: https://patch.msgid.link/cover.1773945414.git.dcaratti@redhat.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
fb78a629b4
|
|
@ -3,7 +3,7 @@
|
|||
obj-$(CONFIG_NETDEVSIM) += netdevsim.o
|
||||
|
||||
netdevsim-objs := \
|
||||
netdev.o dev.o ethtool.o fib.o bus.o health.o hwstats.o udp_tunnels.o
|
||||
netdev.o dev.o ethtool.o fib.o bus.o health.o hwstats.o udp_tunnels.o tc.o
|
||||
|
||||
ifeq ($(CONFIG_BPF_SYSCALL),y)
|
||||
netdevsim-objs += \
|
||||
|
|
|
|||
|
|
@ -202,12 +202,6 @@ static int nsim_change_mtu(struct net_device *dev, int new_mtu)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)
|
||||
{
|
||||
return nsim_bpf_setup_tc_block_cb(type, type_data, cb_priv);
|
||||
}
|
||||
|
||||
static int nsim_set_vf_mac(struct net_device *dev, int vf, u8 *mac)
|
||||
{
|
||||
struct netdevsim *ns = netdev_priv(dev);
|
||||
|
|
@ -338,51 +332,6 @@ static int nsim_set_vf_link_state(struct net_device *dev, int vf, int state)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats)
|
||||
{
|
||||
stats->window_drops = 0;
|
||||
stats->tx_overruns = 0;
|
||||
}
|
||||
|
||||
static int nsim_setup_tc_taprio(struct net_device *dev,
|
||||
struct tc_taprio_qopt_offload *offload)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
switch (offload->cmd) {
|
||||
case TAPRIO_CMD_REPLACE:
|
||||
case TAPRIO_CMD_DESTROY:
|
||||
break;
|
||||
case TAPRIO_CMD_STATS:
|
||||
nsim_taprio_stats(&offload->stats);
|
||||
break;
|
||||
default:
|
||||
err = -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static LIST_HEAD(nsim_block_cb_list);
|
||||
|
||||
static int
|
||||
nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data)
|
||||
{
|
||||
struct netdevsim *ns = netdev_priv(dev);
|
||||
|
||||
switch (type) {
|
||||
case TC_SETUP_QDISC_TAPRIO:
|
||||
return nsim_setup_tc_taprio(dev, type_data);
|
||||
case TC_SETUP_BLOCK:
|
||||
return flow_block_cb_setup_simple(type_data,
|
||||
&nsim_block_cb_list,
|
||||
nsim_setup_tc_block_cb,
|
||||
ns, ns, true);
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
nsim_set_features(struct net_device *dev, netdev_features_t features)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -455,6 +455,9 @@ static inline void
|
|||
nsim_psp_handle_ext(struct sk_buff *skb, struct skb_ext *psp_ext) {}
|
||||
#endif
|
||||
|
||||
int nsim_setup_tc(struct net_device *dev, enum tc_setup_type type,
|
||||
void *type_data);
|
||||
|
||||
struct nsim_bus_dev {
|
||||
struct device dev;
|
||||
struct list_head list;
|
||||
|
|
|
|||
79
drivers/net/netdevsim/tc.c
Normal file
79
drivers/net/netdevsim/tc.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#include <linux/netdevice.h>
|
||||
#include <net/pkt_sched.h>
|
||||
#include <net/pkt_cls.h>
|
||||
|
||||
#include "netdevsim.h"
|
||||
|
||||
static int
|
||||
nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv)
|
||||
{
|
||||
return nsim_bpf_setup_tc_block_cb(type, type_data, cb_priv);
|
||||
}
|
||||
|
||||
static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats)
|
||||
{
|
||||
stats->window_drops = 0;
|
||||
stats->tx_overruns = 0;
|
||||
}
|
||||
|
||||
static int nsim_setup_tc_taprio(struct net_device *dev,
|
||||
struct tc_taprio_qopt_offload *offload)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
switch (offload->cmd) {
|
||||
case TAPRIO_CMD_REPLACE:
|
||||
case TAPRIO_CMD_DESTROY:
|
||||
break;
|
||||
case TAPRIO_CMD_STATS:
|
||||
nsim_taprio_stats(&offload->stats);
|
||||
break;
|
||||
default:
|
||||
err = -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int nsim_setup_tc_ets(struct net_device *dev,
|
||||
struct tc_ets_qopt_offload *offload)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
switch (offload->command) {
|
||||
case TC_ETS_REPLACE:
|
||||
case TC_ETS_DESTROY:
|
||||
break;
|
||||
case TC_ETS_STATS:
|
||||
_bstats_update(offload->stats.bstats, 0, 0);
|
||||
break;
|
||||
default:
|
||||
err = -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static LIST_HEAD(nsim_block_cb_list);
|
||||
|
||||
int
|
||||
nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data)
|
||||
{
|
||||
struct netdevsim *ns = netdev_priv(dev);
|
||||
|
||||
switch (type) {
|
||||
case TC_SETUP_QDISC_TAPRIO:
|
||||
return nsim_setup_tc_taprio(dev, type_data);
|
||||
case TC_SETUP_QDISC_ETS:
|
||||
return nsim_setup_tc_ets(dev, type_data);
|
||||
case TC_SETUP_BLOCK:
|
||||
return flow_block_cb_setup_simple(type_data,
|
||||
&nsim_block_cb_list,
|
||||
nsim_setup_tc_block_cb,
|
||||
ns, ns, true);
|
||||
default:
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
}
|
||||
|
|
@ -984,5 +984,28 @@
|
|||
"matchCount": "1",
|
||||
"teardown": [
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "41f5",
|
||||
"name": "ETS offload where the sum of quanta wraps u32",
|
||||
"category": [
|
||||
"qdisc",
|
||||
"ets"
|
||||
],
|
||||
"plugins": {
|
||||
"requires": "nsPlugin"
|
||||
},
|
||||
"setup": [
|
||||
"echo \"1 1 4\" > /sys/bus/netdevsim/new_device",
|
||||
"$ETHTOOL -K $ETH hw-tc-offload on"
|
||||
],
|
||||
"cmdUnderTest": "$TC qdisc add dev $ETH root ets quanta 4294967294 1 1",
|
||||
"expExitCode": "0",
|
||||
"verifyCmd": "$TC qdisc show dev $ETH",
|
||||
"matchPattern": "qdisc ets .*bands 3 quanta 4294967294 1 1",
|
||||
"matchCount": "1",
|
||||
"teardown": [
|
||||
"echo \"1\" > /sys/bus/netdevsim/del_device"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -755,6 +755,9 @@ def check_default_settings(args, remaining, pm):
|
|||
NAMES['DEV2'] = args.device
|
||||
if 'TIMEOUT' not in NAMES:
|
||||
NAMES['TIMEOUT'] = None
|
||||
if 'ETHTOOL' in NAMES and not os.path.isfile(NAMES['ETHTOOL']):
|
||||
print(f"The specified ethtool path {NAMES['ETHTOOL']} does not exist.")
|
||||
exit(1)
|
||||
if not os.path.isfile(NAMES['TC']):
|
||||
print("The specified tc path " + NAMES['TC'] + " does not exist.")
|
||||
exit(1)
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ NAMES = {
|
|||
'DEV1': 'v0p1',
|
||||
'DEV2': '',
|
||||
'DUMMY': 'dummy1',
|
||||
'ETHTOOL': '/usr/sbin/ethtool',
|
||||
'ETH': 'eth0',
|
||||
'BATCH_FILE': './batch.txt',
|
||||
'BATCH_DIR': 'tmp',
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user