Skip to content

Commit 93a129e

Browse files
jpirkodavem330
authored andcommitted
net: sched: expose HW stats types per action used by drivers
It may be up to the driver (in case ANY HW stats is passed) to select which type of HW stats he is going to use. Add an infrastructure to expose this information to user. $ tc filter add dev enp3s0np1 ingress proto ip handle 1 pref 1 flower dst_ip 192.168.1.1 action drop $ tc -s filter show dev enp3s0np1 ingress filter protocol ip pref 1 flower chain 0 filter protocol ip pref 1 flower chain 0 handle 0x1 eth_type ipv4 dst_ip 192.168.1.1 in_hw in_hw_count 2 action order 1: gact action drop random type none pass val 0 index 1 ref 1 bind 1 installed 10 sec used 10 sec Action statistics: Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0) backlog 0b 0p requeues 0 used_hw_stats immediate <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8953b07 commit 93a129e

18 files changed

Lines changed: 54 additions & 17 deletions

File tree

‎drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1639,7 +1639,7 @@ static int bnxt_tc_get_flow_stats(struct bnxt *bp,
16391639
spin_unlock(&flow->stats_lock);
16401640

16411641
flow_stats_update(&tc_flow_cmd->stats, stats.bytes, stats.packets,
1642-
lastused);
1642+
lastused, FLOW_ACTION_HW_STATS_DELAYED);
16431643
return 0;
16441644
}
16451645

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,8 @@ int cxgb4_tc_flower_stats(struct net_device *dev,
903903
ofld_stats->last_used = jiffies;
904904
flow_stats_update(&cls->stats, bytes - ofld_stats->byte_count,
905905
packets - ofld_stats->packet_count,
906-
ofld_stats->last_used);
906+
ofld_stats->last_used,
907+
FLOW_ACTION_HW_STATS_IMMEDIATE);
907908

908909
ofld_stats->packet_count = packets;
909910
ofld_stats->byte_count = bytes;

‎drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_matchall.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ int cxgb4_tc_matchall_stats(struct net_device *dev,
346346
flow_stats_update(&cls_matchall->stats,
347347
bytes - tc_port_matchall->ingress.bytes,
348348
packets - tc_port_matchall->ingress.packets,
349-
tc_port_matchall->ingress.last_used);
349+
tc_port_matchall->ingress.last_used,
350+
FLOW_ACTION_HW_STATS_IMMEDIATE);
350351

351352
tc_port_matchall->ingress.packets = packets;
352353
tc_port_matchall->ingress.bytes = bytes;

‎drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ mlx5_tc_ct_block_flow_offload_stats(struct mlx5_ct_ft *ft,
666666
return -ENOENT;
667667

668668
mlx5_fc_query_cached(entry->counter, &bytes, &packets, &lastuse);
669-
flow_stats_update(&f->stats, bytes, packets, lastuse);
669+
flow_stats_update(&f->stats, bytes, packets, lastuse,
670+
FLOW_ACTION_HW_STATS_DELAYED);
670671

671672
return 0;
672673
}

‎drivers/net/ethernet/mellanox/mlx5/core/en_tc.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4468,7 +4468,8 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
44684468
no_peer_counter:
44694469
mlx5_devcom_release_peer_data(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
44704470
out:
4471-
flow_stats_update(&f->stats, bytes, packets, lastuse);
4471+
flow_stats_update(&f->stats, bytes, packets, lastuse,
4472+
FLOW_ACTION_HW_STATS_DELAYED);
44724473
trace_mlx5e_stats_flower(f);
44734474
errout:
44744475
mlx5e_flow_put(priv, flow);
@@ -4585,7 +4586,8 @@ void mlx5e_tc_stats_matchall(struct mlx5e_priv *priv,
45854586
dpkts = cur_stats.rx_packets - rpriv->prev_vf_vport_stats.rx_packets;
45864587
dbytes = cur_stats.rx_bytes - rpriv->prev_vf_vport_stats.rx_bytes;
45874588
rpriv->prev_vf_vport_stats = cur_stats;
4588-
flow_stats_update(&ma->stats, dpkts, dbytes, jiffies);
4589+
flow_stats_update(&ma->stats, dpkts, dbytes, jiffies,
4590+
FLOW_ACTION_HW_STATS_DELAYED);
45894591
}
45904592

45914593
static void mlx5e_tc_hairpin_update_dead_peer(struct mlx5e_priv *priv,

‎drivers/net/ethernet/mellanox/mlxsw/spectrum.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ struct mlxsw_sp_acl_rule_info *
786786
mlxsw_sp_acl_rule_rulei(struct mlxsw_sp_acl_rule *rule);
787787
int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
788788
struct mlxsw_sp_acl_rule *rule,
789-
u64 *packets, u64 *bytes, u64 *last_use);
789+
u64 *packets, u64 *bytes, u64 *last_use,
790+
enum flow_action_hw_stats *used_hw_stats);
790791

