Re: [PATCH net-next v4 4/4] net: dsa: yt921x: Add port qdisc tbf support
From: Jakub Kicinski
Date: Mon Apr 13 2026 - 18:35:44 EST
On Fri, 10 Apr 2026 01:12:04 +0800 David Yang wrote:
> +static int
> +yt921x_tbf_validate(struct yt921x_priv *priv,
> + const struct tc_tbf_qopt_offload *qopt, int *queuep)
> +{
> + struct device *dev = to_device(priv);
> + int queue = -1;
> +
> + /* TODO: queue support */
> + if (qopt->parent != TC_H_ROOT) {
> + dev_err(dev, "Parent should be \"root\"\n");
Let's add extack to the offload struct like htb does and report this to
the user instead of the logs?
> + return -EOPNOTSUPP;
> + }
> +
> + switch (qopt->command) {
> + case TC_TBF_REPLACE: {
> + const struct tc_tbf_qopt_offload_replace_params *p;
> +
> + p = &qopt->replace_params;
> +
> + if (!p->rate.mpu) {
> + dev_info(dev, "Assuming you want mpu = 64\n");
BTW we can use extack for "warnings" like this, too
> + } else if (p->rate.mpu != 64) {
> + dev_err(dev, "mpu other than 64 not supported\n");
> + return -EINVAL;
> + }
> + break;
> + }
> + default:
> + break;
> + }
> +
> + *queuep = queue;
> + return 0;
> +}
> +
> +static int
> +yt921x_dsa_port_setup_tc_tbf_port(struct dsa_switch *ds, int port,
> + const struct tc_tbf_qopt_offload *qopt)
> +{
> + struct yt921x_priv *priv = to_yt921x_priv(ds);
> + u32 ctrls[2];
> + int res;
> +
> + switch (qopt->command) {
> + case TC_TBF_DESTROY:
> + ctrls[0] = 0;
> + ctrls[1] = 0;
> + break;
> + case TC_TBF_REPLACE: {
> + const struct tc_tbf_qopt_offload_replace_params *p;
> + struct yt921x_marker marker;
> + u64 burst;
> +
> + p = &qopt->replace_params;
> +
> + /* where is burst??? */
Why not add it?
> + burst = div_u64(priv->port_shape_slot_ns * p->rate.rate_bytes_ps,
> + 1000000000) + 10000;
--
pw-bot: cr