Commit 3a77f5a2 authored by Petr Machata's avatar Petr Machata Committed by David S. Miller

mlxsw: spectrum_buffers: Add struct mlxsw_sp_hdroom

The port headroom handling is currently strewn across several modules and
tricky to follow: MTU, DCB PFC, DCB ETS and ethtool pause all influence the
settings, and then there is the completely separate initial configuraion in
spectrum_buffers. A following patch will implement the dcbnl_setbuffer
callback, which is going to further complicate the landscape.

In order to simplify work with port buffers, the following patches are
going to centralize all port-buffer handling in spectrum_buffers. As a
first step, introduce a (currently empty) struct mlxsw_sp_hdroom that will
keep the configuration parameters, and allocate and free it in appropriate
places.
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 045e42f3
...@@ -1709,6 +1709,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -1709,6 +1709,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false); mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false);
err_port_tc_mc_mode: err_port_tc_mc_mode:
err_port_ets_init: err_port_ets_init:
mlxsw_sp_port_buffers_fini(mlxsw_sp_port);
err_port_buffers_init: err_port_buffers_init:
err_port_admin_status_set: err_port_admin_status_set:
err_port_mtu_set: err_port_mtu_set:
...@@ -1745,6 +1746,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -1745,6 +1746,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
mlxsw_sp_port_fids_fini(mlxsw_sp_port); mlxsw_sp_port_fids_fini(mlxsw_sp_port);
mlxsw_sp_port_dcb_fini(mlxsw_sp_port); mlxsw_sp_port_dcb_fini(mlxsw_sp_port);
mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false); mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false);
mlxsw_sp_port_buffers_fini(mlxsw_sp_port);
mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT); mlxsw_sp_port_swid_set(mlxsw_sp_port, MLXSW_PORT_SWID_DISABLED_PORT);
mlxsw_sp_port_module_unmap(mlxsw_sp_port); mlxsw_sp_port_module_unmap(mlxsw_sp_port);
free_percpu(mlxsw_sp_port->pcpu_stats); free_percpu(mlxsw_sp_port->pcpu_stats);
......
...@@ -316,6 +316,7 @@ struct mlxsw_sp_port { ...@@ -316,6 +316,7 @@ struct mlxsw_sp_port {
u8 split_base_local_port; u8 split_base_local_port;
int max_mtu; int max_mtu;
u32 max_speed; u32 max_speed;
struct mlxsw_sp_hdroom *hdroom;
}; };
struct mlxsw_sp_port_type_speed_ops { struct mlxsw_sp_port_type_speed_ops {
...@@ -437,9 +438,13 @@ int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port, ...@@ -437,9 +438,13 @@ int mlxsw_sp_port_admin_status_set(struct mlxsw_sp_port *mlxsw_sp_port,
bool is_up); bool is_up);
/* spectrum_buffers.c */ /* spectrum_buffers.c */
struct mlxsw_sp_hdroom {
};
int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp); int mlxsw_sp_buffers_init(struct mlxsw_sp *mlxsw_sp);
void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp); void mlxsw_sp_buffers_fini(struct mlxsw_sp *mlxsw_sp);
int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port); int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port);
void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port);
int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
unsigned int sb_index, u16 pool_index, unsigned int sb_index, u16 pool_index,
struct devlink_sb_pool_info *pool_info); struct devlink_sb_pool_info *pool_info);
......
...@@ -995,17 +995,33 @@ int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port) ...@@ -995,17 +995,33 @@ int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port)
{ {
int err; int err;
mlxsw_sp_port->hdroom = kzalloc(sizeof(*mlxsw_sp_port->hdroom), GFP_KERNEL);
if (!mlxsw_sp_port->hdroom)
return -ENOMEM;
err = mlxsw_sp_port_headroom_init(mlxsw_sp_port); err = mlxsw_sp_port_headroom_init(mlxsw_sp_port);
if (err) if (err)
return err; goto err_headroom_init;
err = mlxsw_sp_port_sb_cms_init(mlxsw_sp_port); err = mlxsw_sp_port_sb_cms_init(mlxsw_sp_port);
if (err) if (err)
return err; goto err_port_sb_cms_init;
err = mlxsw_sp_port_sb_pms_init(mlxsw_sp_port); err = mlxsw_sp_port_sb_pms_init(mlxsw_sp_port);
if (err)
goto err_port_sb_pms_init;
return 0;
err_port_sb_pms_init:
err_port_sb_cms_init:
err_headroom_init:
kfree(mlxsw_sp_port->hdroom);
return err; return err;
} }
void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port)
{
kfree(mlxsw_sp_port->hdroom);
}
int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core, int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
unsigned int sb_index, u16 pool_index, unsigned int sb_index, u16 pool_index,
struct devlink_sb_pool_info *pool_info) struct devlink_sb_pool_info *pool_info)
......
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