Commit 290fe2c5 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

mlxsw: spectrum_qdisc: Simplify mlxsw_sp_qdisc_compare()

The purpose of this function is to filter out events that are related to
qdiscs that are not offloaded, or are not offloaded anymore. But the
function is unnecessarily thorough:

- mlxsw_sp_qdisc pointer is never NULL in the context where it is called
- Two qdiscs with the same handle will never have different types. Even
  when replacing one qdisc with another in the same class, Linux will not
  permit handle reuse unless the qdisc type also matches.

Simplify the function by omitting these two unnecessary conditions.
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 17c0e6d1
...@@ -87,12 +87,9 @@ struct mlxsw_sp_qdisc_state { ...@@ -87,12 +87,9 @@ struct mlxsw_sp_qdisc_state {
}; };
static bool static bool
mlxsw_sp_qdisc_compare(struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, u32 handle, mlxsw_sp_qdisc_compare(struct mlxsw_sp_qdisc *mlxsw_sp_qdisc, u32 handle)
enum mlxsw_sp_qdisc_type type)
{ {
return mlxsw_sp_qdisc && mlxsw_sp_qdisc->ops && return mlxsw_sp_qdisc->ops && mlxsw_sp_qdisc->handle == handle;
mlxsw_sp_qdisc->ops->type == type &&
mlxsw_sp_qdisc->handle == handle;
} }
static struct mlxsw_sp_qdisc * static struct mlxsw_sp_qdisc *
...@@ -579,8 +576,7 @@ int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -579,8 +576,7 @@ int mlxsw_sp_setup_tc_red(struct mlxsw_sp_port *mlxsw_sp_port,
&mlxsw_sp_qdisc_ops_red, &mlxsw_sp_qdisc_ops_red,
&p->set); &p->set);
if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle))
MLXSW_SP_QDISC_RED))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (p->command) { switch (p->command) {
...@@ -780,8 +776,7 @@ int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -780,8 +776,7 @@ int mlxsw_sp_setup_tc_tbf(struct mlxsw_sp_port *mlxsw_sp_port,
&mlxsw_sp_qdisc_ops_tbf, &mlxsw_sp_qdisc_ops_tbf,
&p->replace_params); &p->replace_params);
if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle))
MLXSW_SP_QDISC_TBF))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (p->command) { switch (p->command) {
...@@ -886,8 +881,7 @@ int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -886,8 +881,7 @@ int mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
&mlxsw_sp_qdisc_ops_fifo, NULL); &mlxsw_sp_qdisc_ops_fifo, NULL);
} }
if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle))
MLXSW_SP_QDISC_FIFO))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (p->command) { switch (p->command) {
...@@ -1247,8 +1241,7 @@ int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1247,8 +1241,7 @@ int mlxsw_sp_setup_tc_prio(struct mlxsw_sp_port *mlxsw_sp_port,
&mlxsw_sp_qdisc_ops_prio, &mlxsw_sp_qdisc_ops_prio,
&p->replace_params); &p->replace_params);
if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle))
MLXSW_SP_QDISC_PRIO))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (p->command) { switch (p->command) {
...@@ -1280,8 +1273,7 @@ int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1280,8 +1273,7 @@ int mlxsw_sp_setup_tc_ets(struct mlxsw_sp_port *mlxsw_sp_port,
&mlxsw_sp_qdisc_ops_ets, &mlxsw_sp_qdisc_ops_ets,
&p->replace_params); &p->replace_params);
if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle, if (!mlxsw_sp_qdisc_compare(mlxsw_sp_qdisc, p->handle))
MLXSW_SP_QDISC_ETS))
return -EOPNOTSUPP; return -EOPNOTSUPP;
switch (p->command) { switch (p->command) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment