mlxsw: spectrum_qdisc: Destroy children in mlxsw_sp_qdisc_destroy()
authorPetr Machata <petrm@nvidia.com>
Tue, 19 Oct 2021 08:07:07 +0000 (11:07 +0300)
committerDavid S. Miller <davem@davemloft.net>
Tue, 19 Oct 2021 11:24:51 +0000 (12:24 +0100)
Currently ETS and PRIO are the only offloaded classful qdiscs. Since they
are both similar, their destroy handler is the same, and it handles
children destruction itself. But now it is possible to do it generically
for any classful qdisc. Therefore promote the recursive destruction from
the ETS handler to mlxsw_sp_qdisc_destroy(), so that RED and TBF pick it up
in follow-up patches.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c

index 7f29f51bdf1b64302d40c6858b9336ad9fa91447..8ececee1b79be854f0302279fb5093583f53c36f 100644 (file)
@@ -232,6 +232,7 @@ mlxsw_sp_qdisc_destroy(struct mlxsw_sp_port *mlxsw_sp_port,
        struct mlxsw_sp_qdisc *root_qdisc = &mlxsw_sp_port->qdisc->root_qdisc;
        int err_hdroom = 0;
        int err = 0;
+       int i;
 
        if (!mlxsw_sp_qdisc)
                return 0;
@@ -249,6 +250,9 @@ mlxsw_sp_qdisc_destroy(struct mlxsw_sp_port *mlxsw_sp_port,
        if (!mlxsw_sp_qdisc->ops)
                return 0;
 
+       for (i = 0; i < mlxsw_sp_qdisc->num_classes; i++)
+               mlxsw_sp_qdisc_destroy(mlxsw_sp_port,
+                                      &mlxsw_sp_qdisc->qdiscs[i]);
        mlxsw_sp_qdisc_reduce_parent_backlog(mlxsw_sp_qdisc);
        if (mlxsw_sp_qdisc->ops->destroy)
                err = mlxsw_sp_qdisc->ops->destroy(mlxsw_sp_port,
@@ -1123,8 +1127,6 @@ static int __mlxsw_sp_qdisc_ets_destroy(struct mlxsw_sp_port *mlxsw_sp_port,
                mlxsw_sp_port_ets_set(mlxsw_sp_port,
                                      MLXSW_REG_QEEC_HR_SUBGROUP,
                                      i, 0, false, 0);
-               mlxsw_sp_qdisc_destroy(mlxsw_sp_port,
-                                      &mlxsw_sp_qdisc->qdiscs[i]);
        }
 
        kfree(mlxsw_sp_qdisc->ets_data);