Commit 5ebc6031 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

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: default avatarPetr Machata <petrm@nvidia.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarIdo Schimmel <idosch@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 69e408a2
......@@ -592,6 +592,62 @@ static int mlxsw_sp_dcbnl_ieee_setpfc(struct net_device *dev,
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)
......
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