aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/sch_prio.c
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-10-31 03:44:18 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-31 03:44:18 -0400
commit48a8f519e0fe22a5c98523286b2a120841a11dd5 (patch)
treeec70428b026091669bf1e23779f9cfdd1a1ca46f /net/sched/sch_prio.c
parent90d841fd0a5e02affd4e2bbdde4f710c61599281 (diff)
pkt_sched: Add ->peek() methods for fifo, prio and SFQ qdiscs.
From: Patrick McHardy <kaber@trash.net> Just as a demonstration how easy adding a peek operation to the work-conserving qdiscs actually is. It doesn't need to keep or change any internal state in many cases thanks to the guarantee that the packet will either be dequeued or, if another packet arrives, the upper qdisc will immediately ->peek again to reevaluate the state. (This is only slightly modified Patrick's patch.) Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/sch_prio.c')
-rw-r--r--net/sched/sch_prio.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index 504a78cdb718..3651da3e2802 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -120,6 +120,19 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch)
120 return ret; 120 return ret;
121} 121}
122 122
123static struct sk_buff *prio_peek(struct Qdisc *sch)
124{
125 struct prio_sched_data *q = qdisc_priv(sch);
126 int prio;
127
128 for (prio = 0; prio < q->bands; prio++) {
129 struct Qdisc *qdisc = q->queues[prio];
130 struct sk_buff *skb = qdisc->ops->peek(qdisc);
131 if (skb)
132 return skb;
133 }
134 return NULL;
135}
123 136
124static struct sk_buff *prio_dequeue(struct Qdisc* sch) 137static struct sk_buff *prio_dequeue(struct Qdisc* sch)
125{ 138{
@@ -421,6 +434,7 @@ static struct Qdisc_ops prio_qdisc_ops __read_mostly = {
421 .priv_size = sizeof(struct prio_sched_data), 434 .priv_size = sizeof(struct prio_sched_data),
422 .enqueue = prio_enqueue, 435 .enqueue = prio_enqueue,
423 .dequeue = prio_dequeue, 436 .dequeue = prio_dequeue,
437 .peek = prio_peek,
424 .requeue = prio_requeue, 438 .requeue = prio_requeue,
425 .drop = prio_drop, 439 .drop = prio_drop,
426 .init = prio_init, 440 .init = prio_init,