From 0a9435e01bde512bcb5148f684e10021f35d17af Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 27 Nov 2026 13:52:01 +0100 Subject: [PATCH 1/9] doc: qos: say what the traffic class table does The section listed the settings without saying what the table is for, and the per-switch limit was only mentioned as a Marvell detail. Define the table up front and state the limit as the general rule for switches. Signed-off-by: Joachim Wiberg --- doc/qos.md | 58 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/doc/qos.md b/doc/qos.md index 030134255d..06a3699686 100644 --- a/doc/qos.md +++ b/doc/qos.md @@ -52,11 +52,12 @@ admin@example:/config/interface/…/qos/> set egress remark pcp from-priority admin@example:/config/interface/…/qos/> leave -**Let ordinary and background traffic share an uplink.** On a port -with eight traffic classes, ordinary traffic, priority 0, is in class 1 -and background traffic, priority 1, in class 0. With weights of 80 and -20 percent, background traffic keeps a fifth of a busy port and -ordinary traffic the rest. The classes above stay strict: +**Let ordinary and background traffic share an uplink.** Background +traffic, priority 1, is meant to yield to ordinary traffic, priority 0, +so on a port with eight traffic classes it waits in the lowest class, 0, +and ordinary traffic in class 1, see [Defaults](#defaults). With +weights of 80 and 20 percent, background traffic keeps a fifth of a busy +port and ordinary traffic the rest. The classes above stay strict:
admin@example:/config/> edit interface e10 qos egress
 admin@example:/config/interface/…/egress/> set traffic-class 1 algorithm enhanced-transmission-selection
@@ -221,14 +222,28 @@ Configured under `qos egress`:
 Traffic class settings.
 ///
 
-The first two live under `traffic-class-table`.  The number of classes
-is not configuration: a port has one class per transmit queue, at most
-eight, and a single-queue port has no queue structure to respect and gets
-all eight.  The count is reported as `max-traffic-classes` and picks the
-column of the preset.  The mapping is a preset, `ieee` for an ordinary
-bridge or `ieee-sr` for ports carrying reserved streams, both described
-below, or a custom table where an unset priority falls back to the `ieee`
-value.  The algorithm is `strict-priority` (default) or
+A traffic class is a queue on the port a frame leaves by.  The
+`traffic-class-table` says which class a frame of each priority waits
+in, and the `traffic-class` list how the port chooses the class to send
+from next.  The table only decides the queue: the frame keeps its
+priority, and with it the PCP and DSCP it leaves with.
+
+The first two settings live under `traffic-class-table`.  The number of
+classes is not configuration: a port has one class per transmit queue,
+at most eight, and a single-queue port has no queue structure to respect
+and gets all eight.  The count is reported as `max-traffic-classes` and
+picks the column of the preset.  The mapping is a preset, `ieee` for an
+ordinary bridge or `ieee-sr` for ports carrying reserved streams, both
+described below, or a custom table where an unset priority falls back to
+the `ieee` value.  With eight classes the `ieee` preset puts every
+priority in the class of its own number, except that priorities 0 and 1
+trade places.
+
+The table is set per port, but most switches hold one for all their
+ports, see [Hardware Offload](#hardware-offload).  Give the ports of a
+switch the same table, e.g. with a [profile](#profiles).
+
+The algorithm is `strict-priority` (default) or
 `enhanced-transmission-selection`, the latter sharing what the strict
 classes leave in proportion to `bandwidth`, a percentage the weighted
 classes of a port sum to 100 with.  The scheduler is work-conserving, so
@@ -639,6 +654,13 @@ has taken with the current configuration.  A supported stage missing
 from `offload` fell back to the kernel, e.g. a traffic class table the
 fabric cannot carry; a stage not supported always runs there.
 
+A switch chooses the queue of a frame when the frame arrives, from the
+priority it has just classified, before the frame reaches the port it
+leaves by.  Most switches therefore keep one traffic class table for
+all their ports, and a port whose own table differs from it is not
+offloaded.  Only a switch that looks the queue up again per egress port,
+like the LAN969x below, honours a table of its own on each port.
+
 Each feature maps to one Linux mechanism, and whether it reaches the
 hardware depends on the driver implementing the matching hook:
 
@@ -713,12 +735,10 @@ rest by Weighted Round Robin (WRR)[^11] with the `bandwidth` shares as
 weights.  The `egress-shaper` is the port's own shaper.  Four
 hardware details show through:
 
-- A frame's output queue is chosen where it enters the switch, by the
-  ingress port's tables, so the `traffic-class-table` is one per switch
-  chip, not per port.  The port configured most recently defines it,
-  and every port whose own table differs is no longer offloaded: its
-  `offload` list under `capabilities` leaves out
-  `transmission-selection`.  Give every port the same table.
+- The `traffic-class-table` is one per switch chip.  The port
+  configured most recently defines it, and every port whose own table
+  differs is no longer offloaded: its `offload` list under
+  `capabilities` leaves out `transmission-selection`.
 - The WRR weights are one set per switch chip as well, defined the
   same way by the port configured most recently for each weighted
   class.  Give every port with weighted classes the same shares.

From 5db0262a33cf438dfe18b1e9335cafadd9c6d697 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg 
Date: Fri, 27 Nov 2026 14:23:07 +0100
Subject: [PATCH 2/9] board/common: add QoS quirks for FlexSwitch ports on
 Saline

Without an entry confd sets the ports up as plain NICs, with an ets
root and the credit-based and time-aware shapers in software, so only
frames from the CPU are scheduled and shaped.

List what the pasw driver offloads: classification, the mqprio and
taprio roots, and the two shapers.

Signed-off-by: Joachim Wiberg 
---
 board/common/rootfs/etc/interface-quirks.json | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/board/common/rootfs/etc/interface-quirks.json b/board/common/rootfs/etc/interface-quirks.json
index f1a52b8be9..1729c97e45 100644
--- a/board/common/rootfs/etc/interface-quirks.json
+++ b/board/common/rootfs/etc/interface-quirks.json
@@ -15,5 +15,11 @@
 	"qos-trust-order": ["pcp", "dscp", "dscp-pcp"],
 	"qos-offload": ["classification", "remarking", "transmission-selection", "egress-shaper"],
 	"qos-root-qdisc": ["ets"]
+    },
+    "@driver=pasw-saline": {
+	"comment": "Packet Architects FlexSwitch ports on Saline; strict priority only, shapers and gates per queue",
+	"qos-trust-order": ["pcp", "dscp-pcp"],
+	"qos-offload": ["classification", "transmission-selection", "credit-based-shaper", "time-aware-shaper"],
+	"qos-root-qdisc": ["mqprio", "taprio"]
     }
 }

From de29f6d94e160b9fd48947a3fc89c7b6cf20166d Mon Sep 17 00:00:00 2001
From: Joachim Wiberg 
Date: Thu, 3 Dec 2026 19:11:03 +0100
Subject: [PATCH 3/9] confd: take the traffic class table to a switch over DCB

The traffic-class-table of a port is written as the map of its root
qdisc.  A switch does not have to take it from there: upstream, lan966x
and sparx5 refuse any map but one to one, and the FlexSwitch driver
ignores the map.  How a switch does take the table depends on what it
keeps for a frame, so let a quirk of the port say:

 - qos-ets-table: the switch keeps the priority and the queue of a frame
   apart, and takes the table between them as the IEEE ETS managed
   object.  Write it with

       dcb ets set dev PORT prio-tc ...

 - qos-class-at-ingress: the switch has one field for both, and picks
   the queue where a frame comes in.  Write each dcb app priority as its
   traffic class, and map the class back to the priority with dcb rewr,
   so a tagged frame leaves with its priority as PCP.  A table with two
   priorities on one class has no way back, and nothing is rewritten
   for it.

Either way the root qdisc gets one class per priority, as it only says
how the classes are served, and a change to the table no longer
replaces it.  A port with neither quirk works as before.

The FlexSwitch ports on Saline have one field, so put them on
qos-class-at-ingress.

qos-pcp-encoded now means the port always writes the PCP from the
priority, where it used to mean its PCP table is left alone.  The
operational datastore reports the rewrite from the table itself, and
reads the traffic class table of a qos-ets-table port from the ETS
object.

Issue #1611

Signed-off-by: Joachim Wiberg 
---
 board/common/rootfs/etc/interface-quirks.json |   1 +
 src/confd/src/if-qos.c                        | 149 ++++++++++++++----
 src/confd/yang/confd.inc                      |   2 +-
 src/confd/yang/confd/infix-qos.yang           |   2 +-
 ...6-10-28.yang => infix-qos@2026-12-05.yang} |  14 +-
 src/yangerd/internal/qosmonitor/dcb.go        |  20 ++-
 src/yangerd/internal/qosmonitor/dcb_test.go   |   5 +-
 src/yangerd/internal/qosmonitor/qos.go        |  20 +--
 src/yangerd/internal/qosmonitor/qos_test.go   |  27 +++-
 src/yangerd/internal/qosmonitor/qosmonitor.go |   2 +-
 src/yangerd/internal/qosmonitor/settings.go   |  11 +-
 src/yangerd/internal/quirks/quirks_test.go    |   4 +-
 12 files changed, 199 insertions(+), 58 deletions(-)
 rename src/confd/yang/confd/{infix-qos@2026-10-28.yang => infix-qos@2026-12-05.yang} (96%)

diff --git a/board/common/rootfs/etc/interface-quirks.json b/board/common/rootfs/etc/interface-quirks.json
index 1729c97e45..69967f8bcc 100644
--- a/board/common/rootfs/etc/interface-quirks.json
+++ b/board/common/rootfs/etc/interface-quirks.json
@@ -19,6 +19,7 @@
     "@driver=pasw-saline": {
 	"comment": "Packet Architects FlexSwitch ports on Saline; strict priority only, shapers and gates per queue",
 	"qos-trust-order": ["pcp", "dscp-pcp"],
+	"qos-class-at-ingress": true,
 	"qos-offload": ["classification", "transmission-selection", "credit-based-shaper", "time-aware-shaper"],
 	"qos-root-qdisc": ["mqprio", "taprio"]
     }
