Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+110 -52
+1 -1
drivers/net/netdevsim/Makefile
··· 3 3 obj-$(CONFIG_NETDEVSIM) += netdevsim.o 4 4 5 5 netdevsim-objs := \ 6 - netdev.o dev.o ethtool.o fib.o bus.o health.o hwstats.o udp_tunnels.o 6 + netdev.o dev.o ethtool.o fib.o bus.o health.o hwstats.o udp_tunnels.o tc.o 7 7 8 8 ifeq ($(CONFIG_BPF_SYSCALL),y) 9 9 netdevsim-objs += \
-51
drivers/net/netdevsim/netdev.c
··· 202 202 return 0; 203 203 } 204 204 205 - static int 206 - nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) 207 - { 208 - return nsim_bpf_setup_tc_block_cb(type, type_data, cb_priv); 209 - } 210 - 211 205 static int nsim_set_vf_mac(struct net_device *dev, int vf, u8 *mac) 212 206 { 213 207 struct netdevsim *ns = netdev_priv(dev); ··· 330 336 nsim_dev->vfconfigs[vf].link_state = state; 331 337 332 338 return 0; 333 - } 334 - 335 - static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats) 336 - { 337 - stats->window_drops = 0; 338 - stats->tx_overruns = 0; 339 - } 340 - 341 - static int nsim_setup_tc_taprio(struct net_device *dev, 342 - struct tc_taprio_qopt_offload *offload) 343 - { 344 - int err = 0; 345 - 346 - switch (offload->cmd) { 347 - case TAPRIO_CMD_REPLACE: 348 - case TAPRIO_CMD_DESTROY: 349 - break; 350 - case TAPRIO_CMD_STATS: 351 - nsim_taprio_stats(&offload->stats); 352 - break; 353 - default: 354 - err = -EOPNOTSUPP; 355 - } 356 - 357 - return err; 358 - } 359 - 360 - static LIST_HEAD(nsim_block_cb_list); 361 - 362 - static int 363 - nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) 364 - { 365 - struct netdevsim *ns = netdev_priv(dev); 366 - 367 - switch (type) { 368 - case TC_SETUP_QDISC_TAPRIO: 369 - return nsim_setup_tc_taprio(dev, type_data); 370 - case TC_SETUP_BLOCK: 371 - return flow_block_cb_setup_simple(type_data, 372 - &nsim_block_cb_list, 373 - nsim_setup_tc_block_cb, 374 - ns, ns, true); 375 - default: 376 - return -EOPNOTSUPP; 377 - } 378 339 } 379 340 380 341 static int
+3
drivers/net/netdevsim/netdevsim.h
··· 455 455 nsim_psp_handle_ext(struct sk_buff *skb, struct skb_ext *psp_ext) {} 456 456 #endif 457 457 458 + int nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, 459 + void *type_data); 460 + 458 461 struct nsim_bus_dev { 459 462 struct device dev; 460 463 struct list_head list;
+79
drivers/net/netdevsim/tc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + 3 + #include <linux/netdevice.h> 4 + #include <net/pkt_sched.h> 5 + #include <net/pkt_cls.h> 6 + 7 + #include "netdevsim.h" 8 + 9 + static int 10 + nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) 11 + { 12 + return nsim_bpf_setup_tc_block_cb(type, type_data, cb_priv); 13 + } 14 + 15 + static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats) 16 + { 17 + stats->window_drops = 0; 18 + stats->tx_overruns = 0; 19 + } 20 + 21 + static int nsim_setup_tc_taprio(struct net_device *dev, 22 + struct tc_taprio_qopt_offload *offload) 23 + { 24 + int err = 0; 25 + 26 + switch (offload->cmd) { 27 + case TAPRIO_CMD_REPLACE: 28 + case TAPRIO_CMD_DESTROY: 29 + break; 30 + case TAPRIO_CMD_STATS: 31 + nsim_taprio_stats(&offload->stats); 32 + break; 33 + default: 34 + err = -EOPNOTSUPP; 35 + } 36 + 37 + return err; 38 + } 39 + 40 + static int nsim_setup_tc_ets(struct net_device *dev, 41 + struct tc_ets_qopt_offload *offload) 42 + { 43 + int err = 0; 44 + 45 + switch (offload->command) { 46 + case TC_ETS_REPLACE: 47 + case TC_ETS_DESTROY: 48 + break; 49 + case TC_ETS_STATS: 50 + _bstats_update(offload->stats.bstats, 0, 0); 51 + break; 52 + default: 53 + err = -EOPNOTSUPP; 54 + } 55 + 56 + return err; 57 + } 58 + 59 + static LIST_HEAD(nsim_block_cb_list); 60 + 61 + int 62 + nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) 63 + { 64 + struct netdevsim *ns = netdev_priv(dev); 65 + 66 + switch (type) { 67 + case TC_SETUP_QDISC_TAPRIO: 68 + return nsim_setup_tc_taprio(dev, type_data); 69 + case TC_SETUP_QDISC_ETS: 70 + return nsim_setup_tc_ets(dev, type_data); 71 + case TC_SETUP_BLOCK: 72 + return flow_block_cb_setup_simple(type_data, 73 + &nsim_block_cb_list, 74 + nsim_setup_tc_block_cb, 75 + ns, ns, true); 76 + default: 77 + return -EOPNOTSUPP; 78 + } 79 + }
+23
tools/testing/selftests/tc-testing/tc-tests/qdiscs/ets.json
··· 984 984 "matchCount": "1", 985 985 "teardown": [ 986 986 ] 987 + }, 988 + { 989 + "id": "41f5", 990 + "name": "ETS offload where the sum of quanta wraps u32", 991 + "category": [ 992 + "qdisc", 993 + "ets" 994 + ], 995 + "plugins": { 996 + "requires": "nsPlugin" 997 + }, 998 + "setup": [ 999 + "echo \"1 1 4\" > /sys/bus/netdevsim/new_device", 1000 + "$ETHTOOL -K $ETH hw-tc-offload on" 1001 + ], 1002 + "cmdUnderTest": "$TC qdisc add dev $ETH root ets quanta 4294967294 1 1", 1003 + "expExitCode": "0", 1004 + "verifyCmd": "$TC qdisc show dev $ETH", 1005 + "matchPattern": "qdisc ets .*bands 3 quanta 4294967294 1 1", 1006 + "matchCount": "1", 1007 + "teardown": [ 1008 + "echo \"1\" > /sys/bus/netdevsim/del_device" 1009 + ] 987 1010 } 988 1011 ]
+3
tools/testing/selftests/tc-testing/tdc.py
··· 755 755 NAMES['DEV2'] = args.device 756 756 if 'TIMEOUT' not in NAMES: 757 757 NAMES['TIMEOUT'] = None 758 + if 'ETHTOOL' in NAMES and not os.path.isfile(NAMES['ETHTOOL']): 759 + print(f"The specified ethtool path {NAMES['ETHTOOL']} does not exist.") 760 + exit(1) 758 761 if not os.path.isfile(NAMES['TC']): 759 762 print("The specified tc path " + NAMES['TC'] + " does not exist.") 760 763 exit(1)
+1
tools/testing/selftests/tc-testing/tdc_config.py
··· 17 17 'DEV1': 'v0p1', 18 18 'DEV2': '', 19 19 'DUMMY': 'dummy1', 20 + 'ETHTOOL': '/usr/sbin/ethtool', 20 21 'ETH': 'eth0', 21 22 'BATCH_FILE': './batch.txt', 22 23 'BATCH_DIR': 'tmp',