]> git.karo-electronics.de Git - linux-beck.git/blobdiff - include/net/sch_generic.h
pkt_sched: Add peek emulation for non-work-conserving qdiscs.
[linux-beck.git] / include / net / sch_generic.h
index da6839a7ff50e264d694a2c2b2309375ff6aadcb..9dcb5bfe094a3c6b833f253c1e04cba17c3d89ae 100644 (file)
@@ -438,6 +438,29 @@ static inline struct sk_buff *qdisc_peek_head(struct Qdisc *sch)
        return skb_peek(&sch->q);
 }
 
+/* generic pseudo peek method for non-work-conserving qdisc */
+static inline struct sk_buff *qdisc_peek_dequeued(struct Qdisc *sch)
+{
+       /* we can reuse ->gso_skb because peek isn't called for root qdiscs */
+       if (!sch->gso_skb)
+               sch->gso_skb = sch->dequeue(sch);
+
+       return sch->gso_skb;
+}
+
+/* use instead of qdisc->dequeue() for all qdiscs queried with ->peek() */
+static inline struct sk_buff *qdisc_dequeue_peeked(struct Qdisc *sch)
+{
+       struct sk_buff *skb = sch->gso_skb;
+
+       if (skb)
+               sch->gso_skb = NULL;
+       else
+               skb = sch->dequeue(sch);
+
+       return skb;
+}
+
 static inline int __qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch,
                                  struct sk_buff_head *list)
 {