From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiri Pirko Subject: [patch net-next 11/11] mlxsw: spectrum: qdiscs: Remove qdisc before setting a new one Date: Wed, 10 Jan 2018 15:00:07 +0100 Message-ID: <20180110140007.28924-12-jiri@resnulli.us> References: <20180110140007.28924-1-jiri@resnulli.us> Cc: nogahf@mellanox.com, davem@davemloft.net, idosch@mellanox.com, mlxsw@mellanox.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com To: netdev@vger.kernel.org Return-path: Received: from mail-wr0-f194.google.com ([209.85.128.194]:45551 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754910AbeAJOAS (ORCPT ); Wed, 10 Jan 2018 09:00:18 -0500 Received: by mail-wr0-f194.google.com with SMTP id 16so4929311wry.12 for ; Wed, 10 Jan 2018 06:00:17 -0800 (PST) In-Reply-To: <20180110140007.28924-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org List-ID: From: Nogah Frankel If a qdisc is being replaced by another qdisc of the same type, it can simply override over its configuration. However, if it replaces a qdisc of another type, it needs to be removed before setting the new qdisc. Signed-off-by: Nogah Frankel Reviewed-by: Yuval Mintz Signed-off-by: Jiri Pirko --- drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c index c896ee721523..273300b75a68 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c @@ -115,6 +115,13 @@ mlxsw_sp_qdisc_replace(struct mlxsw_sp_port *mlxsw_sp_port, u32 handle, { int err; + if (mlxsw_sp_qdisc->ops && mlxsw_sp_qdisc->ops->type != ops->type) + /* In case this location contained a different qdisc of the + * same type we can override the old qdisc configuration. + * Otherwise, we need to remove the old qdisc before setting the + * new one. + */ + mlxsw_sp_qdisc_destroy(mlxsw_sp_port, mlxsw_sp_qdisc); err = ops->check_params(mlxsw_sp_port, mlxsw_sp_qdisc, params); if (err) goto err_bad_param; -- 2.14.3