From: Amir Vadai <amir@vadai.me>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Or Gerlitz <ogerlitz@mellanox.com>,
Amir Vadai <amir@vadai.me>, Saeed Mahameed <saeedm@mellanox.com>,
Amir Vadai <amirva@mellanox.com>
Subject: [PATCH net-next 1/8] net/sched: Enable netdev drivers to update statistics of offloaded actions
Date: Fri, 13 May 2016 12:55:35 +0000 [thread overview]
Message-ID: <1463144142-13810-2-git-send-email-amir@vadai.me> (raw)
In-Reply-To: <1463144142-13810-1-git-send-email-amir@vadai.me>
From: Amir Vadai <amirva@mellanox.com>
Introduce stats_update callback. netdev driver could call it for offloaded
actions to update the basic statistics (packets, bytes and last use).
Since bstats_update() and bstats_cpu_update() use skb as an argument to
get the counters, _bstats_update() and _bstats_cpu_update(), that get
bytes and packets as arguments, were added.
Signed-off-by: Amir Vadai <amirva@mellanox.com>
---
include/net/act_api.h | 12 ++++++++++++
include/net/sch_generic.h | 20 ++++++++++++++++++--
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 03e322b..2cd9e9b 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -106,6 +106,7 @@ struct tc_action_ops {
int bind);
int (*walk)(struct net *, struct sk_buff *,
struct netlink_callback *, int, struct tc_action *);
+ void (*stats_update)(struct tc_action *, u64, u32, u64);
};
struct tc_action_net {
@@ -178,10 +179,21 @@ int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
#define tc_for_each_action(_a, _exts) \
list_for_each_entry(a, &(_exts)->actions, list)
+
+static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
+ u64 packets, u64 lastuse)
+{
+ if (!a->ops->stats_update)
+ return;
+
+ a->ops->stats_update(a, bytes, packets, lastuse);
+}
+
#else /* CONFIG_NET_CLS_ACT */
#define tc_no_actions(_exts) true
#define tc_for_each_action(_a, _exts) while (0)
+#define tcf_action_stats_update(a, bytes, packets, lastuse)
#endif /* CONFIG_NET_CLS_ACT */
#endif
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 46e55f0..a1fd76c 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -527,11 +527,27 @@ static inline bool qdisc_is_percpu_stats(const struct Qdisc *q)
return q->flags & TCQ_F_CPUSTATS;
}
+static inline void _bstats_update(struct gnet_stats_basic_packed *bstats,
+ __u64 bytes, __u32 packets)
+{
+ bstats->bytes += bytes;
+ bstats->packets += packets;
+}
+
static inline void bstats_update(struct gnet_stats_basic_packed *bstats,
const struct sk_buff *skb)
{
- bstats->bytes += qdisc_pkt_len(skb);
- bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1;
+ _bstats_update(bstats,
+ qdisc_pkt_len(skb),
+ skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1);
+}
+
+static inline void _bstats_cpu_update(struct gnet_stats_basic_cpu *bstats,
+ __u64 bytes, __u32 packets)
+{
+ u64_stats_update_begin(&bstats->syncp);
+ _bstats_update(&bstats->bstats, bytes, packets);
+ u64_stats_update_end(&bstats->syncp);
}
static inline void bstats_cpu_update(struct gnet_stats_basic_cpu *bstats,
--
2.8.0
next prev parent reply other threads:[~2016-05-13 12:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 12:55 [PATCH net-next 0/8] sched,mlx5: Offloaded TC flower filter statistics Amir Vadai
2016-05-13 12:55 ` Amir Vadai [this message]
2016-05-13 12:55 ` [PATCH net-next 2/8] net/sched: act_gact: Update statistics when offloaded to hardware Amir Vadai
2016-05-13 12:55 ` [PATCH net-next 3/8] net/sched: cls_flower: Hardware offloaded filters statistics support Amir Vadai
2016-05-13 12:55 ` [PATCH net-next 4/8] net/mlx5_core: Use a macro in mlx5_command_str() Amir Vadai
2016-05-13 12:55 ` [PATCH net-next 5/8] net/mlx5_core: Firmware commands to support flow counters Amir Vadai
2016-05-13 12:55 ` [PATCH net-next 6/8] net/mlx5_core: Introduce flow steering destination of type counter Amir Vadai
2016-05-13 12:55 ` [PATCH net-next 7/8] net/mlx5_core: Flow counters infrastructure Amir Vadai
2016-05-13 12:55 ` [PATCH net-next 8/8] net/mlx5e: Hardware offloaded flower filter statistics support Amir Vadai
2016-05-16 17:44 ` [PATCH net-next 0/8] sched,mlx5: Offloaded TC flower filter statistics David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1463144142-13810-2-git-send-email-amir@vadai.me \
--to=amir@vadai.me \
--cc=amirva@mellanox.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=saeedm@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).