1 // SPDX-License-Identifier: GPL-2.0 2 3 #include <linux/netdevice.h> 4 #include <net/pkt_sched.h> 5 6 #include "netdevsim.h" 7 8 static int 9 nsim_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv) 10 { 11 return nsim_bpf_setup_tc_block_cb(type, type_data, cb_priv); 12 } 13 14 static void nsim_taprio_stats(struct tc_taprio_qopt_stats *stats) 15 { 16 stats->window_drops = 0; 17 stats->tx_overruns = 0; 18 } 19 20 static int nsim_setup_tc_taprio(struct net_device *dev, 21 struct tc_taprio_qopt_offload *offload) 22 { 23 int err = 0; 24 25 switch (offload->cmd) { 26 case TAPRIO_CMD_REPLACE: 27 case TAPRIO_CMD_DESTROY: 28 break; 29 case TAPRIO_CMD_STATS: 30 nsim_taprio_stats(&offload->stats); 31 break; 32 default: 33 err = -EOPNOTSUPP; 34 } 35 36 return err; 37 } 38 39 static LIST_HEAD(nsim_block_cb_list); 40 41 int 42 nsim_setup_tc(struct net_device *dev, enum tc_setup_type type, void *type_data) 43 { 44 struct netdevsim *ns = netdev_priv(dev); 45 46 switch (type) { 47 case TC_SETUP_QDISC_TAPRIO: 48 return nsim_setup_tc_taprio(dev, type_data); 49 case TC_SETUP_BLOCK: 50 return flow_block_cb_setup_simple(type_data, 51 &nsim_block_cb_list, 52 nsim_setup_tc_block_cb, 53 ns, ns, true); 54 default: 55 return -EOPNOTSUPP; 56 } 57 } 58