mlxsw: spectrum: Allow fetch-and-clear of flow counters
For the report_delta-like interface like a previous patch has added for collection of NH group statistics, it's easiest to read the counter and have the HW clear it right away. Thus, change mlxsw_sp_flow_counter_get() to take a bool indicating whether this should be done. Signed-off-by: Petr Machata <petrm@nvidia.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://lore.kernel.org/r/6a096ede8ee92d5041e3832242c3bbc137198aba.1709901020.git.petrm@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
8acb480e43
commit
6fb88aaf27
@ -176,13 +176,15 @@ MLXSW_ITEM32(tx, hdr, fid, 0x08, 16, 16);
|
||||
MLXSW_ITEM32(tx, hdr, type, 0x0C, 0, 4);
|
||||
|
||||
int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
|
||||
unsigned int counter_index, u64 *packets,
|
||||
u64 *bytes)
|
||||
unsigned int counter_index, bool clear,
|
||||
u64 *packets, u64 *bytes)
|
||||
{
|
||||
enum mlxsw_reg_mgpc_opcode op = clear ? MLXSW_REG_MGPC_OPCODE_CLEAR :
|
||||
MLXSW_REG_MGPC_OPCODE_NOP;
|
||||
char mgpc_pl[MLXSW_REG_MGPC_LEN];
|
||||
int err;
|
||||
|
||||
mlxsw_reg_mgpc_pack(mgpc_pl, counter_index, MLXSW_REG_MGPC_OPCODE_NOP,
|
||||
mlxsw_reg_mgpc_pack(mgpc_pl, counter_index, op,
|
||||
MLXSW_REG_FLOW_COUNTER_SET_TYPE_PACKETS_BYTES);
|
||||
err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(mgpc), mgpc_pl);
|
||||
if (err)
|
||||
|
@ -706,8 +706,8 @@ int mlxsw_sp_port_kill_vid(struct net_device *dev,
|
||||
int mlxsw_sp_port_vlan_set(struct mlxsw_sp_port *mlxsw_sp_port, u16 vid_begin,
|
||||
u16 vid_end, bool is_member, bool untagged);
|
||||
int mlxsw_sp_flow_counter_get(struct mlxsw_sp *mlxsw_sp,
|
||||
unsigned int counter_index, u64 *packets,
|
||||
u64 *bytes);
|
||||
unsigned int counter_index, bool clear,
|
||||
u64 *packets, u64 *bytes);
|
||||
int mlxsw_sp_flow_counter_alloc(struct mlxsw_sp *mlxsw_sp,
|
||||
unsigned int *p_counter_index);
|
||||
void mlxsw_sp_flow_counter_free(struct mlxsw_sp *mlxsw_sp,
|
||||
|
@ -1024,7 +1024,7 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
|
||||
rulei = mlxsw_sp_acl_rule_rulei(rule);
|
||||
if (rulei->counter_valid) {
|
||||
err = mlxsw_sp_flow_counter_get(mlxsw_sp, rulei->counter_index,
|
||||
¤t_packets,
|
||||
false, ¤t_packets,
|
||||
¤t_bytes);
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -361,7 +361,7 @@ static int mlxsw_sp_mr_tcam_route_stats(struct mlxsw_sp *mlxsw_sp,
|
||||
struct mlxsw_sp_mr_tcam_route *route = route_priv;
|
||||
|
||||
return mlxsw_sp_flow_counter_get(mlxsw_sp, route->counter_index,
|
||||
packets, bytes);
|
||||
false, packets, bytes);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2251,7 +2251,7 @@ int mlxsw_sp_neigh_counter_get(struct mlxsw_sp *mlxsw_sp,
|
||||
return -EINVAL;
|
||||
|
||||
return mlxsw_sp_flow_counter_get(mlxsw_sp, neigh_entry->counter_index,
|
||||
p_counter, NULL);
|
||||
false, p_counter, NULL);
|
||||
}
|
||||
|
||||
static struct mlxsw_sp_neigh_entry *
|
||||
@ -3186,7 +3186,7 @@ int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp,
|
||||
return -EINVAL;
|
||||
|
||||
return mlxsw_sp_flow_counter_get(mlxsw_sp, nh->counter_index,
|
||||
p_counter, NULL);
|
||||
false, p_counter, NULL);
|
||||
}
|
||||
|
||||
struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next(struct mlxsw_sp_router *router,
|
||||
|
Loading…
x
Reference in New Issue
Block a user