From: Jakub Kicinski <kuba@kernel.org>
To: Cedric Jehasse via B4 Relay
<devnull+cedric.jehasse.luminex.be@kernel.org>
Cc: cedric.jehasse@luminex.be, "Andrew Lunn" <andrew@lunn.ch>,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Russell King" <linux@armlinux.org.uk>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Luke Howard" <lukeh@padl.com>, "Marek Behún" <kabel@kernel.org>,
"Cedric Jehasse" <cedric.jehasse@gmail.com>
Subject: Re: [PATCH net-next v7 2/2] net: dsa: mv88e6xxx: add support for credit based shaper
Date: Fri, 12 Jun 2026 15:36:56 -0700 [thread overview]
Message-ID: <20260612153656.4c5b8c62@kernel.org> (raw)
In-Reply-To: <20260609-net-next-mv88e6xxx-cbs-v7-2-7d5d732df545@luminex.be>
On Tue, 09 Jun 2026 14:10:51 +0200 Cedric Jehasse via B4 Relay wrote:
> From: Cedric Jehasse <cedric.jehasse@luminex.be>
>
> Some of the chips supported by this driver have credit based shaper
> support. Support is added for the 6341, 6352, 6390 and 6393 families.
> This is configured using the Qav registers in the AVB register block.
> There are small differences in the Qav registers between the chip
> families (eg. the unit used for the rate and number of bits in the
> registers). mv88e6xxx_qav_info is introduced to configure this per chip.
>
> Eg. setting up 20mbps credit based shaper on a 1GBit link:
> tc qdisc add dev p8 parent root handle 100: mqprio \
> num_tc 8 \
> map 0 0 6 7 0 5 0 0 0 0 0 0 0 0 0 0 \
> queues 1@0 1@1 1@2 1@3 1@4 1@5 1@6 1@7 \
> hw 0
>
> tc qdisc replace dev p8 parent 100:8 cbs locredit -1470 hicredit 30 \
> sendslope -980000 idleslope 20000 offload 1
Are DSA ports multi-queue? I would have expected a DSA driver to
offload PRIO not MQPRIO.
I seem to recall other discussion on the ML on the topic.
It'd be great to get some review tags from folks familiar with
the device.
> Note: only idleslope and hicredit can be programmed in the switch
> registers, other parameters won't affect settings.
> +static int mv88e6xxx_setup_tc_cbs(struct dsa_switch *ds, int port,
> + struct tc_cbs_qopt_offload *cbs)
please stick an extack into struct tc_cbs_qopt_offload and use it to
report the reason for rejection back to the user
> +{
> + const struct mv88e6xxx_avb_ops *avb_ops;
> + struct mv88e6xxx_chip *chip = ds->priv;
> + const struct mv88e6xxx_qav_info *qav;
> + const struct mv88e6xxx_ops *ops;
> + int hilimit_reg;
> + int rate_reg;
> + u8 queue_bit;
> + u32 rate = 0;
> + u16 hilimit;
> + int err;
> +
> + ops = chip->info->ops;
> + avb_ops = ops->avb_ops;
> + qav = chip->info->qav;
> +
> + if (!qav || !avb_ops || !avb_ops->port_qav_write ||
> + !ops->port_set_scheduling_mode)
> + return -EOPNOTSUPP;
> +
> + if (!dsa_is_user_port(ds, port))
> + return -EOPNOTSUPP;
> +
> + if (!(qav->queue_mask & BIT(cbs->queue)))
> + return -EOPNOTSUPP;
> +
> + queue_bit = BIT(cbs->queue);
> + rate_reg = MV88E6XXX_PORT_QAV_CFG_RATE(cbs->queue);
> + hilimit_reg = MV88E6XXX_PORT_QAV_CFG_HILIMIT(cbs->queue);
> +
> + if (cbs->enable) {
> + if (cbs->hicredit <= 0 ||
> + cbs->hicredit > qav->hilimit_mask)
> + return -ERANGE;
> +
> + rate = DIV_ROUND_UP(cbs->idleslope, qav->rate_unit);
> + if (rate > qav->rate_mask)
> + return -ERANGE;
> + /* avoid using zero rate */
> + rate = max_t(u16, rate, 1);
> + }
> +
> + mv88e6xxx_reg_lock(chip);
> +
> + if (!cbs->enable) {
> + err = mv88e6xxx_port_qav_write(chip, port, rate_reg, 0);
> + if (err)
> + goto unlock;
> +
> + if (!(chip->ports[port].cbs_active_queues & ~queue_bit)) {
> + err = mv88e6xxx_port_set_scheduling_mode(chip, port, 0);
> + if (err)
> + goto unlock;
> + }
> + chip->ports[port].cbs_active_queues &= ~queue_bit;
> + goto unlock;
> + }
> +
> + hilimit = cbs->hicredit & qav->hilimit_mask;
> + err = mv88e6xxx_port_qav_write(chip, port, hilimit_reg, hilimit);
> + if (err)
> + goto unlock;
> +
> + err = mv88e6xxx_port_qav_write(chip, port, rate_reg, rate);
> + if (err)
> + goto unlock;
> +
> + if (!chip->ports[port].cbs_active_queues) {
> + u8 sched_mode = chip->info->num_tx_queues - 1;
> +
> + err = mv88e6xxx_port_set_scheduling_mode(chip, port,
> + sched_mode);
> + if (err) {
> + mv88e6xxx_port_qav_write(chip, port, rate_reg, 0);
> + goto unlock;
> + }
> + }
> + chip->ports[port].cbs_active_queues |= queue_bit;
> +
> +unlock:
> + mv88e6xxx_reg_unlock(chip);
> +
> + return err;
> +}
> +int mv88e6390_port_set_scheduling_mode(struct mv88e6xxx_chip *chip, int port,
> + u8 mode)
> +{
> + u16 reg;
> + int err;
> +
> + if (mode > MV88E6390_PORT_QUEUE_CTL_SCHEDULE_MASK)
> + return -EINVAL;
> +
> + reg = MV88E6390_PORT_QUEUE_CTL_UPDATE |
> + (MV88E6390_PORT_QUEUE_CTL_SCHEDULE <<
> + MV88E6390_PORT_QUEUE_CTL_PTR_SHIFT) |
> + (mode & MV88E6390_PORT_QUEUE_CTL_SCHEDULE_MASK);
> +
> + err = mv88e6xxx_port_write(chip, port, MV88E6390_PORT_QUEUE_CTL,
> + reg);
> + if (err)
> + return err;
> +
> + return mv88e6xxx_port_wait_bit(chip, port, MV88E6390_PORT_QUEUE_CTL,
> + __bf_shf(MV88E6390_PORT_QUEUE_CTL_UPDATE)
> + , 0);
odd placement of the comma
--
pw-bot: cr
next prev parent reply other threads:[~2026-06-12 22:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 12:10 [PATCH net-next v7 0/2] net: dsa: mv88e6xxx: add support for credit based shaper Cedric Jehasse via B4 Relay
2026-06-09 12:10 ` Cedric Jehasse
2026-06-09 12:10 ` [PATCH net-next v7 1/2] net: dsa: mv88e6xxx: use the hw tx queues Cedric Jehasse via B4 Relay
2026-06-09 12:10 ` Cedric Jehasse
2026-06-09 12:10 ` [PATCH net-next v7 2/2] net: dsa: mv88e6xxx: add support for credit based shaper Cedric Jehasse via B4 Relay
2026-06-09 12:10 ` Cedric Jehasse
2026-06-12 22:36 ` Jakub Kicinski [this message]
2026-06-13 3:37 ` Luke Howard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260612153656.4c5b8c62@kernel.org \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=cedric.jehasse@gmail.com \
--cc=cedric.jehasse@luminex.be \
--cc=davem@davemloft.net \
--cc=devnull+cedric.jehasse.luminex.be@kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kabel@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=lukeh@padl.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.