flow_offload: add statistics retrieval infrastructure and use it
authorPablo Neira Ayuso <pablo@netfilter.org>
Sat, 2 Feb 2019 11:50:47 +0000 (12:50 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 6 Feb 2019 18:38:25 +0000 (10:38 -0800)
This patch provides the flow_stats structure that acts as container for
tc_cls_flower_offload, then we can use to restore the statistics on the
existing TC actions. Hence, tcf_exts_stats_update() is not used from
drivers anymore.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt_tc.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_flower.c
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
drivers/net/ethernet/netronome/nfp/flower/offload.c
include/net/flow_offload.h
include/net/pkt_cls.h
net/sched/cls_flower.c

index 90a2170c51382ef52cd760bd8c98f9d7c34d59db..6a87434b71732cd57f63e6c6468a41efc7b354c8 100644 (file)
@@ -1396,8 +1396,8 @@ static int bnxt_tc_get_flow_stats(struct bnxt *bp,
        lastused = flow->lastused;
        spin_unlock(&flow->stats_lock);
 
-       tcf_exts_stats_update(tc_flow_cmd->exts, stats.bytes, stats.packets,
-                             lastused);
+       flow_stats_update(&tc_flow_cmd->stats, stats.bytes, stats.packets,
+                         lastused);
        return 0;
 }
 
index 39c5af5dad3d87f30d3c3072f6494ad5b81a2012..8a2d66ee1d7baade7a4711006f737f3995d637ad 100644 (file)
@@ -807,9 +807,9 @@ int cxgb4_tc_flower_stats(struct net_device *dev,
        if (ofld_stats->packet_count != packets) {
                if (ofld_stats->prev_packet_count != packets)
                        ofld_stats->last_used = jiffies;
-               tcf_exts_stats_update(cls->exts, bytes - ofld_stats->byte_count,
-                                     packets - ofld_stats->packet_count,
-                                     ofld_stats->last_used);
+               flow_stats_update(&cls->stats, bytes - ofld_stats->byte_count,
+                                 packets - ofld_stats->packet_count,
+                                 ofld_stats->last_used);
 
                ofld_stats->packet_count = packets;
                ofld_stats->byte_count = bytes;
index 1c8e8da166bd5c6f71e20a062dbbd5d314f3d053..c4c6bbcafc68c6fba119c99db17a057dbbbb9176 100644 (file)
@@ -3071,7 +3071,7 @@ int mlx5e_stats_flower(struct net_device *dev, struct mlx5e_priv *priv,
        mlx5_devcom_release_peer_data(devcom, MLX5_DEVCOM_ESW_OFFLOADS);
 
 out:
-       tcf_exts_stats_update(f->exts, bytes, packets, lastuse);
+       flow_stats_update(&f->stats, bytes, packets, lastuse);
 
        return 0;
 }
index a20379e29e0261d96f22df9754519cb3807bae8e..c090ecb62041ed71f97dc0a2452c7e8a13608f9b 100644 (file)
@@ -460,7 +460,7 @@ int mlxsw_sp_flower_stats(struct mlxsw_sp *mlxsw_sp,
        if (err)
                goto err_rule_get_stats;
 
-       tcf_exts_stats_update(f->exts, bytes, packets, lastuse);
+       flow_stats_update(&f->stats, bytes, packets, lastuse);
 
        mlxsw_sp_acl_ruleset_put(mlxsw_sp, ruleset);
        return 0;
index 74f7ff292052fc47741ec0914d3ef59cb4148d6c..fe1469d201af4841b411de2c9868072e27ec0db3 100644 (file)
@@ -554,9 +554,8 @@ nfp_flower_get_stats(struct nfp_app *app, struct net_device *netdev,
        ctx_id = be32_to_cpu(nfp_flow->meta.host_ctx_id);
 
        spin_lock_bh(&priv->stats_lock);
-       tcf_exts_stats_update(flow->exts, priv->stats[ctx_id].bytes,
-                             priv->stats[ctx_id].pkts,
-                             priv->stats[ctx_id].used);
+       flow_stats_update(&flow->stats, priv->stats[ctx_id].bytes,
+                         priv->stats[ctx_id].pkts, priv->stats[ctx_id].used);
 
        priv->stats[ctx_id].pkts = 0;
        priv->stats[ctx_id].bytes = 0;
index dabc819b6cc9fe1beefb2d21ee11c4dbfec1205d..f9ce39992dbdfd19b8c8dafec30f89e42e209649 100644 (file)
@@ -179,4 +179,18 @@ static inline bool flow_rule_match_key(const struct flow_rule *rule,
        return dissector_uses_key(rule->match.dissector, key);
 }
 
+struct flow_stats {
+       u64     pkts;
+       u64     bytes;
+       u64     lastused;
+};
+
+static inline void flow_stats_update(struct flow_stats *flow_stats,
+                                    u64 bytes, u64 pkts, u64 lastused)
+{
+       flow_stats->pkts        = pkts;
+       flow_stats->bytes       = bytes;
+       flow_stats->lastused    = lastused;
+}
+
 #endif /* _NET_FLOW_OFFLOAD_H */
index c470c100b92623e57ce4ba7200a653f4bcb687dc..bea1b1c3ea9bbdad19ab9f0b333d3fd5b5afb856 100644 (file)
@@ -765,6 +765,7 @@ struct tc_cls_flower_offload {
        enum tc_fl_command command;
        unsigned long cookie;
        struct flow_rule *rule;
+       struct flow_stats stats;
        struct tcf_exts *exts;
        u32 classid;
 };
index 48c54ef52a98801de1bb425b6028e4e43bef6009..8ec85056aa0d5434c3d944eab7281a0ac6fded75 100644 (file)
@@ -429,6 +429,10 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
        cls_flower.classid = f->res.classid;
 
        tc_setup_cb_call(block, TC_SETUP_CLSFLOWER, &cls_flower, false);
+
+       tcf_exts_stats_update(&f->exts, cls_flower.stats.bytes,
+                             cls_flower.stats.pkts,
+                             cls_flower.stats.lastused);
 }
 
 static bool __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f,