]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: netdevsim: mimic tc-taprio offload
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 7 Aug 2023 19:33:21 +0000 (22:33 +0300)
committerJakub Kicinski <kuba@kernel.org>
Wed, 9 Aug 2023 22:59:21 +0000 (15:59 -0700)
To be able to use netdevsim for tc-testing with an offloaded tc-taprio
schedule, it needs to report a PTP clock (which it now does), and to
accept ndo_setup_tc(TC_SETUP_QDISC_TAPRIO) calls.

Since netdevsim has no packet I/O, this doesn't do anything intelligent,
it only allows taprio offload code paths to go through some level of
automated testing.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://lore.kernel.org/r/20230807193324.4128292-9-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/netdevsim/netdev.c

index 2a4a0c4065cf41c9b15376380a30efadc0bc11d0..2eac92f49631f84f5914f420e9e15794da00f730 100644 (file)
@@ -209,6 +209,31 @@ 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
@@ -217,6 +242,8 @@ 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,