From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jakub Kicinski Subject: Re: [PATCH net-next,v4 05/12] flow_offload: add statistics retrieval infrastructure and use it Date: Thu, 29 Nov 2018 12:48:22 -0800 Message-ID: <20181129124822.178e17a6@cakuba.netronome.com> References: <20181129022231.2740-1-pablo@netfilter.org> <20181129022231.2740-6-pablo@netfilter.org> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, davem@davemloft.net, thomas.lendacky@amd.com, f.fainelli@gmail.com, ariel.elior@cavium.com, michael.chan@broadcom.com, santosh@chelsio.com, madalin.bucur@nxp.com, yisen.zhuang@huawei.com, salil.mehta@huawei.com, jeffrey.t.kirsher@intel.com, tariqt@mellanox.com, saeedm@mellanox.com, jiri@mellanox.com, idosch@mellanox.com, peppe.cavallaro@st.com, grygorii.strashko@ti.com, andrew@lunn.ch, vivien.didelot@savoirfairelinux.com, alexandre.torgue@st.com, joabreu@synopsys.com, linux-net-drivers@solarflare.com, ganeshgr@chelsio.com, ogerlitz@mellanox.com, Manish.Chopra@cavium.com, marcelo.leitner@gmail.com To: Pablo Neira Ayuso Return-path: Received: from mail-qk1-f196.google.com ([209.85.222.196]:45900 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbeK3HzL (ORCPT ); Fri, 30 Nov 2018 02:55:11 -0500 Received: by mail-qk1-f196.google.com with SMTP id y78so1906639qka.12 for ; Thu, 29 Nov 2018 12:48:29 -0800 (PST) In-Reply-To: <20181129022231.2740-6-pablo@netfilter.org> Sender: netdev-owner@vger.kernel.org List-ID: On Thu, 29 Nov 2018 03:22:24 +0100, Pablo Neira Ayuso wrote: > 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 > diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h > index dabc819b6cc9..040c092c000a 100644 > --- a/include/net/flow_offload.h > +++ b/include/net/flow_offload.h > @@ -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 pkts, u64 bytes, u64 lastused) > +{ > + flow_stats->pkts = pkts; > + flow_stats->bytes = bytes; > + flow_stats->lastused = lastused; > +} > + > #endif /* _NET_FLOW_OFFLOAD_H */ > diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h > index abb035f84321..a08c06e383db 100644 > --- a/include/net/pkt_cls.h > +++ b/include/net/pkt_cls.h > @@ -767,6 +767,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; > }; > diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c > index 8898943b8ee6..b88cf29aff7b 100644 > --- a/net/sched/cls_flower.c > +++ b/net/sched/cls_flower.c > @@ -432,6 +432,10 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) > > tc_setup_cb_call(block, &f->exts, 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, Apart from the bug Venkat mentioned I think this patch exposes a potentially strange and unexpected TC-ism through to the abstracted API. The stats for TC store the increment in update cycle, so flow->stats will be equal to the diff between TC_CLSFLOWER_STATS calls. Its this behaviour going to be subsystem-specific? Looks not-so-clean.