mlxsw: spectrum_dcb: Implement dcbnl_setbuffer / getbuffer
Add dcbnl_setbuffer, which bounces requests if a headroom is in DCB mode. Implement dcbnl_getbuffer such that it can always be used to determine port-buffer configuration, regardless of headroom mode. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
69e408a2cf
Коммит
5ebc6031e6
drivers/net/ethernet/mellanox/mlxsw
|
@ -592,6 +592,62 @@ err_port_pfc_set:
|
|||
return err;
|
||||
}
|
||||
|
||||
static int mlxsw_sp_dcbnl_getbuffer(struct net_device *dev, struct dcbnl_buffer *buf)
|
||||
{
|
||||
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
|
||||
struct mlxsw_sp_hdroom *hdroom = mlxsw_sp_port->hdroom;
|
||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||
int prio;
|
||||
int i;
|
||||
|
||||
buf->total_size = 0;
|
||||
|
||||
BUILD_BUG_ON(DCBX_MAX_BUFFERS > MLXSW_SP_PB_COUNT);
|
||||
for (i = 0; i < MLXSW_SP_PB_COUNT; i++) {
|
||||
u32 bytes = mlxsw_sp_cells_bytes(mlxsw_sp, hdroom->bufs.buf[i].size_cells);
|
||||
|
||||
if (i < DCBX_MAX_BUFFERS)
|
||||
buf->buffer_size[i] = bytes;
|
||||
buf->total_size += bytes;
|
||||
}
|
||||
|
||||
buf->total_size += mlxsw_sp_cells_bytes(mlxsw_sp, hdroom->int_buf.size_cells);
|
||||
|
||||
for (prio = 0; prio < IEEE_8021Q_MAX_PRIORITIES; prio++)
|
||||
buf->prio2buffer[prio] = hdroom->prios.prio[prio].buf_idx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mlxsw_sp_dcbnl_setbuffer(struct net_device *dev, struct dcbnl_buffer *buf)
|
||||
{
|
||||
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
|
||||
struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
|
||||
struct mlxsw_sp_hdroom hdroom;
|
||||
int prio;
|
||||
int i;
|
||||
|
||||
hdroom = *mlxsw_sp_port->hdroom;
|
||||
|
||||
if (hdroom.mode != MLXSW_SP_HDROOM_MODE_TC) {
|
||||
netdev_err(dev, "The use of dcbnl_setbuffer is only allowed if egress is configured using TC\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (prio = 0; prio < IEEE_8021Q_MAX_PRIORITIES; prio++)
|
||||
hdroom.prios.prio[prio].set_buf_idx = buf->prio2buffer[prio];
|
||||
|
||||
BUILD_BUG_ON(DCBX_MAX_BUFFERS > MLXSW_SP_PB_COUNT);
|
||||
for (i = 0; i < DCBX_MAX_BUFFERS; i++)
|
||||
hdroom.bufs.buf[i].set_size_cells = mlxsw_sp_bytes_cells(mlxsw_sp,
|
||||
buf->buffer_size[i]);
|
||||
|
||||
mlxsw_sp_hdroom_prios_reset_buf_idx(&hdroom);
|
||||
mlxsw_sp_hdroom_bufs_reset_lossiness(&hdroom);
|
||||
mlxsw_sp_hdroom_bufs_reset_sizes(mlxsw_sp_port, &hdroom);
|
||||
return mlxsw_sp_hdroom_configure(mlxsw_sp_port, &hdroom);
|
||||
}
|
||||
|
||||
static const struct dcbnl_rtnl_ops mlxsw_sp_dcbnl_ops = {
|
||||
.ieee_getets = mlxsw_sp_dcbnl_ieee_getets,
|
||||
.ieee_setets = mlxsw_sp_dcbnl_ieee_setets,
|
||||
|
@ -604,6 +660,9 @@ static const struct dcbnl_rtnl_ops mlxsw_sp_dcbnl_ops = {
|
|||
|
||||
.getdcbx = mlxsw_sp_dcbnl_getdcbx,
|
||||
.setdcbx = mlxsw_sp_dcbnl_setdcbx,
|
||||
|
||||
.dcbnl_getbuffer = mlxsw_sp_dcbnl_getbuffer,
|
||||
.dcbnl_setbuffer = mlxsw_sp_dcbnl_setbuffer,
|
||||
};
|
||||
|
||||
static int mlxsw_sp_port_ets_init(struct mlxsw_sp_port *mlxsw_sp_port)
|
||||
|
|
Загрузка…
Ссылка в новой задаче