Commit 91796f50 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

mlxsw: spectrum_qdisc: Extract two helpers for handling future FIFOs

Extract from __mlxsw_sp_qdisc_ets_replace() two helpers for handling of one
future FIFO resp. reinitializing the array of future FIFOs.
Signed-off-by: default avatarPetr Machata <petrm@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 76ff72a7
...@@ -1022,6 +1022,32 @@ static struct mlxsw_sp_qdisc_ops mlxsw_sp_qdisc_ops_fifo = { ...@@ -1022,6 +1022,32 @@ static struct mlxsw_sp_qdisc_ops mlxsw_sp_qdisc_ops_fifo = {
.clean_stats = mlxsw_sp_setup_tc_qdisc_leaf_clean_stats, .clean_stats = mlxsw_sp_setup_tc_qdisc_leaf_clean_stats,
}; };
static int
mlxsw_sp_qdisc_future_fifo_replace(struct mlxsw_sp_port *mlxsw_sp_port,
u32 handle, unsigned int band,
struct mlxsw_sp_qdisc *child_qdisc)
{
struct mlxsw_sp_qdisc_state *qdisc_state = mlxsw_sp_port->qdisc;
if (handle == qdisc_state->future_handle &&
qdisc_state->future_fifos[band])
return mlxsw_sp_qdisc_replace(mlxsw_sp_port, TC_H_UNSPEC,
child_qdisc,
&mlxsw_sp_qdisc_ops_fifo,
NULL);
return 0;
}
static void
mlxsw_sp_qdisc_future_fifos_init(struct mlxsw_sp_port *mlxsw_sp_port,
u32 handle)
{
struct mlxsw_sp_qdisc_state *qdisc_state = mlxsw_sp_port->qdisc;
qdisc_state->future_handle = handle;
memset(qdisc_state->future_fifos, 0, sizeof(qdisc_state->future_fifos));
}
static int __mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, static int __mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
struct tc_fifo_qopt_offload *p) struct tc_fifo_qopt_offload *p)
{ {
...@@ -1037,9 +1063,8 @@ static int __mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1037,9 +1063,8 @@ static int __mlxsw_sp_setup_tc_fifo(struct mlxsw_sp_port *mlxsw_sp_port,
/* This notifications is for a different Qdisc than /* This notifications is for a different Qdisc than
* previously. Wipe the future cache. * previously. Wipe the future cache.
*/ */
memset(qdisc_state->future_fifos, 0, mlxsw_sp_qdisc_future_fifos_init(mlxsw_sp_port,
sizeof(qdisc_state->future_fifos)); parent_handle);
qdisc_state->future_handle = parent_handle;
} }
band = TC_H_MIN(p->parent) - 1; band = TC_H_MIN(p->parent) - 1;
...@@ -1141,7 +1166,6 @@ __mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1141,7 +1166,6 @@ __mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port,
const u8 *priomap) const u8 *priomap)
{ {
struct mlxsw_sp_qdisc_ets_data *ets_data = mlxsw_sp_qdisc->ets_data; struct mlxsw_sp_qdisc_ets_data *ets_data = mlxsw_sp_qdisc->ets_data;
struct mlxsw_sp_qdisc_state *qdisc_state = mlxsw_sp_port->qdisc;
struct mlxsw_sp_qdisc_ets_band *ets_band; struct mlxsw_sp_qdisc_ets_band *ets_band;
struct mlxsw_sp_qdisc *child_qdisc; struct mlxsw_sp_qdisc *child_qdisc;
u8 old_priomap, new_priomap; u8 old_priomap, new_priomap;
...@@ -1201,15 +1225,10 @@ __mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1201,15 +1225,10 @@ __mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port,
child_qdisc->stats_base.backlog = backlog; child_qdisc->stats_base.backlog = backlog;
} }
if (handle == qdisc_state->future_handle && err = mlxsw_sp_qdisc_future_fifo_replace(mlxsw_sp_port, handle,
qdisc_state->future_fifos[band]) { band, child_qdisc);
err = mlxsw_sp_qdisc_replace(mlxsw_sp_port, TC_H_UNSPEC, if (err)
child_qdisc, return err;
&mlxsw_sp_qdisc_ops_fifo,
NULL);
if (err)
return err;
}
} }
for (; band < IEEE_8021QAZ_MAX_TCS; band++) { for (; band < IEEE_8021QAZ_MAX_TCS; band++) {
ets_band = &ets_data->bands[band]; ets_band = &ets_data->bands[band];
...@@ -1223,8 +1242,7 @@ __mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -1223,8 +1242,7 @@ __mlxsw_sp_qdisc_ets_replace(struct mlxsw_sp_port *mlxsw_sp_port,
ets_band->tclass_num, 0, false, 0); ets_band->tclass_num, 0, false, 0);
} }
qdisc_state->future_handle = TC_H_UNSPEC; mlxsw_sp_qdisc_future_fifos_init(mlxsw_sp_port, TC_H_UNSPEC);
memset(qdisc_state->future_fifos, 0, sizeof(qdisc_state->future_fifos));
return 0; return 0;
} }
......
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