Commit 29afcd69 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files

Merge branch 'improve-the-taprio-qdisc-s-relationship-with-its-children'

Vladimir Oltean says:

====================
Improve the taprio qdisc's relationship with its children

v1: https://lore.kernel.org/lkml/20230531173928.1942027-1-vladimir.oltean@nxp.com/

Prompted by Vinicius' request to consolidate some child Qdisc
dereferences in taprio:
https://lore.kernel.org/netdev/87edmxv7x2.fsf@intel.com/

I remembered that I had left some unfinished work in this Qdisc, namely
commit af7b29b1 ("Revert "net/sched: taprio: make qdisc_leaf() see
the per-netdev-queue pfifo child qdiscs"").

This patch set represents another stab at, essentially, what's in the
title. Not only does taprio not properly detect when it's grafted as a
non-root qdisc, but it also returns incorrect per-class stats.
Eventually, Vinicius' request is addressed too, although in a different
form than the one he requested (which was purely cosmetic).

Review from people more experienced with Qdiscs than me would be
appreciated. I tried my best to explain what I consider to be problems.
I am deliberately targeting net-next because the changes are too
invasive for net - they were reverted from stable once already.
====================

Link: https://lore.kernel.org/r/20230807193324.4128292-1-vladimir.oltean@nxp.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents e972a547 29c298d2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -17170,6 +17170,13 @@ F: drivers/ptp/*
F:	include/linux/ptp_cl*
K:	(?:\b|_)ptp(?:\b|_)
PTP MOCKUP CLOCK SUPPORT
M:	Vladimir Oltean <vladimir.oltean@nxp.com>
L:	netdev@vger.kernel.org
S:	Maintained
F:	drivers/ptp/ptp_mock.c
F:	include/linux/ptp_mock.h
PTP VIRTUAL CLOCK SUPPORT
M:	Yangbo Lu <yangbo.lu@nxp.com>
L:	netdev@vger.kernel.org
+1 −0
Original line number Diff line number Diff line
@@ -592,6 +592,7 @@ config NETDEVSIM
	depends on INET
	depends on IPV6 || IPV6=n
	depends on PSAMPLE || PSAMPLE=n
	depends on PTP_1588_CLOCK_MOCK || PTP_1588_CLOCK_MOCK=n
	select NET_DEVLINK
	help
	  This driver is a developer testing tool and software model that can
+11 −0
Original line number Diff line number Diff line
@@ -140,6 +140,16 @@ nsim_set_fecparam(struct net_device *dev, struct ethtool_fecparam *fecparam)
	return 0;
}

static int nsim_get_ts_info(struct net_device *dev,
			    struct ethtool_ts_info *info)
{
	struct netdevsim *ns = netdev_priv(dev);

	info->phc_index = mock_phc_index(ns->phc);

	return 0;
}

static const struct ethtool_ops nsim_ethtool_ops = {
	.supported_coalesce_params	= ETHTOOL_COALESCE_ALL_PARAMS,
	.get_pause_stats	        = nsim_get_pause_stats,
@@ -153,6 +163,7 @@ static const struct ethtool_ops nsim_ethtool_ops = {
	.set_channels			= nsim_set_channels,
	.get_fecparam			= nsim_get_fecparam,
	.set_fecparam			= nsim_set_fecparam,
	.get_ts_info			= nsim_get_ts_info,
};

static void nsim_ethtool_ring_init(struct netdevsim *ns)
+37 −1
Original line number Diff line number Diff line
@@ -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,
@@ -291,13 +318,19 @@ static void nsim_setup(struct net_device *dev)

static int nsim_init_netdevsim(struct netdevsim *ns)
{
	struct mock_phc *phc;
	int err;

	phc = mock_phc_create(&ns->nsim_bus_dev->dev);
	if (IS_ERR(phc))
		return PTR_ERR(phc);

	ns->phc = phc;
	ns->netdev->netdev_ops = &nsim_netdev_ops;

	err = nsim_udp_tunnels_info_create(ns->nsim_dev, ns->netdev);
	if (err)
		return err;
		goto err_phc_destroy;

	rtnl_lock();
	err = nsim_bpf_init(ns);
@@ -320,6 +353,8 @@ static int nsim_init_netdevsim(struct netdevsim *ns)
err_utn_destroy:
	rtnl_unlock();
	nsim_udp_tunnels_info_destroy(ns->netdev);
err_phc_destroy:
	mock_phc_destroy(ns->phc);
	return err;
}

@@ -383,6 +418,7 @@ void nsim_destroy(struct netdevsim *ns)
	rtnl_unlock();
	if (nsim_dev_port_is_pf(ns->nsim_dev_port))
		nsim_udp_tunnels_info_destroy(dev);
	mock_phc_destroy(ns->phc);
	free_netdev(dev);
}

+2 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include <linux/ptp_mock.h>
#include <linux/u64_stats_sync.h>
#include <net/devlink.h>
#include <net/udp_tunnel.h>
@@ -93,6 +94,7 @@ struct netdevsim {
	struct net_device *netdev;
	struct nsim_dev *nsim_dev;
	struct nsim_dev_port *nsim_dev_port;
	struct mock_phc *phc;

	u64 tx_packets;
	u64 tx_bytes;
Loading