All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: netdev@vger.kernel.org
Cc: nogahf@mellanox.com, davem@davemloft.net, idosch@mellanox.com,
	mlxsw@mellanox.com, jhs@mojatatu.com, xiyou.wangcong@gmail.com
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	[thread overview]
Message-ID: <20180110140007.28924-12-jiri@resnulli.us> (raw)
In-Reply-To: <20180110140007.28924-1-jiri@resnulli.us>

From: Nogah Frankel <nogahf@mellanox.com>

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 <nogahf@mellanox.com>
Reviewed-by: Yuval Mintz <yuvalm@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 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

  parent reply	other threads:[~2018-01-10 14:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-10 13:59 [patch net-next 00/11] mlxsw qdisc refactoring Jiri Pirko
2018-01-10 13:59 ` [patch net-next 01/11] mlxsw: spectrum: qdiscs: Move qdisc's declarations to its designated file Jiri Pirko
2018-01-10 13:59 ` [patch net-next 02/11] net: sch: red: Change the name of the stats struct to be generic Jiri Pirko
2018-01-10 13:59 ` [patch net-next 03/11] net: sch: red: Change offloaded xstats to be incremental Jiri Pirko
2018-01-10 14:00 ` [patch net-next 04/11] mlxsw: spectrum: qdiscs: Clean qdisc statistics structs Jiri Pirko
2018-01-10 14:00 ` [patch net-next 05/11] mlxsw: spectrum: qdiscs: Make the clean stats function to be for RED only Jiri Pirko
2018-01-10 14:00 ` [patch net-next 06/11] mlxsw: spectrum: qdiscs: Add tclass number to the mlxsw_sp_qdisc Jiri Pirko
2018-01-10 14:00 ` [patch net-next 07/11] mlxsw: spectrum: qdiscs: Unite all handle checks Jiri Pirko
2018-01-10 14:00 ` [patch net-next 08/11] mlxsw: spectrum: qdiscs: Add an ops struct Jiri Pirko
2018-01-10 14:00 ` [patch net-next 09/11] mlxsw: spectrum: qdiscs: Create a generic destroy function Jiri Pirko
2018-01-10 14:00 ` [patch net-next 10/11] mlxsw: spectrum: qdiscs: Create a generic replace function Jiri Pirko
2018-01-10 14:00 ` Jiri Pirko [this message]
2018-01-10 21:08 ` [patch net-next 00/11] mlxsw qdisc refactoring David Miller

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=20180110140007.28924-12-jiri@resnulli.us \
    --to=jiri@resnulli.us \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=jhs@mojatatu.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nogahf@mellanox.com \
    --cc=xiyou.wangcong@gmail.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.