diff --git a/src/confd/src/if-qos.c b/src/confd/src/if-qos.c
index 04a153ff05..0b02fa5d40 100644
--- a/src/confd/src/if-qos.c
+++ b/src/confd/src/if-qos.c
@@ -83,6 +83,10 @@ struct qos_gates {
 struct qos_egress {
 	int      num_tc;
 	uint8_t  map[NUM_PRIO];
+	bool     at_ingress;		/* the fabric queues by the dcb app priority */
+	bool     ets_table;		/* the fabric takes the table as the DCB ETS object */
+	bool     direct;		/* the table is not in the root qdisc, queue[] is 1:1 */
+	uint8_t  queue[NUM_PRIO];	/* priority to class as the root qdisc takes it */
 	enum tsa algo[MAX_TC];
 	uint8_t  bandwidth[MAX_TC];	/* percent, ETS classes only */
 	uint64_t idle[MAX_TC];		/* bits/s, CBS classes only */
@@ -229,17 +233,56 @@ static void gen_shaper_log(FILE *fp, const char *ifname, const char *stage)
 }
 
 /*
- * A switch fabric that encodes the PCP from the frame priority on every
- * port, as an 802.1Q bridge does, is left to it: the tables it boots
- * with are the identity encoding and are never disabled, so a cascade
- * of chips, which carries only the priority between them, behaves like
- * a single chip.  remark pcp then changes nothing.
+ * A switch fabric queues a frame by the priority dcb app gives it where
+ * it comes in, and takes no priority to traffic class table of its own.
+ * The table is applied in dcb app instead, see gen_ingress_dcb().
+ */
+static bool qos_class_at_ingress(const char *ifname)
+{
+	return iface_has_quirk(ifname, "qos-class-at-ingress");
+}
+
+/*
+ * A switch fabric keeps the priority and the traffic class of a frame
+ * apart, and takes the priority to traffic class table as the IEEE ETS
+ * managed object, dcb ets, see gen_ets_table().  A qdisc on such a port
+ * only says how the classes are served.
+ */
+static bool qos_ets_table(const char *ifname)
+{
+	return iface_has_quirk(ifname, "qos-ets-table");
+}
+
+/*
+ * A switch fabric that carries only the priority of a frame between its
+ * chips writes the PCP from it on every port, so a frame leaves the same
+ * whether it crossed a chip or not.
  */
 static bool qos_pcp_encoded(const char *ifname)
 {
 	return iface_has_quirk(ifname, "qos-pcp-encoded");
 }
 
+/* The priority each traffic class holds, false when two share a class. */
+static bool qos_class_prio(const uint8_t *map, uint8_t *prio)
+{
+	unsigned int seen = 0;
+	int i;
+
+	for (i = 0; i < NUM_PRIO; i++) {
+		seen |= 1U << map[i];
+		prio[map[i]] = i;
+	}
+
+	return seen == (1U << NUM_PRIO) - 1;
+}
+
+/* A priority as dcb app takes it: its traffic class on such a fabric, else itself */
+static int qos_app_prio(const struct qos_egress *eg, int prio)
+{
+	return eg->at_ingress ? eg->map[prio] : prio;
+}
+
 /* Unknown drivers are not limited: without DCB the order is honoured in software. */
 static bool qos_trust_supported(const char *ifname, const char *order)
 {
@@ -269,8 +312,8 @@ enum qos_root {
 /*
  * A fabric shapes a queue, not an ets band, so a shaped class needs a
  * root with one queue per class, mqprio, where the fabric takes it; so
- * does a fabric that takes mqprio but not ets, to queue by the table.
- * Gates take taprio in any case.
+ * does a fabric that takes mqprio but not ets.  Gates take taprio in
+ * any case.
  */
 static enum qos_root qos_root(const char *ifname, const struct qos_egress *eg)
 {
@@ -339,6 +382,12 @@ static int qos_parse_egress(struct lyd_node *egress, const char *ifname, struct
 			eg->map[i] = atoi(val);
 	}
 
+	eg->at_ingress = qos_class_at_ingress(ifname);
+	eg->ets_table = qos_ets_table(ifname);
+	eg->direct = eg->at_ingress || eg->ets_table;
+	for (i = 0; i < NUM_PRIO; i++)
+		eg->queue[i] = eg->direct ? MIN(i, eg->num_tc - 1) : eg->map[i];
+
 	for (i = 0; i < MAX_TC; i++)
 		eg->algo[i] = TSA_STRICT;
 
@@ -904,12 +953,18 @@ static void qos_parse_ingress(struct lyd_node *ingress, struct qos_ingress *in)
 /*
  * One DCB APP table per port, the trust order as dcb apptrust.  Drivers
  * without the operations fail the calls; app_err then selects the
- * software path below.
+ * software path below.  On a port that queues by the dcb app priority,
+ * each priority is written as its traffic class.
  */
-static void gen_ingress_dcb(FILE *fp, const char *ifname, const struct qos_ingress *in)
+static void gen_ingress_dcb(FILE *fp, const char *ifname, const struct qos_ingress *in,
+			    const struct qos_egress *eg)
 {
 	int i, dei, n;
 
+	if (eg->at_ingress)
+		fputs("# The switch queues a frame by its dcb app priority, so the traffic\n"
+		      "# class table is applied here: PCP or DSCP to priority to traffic class.\n", fp);
+
 	fputs("trust_err=0 app_err=0 rewr_err=0\n", fp);
 	fprintf(fp, "dcb apptrust set dev %s order %s 2>/dev/null || trust_err=1\n", ifname, in->order);
 	fprintf(fp, "dcb app flush dev %s default-prio pcp-prio dscp-prio 2>/dev/null || app_err=1\n",
@@ -920,14 +975,15 @@ static void gen_ingress_dcb(FILE *fp, const char *ifname, const struct qos_ingre
 		for (dei = 0; dei < 2; dei++)
 			if (in->pcp[i][dei] >= 0)
 				fprintf(fp, "%s %d%s:%d", n++ ? "" : " pcp-prio", i,
-					dei ? "de" : "nd", in->pcp[i][dei]);
+					dei ? "de" : "nd", qos_app_prio(eg, in->pcp[i][dei]));
 
 	for (i = 0, n = 0; i < 64; i++)
 		if (in->dscp[i] >= 0)
-			fprintf(fp, "%s %d:%d", n++ ? "" : " dscp-prio", i, in->dscp[i]);
+			fprintf(fp, "%s %d:%d", n++ ? "" : " dscp-prio", i,
+				qos_app_prio(eg, in->dscp[i]));
 
 	/* default-prio takes every following word as a priority, so it goes last */
-	fprintf(fp, " default-prio %d 2>/dev/null || app_err=1\n", in->dflt);
+	fprintf(fp, " default-prio %d 2>/dev/null || app_err=1\n", qos_app_prio(eg, in->dflt));
 }
 
 /*
@@ -981,12 +1037,13 @@ static void gen_ingress_flower(FILE *fp, const char *ifname, const struct qos_in
 	fputs("EOF\n", fp);
 }
 
-static void gen_ingress(FILE *fp, const char *ifname, struct lyd_node *ingress)
+static void gen_ingress(FILE *fp, const char *ifname, struct lyd_node *ingress,
+			const struct qos_egress *eg)
 {
 	struct qos_ingress in;
 
 	qos_parse_ingress(ingress, &in);
-	gen_ingress_dcb(fp, ifname, &in);
+	gen_ingress_dcb(fp, ifname, &in, eg);
 
 	fputs("if [ $app_err -ne 0 ]; then\n", fp);
 	gen_ingress_flower(fp, ifname, &in);
@@ -1033,9 +1090,20 @@ static void gen_remark_pedit(FILE *fp, const char *ifname)
  * one entry per DEI value; both map priority to PCP 1:1 since nothing
  * assigns a drop precedence yet.  prio-dscp uses the class selector
  * codepoints, CS0 to CS7.
+ *
+ * On a port that queues by the dcb app priority the table is keyed by
+ * traffic class and gives the priority behind it.  Such a port writes
+ * the PCP of every frame it sends tagged, so the PCP entries are there
+ * with or without remark pcp: a frame then leaves with its priority,
+ * where it would otherwise leave with its traffic class.  A table with
+ * two priorities on one class has no way back, so nothing is rewritten
+ * for it.
  */
-static void gen_remark(FILE *fp, const char *ifname, struct lyd_node *remark)
+static void gen_remark(FILE *fp, const char *ifname, struct lyd_node *remark,
+		       const struct qos_egress *eg)
 {
+	uint8_t prio[NUM_PRIO] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+	bool unique = !eg->at_ingress || qos_class_prio(eg->map, prio);
 	const char *pcp, *dscp;
 	int i;
 
@@ -1045,21 +1113,26 @@ static void gen_remark(FILE *fp, const char *ifname, struct lyd_node *remark)
 	if (!qos_offloads(ifname, "remarking")) {
 		fputs("rewr_err=1\n", fp);
 	} else {
-		bool encoded = qos_pcp_encoded(ifname);
-
-		fprintf(fp, "dcb rewr flush dev %s%s prio-dscp 2>/dev/null || rewr_err=1\n", ifname,
-			encoded ? "" : " prio-pcp");
+		fprintf(fp, "dcb rewr flush dev %s prio-pcp prio-dscp 2>/dev/null || rewr_err=1\n", ifname);
 		/* One code point per priority, a DEI 1 entry would replace the DEI 0 one */
-		if (!encoded && pcp && !strcmp(pcp, "from-priority")) {
+		if (!unique) {
+			if (qos_is_explicit(remark))
+				fprintf(fp, "logger -t confd -p user.notice \"%s: priorities share a "
+					"traffic class, forwarded frames are not remarked\"\n", ifname);
+		} else if (eg->at_ingress || qos_pcp_encoded(ifname) ||
+			   (pcp && !strcmp(pcp, "from-priority"))) {
+			if (eg->at_ingress)
+				fputs("# dcb app gave each frame its traffic class as priority; map the\n"
+				      "# class back, so a tagged frame leaves with its priority as PCP.\n", fp);
 			fprintf(fp, "dcb rewr add dev %s prio-pcp", ifname);
 			for (i = 0; i < NUM_PRIO; i++)
-				fprintf(fp, " %d:%dnd", i, i);
+				fprintf(fp, " %d:%dnd", i, prio[i]);
 			fputs(" 2>/dev/null || rewr_err=1\n", fp);
 		}
-		if (dscp && !strcmp(dscp, "from-priority")) {
+		if (unique && dscp && !strcmp(dscp, "from-priority")) {
 			fprintf(fp, "dcb rewr add dev %s prio-dscp", ifname);
 			for (i = 0; i < NUM_PRIO; i++)
-				fprintf(fp, " %d:%d", i, i << 3);
+				fprintf(fp, " %d:%d", i, prio[i] << 3);
 			fputs(" 2>/dev/null || rewr_err=1\n", fp);
 		}
 	}
@@ -1163,7 +1236,7 @@ static void gen_queue_map(FILE *fp, const struct qos_egress *eg)
 
 	fprintf(fp, " num_tc %d map", eg->num_tc);
 	for (i = 0; i < NUM_PRIO; i++)
-		fprintf(fp, " %d", eg->map[i]);
+		fprintf(fp, " %d", eg->queue[i]);
 	fputs(" queues", fp);
 	for (i = 0; i < eg->num_tc; i++)
 		fprintf(fp, " 1@%d", i);
@@ -1231,10 +1304,25 @@ static void gen_ets(FILE *fp, const char *ifname, struct qos_egress *eg, const c
 	}
 	fputs(" priomap", fp);
 	for (i = 0; i < NUM_PRIO; i++)
-		fprintf(fp, " %d", eg->num_tc - 1 - eg->map[i]);
+		fprintf(fp, " %d", eg->num_tc - 1 - eg->queue[i]);
 	fputc('\n', fp);
 }
 
+/*
+ * The priority to traffic class table as the IEEE ETS managed object.
+ * Only its map is used; transmission selection is set up by the qdisc.
+ */
+static void gen_ets_table(FILE *fp, const char *ifname, const struct qos_egress *eg)
+{
+	int i;
+
+	fprintf(fp, "dcb ets set dev %s prio-tc", ifname);
+	for (i = 0; i < NUM_PRIO; i++)
+		fprintf(fp, " %d:%d", i, eg->map[i]);
+	fprintf(fp, " || logger -t confd -p user.err \"%s: failed setting the traffic class table\"\n",
+		ifname);
+}
+
 static void gen_egress(FILE *fp, const char *ifname, struct qos_egress *eg)
 {
 	const char *attach = "root handle 1:";
@@ -1295,7 +1383,7 @@ static int gen_reset(struct dagger *net, const char *ifname)
 	fputs("EOF\n", fp);
 	fputs("dcb -f -b - 2>/dev/null </dev/null\n", ifname);
-	gen_ingress(fp, ifname, ingress);
-	gen_remark(fp, ifname, remark);
+	gen_ingress(fp, ifname, ingress, &eg);
+	gen_remark(fp, ifname, remark, &eg);
+	if (eg.ets_table)
+		gen_ets_table(fp, ifname, &eg);
 	gen_dcb_log(fp, ifname, ingress, remark);
 
 	/* The profile in use, read back as operational state */
@@ -1437,7 +1527,8 @@ int netdag_gen_qos(sr_session_ctx_t *session, struct dagger *net, struct lyd_nod
 	 * the traffic classes changed, not for an ingress or remark edit.
 	 */
 	if (lydx_get_op(dif) == LYDX_OP_CREATE || qos_profile_switched(dqos) ||
-	    qos_has_change(lydx_get_descendant(lyd_child(dsrc), "egress", "traffic-class-table", NULL)) ||
+	    (!eg.direct && qos_has_change(lydx_get_descendant(lyd_child(dsrc), "egress",
+							      "traffic-class-table", NULL))) ||
 	    qos_has_change(lydx_get_descendant(lyd_child(dsrc), "egress", "traffic-class", NULL)) ||
 	    qos_has_change(lydx_get_child(dqos, "egress-shaper")) ||
 	    qos_has_change(dcbsa) || qos_has_change(dgates))
diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc
index bdbf6c56e0..550e586313 100644
--- a/src/confd/yang/confd.inc
+++ b/src/confd/yang/confd.inc
@@ -42,7 +42,7 @@ MODULES=(
 	"ieee802-ethernet-phy-type@2025-09-10.yang"
 	"infix-ethernet-interface@2026-10-31.yang"
 	"infix-factory-default@2023-06-28.yang"
-	"infix-qos@2026-10-28.yang"
+	"infix-qos@2026-12-05.yang"
 	"infix-interfaces@2026-11-11.yang -e vlan-filtering -e egress-shaper"
 	"ietf-crypto-types -e cleartext-symmetric-keys"
 	"infix-crypto-types@2026-10-27.yang"
diff --git a/src/confd/yang/confd/infix-qos.yang b/src/confd/yang/confd/infix-qos.yang
index 0941c41255..710ef8e1f9 120000
--- a/src/confd/yang/confd/infix-qos.yang
+++ b/src/confd/yang/confd/infix-qos.yang
@@ -1 +1 @@
-infix-qos@2026-10-28.yang
\ No newline at end of file
+infix-qos@2026-12-05.yang
\ No newline at end of file
diff --git a/src/confd/yang/confd/infix-qos@2026-10-28.yang b/src/confd/yang/confd/infix-qos@2026-12-05.yang
similarity index 96%
rename from src/confd/yang/confd/infix-qos@2026-10-28.yang
rename to src/confd/yang/confd/infix-qos@2026-12-05.yang
index 1595269378..423593705f 100644
--- a/src/confd/yang/confd/infix-qos@2026-10-28.yang
+++ b/src/confd/yang/confd/infix-qos@2026-12-05.yang
@@ -24,6 +24,12 @@ module infix-qos {
      profile; the profile list instantiates them once per name.  IEEE
      802.1Q names and types are used where 802.1Q defines the concept.";
 
+  revision 2026-12-05 {
+    description "Describe what a switch that picks the queue at ingress
+                 reports for the traffic class table.";
+    reference "internal";
+  }
+
   revision 2026-10-28 {
     description "Initial revision: the pipeline groupings and the
                  qos-profile list under /system.";
@@ -351,7 +357,13 @@ module infix-qos {
         description "Priority to traffic-class binding.
 
            Node names follow the IEEE 802.1Q-2022 traffic class
-           table.";
+           table.
+
+           Some switches pick the queue where a frame comes in, so a
+           forwarded frame is queued by the table of the port it
+           arrived on.  In the operational datastore the ingress
+           pcp-map and dscp-map of such a port then hold the traffic
+           class, and this table reads one to one.";
         reference "12.6.3, 8.6.6 of IEEE Std 802.1Q-2022";
 
         choice mode {
diff --git a/src/yangerd/internal/qosmonitor/dcb.go b/src/yangerd/internal/qosmonitor/dcb.go
index e2173c3505..2f3c44bd99 100644
--- a/src/yangerd/internal/qosmonitor/dcb.go
+++ b/src/yangerd/internal/qosmonitor/dcb.go
@@ -11,17 +11,22 @@ import (
 const (
 	dcbCmdIEEEGet     = 21
 	dcbAttrIEEE       = 13
+	dcbAttrETS        = 1
 	dcbAttrAppTable   = 3
 	dcbAttrTrustTable = 11
 	dcbAttrRewrTable  = 12
 	dcbSelectorEther  = 1
 	dcbSelectorDSCP   = 5
 	dcbSelectorPCP    = 255
+
+	// struct ieee_ets: three bytes, then eight per array, prio_tc fourth
+	etsPrioTC = 3 + 3*8
 )
 
-// DCB reads the DCB trust order, application and rewrite tables of a
-// port over rtnetlink.  dcb(8) cannot serve as a batch helper for this: it writes
-// one JSON document for the life of the process.  Only the monitor's
+// DCB reads the DCB trust order, application and rewrite tables and the
+// ETS object of a port over rtnetlink.  dcb(8) cannot serve as a batch
+// helper for this: it writes one JSON document for the life of the
+// process.  Only the monitor's
 // worker calls it.
 type DCB struct {
 	conn *netlink.Conn
@@ -51,10 +56,11 @@ type dcbTables struct {
 	Trust    []uint8 // selectors in the order they are trusted
 	App      []dcbApp
 	Rewr     []dcbApp
+	PrioTC   []uint8 // priority to traffic class of the ETS object, nil without one
 }
 
-// Tables reads the port's trust order, its application table and its
-// rewrite table.
+// Tables reads the port's trust order, its application and rewrite
+// tables and its ETS object.
 func (d *DCB) Tables(ifname string) (dcbTables, error) {
 	ae := netlink.NewAttributeEncoder()
 	ae.String(dcbAttrIfname, ifname)
@@ -93,6 +99,10 @@ func parseIEEE(data []byte, t *dcbTables) {
 		ad.Nested(func(nad *netlink.AttributeDecoder) error {
 			for nad.Next() {
 				switch nad.Type() {
+				case dcbAttrETS:
+					if b := nad.Bytes(); len(b) >= etsPrioTC+8 {
+						t.PrioTC = append([]uint8(nil), b[etsPrioTC:etsPrioTC+8]...)
+					}
 				case dcbAttrAppTable:
 					t.App = append(t.App, apps(nad.Bytes())...)
 				case dcbAttrRewrTable:
diff --git a/src/yangerd/internal/qosmonitor/dcb_test.go b/src/yangerd/internal/qosmonitor/dcb_test.go
index 2706c59781..2c9b18f7f0 100644
--- a/src/yangerd/internal/qosmonitor/dcb_test.go
+++ b/src/yangerd/internal/qosmonitor/dcb_test.go
@@ -22,7 +22,9 @@ func ieeeReply(t *testing.T, app, rewr [][]byte) []byte {
 	ae := netlink.NewAttributeEncoder()
 	ae.String(dcbAttrIfname, "e1")
 	ae.Nested(dcbAttrIEEE, func(nae *netlink.AttributeEncoder) error {
-		nae.Bytes(1, make([]byte, 59)) // ETS, skipped
+		ets := make([]byte, 59) // struct ieee_ets
+		copy(ets[etsPrioTC:], []byte{1, 0, 2, 3, 4, 5, 6, 7})
+		nae.Bytes(dcbAttrETS, ets)
 		nae.Nested(dcbAttrAppTable, table(app))
 		nae.Nested(dcbAttrTrustTable, func(tae *netlink.AttributeEncoder) error {
 			tae.Uint8(1, dcbSelectorDSCP)
@@ -73,6 +75,7 @@ func TestParseIEEETables(t *testing.T) {
 		Trust:    []uint8{dcbSelectorDSCP, dcbSelectorPCP},
 		App:      []dcbApp{{dcbSelectorDSCP, 5, 46}, {dcbSelectorPCP, 3, 11}},
 		Rewr:     []dcbApp{{dcbSelectorPCP, 3, 3}},
+		PrioTC:   []uint8{1, 0, 2, 3, 4, 5, 6, 7},
 	}
 	if !reflect.DeepEqual(got, want) {
 		t.Fatalf("got  %+v\nwant %+v", got, want)
diff --git a/src/yangerd/internal/qosmonitor/qos.go b/src/yangerd/internal/qosmonitor/qos.go
index 44ea6ca2d9..341d233a5e 100644
--- a/src/yangerd/internal/qosmonitor/qos.go
+++ b/src/yangerd/internal/qosmonitor/qos.go
@@ -28,16 +28,16 @@ type schedLimits struct {
 
 // port is what the kernel and the quirks say about one port's QoS.
 type port struct {
-	TxQueues   int
-	Trust      []string // quirk qos-trust-order, nil without DCB
-	Supported  []string // quirk qos-offload
-	Sched      schedLimits
-	DCB        dcbTables       // trust order, app and rewrite tables
-	PCPEncoded bool            // quirk qos-pcp-encoded, the fabric always writes the PCP
-	Qdiscs     json.RawMessage // tc qdisc show
-	Ingress    json.RawMessage // tc filter show ingress, of a port classifying in software
-	Remarks    bool            // the port remarks the DSCP in software
-	Profile    string          // the profile confd applied, from /run/qos
+	TxQueues  int
+	Trust     []string // quirk qos-trust-order, nil without DCB
+	Supported []string // quirk qos-offload
+	Sched     schedLimits
+	DCB       dcbTables       // trust order, app and rewrite tables, ETS object
+	ETSTable  bool            // quirk qos-ets-table, the traffic class table is the ETS object's
+	Qdiscs    json.RawMessage // tc qdisc show
+	Ingress   json.RawMessage // tc filter show ingress, of a port classifying in software
+	Remarks   bool            // the port remarks the DSCP in software
+	Profile   string          // the profile confd applied, from /run/qos
 }
 
 type qdisc struct {
diff --git a/src/yangerd/internal/qosmonitor/qos_test.go b/src/yangerd/internal/qosmonitor/qos_test.go
index 3cc16dfef9..ce1486651f 100644
--- a/src/yangerd/internal/qosmonitor/qos_test.go
+++ b/src/yangerd/internal/qosmonitor/qos_test.go
@@ -335,11 +335,34 @@ func TestEgressETS(t *testing.T) {
 	}
 }
 
+func TestEgressETSTable(t *testing.T) {
+	// The table is the ETS object's, the qdisc map is one to one
+	p := port{
+		ETSTable: true,
+		DCB:      dcbTables{PrioTC: []uint8{1, 0, 2, 3, 4, 5, 6, 7}},
+		Qdiscs: json.RawMessage(`[
+			{"kind":"ets","handle":"1:","root":true,"options":{"bands":8,"strict":8,"priomap":[7,6,5,4,3,2,1,0,7,7,7,7,7,7,7,7]}}]`),
+	}
+	want := map[string]any{
+		"priority0": 1.0, "priority1": 0.0, "priority2": 2.0, "priority3": 3.0,
+		"priority4": 4.0, "priority5": 5.0, "priority6": 6.0, "priority7": 7.0,
+	}
+	if got := egressJSON(t, p)["traffic-class-table"]; !reflect.DeepEqual(got, want) {
+		t.Fatalf("got  %v\nwant %v", got, want)
+	}
+
+	// Without the quirk the object says nothing about the port
+	p.ETSTable = false
+	want["priority0"], want["priority1"] = 0.0, 1.0
+	if got := egressJSON(t, p)["traffic-class-table"]; !reflect.DeepEqual(got, want) {
+		t.Fatalf("got  %v\nwant %v", got, want)
+	}
+}
+
 func TestEgressQueues(t *testing.T) {
 	// mqprio and taprio number the classes as the model does
 	p := port{
-		PCPEncoded: true,
-		DCB:        dcbTables{Rewr: []dcbApp{{dcbSelectorDSCP, 1, 8}}},
+		DCB: dcbTables{Rewr: []dcbApp{{dcbSelectorPCP, 1, 0}, {dcbSelectorDSCP, 1, 8}}},
 		Qdiscs: json.RawMessage(`[
 			{"kind":"mqprio","handle":"1:","root":true,"options":{"tc":2,"map":[0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0],"mode":"dcb"}},
 			{"kind":"cbs","handle":"8003:","parent":"1:2","options":{"idleslope":20000,"offload":1}}]`),
diff --git a/src/yangerd/internal/qosmonitor/qosmonitor.go b/src/yangerd/internal/qosmonitor/qosmonitor.go
index 4e03643a7e..6e5c178574 100644
--- a/src/yangerd/internal/qosmonitor/qosmonitor.go
+++ b/src/yangerd/internal/qosmonitor/qosmonitor.go
@@ -352,7 +352,7 @@ func (m *Monitor) read(l link) port {
 		m.log.Debug("qosmonitor: tc", "ifname", l.Name, "err", err)
 	}
 	if p.Trust != nil {
-		json.Unmarshal(q.Get("qos-pcp-encoded"), &p.PCPEncoded)
+		json.Unmarshal(q.Get("qos-ets-table"), &p.ETSTable)
 		if p.DCB, err = m.dcb.Tables(l.Name); err != nil {
 			m.log.Debug("qosmonitor: dcb", "ifname", l.Name, "err", err)
 		}
diff --git a/src/yangerd/internal/qosmonitor/settings.go b/src/yangerd/internal/qosmonitor/settings.go
index 5886f8a4fa..c63e2fb39e 100644
--- a/src/yangerd/internal/qosmonitor/settings.go
+++ b/src/yangerd/internal/qosmonitor/settings.go
@@ -212,7 +212,9 @@ type schedOpts struct {
 // egress is the traffic class layout a port runs, from its scheduler
 // qdisc and the shapers below it, and what it remarks.  The bands of an
 // ets qdisc count down from the top class, strict ones first; mqprio
-// and taprio number the classes as the model does.
+// and taprio number the classes as the model does.  A port that takes
+// its priority to traffic class table as the ETS object has it there,
+// and a qdisc map that says nothing.
 func egress(p port, qdiscs []qdisc) map[string]any {
 	out := map[string]any{}
 
@@ -228,7 +230,9 @@ func egress(p port, qdiscs []qdisc) map[string]any {
 			table := map[string]any{}
 			for prio := 0; prio < 8; prio++ {
 				tc := prioMap[prio]
-				if sched.Kind == "ets" {
+				if p.ETSTable && len(p.DCB.PrioTC) == 8 {
+					tc = int(p.DCB.PrioTC[prio])
+				} else if sched.Kind == "ets" {
 					tc = num - 1 - tc
 				}
 				table["priority"+strconv.Itoa(prio)] = tc
@@ -247,9 +251,6 @@ func egress(p port, qdiscs []qdisc) map[string]any {
 			remark["dscp"] = "from-priority"
 		}
 	}
-	if p.PCPEncoded {
-		remark["pcp"] = "from-priority"
-	}
 	if p.Remarks {
 		remark["dscp"] = "from-priority"
 	}
diff --git a/src/yangerd/internal/quirks/quirks_test.go b/src/yangerd/internal/quirks/quirks_test.go
index 10c2eef1d8..134f5774e1 100644
--- a/src/yangerd/internal/quirks/quirks_test.go
+++ b/src/yangerd/internal/quirks/quirks_test.go
@@ -13,7 +13,7 @@ func TestLoadAndGet(t *testing.T) {
 	product := filepath.Join(dir, "product.json")
 	os.WriteFile(system, []byte(`{
 		"@driver=sparx5-switch": {"qos-offload": ["classification"], "sched-supported-list-max": 10000},
-		"@driver=mv88e6085": {"qos-pcp-encoded": true}
+		"@driver=mv88e6085": {"qos-ets-table": true}
 	}`), 0o644)
 	os.WriteFile(product, []byte(`{
 		"@driver=sparx5-switch": {"qos-offload": ["classification", "time-aware-shaper"], "sched-supported-list-max": 3000},
@@ -35,7 +35,7 @@ func TestLoadAndGet(t *testing.T) {
 	if got := q.For("e3", "mv88e6085").Strings("qos-offload"); got != nil {
 		t.Fatalf("unset list quirk should be nil, got %v", got)
 	}
-	if got := q.For("e3", "").Get("qos-pcp-encoded"); got != nil {
+	if got := q.For("e3", "").Get("qos-ets-table"); got != nil {
 		t.Fatalf("no driver should match no driver entry, got %s", got)
 	}
 }

From 99d872ff6ad0d74b76682badc596f90182d8da75 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg 
Date: Thu, 3 Dec 2026 19:11:30 +0100
Subject: [PATCH 4/9] linux: queue frames by the ETS managed object on Marvell

A frame that crosses from one switch chip to the next on a DCP-SC-28P
was queued by the priority to traffic class table on the first chip
only.  The driver programmed the table into user ports, and the next
chip takes its queue from the port between the chips.

Program the table into every port, and take it from the IEEE ETS
managed object in place of the priority map of the ets qdisc.  The
qdisc then only says how the queues are served.  Put the ports on the
quirk qos-ets-table, so the table is written with dcb ets; the driver
now refuses an ets qdisc with any other map than one band per priority,
so the kernel patch and the quirk go together.

An untagged frame from the CPU waits in the traffic class of its
priority.  A tagged one waits in the queue with the number of its PCP.

The patch is numbered after the four that the kernel branch has ahead
of this one.

Fixes #1611

Signed-off-by: Joachim Wiberg 
---
 board/common/rootfs/etc/interface-quirks.json |   3 +-
 doc/ChangeLog.md                              |   2 +
 doc/qos.md                                    |  13 +-
 ...x-Queue-frames-by-the-ETS-managed-ob.patch | 393 ++++++++++++++++++
 4 files changed, 404 insertions(+), 7 deletions(-)
 create mode 100644 patches/linux/6.18.66/0162-net-dsa-mv88e6xxx-Queue-frames-by-the-ETS-managed-ob.patch

diff --git a/board/common/rootfs/etc/interface-quirks.json b/board/common/rootfs/etc/interface-quirks.json
index 69967f8bcc..9ca0c58f28 100644
--- a/board/common/rootfs/etc/interface-quirks.json
+++ b/board/common/rootfs/etc/interface-quirks.json
@@ -4,8 +4,9 @@
 	"lar-needs-scan": true
     },
     "@driver=mv88e6085": {
-	"comment": "Marvell LinkStreet switch ports; the fabric encodes PCP from the priority itself, so remarking PCP changes nothing",
+	"comment": "Marvell LinkStreet switch ports; a cascade of chips carries only the priority between them",
 	"qos-trust-order": ["pcp", "dscp", "pcp-dscp", "dscp-pcp"],
+	"qos-ets-table": true,
 	"qos-pcp-encoded": true,
 	"qos-offload": ["classification", "remarking", "transmission-selection", "egress-shaper"],
 	"qos-root-qdisc": ["ets"]
diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md
index d670ab44f3..6ea290014e 100644
--- a/doc/ChangeLog.md
+++ b/doc/ChangeLog.md
@@ -9,6 +9,8 @@ All notable changes to the project are documented in this file.
 ### Fixes
 
 - Fix Wi-Fi station roaming on Raspberry Pi
+- Fix #1611: background traffic prioritized above best effort on devices
+  with more than one switch chip
 
 [v26.11.0][] - 2026-11-30
 -------------------------
diff --git a/doc/qos.md b/doc/qos.md
index 06a3699686..95ec2a80b9 100644
--- a/doc/qos.md
+++ b/doc/qos.md
@@ -727,6 +727,9 @@ orders are accepted.  Three hardware details show through:
 - Frames the CPU itself sends, routed or locally originated, are injected
   past the tables, so their DSCP is remarked by the kernel instead and
   their PCP comes from the VLAN interface settings described below.
+  An untagged frame waits in the traffic class of its priority.  A
+  tagged frame waits in the queue with the number of its PCP, whatever
+  the `traffic-class-table` says.
 
 The `traffic-class-table` and the `traffic-class` list apply to hardware
 forwarded frames as well: each priority is queued in its traffic class,
@@ -744,12 +747,10 @@ hardware details show through:
   class.  Give every port with weighted classes the same shares.
 - A frame crossing from one chip to another inside a device carries its
   priority between them, as it would between two switches in a network,
-  and the far chip queues it in the class of that priority.  This is the
-  general rule of QoS in a network: classification at the first ingress
-  decides the priority, and every hop after it trusts and queues by that
-  priority.  Steer traffic with the ingress `dscp-map` and `pcp-map`;
-  a `traffic-class-table` other than the identity holds for frames that
-  enter and leave on the same chip.
+  and the far chip queues it by its own `traffic-class-table`.  This is
+  the general rule of QoS in a network: classification at the first
+  ingress decides the priority, and every hop after it trusts that
+  priority and queues by its own table.
 - The WRR counts frames where `bandwidth` speaks of bytes, so the shares
   hold for traffic of similar frame sizes.
 
diff --git a/patches/linux/6.18.66/0162-net-dsa-mv88e6xxx-Queue-frames-by-the-ETS-managed-ob.patch b/patches/linux/6.18.66/0162-net-dsa-mv88e6xxx-Queue-frames-by-the-ETS-managed-ob.patch
new file mode 100644
index 0000000000..9be11e541a
--- /dev/null
+++ b/patches/linux/6.18.66/0162-net-dsa-mv88e6xxx-Queue-frames-by-the-ETS-managed-ob.patch
@@ -0,0 +1,393 @@
+From 00340a7961f8df45c42997a688b551671d3bdf3b Mon Sep 17 00:00:00 2001
+From: Joachim Wiberg 
+Date: Thu, 3 Dec 2026 15:05:03 +0100
+Subject: [PATCH 162/163] net: dsa: mv88e6xxx: Queue frames by the ETS managed
+ object
+Organization: Wires
+
+A frame that crosses from one chip to the next in a cascade is queued
+without regard to the priority to traffic class map: with IEEE 802.1Q
+Table 8-5, a best effort frame waits in queue 1 on the chip it enters
+and in queue 0 on the next.
+
+The chip picks the queue where a frame comes in, from the ingress table
+of that port, and the next chip does the same from the priority in the
+DSA tag.  The map was only programmed into user ports, so a cascade
+port still queued one to one.  The same holds for frames the CPU sends
+for a bridge the switch forwards for, which enter by the CPU port.
+
+Program the map into every port in use.
+
+The map came from the priority map of the ets or mqprio qdisc.  Model
+the driver on lan966x instead, where the maps of a port are DCB objects
+and a qdisc only says how the queues are served: its ets refuses any
+priomap but the fixed one, and its mqprio takes no map.  lan966x has
+one field for the priority and the queue of a frame and needs no map
+between them.  This chip has two, so take the map as the one DCB object
+made for it, the IEEE ETS managed object, set with
+
+    dcb ets set dev PORT prio-tc ...
+
+Reading the object returns the map the chip runs.  Its algorithms and
+shares are not used, transmission selection stays with the ets qdisc.
+ets now refuses any map but one band per priority, and mqprio ignores
+its map.
+
+Frames the CPU sends on a port carry the traffic class of their
+transmit queue in the DSA tag, where the chip takes it as the queue.
+The ets qdisc leaves the transmit map of the port alone, so load the
+chip's map there, and keep it in step when the object changes.
+
+Signed-off-by: Joachim Wiberg 
+---
+ drivers/net/dsa/mv88e6xxx/chip.c | 200 +++++++++++++++++--------------
+ drivers/net/dsa/mv88e6xxx/chip.h |   8 +-
+ 2 files changed, 117 insertions(+), 91 deletions(-)
+
+diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
+index aaed30ea19e4..84e9e8d3c0dc 100644
+--- a/drivers/net/dsa/mv88e6xxx/chip.c
++++ b/drivers/net/dsa/mv88e6xxx/chip.c
+@@ -7610,24 +7610,20 @@ static int mv88e6xxx_port_del_etype_prio(struct dsa_switch *ds, int port,
+ 	return err;
+ }
+ 
+-/* Program @qpri into the tables of every user port, if it is news */
++/* Program @qpri into the tables of every port.  A frame from another
++ * chip, or forwarded for the CPU, arrives with its priority in the DSA
++ * tag and gets its queue from the table of the port it comes in on, like
++ * any other frame.
++ */
+ static int mv88e6xxx_sync_qpri(struct mv88e6xxx_chip *chip, const u8 *qpri)
+ {
+-	int port, err;
+-
+-	if (!memcmp(qpri, chip->qpri, sizeof(chip->qpri)))
+-		return 0;
++	struct dsa_port *dp;
++	int err;
+ 
+ 	memcpy(chip->qpri, qpri, sizeof(chip->qpri));
+ 
+-	if (!chip->info->ops->port_sync_qpri)
+-		return 0;
+-
+-	for (port = 0; port < mv88e6xxx_num_ports(chip); port++) {
+-		if (!dsa_is_user_port(chip->ds, port))
+-			continue;
+-
+-		err = chip->info->ops->port_sync_qpri(chip, port);
++	dsa_switch_for_each_available_port(dp, chip->ds) {
++		err = chip->info->ops->port_sync_qpri(chip, dp->index);
+ 		if (err)
+ 			return err;
+ 	}
+@@ -7635,7 +7631,7 @@ static int mv88e6xxx_sync_qpri(struct mv88e6xxx_chip *chip, const u8 *qpri)
+ 	return 0;
+ }
+ 
+-/* Whether the chip queues by the map this port's qdisc asked for */
++/* Whether the chip queues by the map this port's ETS object asked for */
+ static bool mv88e6xxx_port_qpri_in_use(struct mv88e6xxx_chip *chip, int port)
+ {
+ 	struct mv88e6xxx_port *mp = &chip->ports[port];
+@@ -7643,54 +7639,69 @@ static bool mv88e6xxx_port_qpri_in_use(struct mv88e6xxx_chip *chip, int port)
+ 	return mp->qmap && !memcmp(mp->qpri, chip->qpri, sizeof(mp->qpri));
+ }
+ 
+-/* Take the queue map a port's qdisc asks for, or drop it with NULL.  The
+- * queue is chosen where a frame enters, by that port's tables, so the
+- * chip has one map: the most recent request defines it, and a port
+- * whose request differs is no longer offloaded, see
+- * mv88e6xxx_port_qpri_in_use().  The identity map is restored when no
+- * port asks for one.
++/* The DSA tag carries the traffic class of the transmit queue, so lay the
++ * queues out one per class and map the priorities like the ingress tables
++ * do, for frames from the CPU to land in the same queue as switched ones.
++ */
++static int mv88e6xxx_port_set_tx_map(struct net_device *dev, const u8 *qpri)
++{
++	int tc, prio, err;
++
++	err = netdev_set_num_tc(dev, 8);
++	if (err)
++		return err;
++
++	for (tc = 0; tc < 8; tc++)
++		netdev_set_tc_queue(dev, tc, 1, tc);
++
++	for (prio = 0; prio < 8; prio++)
++		netdev_set_prio_tc_map(dev, prio, qpri[prio]);
++
++	return 0;
++}
++
++/* Take the queue map a port asks for in its ETS object.  The queue is
++ * chosen where a frame enters, by that port's tables, so the chip has
++ * one map: the most recent request defines it, and the ets qdisc of a
++ * port whose request differs no longer reads as offloaded.
+  */
+ static int mv88e6xxx_port_set_qpri(struct mv88e6xxx_chip *chip, int port,
+ 				   const u8 *qpri)
+ {
+ 	struct mv88e6xxx_port *mp = &chip->ports[port];
++	struct dsa_port *dp;
+ 	int other, prio, err;
+-	u8 map[8];
+-
+-	if (qpri) {
+-		for (prio = 0; prio < ARRAY_SIZE(map); prio++)
+-			map[prio] = min_t(u8, qpri[prio], 7);
+ 
+-		for (other = 0; other < mv88e6xxx_num_ports(chip); other++) {
+-			if (other != port && mv88e6xxx_port_qpri_in_use(chip, other) &&
+-			    memcmp(map, chip->qpri, sizeof(map))) {
+-				dev_info(chip->dev, "p%d: queue map replaces the one p%d asked for, the chip has one\n",
+-					 port, other);
+-				break;
+-			}
+-		}
++	memcpy(mp->qpri, qpri, sizeof(mp->qpri));
++	mp->qmap = true;
+ 
+-		memcpy(mp->qpri, map, sizeof(mp->qpri));
+-		mp->qmap = true;
+-	} else {
+-		mp->qmap = false;
+-
+-		for (prio = 0; prio < ARRAY_SIZE(map); prio++)
+-			map[prio] = prio;
++	if (!memcmp(qpri, chip->qpri, sizeof(chip->qpri)))
++		return 0;
+ 
+-		for (other = 0; other < mv88e6xxx_num_ports(chip); other++) {
+-			if (chip->ports[other].qmap) {
+-				memcpy(map, chip->qpri, sizeof(map));
+-				break;
+-			}
++	for (other = 0; other < mv88e6xxx_num_ports(chip); other++) {
++		if (other != port && mv88e6xxx_port_qpri_in_use(chip, other)) {
++			dev_info(chip->dev, "p%d: queue map replaces the one p%d asked for, the chip has one\n",
++				 port, other);
++			break;
+ 		}
+ 	}
+ 
+ 	mv88e6xxx_reg_lock(chip);
+-	err = mv88e6xxx_sync_qpri(chip, map);
++	err = mv88e6xxx_sync_qpri(chip, qpri);
+ 	mv88e6xxx_reg_unlock(chip);
++	if (err)
++		return err;
+ 
+-	return err;
++	/* An ets qdisc leaves the transmit map to the driver */
++	dsa_switch_for_each_user_port(dp, chip->ds) {
++		if (!chip->ports[dp->index].ets)
++			continue;
++
++		for (prio = 0; prio < 8; prio++)
++			netdev_set_prio_tc_map(dp->user, prio, qpri[prio]);
++	}
++
++	return 0;
+ }
+ 
+ static int mv88e6xxx_qos_port_mqprio(struct mv88e6xxx_chip *chip, int port,
+@@ -7698,8 +7709,7 @@ static int mv88e6xxx_qos_port_mqprio(struct mv88e6xxx_chip *chip, int port,
+ {
+ 	struct net_device *dev = dsa_to_port(chip->ds, port)->user;
+ 	struct tc_mqprio_qopt *qopt = &mqprio->qopt;
+-	int tc, prio, err = 0, num_txq = 0;
+-	u8 qpri[8];
++	int tc, err = 0, num_txq = 0;
+ 
+ 	if (!qopt->num_tc)
+ 		goto out_reset;
+@@ -7720,39 +7730,13 @@ static int mv88e6xxx_qos_port_mqprio(struct mv88e6xxx_chip *chip, int port,
+ 	if (err)
+ 		goto out_reset;
+ 
+-	/* The first queue of the priority's traffic class */
+-	for (prio = 0; prio < ARRAY_SIZE(qpri); prio++)
+-		qpri[prio] = qopt->offset[qopt->prio_tc_map[prio]];
+-
+-	return mv88e6xxx_port_set_qpri(chip, port, qpri);
++	return 0;
+ 
+ out_reset:
+ 	netdev_reset_tc(dev);
+-	mv88e6xxx_port_set_qpri(chip, port, NULL);
+ 	return err;
+ }
+ 
+-/* The DSA tag carries the traffic class of the transmit queue, so lay the
+- * queues out one per class and map the priorities like the ingress tables
+- * do, for frames from the CPU to land in the same queue as switched ones.
+- */
+-static int mv88e6xxx_port_set_tx_map(struct net_device *dev, const u8 *qpri)
+-{
+-	int tc, prio, err;
+-
+-	err = netdev_set_num_tc(dev, 8);
+-	if (err)
+-		return err;
+-
+-	for (tc = 0; tc < 8; tc++)
+-		netdev_set_tc_queue(dev, tc, 1, tc);
+-
+-	for (prio = 0; prio < 8; prio++)
+-		netdev_set_prio_tc_map(dev, prio, qpri[prio]);
+-
+-	return 0;
+-}
+-
+ /* Band 0 is dequeued first, queue 7 is served first */
+ static u8 mv88e6xxx_ets_queue(const struct tc_ets_qopt_offload_replace_params *p,
+ 			      u8 band)
+@@ -7862,7 +7846,7 @@ static int mv88e6xxx_ets_destroy(struct mv88e6xxx_chip *chip, int port)
+ 
+ 	netdev_reset_tc(dev);
+ 
+-	return mv88e6xxx_port_set_qpri(chip, port, NULL);
++	return 0;
+ }
+ 
+ static int mv88e6xxx_ets_replace(struct mv88e6xxx_chip *chip, int port,
+@@ -7872,7 +7856,7 @@ static int mv88e6xxx_ets_replace(struct mv88e6xxx_chip *chip, int port,
+ 	struct net_device *dev = dsa_to_port(chip->ds, port)->user;
+ 	struct mv88e6xxx_port *mp = &chip->ports[port];
+ 	unsigned int nstrict = 0, band;
+-	u8 qpri[8], wrr[8] = {};
++	u8 wrr[8] = {};
+ 	int prio, other, q, err;
+ 
+ 	if (qopt->parent != TC_H_ROOT &&
+@@ -7885,6 +7869,17 @@ static int mv88e6xxx_ets_replace(struct mv88e6xxx_chip *chip, int port,
+ 	if (!p->bands || p->bands > 8)
+ 		return -EOPNOTSUPP;
+ 
++	/* The priority to traffic class map is the ETS object's */
++	for (prio = 0; prio < 8; prio++) {
++		if (mv88e6xxx_ets_queue(p, p->priomap[prio]) ==
++		    min_t(u8, prio, p->bands - 1))
++			continue;
++
++		dev_err(chip->dev, "p%d: ets must keep one band per priority, highest first; set the traffic class of a priority with dcb ets\n",
++			port);
++		return -EOPNOTSUPP;
++	}
++
+ 	/* Strict bands come first, with no quantum */
+ 	while (nstrict < p->bands && !p->quanta[nstrict])
+ 		nstrict++;
+@@ -7915,9 +7910,6 @@ static int mv88e6xxx_ets_replace(struct mv88e6xxx_chip *chip, int port,
+ 		}
+ 	}
+ 
+-	for (prio = 0; prio < ARRAY_SIZE(qpri); prio++)
+-		qpri[prio] = mv88e6xxx_ets_queue(p, p->priomap[prio]);
+-
+ 	mv88e6xxx_reg_lock(chip);
+ 	err = chip->info->ops->port_set_sched(chip, port,
+ 					      8 - (p->bands - nstrict));
+@@ -7935,11 +7927,7 @@ static int mv88e6xxx_ets_replace(struct mv88e6xxx_chip *chip, int port,
+ 	if (err)
+ 		goto out_reset;
+ 
+-	err = mv88e6xxx_port_set_qpri(chip, port, qpri);
+-	if (err)
+-		goto out_reset;
+-
+-	err = mv88e6xxx_port_set_tx_map(dev, qpri);
++	err = mv88e6xxx_port_set_tx_map(dev, chip->qpri);
+ 	if (err)
+ 		goto out_reset;
+ 
+@@ -7964,7 +7952,8 @@ static int mv88e6xxx_qos_port_ets(struct mv88e6xxx_chip *chip, int port,
+ 		return mv88e6xxx_ets_destroy(chip, port);
+ 	case TC_ETS_STATS:
+ 		/* Nothing to report, but this is what marks it offloaded */
+-		return mv88e6xxx_port_qpri_in_use(chip, port) &&
++		return (!chip->ports[port].qmap ||
++			mv88e6xxx_port_qpri_in_use(chip, port)) &&
+ 		       mv88e6xxx_port_wrr_in_use(chip, port) ? 0 : -EOPNOTSUPP;
+ 	case TC_ETS_GRAFT:
+ 	default:
+@@ -8047,6 +8036,41 @@ static int mv88e6xxx_port_setup_tc(struct dsa_switch *ds, int port,
+ 	}
+ }
+ 
++/* The priority to traffic class map of the ETS object is the queue map.
++ * Transmission selection is set up with the ets qdisc, so every class
++ * reads as strict here and the algorithms and shares of a request are
++ * not used.
++ */
++static int mv88e6xxx_port_get_ets(struct dsa_switch *ds, int port,
++				  struct ieee_ets *ets)
++{
++	struct mv88e6xxx_chip *chip = ds->priv;
++	int i;
++
++	if (!chip->info->ops->port_sync_qpri)
++		return -EOPNOTSUPP;
++
++	ets->ets_cap = 8;
++
++	for (i = 0; i < 8; i++) {
++		ets->prio_tc[i] = chip->qpri[i];
++		ets->tc_tsa[i] = IEEE_8021QAZ_TSA_STRICT;
++	}
++
++	return 0;
++}
++
++static int mv88e6xxx_port_set_ets(struct dsa_switch *ds, int port,
++				  struct ieee_ets *ets)
++{
++	struct mv88e6xxx_chip *chip = ds->priv;
++
++	if (!chip->info->ops->port_sync_qpri)
++		return -EOPNOTSUPP;
++
++	return mv88e6xxx_port_set_qpri(chip, port, ets->prio_tc);
++}
++
+ static const struct phylink_mac_ops mv88e6xxx_phylink_mac_ops = {
+ 	.mac_select_pcs		= mv88e6xxx_mac_select_pcs,
+ 	.mac_prepare		= mv88e6xxx_mac_prepare,
+@@ -8134,6 +8158,8 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
+ 	.port_del_dscp_rewr	= mv88e6xxx_port_del_dscp_rewr,
+ 	.port_add_etype_prio	= mv88e6xxx_port_add_etype_prio,
+ 	.port_del_etype_prio	= mv88e6xxx_port_del_etype_prio,
++	.port_get_ets		= mv88e6xxx_port_get_ets,
++	.port_set_ets		= mv88e6xxx_port_set_ets,
+ 	.port_setup_tc		= mv88e6xxx_port_setup_tc,
+ };
+ 
+diff --git a/drivers/net/dsa/mv88e6xxx/chip.h b/drivers/net/dsa/mv88e6xxx/chip.h
+index 7bf7cdea0bb1..21185b1e98af 100644
+--- a/drivers/net/dsa/mv88e6xxx/chip.h
++++ b/drivers/net/dsa/mv88e6xxx/chip.h
+@@ -307,8 +307,8 @@ struct mv88e6xxx_port {
+ 		u16 proto;
+ 	} etype;
+ 
+-	/* Egress queue per frame priority this port's qdisc asked for,
+-	 * meaningful while qmap is set
++	/* Egress queue per frame priority this port's ETS object asked
++	 * for, once it has asked
+ 	 */
+ 	bool qmap;
+ 	u8 qpri[8];
+@@ -483,8 +483,8 @@ struct mv88e6xxx_chip {
+ 
+ 	/* Egress queue per frame priority.  A frame's queue is chosen
+ 	 * where it enters, by that port's tables, so the map is one per
+-	 * chip, programmed into every user port, and follows the port
+-	 * that asked most recently.
++	 * chip, programmed into every port, and follows the port that
++	 * asked most recently.
+ 	 */
+ 	u8 qpri[8];
+ 

From ffc241d25cc04ab1df7acc1c5c942f250a6c9024 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg 
Date: Thu, 3 Dec 2026 15:05:33 +0100
Subject: [PATCH 5/9] linux: queue frames by the ETS managed object on LAN969x

LAN969x picks the queue of a frame on the port it leaves by, from a
table the driver wrote from the priority map of the root qdisc.  That
made the map of a qdisc the home of the priority to traffic class
table.

Take the table as the IEEE ETS managed object instead, and put the
ports on the quirk qos-ets-table, so the table is written with dcb ets
and the root qdisc, ets, mqprio or taprio, gets one class per priority.
The driver is modelled on lan966x here, where the maps of a port are
DCB objects and a qdisc only says how the queues are served.

The driver now refuses an ets qdisc with any other map, so the kernel
patch and the quirk go together.

Signed-off-by: Joachim Wiberg 
---
 .../etc/product/interface-quirks.json         |   1 +
 ...eue-frames-by-the-ETS-managed-object.patch | 269 ++++++++++++++++++
 2 files changed, 270 insertions(+)
 create mode 100644 patches/linux/6.18.66/0163-net-sparx5-queue-frames-by-the-ETS-managed-object.patch

diff --git a/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json b/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json
index 96bd5959a1..ffaff34cee 100644
--- a/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json
+++ b/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json
@@ -2,6 +2,7 @@
     "@driver=sparx5-switch": {
 	"comment": "LAN969x switch ports; the gate control list memory is shared by all ports",
 	"qos-trust-order": ["pcp", "dscp", "dscp-pcp"],
+	"qos-ets-table": true,
 	"qos-offload": ["classification", "remarking", "transmission-selection", "egress-shaper", "credit-based-shaper", "time-aware-shaper"],
 	"qos-root-qdisc": ["ets", "mqprio", "taprio"],
 	"sched-supported-list-max": 3000,
diff --git a/patches/linux/6.18.66/0163-net-sparx5-queue-frames-by-the-ETS-managed-object.patch b/patches/linux/6.18.66/0163-net-sparx5-queue-frames-by-the-ETS-managed-object.patch
new file mode 100644
index 0000000000..13e343b10a
--- /dev/null
+++ b/patches/linux/6.18.66/0163-net-sparx5-queue-frames-by-the-ETS-managed-object.patch
@@ -0,0 +1,269 @@
+From 382450e5d95de4b449e2e51a94bc26abc6d63fbd Mon Sep 17 00:00:00 2001
+From: Joachim Wiberg 
+Date: Thu, 3 Dec 2026 15:05:03 +0100
+Subject: [PATCH 163/163] net: sparx5: queue frames by the ETS managed object
+Organization: Wires
+
+The queue system looks up the queue of a frame per egress port, from
+the frame's priority, in XQS:QMAP_SE_TBL.  The table was written from
+the priority map of the root qdisc, ets, mqprio or taprio, and reset
+when the qdisc went away.  That made the map of a qdisc the home of the
+priority to traffic class table.
+
+Model the driver on lan966x instead, where the maps of a port are DCB
+objects and a qdisc only says how the queues are served: its ets
+refuses any priomap but the fixed one, and its mqprio and taprio take
+no map.  lan966x has one field for the priority and the queue of a
+frame and needs no table between them.  This chip has the table, so
+take it as the one DCB object made for it, the IEEE ETS managed object.
+Keep it per port, set it with
+
+    dcb ets set dev PORT prio-tc ...
+
+and report it when the object is read.  Its algorithms and shares are
+not used, transmission selection stays with the qdiscs.
+
+ets refuses any map but one band per priority again, as it did before
+the table was written from it, and mqprio and taprio ignore theirs.
+Removing a qdisc no longer resets the table.
+
+Without CONFIG_SPARX5_DCB the table stays as the chip resets it, every
+priority in the queue of its own number.
+
+Signed-off-by: Joachim Wiberg 
+---
+ .../ethernet/microchip/sparx5/sparx5_dcb.c    | 41 ++++++++++++++++++-
+ .../ethernet/microchip/sparx5/sparx5_main.h   |  1 +
+ .../ethernet/microchip/sparx5/sparx5_qos.c    | 34 +++++----------
+ .../ethernet/microchip/sparx5/sparx5_qos.h    |  2 +-
+ .../ethernet/microchip/sparx5/sparx5_tas.c    |  4 +-
+ .../net/ethernet/microchip/sparx5/sparx5_tc.c |  8 ++++
+ 6 files changed, 62 insertions(+), 28 deletions(-)
+
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c b/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
+index a0d35e3b2676..3fe063d3c8cd 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_dcb.c
+@@ -7,6 +7,7 @@
+ #include 
+ 
+ #include "sparx5_port.h"
++#include "sparx5_qos.h"
+ 
+ enum sparx5_dcb_apptrust_values {
+ 	SPARX5_DCB_APPTRUST_EMPTY,
+@@ -337,7 +338,43 @@ static int sparx5_dcb_setrewr(struct net_device *dev, struct dcb_app *app)
+ 	return err;
+ }
+ 
++/* The priority to traffic class map of the ETS object picks the queue
++ * of a frame on the port it leaves by.  Transmission selection is set up
++ * with a qdisc, so every class reads as strict here and the algorithms
++ * and shares of a request are not used.
++ */
++static int sparx5_dcb_ieee_getets(struct net_device *dev, struct ieee_ets *ets)
++{
++	struct sparx5_port *port = netdev_priv(dev);
++	int i;
++
++	ets->ets_cap = SPX5_PRIOS;
++	for (i = 0; i < SPX5_PRIOS; i++) {
++		ets->prio_tc[i] = port->prio_tc[i];
++		ets->tc_tsa[i] = IEEE_8021QAZ_TSA_STRICT;
++	}
++
++	return 0;
++}
++
++static int sparx5_dcb_ieee_setets(struct net_device *dev, struct ieee_ets *ets)
++{
++	struct sparx5_port *port = netdev_priv(dev);
++	int i;
++
++	for (i = 0; i < SPX5_PRIOS; i++)
++		if (ets->prio_tc[i] >= SPX5_PRIOS)
++			return -ERANGE;
++
++	memcpy(port->prio_tc, ets->prio_tc, sizeof(port->prio_tc));
++	sparx5_tc_prio_tc_set(port);
++
++	return 0;
++}
++
+ const struct dcbnl_rtnl_ops sparx5_dcbnl_ops = {
++	.ieee_getets = sparx5_dcb_ieee_getets,
++	.ieee_setets = sparx5_dcb_ieee_setets,
+ 	.ieee_setapp = sparx5_dcb_ieee_setapp,
+ 	.ieee_delapp = sparx5_dcb_ieee_delapp,
+ 	.dcbnl_setapptrust = sparx5_dcb_setapptrust,
+@@ -349,13 +386,15 @@ const struct dcbnl_rtnl_ops sparx5_dcbnl_ops = {
+ int sparx5_dcb_init(struct sparx5 *sparx5)
+ {
+ 	struct sparx5_port *port;
+-	int i;
++	int i, prio;
+ 
+ 	for (i = 0; i < sparx5->data->consts->n_ports; i++) {
+ 		port = sparx5->ports[i];
+ 		if (!port)
+ 			continue;
+ 		port->ndev->dcbnl_ops = &sparx5_dcbnl_ops;
++		for (prio = 0; prio < SPX5_PRIOS; prio++)
++			port->prio_tc[prio] = prio;
+ 		/* Initialize [dscp, pcp] default trust */
+ 		sparx5_port_apptrust[port->portno] =
+ 			&sparx5_dcb_apptrust_policies
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+index 7445f6c40472..9e24e28fb0d1 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+@@ -246,6 +246,7 @@ struct sparx5_port {
+ 	bool lag_tx_active;
+ 	u32 ets_handle; /* the ets qdisc the hardware runs */
+ 	u32 tbf_handle; /* the root tbf, which an ets may hang under */
++	u8 prio_tc[SPX5_PRIOS]; /* traffic class per priority, the ETS object */
+ };
+ 
+ enum sparx5_core_clockfreq {
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c b/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
+index 3ba5ce1cb0ae..632c5a2fae9f 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_qos.c
+@@ -534,22 +534,20 @@ int sparx5_qos_init(struct sparx5 *sparx5)
+ 	return 0;
+ }
+ 
+-/* Queue each priority in the class @prio_tc says, the identity when NULL */
+-int sparx5_tc_prio_tc_set(struct sparx5_port *port, const u8 *prio_tc)
++/* Queue each priority on the port in the class its ETS object says */
++void sparx5_tc_prio_tc_set(struct sparx5_port *port)
+ {
+ 	struct sparx5 *sparx5 = port->sparx5;
+-	int prio, tc;
++	int prio;
+ 
+ 	/* A port's entries start at its virtual port, 8 * portno at reset */
+ 	for (prio = 0; prio < SPX5_PRIOS; prio++) {
+-		tc = prio_tc ? prio_tc[prio] : prio;
+ 		spx5_wr(port->portno * SPX5_PRIOS + prio, sparx5,
+ 			XQS_MAP_CFG_CFG);
+-		spx5_wr(sparx5_hsch_l0_get_idx(sparx5, port->portno, tc),
++		spx5_wr(sparx5_hsch_l0_get_idx(sparx5, port->portno,
++					       port->prio_tc[prio]),
+ 			sparx5, XQS_QMAP_SE_TBL(0));
+ 	}
+-
+-	return 0;
+ }
+ 
+ int sparx5_tc_mqprio_add(struct net_device *ndev,
+@@ -571,7 +569,7 @@ int sparx5_tc_mqprio_add(struct net_device *ndev,
+ 	netdev_dbg(ndev, "dev->num_tc %u dev->real_num_tx_queues %u\n",
+ 		   ndev->num_tc, ndev->real_num_tx_queues);
+ 
+-	return sparx5_tc_prio_tc_set(netdev_priv(ndev), qopt->prio_tc_map);
++	return 0;
+ }
+ 
+ int sparx5_tc_mqprio_del(struct net_device *ndev)
+@@ -581,7 +579,7 @@ int sparx5_tc_mqprio_del(struct net_device *ndev)
+ 	netdev_dbg(ndev, "dev->num_tc %u dev->real_num_tx_queues %u\n",
+ 		   ndev->num_tc, ndev->real_num_tx_queues);
+ 
+-	return sparx5_tc_prio_tc_set(netdev_priv(ndev), NULL);
++	return 0;
+ }
+ 
+ /* Shape a scheduler element: rate in kbit/s, burst in bytes */
+@@ -661,8 +659,7 @@ int sparx5_tc_ets_add(struct sparx5_port *port,
+ {
+ 	struct sparx5_dwrr dwrr = {0};
+ 	u32 weight[SPX5_PRIOS];
+-	u8 prio_tc[SPX5_PRIOS];
+-	int i, err;
++	int i;
+ 
+ 	for (i = 0; i < SPX5_PRIOS; i++) {
+ 		/* Strict band; skip */
+@@ -679,25 +676,14 @@ int sparx5_tc_ets_add(struct sparx5_port *port,
+ 	}
+ 	sparx5_dwrr_cost_set(&dwrr, weight);
+ 
+-	err = sparx5_dwrr_conf_set(port, &dwrr);
+-	if (err)
+-		return err;
+-
+-	/* Band 0 is served first by tc, queue 7 by the fabric */
+-	for (i = 0; i < SPX5_PRIOS; i++)
+-		prio_tc[i] = SPX5_PRIOS - 1 - params->priomap[i];
+-
+-	return sparx5_tc_prio_tc_set(port, prio_tc);
++	return sparx5_dwrr_conf_set(port, &dwrr);
+ }
+ 
+ int sparx5_tc_ets_del(struct sparx5_port *port)
+ {
+ 	struct sparx5_dwrr dwrr = {0};
+-	int err;
+-
+-	err = sparx5_dwrr_conf_set(port, &dwrr);
+ 
+-	return err ?: sparx5_tc_prio_tc_set(port, NULL);
++	return sparx5_dwrr_conf_set(port, &dwrr);
+ }
+ 
+ int sparx5_tc_cbs_add(struct sparx5_port *port,
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_qos.h b/drivers/net/ethernet/microchip/sparx5/sparx5_qos.h
+index c7f59c0f09f0..106a2f486362 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_qos.h
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_qos.h
+@@ -63,7 +63,7 @@ int sparx5_qos_init(struct sparx5 *sparx5);
+ int sparx5_tas_init(struct sparx5 *sparx5);
+ void sparx5_tas_speed(struct sparx5_port *port, int speed);
+ 
+-int sparx5_tc_prio_tc_set(struct sparx5_port *port, const u8 *prio_tc);
++void sparx5_tc_prio_tc_set(struct sparx5_port *port);
+ 
+ /* Multi-Queue Priority */
+ struct tc_mqprio_qopt;
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c
+index a1d51d35898e..23e3872dfb3b 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tas.c
+@@ -434,7 +434,7 @@ int sparx5_tc_taprio_add(struct sparx5_port *port,
+ 
+ 	sparx5_tas_list_state_set(sparx5, SPX5_TAS_STATE_ADVANCING);
+ 
+-	return sparx5_tc_prio_tc_set(port, qopt->mqprio.qopt.prio_tc_map);
++	return 0;
+ }
+ 
+ int sparx5_tc_taprio_del(struct sparx5_port *port)
+@@ -450,7 +450,7 @@ int sparx5_tc_taprio_del(struct sparx5_port *port)
+ 
+ 	sparx5_tas_guard_band_set(port->sparx5, port->portno, NULL);
+ 
+-	return sparx5_tc_prio_tc_set(port, NULL);
++	return 0;
+ }
+ 
+ void sparx5_tas_speed(struct sparx5_port *port, int speed)
+diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c b/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c
+index 6dbac5cdf279..ba915470423d 100644
+--- a/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c
++++ b/drivers/net/ethernet/microchip/sparx5/sparx5_tc.c
+@@ -139,6 +139,14 @@ static int sparx5_tc_setup_qdisc_ets(struct net_device *ndev,
+ 
+ 		/* Sanity checks */
+ 		for (i = 0; i < SPX5_PRIOS; ++i) {
++			/* Band 0 is served first by tc, queue 7 by the fabric.
++			 * The traffic class of a priority is the ETS object's.
++			 */
++			if (params->priomap[i] != SPX5_PRIOS - 1 - i) {
++				netdev_err(ndev, "ets must keep one band per priority, highest first; set the traffic class of a priority with dcb ets\n");
++				return -EOPNOTSUPP;
++			}
++
+ 			/* Throw an error if we receive zero weights by tc */
+ 			if (params->quanta[i] && params->weights[i] == 0) {
+ 				pr_err("Invalid ets configuration; band %d has weight zero",

From b5b7455faf462f334186cded88f8b94f69f5cd90 Mon Sep 17 00:00:00 2001
From: Joachim Wiberg 
Date: Fri, 4 Dec 2026 11:04:28 +0100
Subject: [PATCH 6/9] confd: add a get-statistics action for the traffic
 classes of a port

Nothing reports how many frames each traffic class of a port has sent.
The only way to see it is to log in and read the counters of the qdisc,
which on a switch port count frames from the CPU alone, and by the band
of the kernel's qdisc where the switch has its own queues.

Add a get-statistics action under the port's qos, like the one for the
frame counters of an Ethernet port: the counters are read from the port
when asked.  Where they come from depends on the port:

 - a port the kernel serves answers from its ets qdisc, with frames,
   octets and discards per class
 - a Marvell port answers from the chip's counter of frames sent per
   queue, named by the new quirk qos-queue-counters
 - a LAN969x port counts per priority, not per queue.  It answers with
   the sum over the priorities its table puts in each class, the table
   read back from the port, so its counters follow the table the port
   runs now.  The quirk qos-priority-counters names the counters
 - any other switch port answers without counters

`show interface NAME` runs the action and lists what it returns in the
traffic class table.

Signed-off-by: Joachim Wiberg 
---
 .../etc/product/interface-quirks.json         |   1 +
 board/common/rootfs/etc/interface-quirks.json |   1 +
 doc/ChangeLog.md                              |   5 +
 doc/qos.md                                    |   7 +
 src/bin/show/__init__.py                      |  32 ++-
 src/confd/src/core.c                          |   4 +
 src/confd/src/if-qos.c                        | 201 ++++++++++++++++++
 src/confd/src/interfaces.h                    |   1 +
 src/confd/yang/confd.inc                      |   2 +-
 src/confd/yang/confd/infix-if-qos.yang        |  52 +++++
 ...0-28.yang => infix-if-qos@2026-12-05.yang} |   0
 src/confd/yang/confd/infix-interfaces.yang    |   6 +
 ....yang => infix-interfaces@2026-12-05.yang} |   0
 src/statd/python/cli_pretty/cli_pretty.py     |  15 +-
 14 files changed, 315 insertions(+), 12 deletions(-)
 rename src/confd/yang/confd/{infix-if-qos@2026-10-28.yang => infix-if-qos@2026-12-05.yang} (100%)
 rename src/confd/yang/confd/{infix-interfaces@2026-11-11.yang => infix-interfaces@2026-12-05.yang} (100%)

diff --git a/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json b/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json
index ffaff34cee..ed133b138f 100644
--- a/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json
+++ b/board/aarch64/microchip-ev23x71a/rootfs/usr/share/product/microchip,ev23x71a/etc/product/interface-quirks.json
@@ -3,6 +3,7 @@
 	"comment": "LAN969x switch ports; the gate control list memory is shared by all ports",
 	"qos-trust-order": ["pcp", "dscp", "dscp-pcp"],
 	"qos-ets-table": true,
+	"qos-priority-counters": ["tx_port_green_p", "tx_port_yellow_p"],
 	"qos-offload": ["classification", "remarking", "transmission-selection", "egress-shaper", "credit-based-shaper", "time-aware-shaper"],
 	"qos-root-qdisc": ["ets", "mqprio", "taprio"],
 	"sched-supported-list-max": 3000,
diff --git a/board/common/rootfs/etc/interface-quirks.json b/board/common/rootfs/etc/interface-quirks.json
index 9ca0c58f28..fef32e36b8 100644
--- a/board/common/rootfs/etc/interface-quirks.json
+++ b/board/common/rootfs/etc/interface-quirks.json
@@ -8,6 +8,7 @@
 	"qos-trust-order": ["pcp", "dscp", "pcp-dscp", "dscp-pcp"],
 	"qos-ets-table": true,
 	"qos-pcp-encoded": true,
+	"qos-queue-counters": "out_queue_",
 	"qos-offload": ["classification", "remarking", "transmission-selection", "egress-shaper"],
 	"qos-root-qdisc": ["ets"]
     },
diff --git a/doc/ChangeLog.md b/doc/ChangeLog.md
index 6ea290014e..83ef39a37d 100644
--- a/doc/ChangeLog.md
+++ b/doc/ChangeLog.md
@@ -6,6 +6,11 @@ All notable changes to the project are documented in this file.
 [v26.12.0][UNRELEASED]
 -------------------------
 
+### Changes
+
+- New `get-statistics` action on the `qos` container of a port, reads the
+  frames each traffic class has sent.  `show interface NAME` lists them
+
 ### Fixes
 
 - Fix Wi-Fi station roaming on Raspberry Pi
diff --git a/doc/qos.md b/doc/qos.md
index 95ec2a80b9..601d12c23d 100644
--- a/doc/qos.md
+++ b/doc/qos.md
@@ -541,6 +541,13 @@ available offload  : egress-shaper, credit-based-shaper, time-aware-shaper
     0  1           strict-priority
 
+On a port that keeps counters per traffic class the table has a `SENT` +column as well, the frames each class has sent, and a `DROPPED` column +where the port counts those. They are read from the port when the +command runs. The `get-statistics` action under the port's `qos` +returns the same counters over [RESTCONF](scripting-restconf.md) and +NETCONF. + Everything shown is read back from the port, from the switch hardware where it does the work and from the kernel elsewhere. It is what the port runs, which for a port on a profile is the profile's settings. diff --git a/src/bin/show/__init__.py b/src/bin/show/__init__.py index 2fb180f34e..271cce7151 100755 --- a/src/bin/show/__init__.py +++ b/src/bin/show/__init__.py @@ -169,20 +169,32 @@ def find_container(data, name: str): return None -def ethernet_statistics(ifname: str): - """Run the get-statistics action on an Ethernet port, None when it fails""" - xpath = (f"/ietf-interfaces:interfaces/interface[name='{ifname}']" - "/ieee802-ethernet-interface:ethernet/infix-ethernet-interface:get-statistics") +def run_action(ifname: str, path: str, what: str): + """Run an action below an interface, its output as JSON, None when it fails""" + xpath = f"/ietf-interfaces:interfaces/interface[name='{ifname}']{path}" result = subprocess.run(["rpc", "-j", xpath], capture_output=True, text=True) if result.returncode != 0: - print(result.stderr.strip() or "reading the Ethernet statistics failed") + print(result.stderr.strip() or f"reading the {what} failed") return None try: - return find_container(json.loads(result.stdout), "frame") + return json.loads(result.stdout) except json.JSONDecodeError: return None +def ethernet_statistics(ifname: str): + """Run the get-statistics action on an Ethernet port, None when it fails""" + out = run_action(ifname, "/ieee802-ethernet-interface:ethernet" + "/infix-ethernet-interface:get-statistics", "Ethernet statistics") + return find_container(out, "frame") if out is not None else None + + +def qos_statistics(ifname: str) -> list: + """Run the get-statistics action on a port's qos, [] when it keeps no counters""" + out = run_action(ifname, "/infix-interfaces:qos/get-statistics", "QoS statistics") + return find_lists(out, "traffic-class", "id") if out is not None else [] + + def find_lists(data, name: str, key: str) -> list: """Collect every list called name whose entries carry key, however the output is wrapped""" found = [] @@ -428,9 +440,13 @@ def interface(args: List[str]) -> None: elif len(args) == 1: iface = args[0] if is_valid_interface_name(iface): - # The frame counters of an Ethernet port are read on request for entry in ifaces: - if entry.get("name") != iface or entry.get("type") != "infix-if-type:ethernet": + if entry.get("name") != iface: + continue + if "infix-interfaces:qos" in entry: + if classes := qos_statistics(iface): + entry["infix-interfaces:qos"]["statistics"] = {"traffic-class": classes} + if entry.get("type") != "infix-if-type:ethernet": continue if frame := ethernet_statistics(iface): eth = entry.setdefault("ieee802-ethernet-interface:ethernet", {}) diff --git a/src/confd/src/core.c b/src/confd/src/core.c index 36e2713256..8a286fb2c5 100644 --- a/src/confd/src/core.c +++ b/src/confd/src/core.c @@ -645,6 +645,10 @@ int sr_plugin_init_cb(sr_session_ctx_t *session, void **priv) if (rc) goto err; + rc = qos_rpc_init(&confd); + if (rc) + goto err; + rc = routing_rpc_init(&confd); if (rc) goto err; diff --git a/src/confd/src/if-qos.c b/src/confd/src/if-qos.c index 0b02fa5d40..32649a719e 100644 --- a/src/confd/src/if-qos.c +++ b/src/confd/src/if-qos.c @@ -1,8 +1,10 @@ /* SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include +#include #include #include @@ -1538,3 +1540,202 @@ int netdag_gen_qos(sr_session_ctx_t *session, struct dagger *net, struct lyd_nod return 0; } + +/* One traffic class of the get-statistics output, a counter left out when negative */ +static void qos_stats_class(struct lyd_node *output, int tc, json_int_t frames, + json_int_t octets, json_int_t discards) +{ + static const char *leaf[] = { "out-frames", "out-octets", "out-discards" }; + json_int_t val[] = { frames, octets, discards }; + struct lyd_node *node; + char buf[32]; + size_t i; + + snprintf(buf, sizeof(buf), "%d", tc); + if (lyd_new_list(output, NULL, "traffic-class", LYD_NEW_VAL_OUTPUT, &node, buf)) + return; + + for (i = 0; i < NELEMS(leaf); i++) { + if (val[i] < 0) + continue; + + snprintf(buf, sizeof(buf), "%" JSON_INTEGER_FORMAT, val[i]); + lyd_new_term(node, NULL, leaf[i], buf, LYD_NEW_VAL_OUTPUT, NULL); + } +} + +/* + * Add up the frame counters a driver lists in ethtool -S as @prefix + * followed by a digit, into @count by that digit. + */ +static bool qos_stats_ethtool(const char *ifname, const char *prefix, json_int_t *count) +{ + size_t len = strlen(prefix); + bool found = false; + char line[128]; + FILE *pp; + + pp = popenf("re", "ethtool -S %s 2>/dev/null", ifname); + if (!pp) + return false; + + while (fgets(line, sizeof(line), pp)) { + char *name = line + strspn(line, " \t"); + int n; + + if (strncmp(name, prefix, len) || !isdigit(name[len]) || name[len + 1] != ':') + continue; + + n = name[len] - '0'; + if (n >= MAX_TC) + continue; + + count[n] += strtoll(&name[len + 2], NULL, 10); + found = true; + } + pclose(pp); + + return found; +} + +/* The traffic class of each priority the port runs, from its ETS object, into @map */ +static void qos_stats_table(const char *ifname, uint8_t *map) +{ + char word[16]; + int prio, tc; + FILE *pp; + + pp = popenf("re", "dcb ets show dev %s prio-tc 2>/dev/null", ifname); + if (!pp) + return; + + while (fscanf(pp, "%15s", word) == 1) + if (sscanf(word, "%d:%d", &prio, &tc) == 2 && + prio >= 0 && prio < NUM_PRIO && tc >= 0 && tc < MAX_TC) + map[prio] = tc; + pclose(pp); +} + +/* + * The switch's own frame counters, per traffic class. A switch that + * counts per queue lists them so. One that counts per priority has what + * a class sent as the sum over the priorities the port's table puts in + * it now. + */ +static void qos_stats_fabric(struct lyd_node *output, const char *ifname, json_t *per_queue, + json_t *per_prio) +{ + json_int_t count[MAX_TC] = { 0 }, sent[MAX_TC] = { 0 }; + uint8_t map[NUM_PRIO] = { 0, 1, 2, 3, 4, 5, 6, 7 }; + bool found = false; + json_t *prefix; + size_t i; + int n; + + if (json_is_string(per_queue)) { + found = qos_stats_ethtool(ifname, json_string_value(per_queue), count); + } else { + json_array_foreach(per_prio, i, prefix) + if (json_is_string(prefix)) + found |= qos_stats_ethtool(ifname, json_string_value(prefix), count); + qos_stats_table(ifname, map); + } + if (!found) + return; + + for (n = 0; n < NUM_PRIO; n++) + sent[map[n]] += count[n]; + for (n = 0; n < MAX_TC; n++) + qos_stats_class(output, n, sent[n], -1, -1); +} + +static bool qos_is_ets_class(json_t *cls) +{ + const char *kind = json_string_value(json_object_get(cls, "class")); + + return kind && !strcmp(kind, "ets"); +} + +/* + * The counters of the kernel's ets qdisc, for a port the kernel serves. + * Band 0 is dequeued first, so class N-1 is the class with minor 1. + */ +static void qos_stats_kernel(struct lyd_node *output, const char *ifname) +{ + json_t *root, *cls; + int bands = 0; + size_t i; + FILE *pp; + + pp = popenf("re", "tc -s -j class show dev %s 2>/dev/null", ifname); + if (!pp) + return; + root = json_loadf(pp, 0, NULL); + pclose(pp); + + json_array_foreach(root, i, cls) + if (qos_is_ets_class(cls)) + bands++; + + json_array_foreach(root, i, cls) { + const char *handle = json_string_value(json_object_get(cls, "handle")); + json_t *st = json_object_get(cls, "stats") ?: cls; + const char *minor = handle ? strchr(handle, ':') : NULL; + int tc; + + if (!qos_is_ets_class(cls) || !minor) + continue; + + tc = bands - (int)strtol(minor + 1, NULL, 16); + if (tc < 0 || tc >= MAX_TC) + continue; + + qos_stats_class(output, tc, json_integer_value(json_object_get(st, "packets")), + json_integer_value(json_object_get(st, "bytes")), + json_integer_value(json_object_get(st, "drops"))); + } + json_decref(root); +} + +/* + * The get-statistics action. The kernel's counters say nothing about a + * switch port, where they count only frames from the CPU and by the band + * of the qdisc, so such a port answers from its fabric or not at all. + */ +static int qos_get_statistics(sr_session_ctx_t *session, uint32_t sub_id, const char *op_path, + const struct lyd_node *input, sr_event_t event, uint32_t request_id, + struct lyd_node *output, void *priv) +{ + json_t *per_queue, *per_prio; + struct lyd_node *iface; + const char *ifname; + + if (event != SR_EV_RPC) + return SR_ERR_OK; + + iface = lyd_parent(lyd_parent(input)); + ifname = iface ? lydx_get_cattr(iface, "name") : NULL; + if (!ifname || !valid_ifname(ifname) || !if_nametoindex(ifname)) + return rpc_failed(session, "No such interface"); + + per_queue = iface_quirk(ifname, "qos-queue-counters"); + per_prio = iface_quirk(ifname, "qos-priority-counters"); + if (per_queue || per_prio) + qos_stats_fabric(output, ifname, per_queue, per_prio); + else if (!iface_quirk(ifname, "qos-offload")) + qos_stats_kernel(output, ifname); + + return SR_ERR_OK; +} + +int qos_rpc_init(struct confd *confd) +{ + int rc; + + REGISTER_RPC_TREE(confd->session, IF_XPATH "/infix-interfaces:qos/get-statistics", + qos_get_statistics, NULL, &confd->sub); + return SR_ERR_OK; +fail: + ERROR("Init qos rpc failed: %s", sr_strerror(rc)); + return rc; +} diff --git a/src/confd/src/interfaces.h b/src/confd/src/interfaces.h index 74d9ae2192..d78103b489 100644 --- a/src/confd/src/interfaces.h +++ b/src/confd/src/interfaces.h @@ -199,6 +199,7 @@ int modem_add_iface(struct lyd_node *cif, struct dagger *net); int modem_del_iface(struct lyd_node *dif, struct dagger *net); /* if-qos.c */ +int qos_rpc_init(struct confd *confd); int netdag_gen_qos(sr_session_ctx_t *session, struct dagger *net, struct lyd_node *cif, struct lyd_node *dif); diff --git a/src/confd/yang/confd.inc b/src/confd/yang/confd.inc index 550e586313..a052861b0f 100644 --- a/src/confd/yang/confd.inc +++ b/src/confd/yang/confd.inc @@ -43,7 +43,7 @@ MODULES=( "infix-ethernet-interface@2026-10-31.yang" "infix-factory-default@2023-06-28.yang" "infix-qos@2026-12-05.yang" - "infix-interfaces@2026-11-11.yang -e vlan-filtering -e egress-shaper" + "infix-interfaces@2026-12-05.yang -e vlan-filtering -e egress-shaper" "ietf-crypto-types -e cleartext-symmetric-keys" "infix-crypto-types@2026-10-27.yang" "ietf-keystore -e symmetric-keys" diff --git a/src/confd/yang/confd/infix-if-qos.yang b/src/confd/yang/confd/infix-if-qos.yang index 02929cee51..819954f895 100644 --- a/src/confd/yang/confd/infix-if-qos.yang +++ b/src/confd/yang/confd/infix-if-qos.yang @@ -10,6 +10,9 @@ submodule infix-if-qos { import ietf-system { prefix sys; } + import ietf-yang-types { + prefix yang; + } import ieee802-dot1q-types { prefix dot1q-types; } @@ -35,6 +38,12 @@ submodule infix-if-qos { modules. VLAN sub-interface PCP mapping stays in infix-if-vlan.yang."; + revision 2026-12-05 { + description "Add the get-statistics action, reads the transmit + counters of a port's traffic classes."; + reference "internal"; + } + revision 2026-10-28 { description "Add QoS profiles: the pipeline inline or by reference to /system/qos-profile, a choice. egress/rate-limit @@ -197,6 +206,49 @@ submodule infix-if-qos { at rate, never below one maximum-size frame."; } } + + action get-statistics { + description + "Read the transmit counters of the port's traffic classes. + + The counters are not operational data. This action reads + them from the port when asked. A counter is listed only where the + port keeps it, and a port that keeps none answers without + any traffic class. On a switch port the counters are the + switch's own, for every frame the port sends. + + A switch that counts per priority reports for each traffic + class the sum over the priorities in it. Its counters follow + the traffic class table the port runs now: change the table, + and the frames already sent count under the new class."; + + output { + list traffic-class { + key "id"; + description "Transmit counters of one traffic class."; + + leaf id { + type dot1q-types:traffic-class-type; + description "Traffic class index."; + } + leaf out-frames { + type yang:counter64; + units frames; + description "Frames sent from the traffic class."; + } + leaf out-octets { + type yang:counter64; + units octets; + description "Octets sent from the traffic class."; + } + leaf out-discards { + type yang:counter64; + units frames; + description "Frames dropped for lack of room in the traffic class."; + } + } + } + } } } } diff --git a/src/confd/yang/confd/infix-if-qos@2026-10-28.yang b/src/confd/yang/confd/infix-if-qos@2026-12-05.yang similarity index 100% rename from src/confd/yang/confd/infix-if-qos@2026-10-28.yang rename to src/confd/yang/confd/infix-if-qos@2026-12-05.yang diff --git a/src/confd/yang/confd/infix-interfaces.yang b/src/confd/yang/confd/infix-interfaces.yang index c1deeb4a07..dc2cac391c 100644 --- a/src/confd/yang/confd/infix-interfaces.yang +++ b/src/confd/yang/confd/infix-interfaces.yang @@ -44,6 +44,12 @@ module infix-interfaces { contact "kernelkit@googlegroups.com"; description "Linux bridge and lag extensions for ietf-interfaces."; + revision 2026-12-05 { + description "Submodule infix-if-qos: the get-statistics action for + the traffic classes of a port."; + reference "internal"; + } + revision 2026-11-11 { description "Submodule infix-if-qos: QoS profiles, and the port's egress/rate-limit becomes egress-shaper."; diff --git a/src/confd/yang/confd/infix-interfaces@2026-11-11.yang b/src/confd/yang/confd/infix-interfaces@2026-12-05.yang similarity index 100% rename from src/confd/yang/confd/infix-interfaces@2026-11-11.yang rename to src/confd/yang/confd/infix-interfaces@2026-12-05.yang diff --git a/src/statd/python/cli_pretty/cli_pretty.py b/src/statd/python/cli_pretty/cli_pretty.py index 7d5c16a43c..4ac31e35ac 100755 --- a/src/statd/python/cli_pretty/cli_pretty.py +++ b/src/statd/python/cli_pretty/cli_pretty.py @@ -2107,6 +2107,8 @@ def __init__(self, iface): self.egress = (self.qos or {}).get("egress", {}) self.shaper = (self.qos or {}).get("egress-shaper", {}) self.offload = self.caps.get("offload", []) + stats = (self.qos or {}).get("statistics", {}).get("traffic-class", []) + self.stats = {int(c["id"]): c for c in stats} cbsa = iface.get("ieee802-dot1dc-cbsa-if:cbsa", {}) self.cbs = {int(c["traffic-class"]): c for c in cbsa.get("cbsa-parameter-table", [])} @@ -2159,13 +2161,20 @@ def pr_detail(self): ids = set(classes) | set(self.cbs) if ids: print() - table = SimpleTable([Column('CLASS', 'right'), Column('PRIORITIES'), Column('ALGORITHM'), - Column('SHARE', 'right'), Column('RESERVED', 'right')]) + columns = [Column('CLASS', 'right'), Column('PRIORITIES'), Column('ALGORITHM'), + Column('SHARE', 'right'), Column('RESERVED', 'right')] + counters = [] + for title, leaf in (('SENT', 'out-frames'), ('DROPPED', 'out-discards')): + if any(leaf in c for c in self.stats.values()): + counters.append(leaf) + columns.append(Column(title, 'right')) + table = SimpleTable(columns) for tc in sorted(ids, reverse=True): tclass = classes.get(tc, {}) algo = remove_yang_prefix(tclass.get("algorithm", "")) share = f"{tclass['bandwidth']}%" if "bandwidth" in tclass else "" - table.row(tc, self.priorities(tc), algo, share, self.slope(tc)) + table.row(tc, self.priorities(tc), algo, share, self.slope(tc), + *[self.stats.get(tc, {}).get(leaf, "") for leaf in counters]) table.print() if self.schedule: From 5cb3caa2e3cf9b6de189bf3b9ac62d213fad04ba Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 4 Dec 2026 11:49:07 +0100 Subject: [PATCH 7/9] test: share the gate control list and root qdisc helpers Five tests each build the gate-parameter-table of a port themselves, with their own copy of the set-gate-states identity, and several wait for the kind of a port's root qdisc with the same expression. Add qos.gate_table() and qos.root_kind() and use them. The tests configure what they did before. Signed-off-by: Joachim Wiberg --- .../case/interfaces/qos_egress_shaper/test.py | 2 +- test/case/interfaces/qos_max_sdu/test.py | 17 ++++-------- test/case/interfaces/qos_tas/test.py | 27 ++++++------------- test/case/use_case/tsn_gate_timing/test.py | 11 +------- test/case/use_case/tsn_guard_band/test.py | 11 +------- test/case/use_case/tsn_schedule/test.py | 11 +------- test/infamy/qos.py | 27 ++++++++++++++++++- 7 files changed, 43 insertions(+), 63 deletions(-) diff --git a/test/case/interfaces/qos_egress_shaper/test.py b/test/case/interfaces/qos_egress_shaper/test.py index c3af25d08a..5d5a06b647 100755 --- a/test/case/interfaces/qos_egress_shaper/test.py +++ b/test/case/interfaces/qos_egress_shaper/test.py @@ -68,7 +68,7 @@ def check(what, throughput): ] } }}) - until(lambda: (qos.root_qdisc(tgtssh, td1) or {}).get("kind") == "tbf") + until(lambda: qos.root_kind(tgtssh, td1) == "tbf") port.require_offload(test, "egress-shaper") with infamy.IsolatedMacVlan(hd0) as ns0, \ diff --git a/test/case/interfaces/qos_max_sdu/test.py b/test/case/interfaces/qos_max_sdu/test.py index 8b15e24061..f834ad546c 100755 --- a/test/case/interfaces/qos_max_sdu/test.py +++ b/test/case/interfaces/qos_max_sdu/test.py @@ -18,7 +18,6 @@ MAX_SDU = 1000 SMALL, LARGE = 900, 1100 # ICMP payloads, 28 bytes below the IP size -SET_GATES = "ieee802-dot1q-sched:set-gate-states" def bridge(td0, td1): @@ -32,16 +31,10 @@ def bridge(td0, td1): def schedule(td1, num_tc): return {"ietf-interfaces": {"interfaces": {"interface": [{ "name": td1, - "ieee802-dot1dc-sched-if:gate-parameter-table": { - "gate-enabled": True, - "admin-cycle-time": {"numerator": 1, "denominator": 1000}, - "admin-base-time": {"seconds": 0, "nanoseconds": 0}, - "admin-control-list": {"gate-control-entry": [ - {"index": 0, "operation-name": SET_GATES, - "gate-states-value": (1 << num_tc) - 1, "time-interval-value": 1_000_000}]}, - "queue-max-sdu-table": [{"traffic-class": tc, "queue-max-sdu": MAX_SDU} - for tc in range(num_tc)], - }, + "ieee802-dot1dc-sched-if:gate-parameter-table": + qos.gate_table([((1 << num_tc) - 1, 1_000_000)], cycle=1_000_000) | { + "queue-max-sdu-table": [{"traffic-class": tc, "queue-max-sdu": MAX_SDU} + for tc in range(num_tc)]}, }]}}} @@ -82,7 +75,7 @@ def pings(ns, size): with test.step("Open all gates toward the listener, max SDU 1000 on every class"): target.put_config_dicts(schedule(td1, port.traffic_classes)) - until(lambda: (qos.root_qdisc(tgtssh, td1) or {}).get("kind") == "taprio") + until(lambda: qos.root_kind(tgtssh, td1) == "taprio") with test.step("Verify a 928-byte packet still reaches the listener"): assert pings(ns0, SMALL), "a 928-byte packet, below the max SDU, was lost" diff --git a/test/case/interfaces/qos_tas/test.py b/test/case/interfaces/qos_tas/test.py index c711307795..674a08b505 100755 --- a/test/case/interfaces/qos_tas/test.py +++ b/test/case/interfaces/qos_tas/test.py @@ -26,19 +26,8 @@ class and the class two below it for 20 µs, and every other class for import infamy.qos as qos from infamy.util import until -SET_GATES = "ieee802-dot1q-sched:set-gate-states" - - -def gates(port, entries, enabled=True): - return { - "gate-enabled": enabled, - "admin-cycle-time": {"numerator": 1, "denominator": 10000}, - "admin-base-time": {"seconds": 0, "nanoseconds": 200}, - "admin-control-list": {"gate-control-entry": [ - {"index": i, "operation-name": SET_GATES, - "gate-states-value": mask, "time-interval-value": interval} - for i, (mask, interval) in enumerate(entries)]}, - } +def gates(entries): + return qos.gate_table(entries, cycle=100_000, base=200) def config(port, table, qos=None): @@ -78,29 +67,29 @@ def oper_table(target, port): txqs = cap.tx_queues with test.step("Reject a gate control list together with a port egress shaper"): - must_reject(target, config(port, gates(port, entries), + must_reject(target, config(port, gates(entries), {"egress-shaper": {"rate": 10_000_000}}), "gates with egress-shaper", "egress-shaper and gate-enabled exclude each other") with test.step("Reject a gate control list together with a weighted class"): - must_reject(target, config(port, gates(port, entries), + must_reject(target, config(port, gates(entries), {"egress": {"traffic-class": [{"id": 0, "algorithm": qos.ETS, "bandwidth": 100}]}}), "gates with a weighted class", "cannot be gated") with test.step("Reject an empty gate control list"): - must_reject(target, config(port, gates(port, [])), + must_reject(target, config(port, gates([])), "gates with an empty list", "empty admin-control-list") if txqs < num_tc: with test.step("Reject the schedule on a port with fewer transmit queues than classes"): - must_reject(target, config(port, gates(port, entries)), + must_reject(target, config(port, gates(entries)), f"gates on a port with {txqs} transmit queues", "needs a transmit queue per traffic class") test.succeed() with test.step("Enable the gate control list on the port"): - target.put_config_dicts(config(port, gates(port, entries))) - until(lambda: (qos.root_qdisc(tgtssh, port) or {}).get("kind") == "taprio") + target.put_config_dicts(config(port, gates(entries))) + until(lambda: qos.root_kind(tgtssh, port) == "taprio") qos.wait_offload(cap, "time-aware-shaper") with test.step("Verify the port reports the list, cycle and base time it runs"): diff --git a/test/case/use_case/tsn_gate_timing/test.py b/test/case/use_case/tsn_gate_timing/test.py index 97f8e4633c..8231bd705a 100755 --- a/test/case/use_case/tsn_gate_timing/test.py +++ b/test/case/use_case/tsn_gate_timing/test.py @@ -48,7 +48,6 @@ class 7, SR class A, 200 to 800 µs. The remaining classes get the COUNT = 999 SLACK = 5_000 # ns past a window's end a probe may arrive TALKER, LISTENER = "192.168.20.1", "192.168.20.2" -SET_GATES = "ieee802-dot1q-sched:set-gate-states" def gptp(ports, client=False): @@ -100,15 +99,7 @@ def schedule(dnlink, wins): return {"ietf-interfaces": {"interfaces": {"interface": [{ "name": dnlink, "infix-interfaces:qos": {"egress": {"traffic-class-table": {"preset": "ieee-sr"}}}, - "ieee802-dot1dc-sched-if:gate-parameter-table": { - "gate-enabled": True, - "admin-cycle-time": {"numerator": 1, "denominator": 1_000_000_000 // CYCLE}, - "admin-base-time": {"seconds": 0, "nanoseconds": 0}, - "admin-control-list": {"gate-control-entry": [ - {"index": i, "operation-name": SET_GATES, - "gate-states-value": mask, "time-interval-value": interval} - for i, (mask, interval) in enumerate(wins)]}, - }, + "ieee802-dot1dc-sched-if:gate-parameter-table": qos.gate_table(wins, cycle=CYCLE), }]}}} diff --git a/test/case/use_case/tsn_guard_band/test.py b/test/case/use_case/tsn_guard_band/test.py index 3e640a593d..94bcb4dcc9 100755 --- a/test/case/use_case/tsn_guard_band/test.py +++ b/test/case/use_case/tsn_guard_band/test.py @@ -49,7 +49,6 @@ MARGIN = 50_000 # ns from the window a waiting probe was sent FLOOD_MIN = 400_000_000 # bps of CS1 the DUT must be sending TALKER, LISTENER = "192.168.20.1", "192.168.20.2" -SET_GATES = "ieee802-dot1q-sched:set-gate-states" PKTGEN = "/proc/net/pktgen" FLOOD_MAC = "02:00:00:00:00:01" # unknown to all: the DUT floods it, the listener drops it @@ -108,15 +107,7 @@ def since_open(phase): def schedule(dnlink): return {"ietf-interfaces": {"interfaces": {"interface": [{ "name": dnlink, - "ieee802-dot1dc-sched-if:gate-parameter-table": { - "gate-enabled": True, - "admin-cycle-time": {"numerator": 1, "denominator": 1_000_000_000 // CYCLE}, - "admin-base-time": {"seconds": 0, "nanoseconds": 0}, - "admin-control-list": {"gate-control-entry": [ - {"index": i, "operation-name": SET_GATES, - "gate-states-value": mask, "time-interval-value": interval} - for i, (mask, interval) in enumerate(WINDOWS)]}, - }, + "ieee802-dot1dc-sched-if:gate-parameter-table": qos.gate_table(WINDOWS, cycle=CYCLE), }]}}} diff --git a/test/case/use_case/tsn_schedule/test.py b/test/case/use_case/tsn_schedule/test.py index 0cf978f530..0f18d3667d 100755 --- a/test/case/use_case/tsn_schedule/test.py +++ b/test/case/use_case/tsn_schedule/test.py @@ -55,7 +55,6 @@ SIZE = 1000 # UDP payload OVERHEAD = 46 + qos.WIRE_OVERHEAD # UDP, IP, Ethernet and FCS, then the wire TOLERANCE = 0.1 -SET_GATES = "ieee802-dot1q-sched:set-gate-states" def windows(speed): @@ -104,15 +103,7 @@ def schedule(td1, wins): "ieee802-dot1dc-cbsa-if:cbsa": { "cbsa-parameter-table": [{"traffic-class": VIDEO, "admin-idle-slope": RESERVE}] }, - "ieee802-dot1dc-sched-if:gate-parameter-table": { - "gate-enabled": True, - "admin-cycle-time": {"numerator": 1, "denominator": 1_000_000_000 // CYCLE}, - "admin-base-time": {"seconds": 0, "nanoseconds": 0}, - "admin-control-list": {"gate-control-entry": [ - {"index": i, "operation-name": SET_GATES, - "gate-states-value": mask, "time-interval-value": interval} - for i, (mask, interval) in enumerate(wins)]}, - }, + "ieee802-dot1dc-sched-if:gate-parameter-table": qos.gate_table(wins, cycle=CYCLE), }]}}} diff --git a/test/infamy/qos.py b/test/infamy/qos.py index 89b7f716b4..47c25a220d 100644 --- a/test/infamy/qos.py +++ b/test/infamy/qos.py @@ -34,6 +34,7 @@ 8: [1, 0, 6, 7, 2, 3, 4, 5], } +SET_GATES = "ieee802-dot1q-sched:set-gate-states" STRICT = "infix-qos:strict-priority" ETS = "infix-qos:enhanced-transmission-selection" CBS = "infix-qos:credit-based-shaper" @@ -98,6 +99,30 @@ def root_qdisc(ssh, port): return None +def root_kind(ssh, port): + """Kind of the port's root qdisc, None while it has none""" + return (root_qdisc(ssh, port) or {}).get("kind") + + +def gate_table(entries, cycle, base=0, enabled=True): + """A port's gate-parameter-table, the gate control list of IEEE 802.1Qbv + + entries are (gate states, interval) pairs in list order, the gate + states a bit mask with one bit per traffic class. The intervals, + the cycle and the base time are in nanoseconds. + """ + return { + "gate-enabled": enabled, + "admin-cycle-time": {"numerator": 1, "denominator": 1_000_000_000 // cycle}, + "admin-base-time": {"seconds": base // 1_000_000_000, + "nanoseconds": base % 1_000_000_000}, + "admin-control-list": {"gate-control-entry": [ + {"index": i, "operation-name": SET_GATES, + "gate-states-value": mask, "time-interval-value": interval} + for i, (mask, interval) in enumerate(entries)]}, + } + + def scheduler(ssh, port): """The ets qdisc: the root, or the child of a tbf root""" root = root_qdisc(ssh, port) @@ -252,7 +277,7 @@ def linked(): }] } }}) - until(lambda: (root_qdisc(port.ssh, port.name) or {}).get("kind") == "tbf") + until(lambda: root_kind(port.ssh, port.name) == "tbf") return 10_000_000 return 0 From 76dd1103e27e27967420639ce7ccfbc9dd1aafef Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 4 Dec 2026 14:53:48 +0100 Subject: [PATCH 8/9] test: follow the traffic class table and its counters to where they are Eight QoS tests read what a port runs over SSH from its root qdisc: the traffic class table from the priority map, and in one test the counters per class. On a switch port neither is there any more. The table is in the DCB ETS object or in dcb app, the qdisc has one class per priority, and the qdisc's counters are the kernel's own, which say nothing about the queues of the switch. Ask the port where its table is and read it from there, in one helper the tests share; qos_traffic_class and qos_factory_default had their own copies of the qdisc check. qos_ingress_classify expects the traffic class in dcb app on a port that keeps it there. qos_queue_assignment reads the counters with the get-statistics action where the port counts at its queues. A switch that counts per priority cannot show the queue of a frame that way, so there the test opens the gate of one traffic class at a time and checks that only the priorities the table puts in it get through. The listener is a static neighbour of the egress port for that: the DUT's own ARP has priority 0 and would wait behind a closed gate, until the entry fails and nothing is routed. Signed-off-by: Joachim Wiberg --- .../interfaces/qos_factory_default/test.adoc | 4 +- .../interfaces/qos_factory_default/test.py | 38 ++---- .../interfaces/qos_ingress_classify/test.adoc | 5 + .../interfaces/qos_ingress_classify/test.py | 51 ++++---- .../interfaces/qos_mixed_selection/test.py | 5 +- test/case/interfaces/qos_profile/test.py | 17 +-- .../interfaces/qos_queue_assignment/test.adoc | 21 +++- .../interfaces/qos_queue_assignment/test.py | 110 ++++++++++++++++-- .../interfaces/qos_traffic_class/test.adoc | 6 +- .../case/interfaces/qos_traffic_class/test.py | 85 ++++---------- .../interfaces/qos_weighted_sharing/test.py | 5 +- test/infamy/capability.py | 40 +++++++ test/infamy/qos.py | 66 +++++------ 13 files changed, 275 insertions(+), 178 deletions(-) diff --git a/test/case/interfaces/qos_factory_default/test.adoc b/test/case/interfaces/qos_factory_default/test.adoc index f20cb09f2e..92a9efa26b 100644 --- a/test/case/interfaces/qos_factory_default/test.adoc +++ b/test/case/interfaces/qos_factory_default/test.adoc @@ -16,6 +16,8 @@ Verify that the running configuration carries no qos container, that the class count follows the queue count rule, that the root qdisc carries the Table 8-5 map for it, and that classification is in place: in the DCB tables on a port whose driver has them, as tc flower rules otherwise. +A switch that picks the queue where a frame comes in takes the map in +its DCB table instead, and its root qdisc has one class per priority. ==== Topology @@ -26,7 +28,7 @@ image::topology.svg[QoS Defaults Out of the Box topology, align=center, scaledwi . Set up topology and attach to target DUT . Verify the running configuration has no qos container . Verify the class count is the queue count, or eight for one queue -. Verify the root qdisc carries the Table 8-5 map, all strict +. Verify the port runs the Table 8-5 map, all strict . Verify classification trusts PCP by default diff --git a/test/case/interfaces/qos_factory_default/test.py b/test/case/interfaces/qos_factory_default/test.py index 6ace6fbcde..8cdb3e145e 100755 --- a/test/case/interfaces/qos_factory_default/test.py +++ b/test/case/interfaces/qos_factory_default/test.py @@ -14,22 +14,14 @@ class count follows the queue count rule, that the root qdisc carries the Table 8-5 map for it, and that classification is in place: in the DCB tables on a port whose driver has them, as tc flower rules otherwise. +A switch that picks the queue where a frame comes in takes the map in +its DCB table instead, and its root qdisc has one class per priority. """ import json import infamy +import infamy.qos as qos from infamy.util import until -TABLE_8_5 = { - 2: [0, 0, 0, 0, 1, 1, 1, 1], - 3: [0, 0, 0, 0, 1, 1, 2, 2], - 4: [0, 0, 1, 1, 2, 2, 3, 3], - 5: [0, 0, 1, 1, 2, 2, 3, 4], - 6: [1, 0, 2, 2, 3, 3, 4, 5], - 7: [1, 0, 2, 3, 4, 4, 5, 6], - 8: [1, 0, 2, 3, 4, 5, 6, 7], -} - - def running_qos(target, port): running = target.get_config_dict("/ietf-interfaces:interfaces") for iface in running["interfaces"]["interface"]: @@ -38,14 +30,6 @@ def running_qos(target, port): return None -def root_qdisc(ssh, port): - out = ssh.runsh(f"tc -j qdisc show dev {port}").stdout - for qdisc in json.loads(out or "[]"): - if qdisc.get("root"): - return qdisc - return None - - def tx_queues(ssh, port): out = ssh.runsh(f"ls /sys/class/net/{port}/queues").stdout return len([q for q in out.split() if q.startswith("tx-")]) @@ -62,24 +46,16 @@ def tx_queues(ssh, port): assert running_qos(target, port) is None, f"{port} has qos configuration" with test.step("Verify the class count is the queue count, or eight for one queue"): - caps = infamy.capability.Port(target, port, tgtssh).caps + cap = infamy.capability.Port(target, port, tgtssh) + caps = cap.caps queues = tx_queues(tgtssh, port) expected = min(queues, 8) if queues > 1 else 8 print(f"{port}: {queues} tx queues") assert caps.get("max-traffic-classes", 8) == expected, caps num_tc = expected - with test.step("Verify the root qdisc carries the Table 8-5 map, all strict"): - def default_table(): - qdisc = root_qdisc(tgtssh, port) - if not qdisc: - return False - opts = qdisc.get("options", {}) - if qdisc["kind"] == "ets": - return (opts.get("bands") == num_tc and opts.get("strict") == num_tc and - opts.get("priomap", [])[:8] == [num_tc - 1 - tc for tc in TABLE_8_5[num_tc]]) - return False - until(default_table) + with test.step("Verify the port runs the Table 8-5 map, all strict"): + until(lambda: qos.runs_table(cap, num_tc, qos.TABLE_8_5[num_tc], strict=num_tc)) with test.step("Verify classification trusts PCP by default"): if caps.get("supported-trust-order"): diff --git a/test/case/interfaces/qos_ingress_classify/test.adoc b/test/case/interfaces/qos_ingress_classify/test.adoc index d841cb5b93..b8d116f918 100644 --- a/test/case/interfaces/qos_ingress_classify/test.adoc +++ b/test/case/interfaces/qos_ingress_classify/test.adoc @@ -20,6 +20,11 @@ The configuration: - DSCP preset ietf: RFC 4594 groups, e.g. EF (46) to priority 5 - remark pcp and dscp from priority: priority 5 to PCP 5 and DSCP 40 +A switch that picks the queue where a frame comes in holds the traffic +class of each priority in its tables, so there PCP 0 reads as class 1 +with the default traffic class table, and the remark tables map the +class back to the priority. + On a switch port whose driver supports it, the settings go to the switch hardware: the kernel's DCB tables must match and the operational datastore must report classification and remarking as diff --git a/test/case/interfaces/qos_ingress_classify/test.py b/test/case/interfaces/qos_ingress_classify/test.py index 0e9abe2e28..a6e20eed38 100755 --- a/test/case/interfaces/qos_ingress_classify/test.py +++ b/test/case/interfaces/qos_ingress_classify/test.py @@ -18,6 +18,11 @@ - DSCP preset ietf: RFC 4594 groups, e.g. EF (46) to priority 5 - remark pcp and dscp from priority: priority 5 to PCP 5 and DSCP 40 +A switch that picks the queue where a frame comes in holds the traffic +class of each priority in its tables, so there PCP 0 reads as class 1 +with the default traffic class table, and the remark tables map the +class back to the priority. + On a switch port whose driver supports it, the settings go to the switch hardware: the kernel's DCB tables must match and the operational datastore must report classification and remarking as @@ -33,20 +38,10 @@ import json import re import infamy +import infamy.qos as qos from infamy.util import until -def dscp_num(name): - """dcb prints DSCP by name when it knows one: CS1, AF21, EF ...""" - if name.startswith("CS"): - return int(name[2:]) * 8 - if name.startswith("AF"): - return int(name[2]) * 8 + int(name[3]) * 2 - if name == "EF": - return 46 - return int(name) - - def dcb_tokens(ssh, cmd, port): """Return {table: [tokens]} from dcb ... show dev PORT text output, DSCP as numbers""" out = ssh.runsh(f"dcb {cmd} show dev {port}").stdout @@ -58,9 +53,9 @@ def dcb_tokens(ssh, cmd, port): continue tokens = rest.split() if name == "dscp-prio": - tokens = [f"{dscp_num(k)}:{v}" for k, v in (t.split(":") for t in tokens)] + tokens = [f"{qos.dscp_name_to_num(k)}:{v}" for k, v in (t.split(":") for t in tokens)] elif name == "prio-dscp": - tokens = [f"{k}:{dscp_num(v)}" for k, v in (t.split(":") for t in tokens)] + tokens = [f"{k}:{qos.dscp_name_to_num(v)}" for k, v in (t.split(":") for t in tokens)] tables[name] = tokens return tables @@ -97,6 +92,11 @@ def flower_rules(ssh, port): dcb = bool(cap.trust_orders) print(f"{port}: DCB {'supported' if dcb else 'not supported'}") + table = list(range(8)) + if dcb and cap.class_at_ingress: + table = qos.TABLE_8_5[cap.traffic_classes] + print(f"{port}: DCB tables hold the traffic class, {table}") + with test.step("Configure trust dscp-pcp, default priority 2, presets, and remarking"): target.put_config_dicts({"ietf-interfaces": { "interfaces": { @@ -125,23 +125,32 @@ def flower_rules(ssh, port): with test.step("Verify dcb app default priority and PCP and DSCP maps"): app = dcb_tokens(tgtssh, "app", port) print(app) - assert app.get("default-prio") == ["2"], f"default-prio {app.get('default-prio')}" + assert app.get("default-prio") == [str(table[2])], \ + f"default-prio {app.get('default-prio')}" pcp = set(app.get("pcp-prio", [])) - for want in ("0nd:0", "1nd:1", "0de:0", "1de:1", "7nd:7", "7de:7"): + for code, prio in (("0nd", 0), ("1nd", 1), ("0de", 0), ("1de", 1), + ("7nd", 7), ("7de", 7)): + want = f"{code}:{table[prio]}" assert want in pcp, f"missing {want} in pcp-prio {sorted(pcp)}" dscp = set(app.get("dscp-prio", [])) - for want in ("0:0", "8:1", "26:3", "46:5", "48:6", "56:7"): + for code, prio in ((0, 0), (8, 1), (26, 3), (46, 5), (48, 6), (56, 7)): + want = f"{code}:{table[prio]}" assert want in dscp, f"missing {want} in dscp-prio {sorted(dscp)}" with test.step("Verify dcb rewr priority to PCP and DSCP maps"): rewr = dcb_tokens(tgtssh, "rewr", port) print(rewr) pcp = set(rewr.get("prio-pcp", [])) - for want in ("0:0nd", "5:5nd", "7:7nd"): - assert want in pcp, f"missing {want} in prio-pcp {sorted(pcp)}" dscp = set(rewr.get("prio-dscp", [])) - for want in ("0:0", "1:8", "5:40", "7:56"): - assert want in dscp, f"missing {want} in prio-dscp {sorted(dscp)}" + if len(set(table)) == 8: + for prio in (0, 5, 7): + want = f"{table[prio]}:{prio}nd" + assert want in pcp, f"missing {want} in prio-pcp {sorted(pcp)}" + for prio, code in ((0, 0), (1, 8), (5, 40), (7, 56)): + want = f"{table[prio]}:{code}" + assert want in dscp, f"missing {want} in prio-dscp {sorted(dscp)}" + else: + assert not pcp and not dscp, f"rewrite with priorities sharing a class: {rewr}" with test.step("Verify classification and remarking are reported as offloaded"): until(lambda: {"classification", "remarking"} <= set(cap.offload)) @@ -185,7 +194,7 @@ def flower_rules(ssh, port): target.put_config_dicts({}, delete=[f"/ietf-interfaces:interfaces/interface[name='{port}']" "/infix-interfaces:qos"]) if dcb: - until(lambda: dcb_tokens(tgtssh, "app", port).get("default-prio") == ["0"]) + until(lambda: dcb_tokens(tgtssh, "app", port).get("default-prio") == [str(table[0])]) assert dcb_tokens(tgtssh, "apptrust", port).get("order") == ["pcp"] assert not dcb_tokens(tgtssh, "rewr", port).get("prio-dscp") else: diff --git a/test/case/interfaces/qos_mixed_selection/test.py b/test/case/interfaces/qos_mixed_selection/test.py index 0f0a5fe4fa..cb2b43c51d 100755 --- a/test/case/interfaces/qos_mixed_selection/test.py +++ b/test/case/interfaces/qos_mixed_selection/test.py @@ -82,9 +82,8 @@ class above AF21 and CS1, which share the rest 2:1. } }}) quanta = [SHARES[tc] * qos.ETS_QUANTUM_UNIT for tc in sorted(SHARES, reverse=True)] - until(lambda: qos.scheduler_matches(qos.scheduler(tgtssh, td1), num_tc, - qos.TABLE_8_5[num_tc], - strict=num_tc - len(SHARES), quanta=quanta)) + until(lambda: qos.runs_table(port, num_tc, qos.TABLE_8_5[num_tc], + strict=num_tc - len(SHARES), quanta=quanta)) qos.wait_offload(port) with test.step("Slow the egress port so its queues can fill"): diff --git a/test/case/interfaces/qos_profile/test.py b/test/case/interfaces/qos_profile/test.py index 78f2c508bd..de33b81f41 100755 --- a/test/case/interfaces/qos_profile/test.py +++ b/test/case/interfaces/qos_profile/test.py @@ -16,8 +16,9 @@ PROFILE = "/ietf-system:system/infix-qos:qos-profile" -def runs(ssh, port, num_tc, table): - return qos.scheduler_matches(qos.scheduler(ssh, port), num_tc, table[num_tc], strict=num_tc) +def runs(port, table): + num_tc = port.traffic_classes + return qos.runs_table(port, num_tc, table[num_tc], strict=num_tc) with infamy.Test() as test: @@ -27,8 +28,8 @@ def runs(ssh, port, num_tc, table): tgtssh = env.attach("target", "mgmt", "ssh") p0 = target["data1"] p1 = target["data2"] - port0 = infamy.capability.Port(target, p0) - port1 = infamy.capability.Port(target, p1) + port0 = infamy.capability.Port(target, p0, tgtssh) + port1 = infamy.capability.Port(target, p1, tgtssh) with test.step("Define profile 'sr' with the ieee-sr traffic class table and put both ports on it"): target.put_config_dicts({ @@ -42,8 +43,8 @@ def runs(ssh, port, num_tc, table): {"name": p1, "enabled": True, "infix-interfaces:qos": {"profile": "sr"}}, ]}}, }) - until(lambda: runs(tgtssh, p0, port0.traffic_classes, qos.TABLE_34_1)) - until(lambda: runs(tgtssh, p1, port1.traffic_classes, qos.TABLE_34_1)) + until(lambda: runs(port0, qos.TABLE_34_1)) + until(lambda: runs(port1, qos.TABLE_34_1)) with test.step("Verify both ports report profile 'sr' in use"): until(lambda: port0.profile == "sr" and port1.profile == "sr") @@ -52,8 +53,8 @@ def runs(ssh, port, num_tc, table): target.put_config_dicts({"ietf-system": {"system": {"infix-qos:qos-profile": [{ "name": "sr", "egress": {"traffic-class-table": {"preset": "ieee"}}, }]}}}) - until(lambda: runs(tgtssh, p0, port0.traffic_classes, qos.TABLE_8_5)) - until(lambda: runs(tgtssh, p1, port1.traffic_classes, qos.TABLE_8_5)) + until(lambda: runs(port0, qos.TABLE_8_5)) + until(lambda: runs(port1, qos.TABLE_8_5)) with test.step("Reject deleting the profile while ports use it"): qos.must_reject("delete of a referenced profile", target, {}, diff --git a/test/case/interfaces/qos_queue_assignment/test.adoc b/test/case/interfaces/qos_queue_assignment/test.adoc index d5ad0d2ad0..1724c24cbe 100644 --- a/test/case/interfaces/qos_queue_assignment/test.adoc +++ b/test/case/interfaces/qos_queue_assignment/test.adoc @@ -9,10 +9,20 @@ which queue each priority uses. This test checks that frames end up in the queue the table names, for the `ieee` preset, the `ieee-sr` preset and a custom table. -A hundred datagrams are sent at each priority, routed through the DUT -to the listener, and the egress port's per-class counters are read -before and after. The class the table names must grow by at least a -hundred, and no other class by anywhere near it. +Datagrams are sent at each priority, routed through the DUT to the +listener. Which queue they took is read in one of two ways: + + - where the port counts the frames each queue sends, a hundred are sent + at each priority and its counters per traffic class are read before + and after with the get-statistics action. The class the table names + must grow by at least a hundred, and no other class by anywhere near + it + - a switch that counts per priority cannot show the queue that way. + There a gate control list opens the gate of one traffic class at a + time, twenty datagrams are sent at each priority, and only those of + the priorities the table puts in that class may reach the listener. + The listener is a static neighbour of the egress port for this, since + the DUT's own ARP would otherwise wait behind a closed gate Frames enter tagged, on a VLAN interface that takes the priority straight from the PCP, so the table on the egress port is all that is @@ -30,7 +40,10 @@ image::topology.svg[QoS Queue Assignment topology, align=center, scaledwidth=75% . Set up topology and attach to target DUT . Configure a routed path, tagged ingress with priority from PCP, egress under test . Set up the talker on VLAN 10 and the listener, resolve neighbours +. Add the listener as a static neighbour of the egress port . Apply the {name} traffic class table on the egress port +. Open the gate of one class at a time, verify only its priorities get through +. Turn the gates off . Send {COUNT} frames at each priority, verify the class each reached diff --git a/test/case/interfaces/qos_queue_assignment/test.py b/test/case/interfaces/qos_queue_assignment/test.py index 5cb4d4c389..7bde5a8681 100755 --- a/test/case/interfaces/qos_queue_assignment/test.py +++ b/test/case/interfaces/qos_queue_assignment/test.py @@ -7,10 +7,20 @@ in the queue the table names, for the `ieee` preset, the `ieee-sr` preset and a custom table. -A hundred datagrams are sent at each priority, routed through the DUT -to the listener, and the egress port's per-class counters are read -before and after. The class the table names must grow by at least a -hundred, and no other class by anywhere near it. +Datagrams are sent at each priority, routed through the DUT to the +listener. Which queue they took is read in one of two ways: + + - where the port counts the frames each queue sends, a hundred are sent + at each priority and its counters per traffic class are read before + and after with the get-statistics action. The class the table names + must grow by at least a hundred, and no other class by anywhere near + it + - a switch that counts per priority cannot show the queue that way. + There a gate control list opens the gate of one traffic class at a + time, twenty datagrams are sent at each priority, and only those of + the priorities the table puts in that class may reach the listener. + The listener is a static neighbour of the egress port for this, since + the DUT's own ARP would otherwise wait behind a closed gate Frames enter tagged, on a VLAN interface that takes the priority straight from the PCP, so the table on the egress port is all that is @@ -19,12 +29,43 @@ priority 0. What remains of the system's own traffic is a handful of frames. """ +import itertools +import json +import re import infamy import infamy.qos as qos from infamy.util import until PRIORITIES = range(8) COUNT = 100 # per priority; the DUT's own chatter is a few frames +BURST = 20 # per priority under gates, where nothing else gets through + + +def gates(port, tc=None): + """Gate control list that keeps only the gate of tc open, off without one""" + table = {"gate-enabled": False} + if tc is not None: + table = qos.gate_table([(1 << tc, 1_000_000)], cycle=1_000_000) + return {"ietf-interfaces": {"interfaces": {"interface": [ + {"name": port, "ieee802-dot1dc-sched-if:gate-parameter-table": table}]}}} + + +def open_gates(target, port): + """Gate states the port runs now, None while a new list is pending or none runs""" + data = target.get_data(f"/ietf-interfaces:interfaces/interface[name='{port}']") + iface = next(iter(data["interfaces"]["interface"]), {}) + table = (iface.get("ieee802-dot1dc-sched-if:gate-parameter-table") + or iface.get("gate-parameter-table") or {}) + entries = list(table.get("oper-control-list", {}).get("gate-control-entry", [])) + if table.get("config-pending") or len(entries) != 1: + return None + return entries[0]["gate-states-value"] + + +def arrived(packets, base): + """Datagrams per priority in tcpdump output, by the port they were sent to""" + ports = [int(port) for port in re.findall(r" > [0-9.]+\.(\d+): ", packets)] + return [ports.count(base + prio) for prio in PRIORITIES] with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): @@ -36,8 +77,17 @@ hd0 = env["host"]["data1"] hd1 = env["host"]["data2"] - num_tc = infamy.capability.Port(target, td1).traffic_classes - print(f"{td1}: {num_tc} traffic classes") + port = infamy.capability.Port(target, td1, tgtssh) + num_tc = port.traffic_classes + by_gates = not port.queue_counters + if by_gates: + if not target.has_model("ieee802-dot1dc-sched-if"): + test.skip(f"{td1} counts per priority and the product has no gates") + port.require_offload(test, "time-aware-shaper") + elif not qos.class_stats(target, td1): + test.skip(f"{td1} keeps no counters per traffic class") + print(f"{td1}: {num_tc} traffic classes, queues read from " + f"{'the gates' if by_gates else 'the counters'}") tables = { "ieee": ({"preset": "ieee"}, qos.TABLE_8_5[num_tc]), "ieee-sr": ({"preset": "ieee-sr"}, qos.TABLE_34_1[num_tc]), @@ -99,7 +149,18 @@ assert dut_mac, "DUT MAC not resolved" print(f"DUT {td0}.10 is {dut_mac}") + if by_gates: + # The DUT's own ARP has priority 0, and would wait behind a closed gate + with test.step("Add the listener as a static neighbour of the egress port"): + mac = json.loads(ns1.runsh("ip -j link show dev iface").stdout)[0]["address"] + target.put_config_dicts({"ietf-interfaces": {"interfaces": {"interface": [{ + "name": td1, + "ipv4": {"neighbor": [{"ip": "192.168.11.2", "link-layer-address": mac}]} + }]}}}) + cleared = [] + # A closed gate keeps its datagrams, so each round sends to ports of its own + bases = itertools.count(7000, 8) for name, (table, prio_map) in tables.items(): with test.step(f"Apply the {name} traffic class table on the egress port"): # Preset and custom leaves are a choice, so clear the previous table @@ -112,21 +173,50 @@ } }}, delete=cleared) cleared = [qos.xpath(td1, "/egress/traffic-class-table")] - until(lambda: qos.scheduler_matches(qos.scheduler(tgtssh, td1), num_tc, prio_map)) + until(lambda: qos.runs_table(port, num_tc, prio_map)) ns0.must_reach("192.168.11.2") + if by_gates: + with test.step("Open the gate of one class at a time, verify only its priorities get through"): + for tc in sorted(set(prio_map)): + target.put_config_dicts(gates(td1, tc)) + until(lambda: open_gates(target, td1) == 1 << tc) + qos.wait_offload(port, "time-aware-shaper") + + base = next(bases) + pcap = ns1.pcap(f"udp and dst portrange {base}-{base + 7}") + with pcap: + for prio in PRIORITIES: + qos.mausezahn(ns0, "iface", "192.168.10.2", "192.168.11.2", dut_mac, + count=BURST, vid=10, pcp=prio, dport=base + prio) + got = arrived(pcap.tcpdump(), base) + print(f"{name}: gate of class {tc} open, datagrams per priority: {got}") + + for prio in PRIORITIES: + if prio_map[prio] == tc: + assert got[prio] == BURST, \ + f"class {tc}: {got[prio]} of {BURST} datagrams at priority {prio} arrived" + else: + assert got[prio] == 0, \ + f"class {tc}: {got[prio]} datagrams at priority {prio} got through a closed gate" + + with test.step("Turn the gates off"): + target.put_config_dicts(gates(td1)) + until(lambda: qos.root_kind(tgtssh, td1) == "ets") + continue + with test.step(f"Send {COUNT} frames at each priority, verify the class each reached"): for prio in PRIORITIES: - before = qos.class_stats(tgtssh, td1, num_tc) + before = qos.class_stats(target, td1) qos.mausezahn(ns0, "iface", "192.168.10.2", "192.168.11.2", dut_mac, count=COUNT, vid=10, pcp=prio) def landed(): - delta = qos.stats_delta(before, qos.class_stats(tgtssh, td1, num_tc)) + delta = qos.stats_delta(before, qos.class_stats(target, td1)) return delta.get(prio_map[prio], {}).get("packets", 0) >= COUNT until(landed, attempts=20) - delta = qos.stats_delta(before, qos.class_stats(tgtssh, td1, num_tc)) + delta = qos.stats_delta(before, qos.class_stats(target, td1)) got = {tc: d["packets"] for tc, d in delta.items() if d["packets"]} print(f"{name}: priority {prio} -> class {prio_map[prio]}: {got}") diff --git a/test/case/interfaces/qos_traffic_class/test.adoc b/test/case/interfaces/qos_traffic_class/test.adoc index b88a5b5ae8..d81e119b3a 100644 --- a/test/case/interfaces/qos_traffic_class/test.adoc +++ b/test/case/interfaces/qos_traffic_class/test.adoc @@ -28,6 +28,10 @@ numbering requires. The egress shaper must be a tbf root qdisc above the same ets table. The operational datastore must report throughout whether the port's switch hardware runs transmission selection. +A switch that picks the queue where a frame comes in takes the map in +its classification instead: there the DCB table of the port must hold +the traffic class of each PCP, and the priomap one class per priority. + The port's class count comes from its transmit queues, or eight for a single-queue port. @@ -39,7 +43,7 @@ image::topology.svg[QoS Traffic Classes and Transmission Selection topology, ali . Set up topology and attach to target DUT . Configure a custom map, the two lowest classes sharing 67:33 -. Verify the root qdisc carries the custom map and shares +. Verify the port runs the custom map and shares . Verify the offload capability matches the qdisc . Switch to the ieee-sr preset and verify SR classes on top . Add a 10 Mbps egress shaper and verify the tbf root above the ets table diff --git a/test/case/interfaces/qos_traffic_class/test.py b/test/case/interfaces/qos_traffic_class/test.py index fce83667b9..f921c3ed8e 100755 --- a/test/case/interfaces/qos_traffic_class/test.py +++ b/test/case/interfaces/qos_traffic_class/test.py @@ -26,60 +26,18 @@ the same ets table. The operational datastore must report throughout whether the port's switch hardware runs transmission selection. +A switch that picks the queue where a frame comes in takes the map in +its classification instead: there the DCB table of the port must hold +the traffic class of each PCP, and the priomap one class per priority. + The port's class count comes from its transmit queues, or eight for a single-queue port. """ -import json import infamy import infamy.qos as qos from infamy.util import until # IEEE 802.1Q-2022 Table 8-5 and Table 34-1, indexed by class count -TABLE_8_5 = { - 2: [0, 0, 0, 0, 1, 1, 1, 1], - 3: [0, 0, 0, 0, 1, 1, 2, 2], - 4: [0, 0, 1, 1, 2, 2, 3, 3], - 5: [0, 0, 1, 1, 2, 2, 3, 4], - 6: [1, 0, 2, 2, 3, 3, 4, 5], - 7: [1, 0, 2, 3, 4, 4, 5, 6], - 8: [1, 0, 2, 3, 4, 5, 6, 7], -} -TABLE_34_1 = { - 2: [0, 0, 1, 1, 0, 0, 0, 0], - 3: [0, 0, 1, 2, 0, 0, 0, 0], - 4: [0, 0, 2, 3, 1, 1, 1, 1], - 5: [0, 0, 3, 4, 1, 1, 2, 2], - 6: [0, 0, 4, 5, 1, 1, 2, 3], - 7: [0, 0, 5, 6, 1, 2, 3, 4], - 8: [1, 0, 6, 7, 2, 3, 4, 5], -} - - -def qos_xpath(port, path=""): - return f"/ietf-interfaces:interfaces/interface[name='{port}']/infix-interfaces:qos{path}" - - -def root_qdisc(ssh, port): - """Return the root qdisc of port as a dict, or None""" - out = ssh.runsh(f"tc -j qdisc show dev {port}").stdout - for qdisc in json.loads(out or "[]"): - if qdisc.get("root"): - return qdisc - return None - - -def qdisc_matches(qdisc, num_tc, prio_map, strict, quanta): - """Check a root qdisc against the expected 802.1Q table""" - if not qdisc: - return False - opts = qdisc.get("options", {}) - if qdisc["kind"] == "ets": - return (opts.get("bands") == num_tc and opts.get("strict") == strict - and opts.get("quanta", []) == quanta - and opts.get("priomap", [])[:8] == [num_tc - 1 - tc for tc in prio_map]) - return False - - with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() @@ -93,10 +51,15 @@ def qdisc_matches(qdisc, num_tc, prio_map, strict, quanta): assert num_tc and 2 <= num_tc <= 8, f"max-traffic-classes {num_tc}" offloaded = cap.offloads("transmission-selection") + def runs(prio_map, strict, quanta, root="ets"): + """Whether the port runs the table and layout, under that kind of root qdisc""" + return (qos.root_kind(tgtssh, port) == root + and qos.runs_table(cap, num_tc, prio_map, strict, quanta)) + with test.step("Configure a custom map, the two lowest classes sharing 67:33"): # Table 8-5 with the two lowest classes swapped, so the map is # visibly custom on any class count - custom = [1 if tc == 0 else 0 if tc == 1 else tc for tc in TABLE_8_5[num_tc]] + custom = [1 if tc == 0 else 0 if tc == 1 else tc for tc in qos.TABLE_8_5[num_tc]] table = {f"priority{prio}": tc for prio, tc in enumerate(custom)} target.put_config_dicts({"ietf-interfaces": { @@ -119,12 +82,11 @@ def qdisc_matches(qdisc, num_tc, prio_map, strict, quanta): } }}) - with test.step("Verify the root qdisc carries the custom map and shares"): - until(lambda: qdisc_matches(root_qdisc(tgtssh, port), num_tc, custom, num_tc - 2, - [67 * 1514, 33 * 1514])) + with test.step("Verify the port runs the custom map and shares"): + until(lambda: runs(custom, num_tc - 2, [67 * 1514, 33 * 1514])) with test.step("Verify the offload capability matches the qdisc"): - taken = root_qdisc(tgtssh, port).get("offloaded", False) + taken = qos.root_qdisc(tgtssh, port).get("offloaded", False) until(lambda: cap.offloads("transmission-selection") == taken) with test.step("Switch to the ieee-sr preset and verify SR classes on top"): @@ -137,8 +99,8 @@ def qdisc_matches(qdisc, num_tc, prio_map, strict, quanta): } }] } - }}, delete=[qos_xpath(port, "/egress")]) - until(lambda: qdisc_matches(root_qdisc(tgtssh, port), num_tc, TABLE_34_1[num_tc], num_tc, [])) + }}, delete=[qos.xpath(port, "/egress")]) + until(lambda: runs(qos.TABLE_34_1[num_tc], num_tc, [])) with test.step("Add a 10 Mbps egress shaper and verify the tbf root above the ets table"): target.put_config_dicts({"ietf-interfaces": { @@ -153,21 +115,18 @@ def qdisc_matches(qdisc, num_tc, prio_map, strict, quanta): }}) def shaped(): - out = tgtssh.runsh(f"tc -j qdisc show dev {port}").stdout - qdiscs = json.loads(out or "[]") - root = [q for q in qdiscs if q.get("root")] - child = [q for q in qdiscs if q.get("parent") == "1:1"] - return (root and root[0]["kind"] == "tbf" and root[0]["options"]["rate"] == 1250000 - and child and qdisc_matches(child[0], num_tc, TABLE_34_1[num_tc], num_tc, [])) + root = qos.root_qdisc(tgtssh, port) or {} + return (root.get("options", {}).get("rate") == 1250000 + and runs(qos.TABLE_34_1[num_tc], num_tc, [], root="tbf")) until(shaped) with test.step("Remove the egress shaper and verify the scheduler is the root again"): - target.put_config_dicts({}, delete=[qos_xpath(port, "/egress-shaper")]) - until(lambda: qdisc_matches(root_qdisc(tgtssh, port), num_tc, TABLE_34_1[num_tc], num_tc, [])) + target.put_config_dicts({}, delete=[qos.xpath(port, "/egress-shaper")]) + until(lambda: runs(qos.TABLE_34_1[num_tc], num_tc, [])) with test.step("Remove qos configuration and verify the default table is back"): - target.put_config_dicts({}, delete=[qos_xpath(port)]) - until(lambda: qdisc_matches(root_qdisc(tgtssh, port), num_tc, TABLE_8_5[num_tc], num_tc, [])) + target.put_config_dicts({}, delete=[qos.xpath(port)]) + until(lambda: runs(qos.TABLE_8_5[num_tc], num_tc, [])) assert cap.offloads("transmission-selection") == offloaded test.succeed() diff --git a/test/case/interfaces/qos_weighted_sharing/test.py b/test/case/interfaces/qos_weighted_sharing/test.py index 18f698a45d..de05d6585e 100755 --- a/test/case/interfaces/qos_weighted_sharing/test.py +++ b/test/case/interfaces/qos_weighted_sharing/test.py @@ -118,9 +118,8 @@ def apply(high, low): }}) quanta = [share * qos.ETS_QUANTUM_UNIT for share in [high, low] + [FILLER] * LOW] - until(lambda: qos.scheduler_matches(qos.scheduler(tgtssh, td1), num_tc, - qos.TABLE_8_5[num_tc], - strict=num_tc - 2 - LOW, quanta=quanta)) + until(lambda: qos.runs_table(port, num_tc, qos.TABLE_8_5[num_tc], + strict=num_tc - 2 - LOW, quanta=quanta)) qos.wait_offload(port) ns0.must_reach("192.168.20.2") diff --git a/test/infamy/capability.py b/test/infamy/capability.py index 46fa5cbfd4..8e2e5e67a9 100644 --- a/test/infamy/capability.py +++ b/test/infamy/capability.py @@ -23,6 +23,7 @@ def __init__(self, target, name, ssh=None): self._switched = None self._driver = None self._tx_queues = None + self._quirks = {} @property def caps(self): @@ -63,6 +64,45 @@ def switched(self): return self._switched + def _has_quirk(self, quirk): + """Whether the port has @quirk in the device's interface quirks""" + if quirk not in self._quirks: + out = self.ssh.runsh( + f"/usr/libexec/infix/has-quirk {quirk} {self.name}", retry=True).stdout + self._quirks[quirk] = out.strip() == "true" + + return self._quirks[quirk] + + @property + def class_at_ingress(self): + """Whether the port's switch picks the queue where a frame comes in. + + Such a port takes the traffic class table in its classification: + its DCB table holds the traffic class of each PCP, and its + scheduler keeps one class per priority. + """ + return self._has_quirk("qos-class-at-ingress") + + @property + def ets_table(self): + """Whether the port's switch takes the traffic class table as the DCB ETS object. + + The priority to traffic class map of the object then holds the + table, and the port's scheduler keeps one class per priority. + """ + return self._has_quirk("qos-ets-table") + + @property + def queue_counters(self): + """Whether the port's traffic class counters are counted at its queues. + + They are on a port the kernel serves, and on a switch that counts + the frames each queue sends. A switch that counts per priority + works its traffic class counters out from the table, so they + cannot show which queue a frame took. + """ + return not self.switched or self._has_quirk("qos-queue-counters") + @property def driver(self): """The driver bound to the port, None when it has no device""" diff --git a/test/infamy/qos.py b/test/infamy/qos.py index 47c25a220d..dfe57a2edf 100644 --- a/test/infamy/qos.py +++ b/test/infamy/qos.py @@ -7,7 +7,6 @@ in traffic classes and hides that. """ import json -import re import subprocess import time @@ -156,42 +155,43 @@ def scheduler_matches(qdisc, num_tc, prio_map, strict=None, quanta=None): return False -def class_stats(ssh, port, num_tc): - """Per traffic class counters of the scheduler: {tc: {packets, bytes, drops}} +def runs_table(port, num_tc, prio_map, strict=None, quanta=None): + """Whether a port runs a traffic class table and scheduler layout - Read from tc -s class show. iproute2 6.14 prints classes as JSON, - older releases ignore -j for classes and print text, so both are - parsed. + The table is in the scheduler on most ports. Two kinds of switch + port keep one class per priority there and the table elsewhere: in + the DCB ETS object, or, where the switch picks the queue as a frame + comes in, in the DCB table for PCP, which shows the table as long as + the port has the default pcp-map. """ - out = ssh.runsh(f"tc -s -j class show dev {port}").stdout.strip() - stats = {} + if port.ets_table: + show, entry = "ets show dev {dev} prio-tc", "{prio}:{tc}" + elif port.class_at_ingress: + show, entry = "app show dev {dev} pcp-prio", "{prio}nd:{tc}" + else: + return scheduler_matches(scheduler(port.ssh, port.name), num_tc, prio_map, strict, quanta) - def tc_of(kind, handle): - minor = int(handle.split(":")[1], 16) - if kind == "ets": - return num_tc - minor # band 0, minor 1, is the top class - return None + direct = [min(prio, num_tc - 1) for prio in range(8)] + if not scheduler_matches(scheduler(port.ssh, port.name), num_tc, direct, strict, quanta): + return False - if out.startswith("["): - for cls in json.loads(out): - tc = tc_of(cls.get("class"), cls.get("handle", "0:0")) - if tc is not None: - st = cls.get("stats", cls) # tc 6.14 nests the counters - stats[tc] = {"packets": st.get("packets", 0), - "bytes": st.get("bytes", 0), - "drops": st.get("drops", 0)} - return stats - - current = None - for line in out.splitlines(): - head = re.match(r"class (\S+) (\S+)", line) - if head: - current = tc_of(head.group(1), head.group(2)) - continue - sent = re.match(r"\s*Sent (\d+) bytes (\d+) pkt \(dropped (\d+)", line) - if sent and current is not None: - stats[current] = {"bytes": int(sent.group(1)), "packets": int(sent.group(2)), - "drops": int(sent.group(3))} + out = port.ssh.runsh(f"dcb {show.format(dev=port.name)} 2>/dev/null").stdout.split() + return all(entry.format(prio=prio, tc=prio_map[prio]) in out for prio in range(8)) + + +def class_stats(target, port): + """Transmit counters per traffic class: {tc: {packets, bytes, drops}} + + Read with the get-statistics action of the port, on request. A + counter the port does not keep reads as 0, and a port that keeps + none gives an empty dict. + """ + out = target.call_action_output(xpath(port, "/get-statistics")) + stats = {} + for cls in out.get("traffic-class", []): + stats[int(cls["id"])] = {"packets": int(cls.get("out-frames", 0)), + "bytes": int(cls.get("out-octets", 0)), + "drops": int(cls.get("out-discards", 0))} return stats From 12eca09ab85c409de6853739faf06aaa95e3174a Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Wed, 2 Dec 2026 11:19:39 +0100 Subject: [PATCH 9/9] test: add QoS bridge PCP preservation A frame must cross a bridge with its priority unchanged, whatever the traffic class table does to its queue. Send frames through two bridged ports and check the PCP they leave with: for the ieee and ieee-sr tables, for an untagged frame tagged on the way out, for a table where priorities share a class, and for a custom pcp-map. On a device with several switch chips the test prints whether the two ports are on one chip or on different ones. Signed-off-by: Joachim Wiberg --- test/case/interfaces/Readme.adoc | 4 + test/case/interfaces/qos.yaml | 3 + .../interfaces/qos_bridge_pcp/Readme.adoc | 1 + test/case/interfaces/qos_bridge_pcp/test.adoc | 48 ++++ test/case/interfaces/qos_bridge_pcp/test.py | 231 ++++++++++++++++++ .../interfaces/qos_bridge_pcp/topology.dot | 24 ++ .../interfaces/qos_bridge_pcp/topology.svg | 51 ++++ 7 files changed, 362 insertions(+) create mode 120000 test/case/interfaces/qos_bridge_pcp/Readme.adoc create mode 100644 test/case/interfaces/qos_bridge_pcp/test.adoc create mode 100755 test/case/interfaces/qos_bridge_pcp/test.py create mode 100644 test/case/interfaces/qos_bridge_pcp/topology.dot create mode 100644 test/case/interfaces/qos_bridge_pcp/topology.svg diff --git a/test/case/interfaces/Readme.adoc b/test/case/interfaces/Readme.adoc index ef94777c3e..bc02ec5df0 100644 --- a/test/case/interfaces/Readme.adoc +++ b/test/case/interfaces/Readme.adoc @@ -146,6 +146,10 @@ include::qos_bridge_classify/Readme.adoc[] <<< +include::qos_bridge_pcp/Readme.adoc[] + +<<< + include::qos_queue_assignment/Readme.adoc[] <<< diff --git a/test/case/interfaces/qos.yaml b/test/case/interfaces/qos.yaml index e3ed2795d9..11c91df680 100644 --- a/test/case/interfaces/qos.yaml +++ b/test/case/interfaces/qos.yaml @@ -17,6 +17,9 @@ - name: QoS Bridge Classification and Remarking case: qos_bridge_classify/test.py +- name: QoS Bridge PCP Preservation + case: qos_bridge_pcp/test.py + - name: QoS Queue Assignment case: qos_queue_assignment/test.py diff --git a/test/case/interfaces/qos_bridge_pcp/Readme.adoc b/test/case/interfaces/qos_bridge_pcp/Readme.adoc new file mode 120000 index 0000000000..ae32c84120 --- /dev/null +++ b/test/case/interfaces/qos_bridge_pcp/Readme.adoc @@ -0,0 +1 @@ +test.adoc \ No newline at end of file diff --git a/test/case/interfaces/qos_bridge_pcp/test.adoc b/test/case/interfaces/qos_bridge_pcp/test.adoc new file mode 100644 index 0000000000..1419e94c6a --- /dev/null +++ b/test/case/interfaces/qos_bridge_pcp/test.adoc @@ -0,0 +1,48 @@ +=== QoS Bridge PCP Preservation + +ifdef::topdoc[:imagesdir: {topdoc}../../test/case/interfaces/qos_bridge_pcp] + +==== Description + +A frame should cross a bridge with its priority unchanged, whatever the +traffic class table does to its queue. Bridge two ports, send frames +straight through, and read the PCP they leave with at the egress port: + + - default settings, the `ieee` table: a tagged frame leaves with the PCP + it came in with, all eight values, so PCP 0 and 1 are not swapped + - the `ieee-sr` table: the same + - an untagged frame, tagged on the way out: it leaves with the default + priority of the ingress port as PCP, not with its traffic class + - a table where two priorities share a traffic class: a tagged frame + keeps its PCP, since the class does not tell the priorities apart + - a custom `pcp-map`, PCP 3 to priority 6, PCP 0 to priority 4, PCP 7 + unmapped to the default priority 2: a switch fabric writes the + priority as PCP, a frame the kernel forwards keeps its PCP + +On a device with several switch chips the two ports may sit on different +chips, and the frame must come out the same. The test prints which case +it ran. The PCP of an untagged frame is checked only on a switch fabric, +since the kernel does not write the priority to a tag it adds. + +==== Topology + +image::topology.svg[QoS Bridge PCP Preservation topology, align=center, scaledwidth=75%] + +==== Sequence + +. Set up topology and attach to target DUT +. Configure a VLAN bridge, VLAN 10 tagged and VLAN 20 untagged on ingress +. Set up host namespaces, VLAN 10 tagged on both, VLAN 20 untagged on the sender +. Verify classification is offloaded +. Send tagged frames with PCP 0 to 7 and default settings, verify the PCP is unchanged +. Verify an untagged frame leaves with PCP 0, the default priority +. Set default priority 1 on ingress +. Verify an untagged frame leaves with PCP 1 and tagged frames are unchanged +. Set the ieee-sr table and default priority 3 +. Verify tagged frames are unchanged and an untagged frame leaves with PCP 3 +. Set a table where two priorities share each traffic class +. Verify tagged frames keep their PCP +. Set the ieee table, default priority 2 and a custom pcp-map +. Verify a fabric writes the mapped priority as PCP and the kernel leaves the PCP + + diff --git a/test/case/interfaces/qos_bridge_pcp/test.py b/test/case/interfaces/qos_bridge_pcp/test.py new file mode 100755 index 0000000000..629e8bac9a --- /dev/null +++ b/test/case/interfaces/qos_bridge_pcp/test.py @@ -0,0 +1,231 @@ +#!/usr/bin/env python3 +""" +QoS Bridge PCP Preservation + +A frame should cross a bridge with its priority unchanged, whatever the +traffic class table does to its queue. Bridge two ports, send frames +straight through, and read the PCP they leave with at the egress port: + + - default settings, the `ieee` table: a tagged frame leaves with the PCP + it came in with, all eight values, so PCP 0 and 1 are not swapped + - the `ieee-sr` table: the same + - an untagged frame, tagged on the way out: it leaves with the default + priority of the ingress port as PCP, not with its traffic class + - a table where two priorities share a traffic class: a tagged frame + keeps its PCP, since the class does not tell the priorities apart + - a custom `pcp-map`, PCP 3 to priority 6, PCP 0 to priority 4, PCP 7 + unmapped to the default priority 2: a switch fabric writes the + priority as PCP, a frame the kernel forwards keeps its PCP + +On a device with several switch chips the two ports may sit on different +chips, and the frame must come out the same. The test prints which case +it ran. The PCP of an untagged frame is checked only on a switch fabric, +since the kernel does not write the priority to a tag it adds. +""" +import re +import infamy +import infamy.qos as qos +from infamy.util import until + +PCPS = range(8) + + +def parse(packets): + """Return {icmp id: (vid, pcp)} from tcpdump -e -v output""" + seen = {} + for m in re.finditer(r"vlan (\d+), p (\d+), .*?ICMP echo request, id (\d+)", packets, re.S): + seen[int(m.group(3))] = (int(m.group(1)), int(m.group(2))) + return seen + + +with infamy.Test() as test: + with test.step("Set up topology and attach to target DUT"): + env = infamy.Env() + target = env.attach("target", "mgmt") + tgtssh = env.attach("target", "mgmt", "ssh") + td0 = target["data1"] + td1 = target["data2"] + hd0 = env["host"]["data1"] + hd1 = env["host"]["data2"] + + ingress = infamy.capability.Port(target, td0, tgtssh) + num_tc = ingress.traffic_classes + dcb = bool(ingress.trust_orders) + if ingress.switched and not dcb: + test.skip(f"{td0} forwards in hardware and its driver has no DCB tables") + + if ingress.switched: + chips = [tgtssh.runsh(f"readlink -f /sys/class/net/{port}/device").stdout.strip() + for port in (td0, td1)] + where = "one switch chip" if chips[0] == chips[1] else "different switch chips" + print(f"{td0} and {td1} are on {where}") + else: + print(f"{td0} is not a switch port, the kernel forwards") + + def qos_config(ingress_qos, table, clear=False): + """Ingress settings on the first port, one traffic class table on both""" + delete = [qos.xpath(port, "/egress/traffic-class-table") for port in (td0, td1)] + target.put_config_dicts({"ietf-interfaces": { + "interfaces": { + "interface": [ + {"name": td0, "infix-interfaces:qos": { + "ingress": ingress_qos, "egress": {"traffic-class-table": table}}}, + {"name": td1, "infix-interfaces:qos": { + "egress": {"traffic-class-table": table}}}, + ] + } + }}, delete=delete if clear else []) + + with test.step("Configure a VLAN bridge, VLAN 10 tagged and VLAN 20 untagged on ingress"): + target.put_config_dicts({"ietf-interfaces": { + "interfaces": { + "interface": [ + { + "name": "br0", + "type": "infix-if-type:bridge", + "enabled": True, + "bridge": { + "vlans": { + "vlan": [ + {"vid": 10, "tagged": [td0, td1]}, + {"vid": 20, "untagged": [td0], "tagged": [td1]}, + ] + } + } + }, + { + "name": td0, + "enabled": True, + "infix-interfaces:bridge-port": {"pvid": 20, "bridge": "br0"}, + }, + { + "name": td1, + "enabled": True, + "infix-interfaces:bridge-port": {"bridge": "br0"}, + }, + ] + } + }}) + + with infamy.IsolatedMacVlan(hd0) as ns0, \ + infamy.IsolatedMacVlan(hd1) as ns1: + + with test.step("Set up host namespaces, VLAN 10 tagged on both, VLAN 20 untagged on the sender"): + ns0.runsh(""" + set -ex + ip link set iface up + ip addr add 192.168.20.1/24 dev iface + ip link add dev vlan10 link iface up type vlan id 10 + ip addr add 192.168.10.1/24 dev vlan10 + """) + ns1.runsh(""" + set -ex + ip link set iface up + ip link add dev vlan10 link iface up type vlan id 10 + ip addr add 192.168.10.2/24 dev vlan10 + ip link add dev vlan20 link iface up type vlan id 20 + ip addr add 192.168.20.2/24 dev vlan20 + """) + ns0.must_reach("192.168.20.2") + ns0.must_reach("192.168.10.2") + + if dcb: + with test.step("Verify classification is offloaded"): + until(lambda: ingress.offloads("classification")) + + def fabric(): + """Whether the egress port writes the PCP from the priority right now""" + return "prio-pcp" in tgtssh.runsh(f"dcb rewr show dev {td1} 2>/dev/null").stdout + + def send(pcps): + """One tagged echo request per PCP and one untagged, captured at the egress port + + The ICMP id of a tagged request is its PCP, 8 for the untagged one. + """ + pcap = ns1.pcap("icmp[icmptype] == icmp-echo") + with pcap: + for pcp in pcps: + qmap = " ".join(f"{prio}:{pcp}" for prio in range(8)) + ns0.runsh(f"ip link set dev vlan10 type vlan egress-qos-map {qmap}") + ns0.runsh(f"ping -c1 -w2 -e {pcp} 192.168.10.2") + ns0.runsh(f"ping -c1 -w2 -e 8 192.168.20.2") + packets = pcap.tcpdump("-e -v") + print(packets) + return parse(packets) + + def tagged(seen, pcp, want, what): + assert pcp in seen, f"{what}: no echo request with PCP {pcp} captured" + assert seen[pcp] == (10, want), \ + f"{what}: PCP {pcp} left as (vid, pcp) {seen[pcp]}, expected {(10, want)}" + + def untagged(seen, want, what): + assert 8 in seen, f"{what}: no untagged echo request captured" + if not fabric(): + print(f"{what}: untagged frame left as {seen[8]}, not checked in software") + return + assert seen[8] == (20, want), \ + f"{what}: untagged frame left as (vid, pcp) {seen[8]}, expected {(20, want)}" + + with test.step("Send tagged frames with PCP 0 to 7 and default settings, verify the PCP is unchanged"): + seen = send(PCPS) + for pcp in PCPS: + tagged(seen, pcp, pcp, "ieee") + + with test.step("Verify an untagged frame leaves with PCP 0, the default priority"): + untagged(seen, 0, "ieee") + + with test.step("Set default priority 1 on ingress"): + qos_config({"default-priority": 1}, {"preset": "ieee"}) + ns0.must_reach("192.168.20.2") + + with test.step("Verify an untagged frame leaves with PCP 1 and tagged frames are unchanged"): + seen = send(PCPS) + for pcp in PCPS: + tagged(seen, pcp, pcp, "ieee, default priority 1") + untagged(seen, 1, "ieee, default priority 1") + + with test.step("Set the ieee-sr table and default priority 3"): + qos_config({"default-priority": 3}, {"preset": "ieee-sr"}) + ns0.must_reach("192.168.20.2") + + with test.step("Verify tagged frames are unchanged and an untagged frame leaves with PCP 3"): + seen = send(PCPS) + for pcp in PCPS: + tagged(seen, pcp, pcp, "ieee-sr") + untagged(seen, 3, "ieee-sr, default priority 3") + + with test.step("Set a table where two priorities share each traffic class"): + shared = {f"priority{prio}": min(prio // 2, num_tc - 1) for prio in PCPS} + qos_config({"default-priority": 3}, shared, clear=True) + ns0.must_reach("192.168.10.2") + + with test.step("Verify tagged frames keep their PCP"): + seen = send(PCPS) + for pcp in PCPS: + tagged(seen, pcp, pcp, "shared classes") + + with test.step("Set the ieee table, default priority 2 and a custom pcp-map"): + custom = { + "default-priority": 2, + "pcp-map": { + "entry": [ + {"pcp": 3, "dei": "false", "priority": 6}, + {"pcp": 3, "dei": "true", "priority": 6}, + {"pcp": 0, "dei": "false", "priority": 4}, + {"pcp": 0, "dei": "true", "priority": 4}, + ] + }, + } + qos_config(custom, {"preset": "ieee"}, clear=True) + ns0.must_reach("192.168.10.2") + + with test.step("Verify a fabric writes the mapped priority as PCP and the kernel leaves the PCP"): + rewrites = fabric() + print(f"{td1} writes the PCP from the priority: {rewrites}") + seen = send((3, 0, 7)) + tagged(seen, 3, 6 if rewrites else 3, "custom pcp-map") + tagged(seen, 0, 4 if rewrites else 0, "custom pcp-map") + tagged(seen, 7, 2 if rewrites else 7, "custom pcp-map, unmapped PCP") + untagged(seen, 2, "custom pcp-map") + + test.succeed() diff --git a/test/case/interfaces/qos_bridge_pcp/topology.dot b/test/case/interfaces/qos_bridge_pcp/topology.dot new file mode 100644 index 0000000000..f288f2f951 --- /dev/null +++ b/test/case/interfaces/qos_bridge_pcp/topology.dot @@ -0,0 +1,24 @@ +graph "1x3" { + layout="neato"; + overlap="false"; + esep="+80"; + + node [shape=record, fontname="DejaVu Sans Mono, Book"]; + edge [color="cornflowerblue", penwidth="2", fontname="DejaVu Serif, Book"]; + + host [ + label="host | { mgmt | data1 | data2 }", + pos="0,12!", + requires="controller", + ]; + + target [ + label="{ mgmt | data1 | data2 } | target", + pos="10,12!", + requires="infix", + ]; + + host:mgmt -- target:mgmt [requires="mgmt", color="lightgray"] + host:data1 -- target:data1 [color="black"] + host:data2 -- target:data2 [color="black"] +} diff --git a/test/case/interfaces/qos_bridge_pcp/topology.svg b/test/case/interfaces/qos_bridge_pcp/topology.svg new file mode 100644 index 0000000000..9517e6397f --- /dev/null +++ b/test/case/interfaces/qos_bridge_pcp/topology.svg @@ -0,0 +1,51 @@ + + + + + + +1x3 + + + +host + +host + +mgmt + +data1 + +data2 + + + +target + +mgmt + +data1 + +data2 + +target + + + +host:mgmt--target:mgmt + + + + +host:data1--target:data1 + + + + +host:data2--target:data2 + + + +