791792
struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
792793

‎drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,8 @@ static void mlxsw_sp_acl_rule_activity_update_work(struct work_struct *work)
967967

968968
int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
969969
struct mlxsw_sp_acl_rule *rule,
970-
u64 *packets, u64 *bytes, u64 *last_use)
970+
u64 *packets, u64 *bytes, u64 *last_use,
971+
enum flow_action_hw_stats *used_hw_stats)
971972

972973
{
973974
struct mlxsw_sp_acl_rule_info *rulei;
@@ -982,6 +983,7 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
982983
&current_bytes);
983984
if (err)
984985
return err;
986+
*used_hw_stats = FLOW_ACTION_HW_STATS_IMMEDIATE;
985987
}
986988
*packets = current_packets - rule->last_packets;
987989
*bytes = current_bytes - rule->last_bytes;

‎drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,7 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
571571
struct mlxsw_sp_acl_block *block,
572572
struct flow_cls_offload *f)
573573
{
574+
enum flow_action_hw_stats used_hw_stats = FLOW_ACTION_HW_STATS_DISABLED;
574575
struct mlxsw_sp_acl_ruleset *ruleset;
575576
struct mlxsw_sp_acl_rule *rule;
576577
u64 packets;
@@ -589,11 +590,11 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
589590
return -EINVAL;
590591

591592
err = mlxsw_sp_acl_rule_get_stats(mlxsw_sp, rule, &packets, &bytes,
592-
&lastuse);
593+
&lastuse, &used_hw_stats);
593594
if (err)
594595
goto err_rule_get_stats;
595596

596-
flow_stats_update(&f->stats, bytes, packets, lastuse);
597+
flow_stats_update(&f->stats, bytes, packets, lastuse, used_hw_stats);
597598

598599
mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset);
599600
return 0;

‎drivers/net/ethernet/mscc/ocelot_flower.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
224224
if (ret)
225225
return ret;
226226

227-
flow_stats_update(&f->stats, 0x0, ace.stats.pkts, 0x0);
227+
flow_stats_update(&f->stats, 0x0, ace.stats.pkts, 0x0,
228+
FLOW_ACTION_HW_STATS_IMMEDIATE);
228229
return 0;
229230
}
230231
EXPORT_SYMBOL_GPL(ocelot_cls_flower_stats);

‎drivers/net/ethernet/netronome/nfp/flower/offload.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,8 @@ nfp_flower_get_stats(struct nfp_app *app, struct net_device *netdev,
14901490
nfp_flower_update_merge_stats(app, nfp_flow);
14911491

14921492
flow_stats_update(&flow->stats, priv->stats[ctx_id].bytes,
1493-
priv->stats[ctx_id].pkts, priv->stats[ctx_id].used);
1493+
priv->stats[ctx_id].pkts, priv->stats[ctx_id].used,
1494+
FLOW_ACTION_HW_STATS_DELAYED);
14941495

14951496
priv->stats[ctx_id].pkts = 0;
14961497
priv->stats[ctx_id].bytes = 0;

0 commit comments

Comments
 (0)