OSDN Git Service

mlxsw: spectrum_buffers: Add struct mlxsw_sp_hdroom
authorPetr Machata <petrm@nvidia.com>
Wed, 16 Sep 2020 06:35:14 +0000 (09:35 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Sep 2020 22:19:29 +0000 (15:19 -0700)
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: 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>
drivers/net/ethernet/mellanox/mlxsw/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/spectrum.h
drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c

index 351d385..ffb0e48 100644 (file)
@@ -1709,6 +1709,7 @@ err_port_dcb_init:
        mlxsw_sp_port_tc_mc_mode_set(mlxsw_sp_port, false);
 err_port_tc_mc_mode:
 err_port_ets_init:
+       mlxsw_sp_port_buffers_fini(mlxsw_sp_port);
 err_port_buffers_init:
 err_port_admin_status_set:
 err_port_mtu_set:
@@ -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_dcb_fini(mlxsw_sp_port);
        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_module_unmap(mlxsw_sp_port);
        free_percpu(mlxsw_sp_port->pcpu_stats);
index a23b677..7441f14 100644 (file)
@@ -316,6 +316,7 @@ struct mlxsw_sp_port {
        u8 split_base_local_port;
        int max_mtu;
        u32 max_speed;
+       struct mlxsw_sp_hdroom *hdroom;
 };
 
 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,
                                   bool is_up);
 
 /* spectrum_buffers.c */
+struct mlxsw_sp_hdroom {
+};
+
 int mlxsw_sp_buffers_init(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);
+void mlxsw_sp_port_buffers_fini(struct mlxsw_sp_port *mlxsw_sp_port);
 int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
                         unsigned int sb_index, u16 pool_index,
                         struct devlink_sb_pool_info *pool_info);
index 6f84557..54218e6 100644 (file)
@@ -995,17 +995,33 @@ int mlxsw_sp_port_buffers_init(struct mlxsw_sp_port *mlxsw_sp_port)
 {
        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);
        if (err)
-               return err;
+               goto err_headroom_init;
        err = mlxsw_sp_port_sb_cms_init(mlxsw_sp_port);
        if (err)
-               return err;
+               goto err_port_sb_cms_init;
        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;
 }
 
+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,
                         unsigned int sb_index, u16 pool_index,
                         struct devlink_sb_pool_info *pool_info)