* [PATCH net-next v2 1/2] net: dsa: realtek: rtl8365mb: default the egress scheduler to WFQ
2026-11-30 13:23 [PATCH net-next v2 0/2] net: dsa: realtek: rtl8365mb: offload ETS strict priority Oleksij Rempel
@ 2026-11-30 13:23 ` Oleksij Rempel
2026-11-30 13:23 ` [PATCH net-next v2 2/2] net: dsa: realtek: rtl8365mb: offload ETS strict priority scheduling Oleksij Rempel
1 sibling, 0 replies; 4+ messages in thread
From: Oleksij Rempel @ 2026-11-30 13:23 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Linus Walleij, Luiz Angelo Daros de Luca, Andrew Lunn,
Vladimir Oltean
Cc: Alvin Šipraga, Simon Horman, netdev, linux-kernel, kernel,
Oleksij Rempel
Set the egress scheduler of every port in use to WFQ (weighted fair
queuing) with equal weights at setup. WFQ serves all queues of a port
in turn, so no queue is served before another.
The chip resets every queue to strict priority. With strict priority a
busy higher queue can starve the lower ones.
By default every frame gets the Best Effort traffic type and uses one
queue. The scheduler change therefore shows only after apptrust or the
default 802.1Q priority of a port is configured.
The next patch lets tc switch a user port to strict priority. No tc
interface reaches the scheduler of the CPU port, so it stays on WFQ.
The microchip ksz9477 family driver uses the same default.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Changes in v2:
- No changes.
---
drivers/net/dsa/realtek/rtl8365mb_main.c | 4 ++
drivers/net/dsa/realtek/rtl8365mb_qos.c | 90 ++++++++++++++++++++++++++++++++
drivers/net/dsa/realtek/rtl8365mb_qos.h | 1 +
3 files changed, 95 insertions(+)
diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
index 6c11c3631eb10f8eebdb8526908534c2256ed12d..a81ef9dfaf970f45a988a1b496c011e0824ba939 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_main.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
@@ -3199,6 +3199,10 @@ static int rtl8365mb_setup(struct dsa_switch *ds)
if (ret)
goto out_teardown_irq;
+ ret = rtl8365mb_qos_sched_init(priv);
+ if (ret)
+ goto out_teardown_irq;
+
/* Start with all ports blocked, including unused ports */
dsa_switch_for_each_port(dp, ds) {
struct rtl8365mb_port *p = &mb->ports[dp->index];
diff --git a/drivers/net/dsa/realtek/rtl8365mb_qos.c b/drivers/net/dsa/realtek/rtl8365mb_qos.c
index 5b9e1abe75c8b43b0cb6d07de0fd2ac09353f9d1..25d18cbc6fd1228fb0bf5c535b2a16548d614087 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_qos.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_qos.c
@@ -90,6 +90,38 @@ static_assert(RTL8365MB_QOS_1Q_REMAP_REG(IEEE_8021Q_MAX_PRIORITIES - 1) <
static_assert(RTL8365MB_QOS_DSCP_PRI_REG(DSCP_MAX - 1) <
RTL8365MB_QOS_PORT_PRI_REG(0));
+/* Egress queue ids per port */
+#define RTL8365MB_QOS_SCHED_QIDS 8
+
+/* Egress scheduler queue type: one bit per (port, queue id), two ports per
+ * register
+ */
+#define RTL8365MB_QOS_SCHED_QTYPE_PORTS_PER_REG 2
+#define RTL8365MB_QOS_SCHED_QTYPE_REG(_p) \
+ (0x0302 + (_p) / RTL8365MB_QOS_SCHED_QTYPE_PORTS_PER_REG)
+#define RTL8365MB_QOS_SCHED_QTYPE_BIT(_p, _qid) \
+ (((_p) % RTL8365MB_QOS_SCHED_QTYPE_PORTS_PER_REG) * \
+ RTL8365MB_QOS_SCHED_QIDS + (_qid))
+
+#define RTL8365MB_QOS_SCHED_QTYPE_STRICT 0
+#define RTL8365MB_QOS_SCHED_QTYPE_WFQ 1
+
+static_assert(RTL8365MB_QOS_SCHED_QIDS *
+ RTL8365MB_QOS_SCHED_QTYPE_PORTS_PER_REG <=
+ RTL8365MB_QOS_REG_BITS);
+
+/* WFQ weight of a queue: one whole register per (port, queue id) */
+#define RTL8365MB_QOS_SCHED_WFQ_WEIGHT_REG(_p, _qid) \
+ (0x030c + (_p) * RTL8365MB_QOS_SCHED_QIDS + (_qid))
+
+/* The unit of the WFQ weight is unknown; the driver writes the same weight to
+ * every queue.
+ */
+#define RTL8365MB_QOS_SCHED_WFQ_WEIGHT_DEFAULT 1
+
+static_assert(RTL8365MB_QOS_SCHED_QTYPE_REG(RTL8365MB_QOS_MAX_PORTS - 1) <
+ RTL8365MB_QOS_SCHED_WFQ_WEIGHT_REG(0, 0));
+
/* Priority-decision weight tables. In the driver's model of the decision
* hardware, a source ranks by its highest set weight bit (a one-hot rank), not
* by numeric magnitude. A weight of zero disables the source.
@@ -294,6 +326,8 @@ static int rtl8365mb_qos_set_qmap_qid(struct realtek_priv *priv, int qmap,
*/
#define RTL8365MB_QOS_QID_TOP 7
+static_assert(RTL8365MB_QOS_QID_TOP < RTL8365MB_QOS_SCHED_QIDS);
+
static u8 rtl8365mb_qos_tc_to_qid(unsigned int num_queues, u8 tc)
{
if (num_queues > 1 && tc == num_queues - 1)
@@ -334,6 +368,62 @@ int rtl8365mb_qos_qmap_init(struct realtek_priv *priv)
return 0;
}
+static int rtl8365mb_qos_write_port_sched(struct realtek_priv *priv, int port,
+ unsigned int num_queues)
+{
+ u32 weight = RTL8365MB_QOS_SCHED_WFQ_WEIGHT_DEFAULT;
+ unsigned int tc;
+ u32 qtype;
+ int ret;
+ u32 reg;
+
+ if (!num_queues || num_queues > RTL8365MB_QOS_SCHED_QIDS)
+ return -EINVAL;
+
+ reg = RTL8365MB_QOS_SCHED_QTYPE_REG(port);
+ qtype = RTL8365MB_QOS_SCHED_QTYPE_WFQ;
+
+ /* Program the queue ids that the traffic-type-to-queue map uses */
+ for (tc = 0; tc < num_queues; tc++) {
+ u32 mask;
+ u32 wreg;
+ u8 qid;
+
+ qid = rtl8365mb_qos_tc_to_qid(num_queues, tc);
+ mask = BIT(RTL8365MB_QOS_SCHED_QTYPE_BIT(port, qid));
+ wreg = RTL8365MB_QOS_SCHED_WFQ_WEIGHT_REG(port, qid);
+
+ ret = regmap_write(priv->map, wreg, weight);
+ if (ret)
+ return ret;
+
+ ret = rtl8365mb_qos_regmap_update_field(priv, reg, mask, qtype);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
+/* The chip resets every queue to strict priority. Put the ports in use on
+ * WFQ with equal weights.
+ */
+int rtl8365mb_qos_sched_init(struct realtek_priv *priv)
+{
+ unsigned int nq = priv->ds.num_tx_queues;
+ struct dsa_port *dp;
+ int ret;
+
+ /* Unused ports carry no traffic; their scheduler is left alone */
+ dsa_switch_for_each_available_port(dp, &priv->ds) {
+ ret = rtl8365mb_qos_write_port_sched(priv, dp->index, nq);
+ if (ret)
+ return ret;
+ }
+
+ return 0;
+}
+
static int rtl8365mb_qos_set_pridec(struct realtek_priv *priv, int table,
int src, u8 weight)
{
diff --git a/drivers/net/dsa/realtek/rtl8365mb_qos.h b/drivers/net/dsa/realtek/rtl8365mb_qos.h
index 9602807f7db5b9c5bf0202612e4cd77b85079cb7..1daeee16e47294dead49b0843a863991de9731cd 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_qos.h
+++ b/drivers/net/dsa/realtek/rtl8365mb_qos.h
@@ -19,6 +19,7 @@ struct realtek_priv;
int rtl8365mb_qos_pridec_init(struct realtek_priv *priv);
int rtl8365mb_qos_qmap_init(struct realtek_priv *priv);
+int rtl8365mb_qos_sched_init(struct realtek_priv *priv);
int rtl8365mb_qos_get_port_prio(struct realtek_priv *priv, int port);
int rtl8365mb_qos_set_port_prio(struct realtek_priv *priv, int port, u8 iprio,
u8 untag_pcp);
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net-next v2 2/2] net: dsa: realtek: rtl8365mb: offload ETS strict priority scheduling
2026-11-30 13:23 [PATCH net-next v2 0/2] net: dsa: realtek: rtl8365mb: offload ETS strict priority Oleksij Rempel
2026-11-30 13:23 ` [PATCH net-next v2 1/2] net: dsa: realtek: rtl8365mb: default the egress scheduler to WFQ Oleksij Rempel
@ 2026-11-30 13:23 ` Oleksij Rempel
2026-12-01 13:26 ` netdev-bot+sashiko
1 sibling, 1 reply; 4+ messages in thread
From: Oleksij Rempel @ 2026-11-30 13:23 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Linus Walleij, Luiz Angelo Daros de Luca, Andrew Lunn,
Vladimir Oltean
Cc: Alvin Šipraga, Simon Horman, netdev, linux-kernel, kernel,
Oleksij Rempel
Offload the ETS qdisc so a user port can be switched from the WFQ
default to strict priority. With WFQ (weighted fair queuing) the
switch serves all queues of a port in turn, by their weights. By
default the driver sets equal weights, so no queue is served before
another. With strict priority a higher queue is always sent first.
Deleting the qdisc puts the port back on WFQ.
The driver offloads only strict bands. sch_ets gives each
bandwidth-sharing band a quantum in bytes. It is not known whether the
hardware WFQ counts bytes or frames. Even equal quanta therefore
cannot be offloaded.
The driver requires one band per queue, so the qdisc describes the
whole port. The driver does not map bands to queues.
If a root ets qdisc breaks one of these rules, the driver logs the
reason and refuses the offload. The qdisc then runs in software and
the port goes back to WFQ. An ets qdisc that is not the root qdisc is
not offloaded.
The priomap is not offloaded. The priomap maps skb->priority values to
bands. The switch queues a frame by its traffic type. The switch takes
it from the port default, the PCP or the DSCP, as the driver programs
it. Frames that the host sends get the default traffic type of the CPU
port. The driver cannot check one map against the other, so it accepts
any priomap.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
Q: What does the user see when the offload of a root ets qdisc is
refused?
A: tc succeeds, and the qdisc runs in software. The driver logs the
reason as "port N: ...". "tc qdisc show" does not mark the qdisc
as offloaded, also when the driver accepts it.
Q: What happens with hw-tc-offload turned off?
A: tc stops telling the driver about ets changes. The port keeps its
last scheduler setting. It follows tc again once the offload is on
and a root ets qdisc is installed again ("tc qdisc replace").
Deleting that qdisc then restores WFQ.
Q: Does the switch queue frames that the host sends by their sch_ets
band?
A: No, not in the switch. The tagger leaves the PRI_EN bit of the
CPU tag clear, so the CPU port default applies. With PRI_EN set,
the switch would use the PRI field of the CPU tag instead.
Q: What happens if a register write fails while the port goes back to
WFQ?
A: The driver stops at the failed write and logs the error. After an
MDIO error the state of the chip is unknown, so the driver does not
retry.
Changes in v2:
- Return -EOPNOTSUPP for TC_ETS_STATS, so tc does not mark the qdisc
as offloaded (sashiko).
- Rate-limit the refusal and restore-WFQ error logs (sashiko).
- Drop the "ets, not prio" paragraph from the message (sashiko).
- Say what the priomap and the switch map from, and drop the band/queue
sentences (sashiko).
- Add a Q&A on a failed register write while going back to WFQ
(sashiko).
---
drivers/net/dsa/realtek/realtek.h | 14 ++++
drivers/net/dsa/realtek/rtl8365mb_main.c | 4 ++
drivers/net/dsa/realtek/rtl8365mb_qos.c | 29 +++++++--
drivers/net/dsa/realtek/rtl8365mb_qos.h | 2 +
drivers/net/dsa/realtek/rtl83xx-qos.c | 108 +++++++++++++++++++++++++++++++
drivers/net/dsa/realtek/rtl83xx-qos.h | 2 +
6 files changed, 153 insertions(+), 6 deletions(-)
diff --git a/drivers/net/dsa/realtek/realtek.h b/drivers/net/dsa/realtek/realtek.h
index cfe56d30f5cb1c6fabf381dd55e73934cbc66abb..af8315a80c642175b955bd4a16c9d34c7c9efdb3 100644
--- a/drivers/net/dsa/realtek/realtek.h
+++ b/drivers/net/dsa/realtek/realtek.h
@@ -45,6 +45,11 @@ struct rtl8366_vlan_4k {
u8 fid;
};
+/* Size of ets_handle[]: the most ports a switch can have and still
+ * offload ETS.
+ */
+#define REALTEK_MAX_PORTS 11
+
struct realtek_fdb_entry {
u8 mac_addr[ETH_ALEN];
u16 vid;
@@ -98,6 +103,9 @@ struct realtek_priv {
int vlan4k_enabled;
void *chip_data; /* Per-chip extra variant data */
+
+ /* Handle of the ETS qdisc offloaded last on each port, or 0 */
+ u32 ets_handle[REALTEK_MAX_PORTS];
};
/* apptrust selector slots: the index into the trust[] array of the
@@ -192,6 +200,12 @@ struct realtek_ops {
const bool *trust, unsigned int n);
int (*qos_get_apptrust)(struct realtek_priv *priv, int port,
bool *trust, unsigned int n);
+ /* Set the scheduler of @port. If @strict, the queues for traffic
+ * classes 0..@num_queues - 1 are strict priority, and a higher traffic
+ * class is served first. Otherwise they are WFQ with equal weights.
+ */
+ int (*qos_set_port_sched)(struct realtek_priv *priv, int port,
+ unsigned int num_queues, bool strict);
};
struct realtek_variant {
diff --git a/drivers/net/dsa/realtek/rtl8365mb_main.c b/drivers/net/dsa/realtek/rtl8365mb_main.c
index a81ef9dfaf970f45a988a1b496c011e0824ba939..d08c389eeb7f0222355774ac18464d92331d1915 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_main.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_main.c
@@ -125,6 +125,8 @@
#define RTL8365MB_LEARN_LIMIT_MAX 2112
#define RTL8365MB_MAX_NUM_EXTINTS 3
+static_assert(RTL8365MB_MAX_NUM_PORTS <= REALTEK_MAX_PORTS);
+
/* Chip identification registers */
#define RTL8365MB_CHIP_ID_REG 0x1300
@@ -3487,6 +3489,7 @@ static const struct dsa_switch_ops rtl8365mb_switch_ops = {
.port_get_apptrust = rtl83xx_port_get_apptrust,
.port_set_apptrust = rtl83xx_port_set_apptrust,
.port_get_dscp_prio = rtl83xx_port_get_dscp_prio,
+ .port_setup_tc = rtl83xx_port_setup_tc,
.port_stp_state_set = rtl8365mb_port_stp_state_set,
.port_fast_age = rtl83xx_port_fast_age,
.port_fdb_add = rtl83xx_port_fdb_add,
@@ -3536,6 +3539,7 @@ static const struct realtek_ops rtl8365mb_ops = {
.qos_set_dscp_prio = rtl8365mb_qos_set_dscp_prio,
.qos_set_apptrust = rtl8365mb_qos_set_apptrust,
.qos_get_apptrust = rtl8365mb_qos_get_apptrust,
+ .qos_set_port_sched = rtl8365mb_qos_set_port_sched,
};
static const char *const rtl8365mb_supplies[] = {
diff --git a/drivers/net/dsa/realtek/rtl8365mb_qos.c b/drivers/net/dsa/realtek/rtl8365mb_qos.c
index 25d18cbc6fd1228fb0bf5c535b2a16548d614087..b3e43a4e136da6fff126a04835a1967963fcc12c 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_qos.c
+++ b/drivers/net/dsa/realtek/rtl8365mb_qos.c
@@ -368,8 +368,9 @@ int rtl8365mb_qos_qmap_init(struct realtek_priv *priv)
return 0;
}
+/* Under strict priority a higher queue id is served first */
static int rtl8365mb_qos_write_port_sched(struct realtek_priv *priv, int port,
- unsigned int num_queues)
+ unsigned int num_queues, bool strict)
{
u32 weight = RTL8365MB_QOS_SCHED_WFQ_WEIGHT_DEFAULT;
unsigned int tc;
@@ -381,7 +382,8 @@ static int rtl8365mb_qos_write_port_sched(struct realtek_priv *priv, int port,
return -EINVAL;
reg = RTL8365MB_QOS_SCHED_QTYPE_REG(port);
- qtype = RTL8365MB_QOS_SCHED_QTYPE_WFQ;
+ qtype = strict ? RTL8365MB_QOS_SCHED_QTYPE_STRICT :
+ RTL8365MB_QOS_SCHED_QTYPE_WFQ;
/* Program the queue ids that the traffic-type-to-queue map uses */
for (tc = 0; tc < num_queues; tc++) {
@@ -393,9 +395,11 @@ static int rtl8365mb_qos_write_port_sched(struct realtek_priv *priv, int port,
mask = BIT(RTL8365MB_QOS_SCHED_QTYPE_BIT(port, qid));
wreg = RTL8365MB_QOS_SCHED_WFQ_WEIGHT_REG(port, qid);
- ret = regmap_write(priv->map, wreg, weight);
- if (ret)
- return ret;
+ if (!strict) {
+ ret = regmap_write(priv->map, wreg, weight);
+ if (ret)
+ return ret;
+ }
ret = rtl8365mb_qos_regmap_update_field(priv, reg, mask, qtype);
if (ret)
@@ -405,6 +409,18 @@ static int rtl8365mb_qos_write_port_sched(struct realtek_priv *priv, int port,
return 0;
}
+int rtl8365mb_qos_set_port_sched(struct realtek_priv *priv, int port,
+ unsigned int num_queues, bool strict)
+{
+ int ret;
+
+ ret = rtl8365mb_qos_check_port(priv, port);
+ if (ret)
+ return ret;
+
+ return rtl8365mb_qos_write_port_sched(priv, port, num_queues, strict);
+}
+
/* The chip resets every queue to strict priority. Put the ports in use on
* WFQ with equal weights.
*/
@@ -416,7 +432,8 @@ int rtl8365mb_qos_sched_init(struct realtek_priv *priv)
/* Unused ports carry no traffic; their scheduler is left alone */
dsa_switch_for_each_available_port(dp, &priv->ds) {
- ret = rtl8365mb_qos_write_port_sched(priv, dp->index, nq);
+ ret = rtl8365mb_qos_write_port_sched(priv, dp->index, nq,
+ false);
if (ret)
return ret;
}
diff --git a/drivers/net/dsa/realtek/rtl8365mb_qos.h b/drivers/net/dsa/realtek/rtl8365mb_qos.h
index 1daeee16e47294dead49b0843a863991de9731cd..d89cf12b4fe436a010f5f777ddd49c15ec9039bc 100644
--- a/drivers/net/dsa/realtek/rtl8365mb_qos.h
+++ b/drivers/net/dsa/realtek/rtl8365mb_qos.h
@@ -26,6 +26,8 @@ int rtl8365mb_qos_set_port_prio(struct realtek_priv *priv, int port, u8 iprio,
int rtl8365mb_qos_set_pcp_prio(struct realtek_priv *priv, u8 pcp, u8 iprio);
int rtl8365mb_qos_get_dscp_prio(struct realtek_priv *priv, u8 dscp);
int rtl8365mb_qos_set_dscp_prio(struct realtek_priv *priv, u8 dscp, u8 iprio);
+int rtl8365mb_qos_set_port_sched(struct realtek_priv *priv, int port,
+ unsigned int num_queues, bool strict);
int rtl8365mb_qos_set_apptrust(struct realtek_priv *priv, int port,
const bool *trust, unsigned int n);
int rtl8365mb_qos_get_apptrust(struct realtek_priv *priv, int port, bool *trust,
diff --git a/drivers/net/dsa/realtek/rtl83xx-qos.c b/drivers/net/dsa/realtek/rtl83xx-qos.c
index f294222987eff8ba283688600c6eaba983669ea6..d2b21521b6de4e4fd0e05c9e04ce9628a444fe2a 100644
--- a/drivers/net/dsa/realtek/rtl83xx-qos.c
+++ b/drivers/net/dsa/realtek/rtl83xx-qos.c
@@ -16,6 +16,7 @@
#include <net/dscp.h>
#include <net/dsa.h>
#include <net/ieee8021q.h>
+#include <net/pkt_cls.h>
#include "realtek.h"
#include "rtl83xx-qos.h"
@@ -208,3 +209,110 @@ int rtl83xx_port_set_apptrust(struct dsa_switch *ds, int port, const u8 *sel,
ARRAY_SIZE(trust));
}
EXPORT_SYMBOL_NS_GPL(rtl83xx_port_set_apptrust, "REALTEK_DSA");
+
+static int
+rtl83xx_setup_tc_ets_replace(struct dsa_switch *ds, int port,
+ struct tc_ets_qopt_offload_replace_params *p)
+{
+ struct realtek_priv *priv = ds->priv;
+ unsigned int nq = ds->num_tx_queues;
+ int i;
+
+ /* The qdisc must have one band per queue. */
+ if (p->bands != nq) {
+ dev_err_ratelimited(priv->dev, "port %d: ETS must configure all %u bands\n",
+ port, nq);
+ return -EOPNOTSUPP;
+ }
+
+ /* Only strict bands can be offloaded. */
+ for (i = 0; i < p->bands; i++) {
+ if (p->quanta[i]) {
+ dev_err_ratelimited(priv->dev, "port %d: ETS weighted bands are not supported\n",
+ port);
+ return -EOPNOTSUPP;
+ }
+ }
+
+ /* The switch does not use the priomap. */
+ return priv->ops->qos_set_port_sched(priv, port, nq, true);
+}
+
+/* Forget the offloaded ETS qdisc of @port and put the port back on WFQ */
+static int rtl83xx_setup_tc_ets_restore_wfq(struct dsa_switch *ds, int port)
+{
+ struct realtek_priv *priv = ds->priv;
+ int ret;
+
+ priv->ets_handle[port] = 0;
+
+ ret = priv->ops->qos_set_port_sched(priv, port, ds->num_tx_queues,
+ false);
+ if (ret)
+ dev_err_ratelimited(priv->dev, "port %d: failed to restore WFQ: %pe\n",
+ port, ERR_PTR(ret));
+
+ return ret;
+}
+
+int rtl83xx_port_setup_tc(struct dsa_switch *ds, int port,
+ enum tc_setup_type type, void *type_data)
+{
+ struct tc_ets_qopt_offload *ets = type_data;
+ struct realtek_priv *priv = ds->priv;
+ int ret;
+
+ if (type != TC_SETUP_QDISC_ETS || !priv->ops->qos_set_port_sched)
+ return -EOPNOTSUPP;
+
+ if (port >= ARRAY_SIZE(priv->ets_handle) || ets->parent != TC_H_ROOT)
+ return -EOPNOTSUPP;
+
+ switch (ets->command) {
+ case TC_ETS_REPLACE:
+ /* sch_ets keeps the qdisc when the offload fails. Put the
+ * port back on WFQ so an earlier strict setup does not stay
+ * active.
+ */
+ ret = rtl83xx_setup_tc_ets_replace(ds, port,
+ &ets->replace_params);
+ if (ret) {
+ rtl83xx_setup_tc_ets_restore_wfq(ds, port);
+ return ret;
+ }
+
+ priv->ets_handle[port] = ets->handle;
+
+ return 0;
+
+ case TC_ETS_DESTROY:
+ /* sch_ets offloads a new root qdisc before it destroys the
+ * old one. Put the port back on WFQ only when DESTROY carries
+ * the handle that was offloaded last. The new qdisc can fail
+ * after the driver has offloaded it, for example in its rate
+ * estimator. In that case qdisc_create() destroys the new
+ * qdisc. Its DESTROY carries the handle offloaded last, so the
+ * port goes back to WFQ. The old qdisc keeps running in
+ * software.
+ *
+ * With hw-tc-offload off, sch_ets sends no DESTROY, so the
+ * port stays strict.
+ */
+ if (ets->handle != priv->ets_handle[port])
+ return 0;
+
+ return rtl83xx_setup_tc_ets_restore_wfq(ds, port);
+
+ case TC_ETS_STATS:
+ /* Do not mark the qdisc as offloaded: its priomap is not.
+ * Its stats stay the software ones. They count only what the
+ * host sends on this port, not traffic the switch forwards.
+ */
+ return -EOPNOTSUPP;
+
+ default:
+ /* Child qdiscs (TC_ETS_GRAFT) run in software */
+ return -EOPNOTSUPP;
+ }
+}
+EXPORT_SYMBOL_NS_GPL(rtl83xx_port_setup_tc, "REALTEK_DSA");
diff --git a/drivers/net/dsa/realtek/rtl83xx-qos.h b/drivers/net/dsa/realtek/rtl83xx-qos.h
index 06dbfd24b1af5cced870f463f15b1b39eceb56ee..8103c3c42840b55a54e85198d283d5d79d6c6c91 100644
--- a/drivers/net/dsa/realtek/rtl83xx-qos.h
+++ b/drivers/net/dsa/realtek/rtl83xx-qos.h
@@ -16,5 +16,7 @@ int rtl83xx_port_get_apptrust(struct dsa_switch *ds, int port, u8 *sel,
int rtl83xx_port_set_apptrust(struct dsa_switch *ds, int port, const u8 *sel,
int nsel);
int rtl83xx_port_get_dscp_prio(struct dsa_switch *ds, int port, u8 dscp);
+int rtl83xx_port_setup_tc(struct dsa_switch *ds, int port,
+ enum tc_setup_type type, void *type_data);
#endif /* _RTL83XX_QOS_H */
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread