summaryrefslogtreecommitdiffstats
path: root/include/net/sch_generic.h
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2017-12-07 09:57:00 -0800
committerDavid S. Miller <davem@davemloft.net>2017-12-08 13:32:26 -0500
commit7e66016f2c65bfc1181f42274fcb7f1183ab1bb5 (patch)
treec3ab895c92d9eef6e0c55d267f8712b956184de5 /include/net/sch_generic.h
parentfd8e8d1a775d82f04215f4b884a1962774805346 (diff)
downloadlinux-7e66016f2c65bfc1181f42274fcb7f1183ab1bb5.tar.gz
linux-7e66016f2c65bfc1181f42274fcb7f1183ab1bb5.tar.bz2
linux-7e66016f2c65bfc1181f42274fcb7f1183ab1bb5.zip
net: sched: helpers to sum qlen and qlen for per cpu logic
Add qdisc qlen helper routines for lockless qdiscs to use. The qdisc qlen is no longer used in the hotpath but it is reported via stats query on the qdisc so it still needs to be tracked. This adds the per cpu operations needed along with a helper to return the summation of per cpu stats. Signed-off-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/sch_generic.h')
-rw-r--r--include/net/sch_generic.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index da2528036e2e..8f8c0afe529b 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -292,11 +292,31 @@ static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz)
BUILD_BUG_ON(sizeof(qcb->data) < sz);
}
+static inline int qdisc_qlen_cpu(const struct Qdisc *q)
+{
+ return this_cpu_ptr(q->cpu_qstats)->qlen;
+}
+
static inline int qdisc_qlen(const struct Qdisc *q)
{
return q->q.qlen;
}
+static inline int qdisc_qlen_sum(const struct Qdisc *q)
+{
+ __u32 qlen = 0;
+ int i;
+
+ if (q->flags & TCQ_F_NOLOCK) {
+ for_each_possible_cpu(i)
+ qlen += per_cpu_ptr(q->cpu_qstats, i)->qlen;
+ } else {
+ qlen = q->q.qlen;
+ }
+
+ return qlen;
+}
+
static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb)
{
return (struct qdisc_skb_cb *)skb->cb;