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)
{
if (!atm_may_send(flow->vcc, skb->truesize))
break;
- skb = flow->q->dequeue(flow->q);
+ skb = qdisc_dequeue_peeked(flow->q);
if (unlikely(!skb))
break;
pr_debug("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p);
tasklet_schedule(&p->task);
- skb = p->link.q->dequeue(p->link.q);
+ skb = qdisc_dequeue_peeked(p->link.q);
if (skb)
sch->q.qlen--;
return skb;
.priv_size = sizeof(struct cbq_sched_data),
.enqueue = cbq_enqueue,
.dequeue = cbq_dequeue,
+ .peek = qdisc_peek_dequeued,
.requeue = cbq_requeue,
.drop = cbq_drop,
.init = cbq_init,
}
}
- skb = cl->qdisc->dequeue(cl->qdisc);
+ skb = qdisc_dequeue_peeked(cl->qdisc);
if (skb == NULL) {
if (net_ratelimit())
printk("HFSC: Non-work-conserving qdisc ?\n");
.dump = hfsc_dump_qdisc,
.enqueue = hfsc_enqueue,
.dequeue = hfsc_dequeue,
+ .peek = qdisc_peek_dequeued,
.requeue = hfsc_requeue,
.drop = hfsc_drop,
.cl_ops = &hfsc_class_ops,
.priv_size = sizeof(struct htb_sched),
.enqueue = htb_enqueue,
.dequeue = htb_dequeue,
+ .peek = qdisc_peek_dequeued,
.requeue = htb_requeue,
.drop = htb_drop,
.init = htb_init,
/* if more time remaining? */
if (cb->time_to_send <= now) {
- skb = q->qdisc->dequeue(q->qdisc);
- if (!skb)
+ skb = qdisc_dequeue_peeked(q->qdisc);
+ if (unlikely(!skb))
return NULL;
pr_debug("netem_dequeue: return skb=%p\n", skb);
.priv_size = sizeof(struct netem_sched_data),
.enqueue = netem_enqueue,
.dequeue = netem_dequeue,
+ .peek = qdisc_peek_dequeued,
.requeue = netem_requeue,
.drop = netem_drop,
.init = netem_init,
toks -= L2T(q, len);
if ((toks|ptoks) >= 0) {
- skb = q->qdisc->dequeue(q->qdisc);
+ skb = qdisc_dequeue_peeked(q->qdisc);
if (unlikely(!skb))
return NULL;
.priv_size = sizeof(struct tbf_sched_data),
.enqueue = tbf_enqueue,
.dequeue = tbf_dequeue,
+ .peek = qdisc_peek_dequeued,
.requeue = tbf_requeue,
.drop = tbf_drop,
.init = tbf_init,