Skip to content

Commit 40bd036

Browse files
jrfastabdavem330
authored andcommitted
net: sched: provide per cpu qstat helpers
The per cpu qstats support was added with per cpu bstat support which is currently used by the ingress qdisc. This patch adds a set of helpers needed to make other qdiscs that use qstats per cpu as well. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 29b86cd commit 40bd036

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

include/net/sch_generic.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,12 +632,39 @@ static inline void qdisc_qstats_backlog_dec(struct Qdisc *sch,
632632
sch->qstats.backlog -= qdisc_pkt_len(skb);
633633
}
634634

635+
static inline void qdisc_qstats_cpu_backlog_dec(struct Qdisc *sch,
636+
const struct sk_buff *skb)
637+
{
638+
this_cpu_sub(sch->cpu_qstats->backlog, qdisc_pkt_len(skb));
639+
}
640+
635641
static inline void qdisc_qstats_backlog_inc(struct Qdisc *sch,
636642
const struct sk_buff *skb)
637643
{
638644
sch->qstats.backlog += qdisc_pkt_len(skb);
639645
}
640646

647+
static inline void qdisc_qstats_cpu_backlog_inc(struct Qdisc *sch,
648+
const struct sk_buff *skb)
649+
{
650+
this_cpu_add(sch->cpu_qstats->backlog, qdisc_pkt_len(skb));
651+
}
652+
653+
static inline void qdisc_qstats_cpu_qlen_inc(struct Qdisc *sch)
654+
{
655+
this_cpu_inc(sch->cpu_qstats->qlen);
656+
}
657+
658+
static inline void qdisc_qstats_cpu_qlen_dec(struct Qdisc *sch)
659+
{
660+
this_cpu_dec(sch->cpu_qstats->qlen);
661+
}
662+
663+
static inline void qdisc_qstats_cpu_requeues_inc(struct Qdisc *sch)
664+
{
665+
this_cpu_inc(sch->cpu_qstats->requeues);
666+
}
667+
641668
static inline void __qdisc_qstats_drop(struct Qdisc *sch, int count)
642669
{
643670
sch->qstats.drops += count;
@@ -845,6 +872,14 @@ static inline void rtnl_qdisc_drop(struct sk_buff *skb, struct Qdisc *sch)
845872
qdisc_qstats_drop(sch);
846873
}
847874

875+
static inline int qdisc_drop_cpu(struct sk_buff *skb, struct Qdisc *sch,
876+
struct sk_buff **to_free)
877+
{
878+
__qdisc_drop(skb, to_free);
879+
qdisc_qstats_cpu_drop(sch);
880+
881+
return NET_XMIT_DROP;
882+
}
848883

849884
static inline int qdisc_drop(struct sk_buff *skb, struct Qdisc *sch,
850885
struct sk_buff **to_free)

0 commit comments

Comments
 (0)