Commit 9deef43d authored by Nogah Frankel's avatar Nogah Frankel Committed by David S. Miller

mlxsw: spectrum: Change stats cache to be local

Change the HW stats cache to be local. Rename it for better clarity.
It holds the results of the last result of HW stats that are being read
periodically, in order to have answer for stats request immediately.
Signed-off-by: default avatarNogah Frankel <nogahf@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 035226b9
...@@ -1328,16 +1328,16 @@ static void update_stats_cache(struct work_struct *work) ...@@ -1328,16 +1328,16 @@ static void update_stats_cache(struct work_struct *work)
{ {
struct mlxsw_sp_port *mlxsw_sp_port = struct mlxsw_sp_port *mlxsw_sp_port =
container_of(work, struct mlxsw_sp_port, container_of(work, struct mlxsw_sp_port,
hw_stats.update_dw.work); periodic_hw_stats.update_dw.work);
if (!netif_carrier_ok(mlxsw_sp_port->dev)) if (!netif_carrier_ok(mlxsw_sp_port->dev))
goto out; goto out;
mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev, mlxsw_sp_port_get_hw_stats(mlxsw_sp_port->dev,
mlxsw_sp_port->hw_stats.cache); &mlxsw_sp_port->periodic_hw_stats.stats);
out: out:
mlxsw_core_schedule_dw(&mlxsw_sp_port->hw_stats.update_dw, mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw,
MLXSW_HW_STATS_UPDATE_TIME); MLXSW_HW_STATS_UPDATE_TIME);
} }
...@@ -1350,7 +1350,7 @@ mlxsw_sp_port_get_stats64(struct net_device *dev, ...@@ -1350,7 +1350,7 @@ mlxsw_sp_port_get_stats64(struct net_device *dev,
{ {
struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev); struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
memcpy(stats, mlxsw_sp_port->hw_stats.cache, sizeof(*stats)); memcpy(stats, &mlxsw_sp_port->periodic_hw_stats.stats, sizeof(*stats));
} }
static int __mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, static int __mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port,
...@@ -2905,14 +2905,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -2905,14 +2905,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
goto err_alloc_sample; goto err_alloc_sample;
} }
mlxsw_sp_port->hw_stats.cache = INIT_DELAYED_WORK(&mlxsw_sp_port->periodic_hw_stats.update_dw,
kzalloc(sizeof(*mlxsw_sp_port->hw_stats.cache), GFP_KERNEL);
if (!mlxsw_sp_port->hw_stats.cache) {
err = -ENOMEM;
goto err_alloc_hw_stats;
}
INIT_DELAYED_WORK(&mlxsw_sp_port->hw_stats.update_dw,
&update_stats_cache); &update_stats_cache);
dev->netdev_ops = &mlxsw_sp_port_netdev_ops; dev->netdev_ops = &mlxsw_sp_port_netdev_ops;
...@@ -3026,7 +3019,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -3026,7 +3019,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
mlxsw_core_port_eth_set(mlxsw_sp->core, mlxsw_sp_port->local_port, mlxsw_core_port_eth_set(mlxsw_sp->core, mlxsw_sp_port->local_port,
mlxsw_sp_port, dev, mlxsw_sp_port->split, mlxsw_sp_port, dev, mlxsw_sp_port->split,
module); module);
mlxsw_core_schedule_dw(&mlxsw_sp_port->hw_stats.update_dw, 0); mlxsw_core_schedule_dw(&mlxsw_sp_port->periodic_hw_stats.update_dw, 0);
return 0; return 0;
err_register_netdev: err_register_netdev:
...@@ -3049,8 +3042,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port, ...@@ -3049,8 +3042,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
err_port_swid_set: err_port_swid_set:
mlxsw_sp_port_module_unmap(mlxsw_sp_port); mlxsw_sp_port_module_unmap(mlxsw_sp_port);
err_port_module_map: err_port_module_map:
kfree(mlxsw_sp_port->hw_stats.cache);
err_alloc_hw_stats:
kfree(mlxsw_sp_port->sample); kfree(mlxsw_sp_port->sample);
err_alloc_sample: err_alloc_sample:
free_percpu(mlxsw_sp_port->pcpu_stats); free_percpu(mlxsw_sp_port->pcpu_stats);
...@@ -3065,7 +3056,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -3065,7 +3056,7 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
{ {
struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port]; struct mlxsw_sp_port *mlxsw_sp_port = mlxsw_sp->ports[local_port];
cancel_delayed_work_sync(&mlxsw_sp_port->hw_stats.update_dw); cancel_delayed_work_sync(&mlxsw_sp_port->periodic_hw_stats.update_dw);
mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp); mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp);
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */ unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
mlxsw_sp->ports[local_port] = NULL; mlxsw_sp->ports[local_port] = NULL;
...@@ -3075,7 +3066,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port) ...@@ -3075,7 +3066,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp *mlxsw_sp, u8 local_port)
mlxsw_sp_port_dcb_fini(mlxsw_sp_port); mlxsw_sp_port_dcb_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);
kfree(mlxsw_sp_port->hw_stats.cache);
kfree(mlxsw_sp_port->sample); kfree(mlxsw_sp_port->sample);
free_percpu(mlxsw_sp_port->pcpu_stats); free_percpu(mlxsw_sp_port->pcpu_stats);
WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list)); WARN_ON_ONCE(!list_empty(&mlxsw_sp_port->vlans_list));
......
...@@ -231,9 +231,9 @@ struct mlxsw_sp_port { ...@@ -231,9 +231,9 @@ struct mlxsw_sp_port {
struct list_head mall_tc_list; struct list_head mall_tc_list;
struct { struct {
#define MLXSW_HW_STATS_UPDATE_TIME HZ #define MLXSW_HW_STATS_UPDATE_TIME HZ
struct rtnl_link_stats64 *cache; struct rtnl_link_stats64 stats;
struct delayed_work update_dw; struct delayed_work update_dw;
} hw_stats; } periodic_hw_stats;
struct mlxsw_sp_port_sample *sample; struct mlxsw_sp_port_sample *sample;
struct list_head vlans_list; struct list_head vlans_list;
}; };
......
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