]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
pkt_sched: Add ->peek() methods for fifo, prio and SFQ qdiscs.
authorPatrick McHardy <kaber@trash.net>
Fri, 31 Oct 2008 07:44:18 +0000 (00:44 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 31 Oct 2008 07:44:18 +0000 (00:44 -0700)
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>
include/net/sch_generic.h
net/sched/sch_fifo.c
net/sched/sch_prio.c
net/sched/sch_sfq.c

index f81f7c4d76fa5d5126662776e70bf70a0eb1ce66..da6839a7ff50e264d694a2c2b2309375ff6aadcb 100644 (file)
@@ -433,6 +433,11 @@ static inline struct sk_buff *qdisc_dequeue_tail(struct Qdisc *sch)
        return __qdisc_dequeue_tail(sch, &sch->q);
 }
 
+static inline struct sk_buff *qdisc_peek_head(struct Qdisc *sch)
+{
+       return skb_peek(&sch->q);
+}
+
 static inline int __qdisc_requeue(struct sk_buff *skb, struct Qdisc *sch,
                                  struct sk_buff_head *list)
 {
index 23d258bfe8ace223e07d0c23dc62fbe7e0ae9faa..8825e8806f41ab9898b6106a336e1bbb312ce059 100644 (file)
@@ -83,6 +83,7 @@ struct Qdisc_ops pfifo_qdisc_ops __read_mostly = {
        .priv_size      =       sizeof(struct fifo_sched_data),
        .enqueue        =       pfifo_enqueue,
        .dequeue        =       qdisc_dequeue_head,
+       .peek           =       qdisc_peek_head,
        .requeue        =       qdisc_requeue,
        .drop           =       qdisc_queue_drop,
        .init           =       fifo_init,
@@ -98,6 +99,7 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = {
        .priv_size      =       sizeof(struct fifo_sched_data),
        .enqueue        =       bfifo_enqueue,
        .dequeue        =       qdisc_dequeue_head,
+       .peek           =       qdisc_peek_head,
        .requeue        =       qdisc_requeue,
        .drop           =       qdisc_queue_drop,
        .init           =       fifo_init,
index 504a78cdb718bb7dd7ba05e60feb1f5fd2e89ea3..3651da3e280211fddfa167dbe595283af399ac29 100644 (file)
@@ -120,6 +120,19 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch)
        return ret;
 }
 
+static struct sk_buff *prio_peek(struct Qdisc *sch)
+{
+       struct prio_sched_data *q = qdisc_priv(sch);
+       int prio;
+
+       for (prio = 0; prio < q->bands; prio++) {
+               struct Qdisc *qdisc = q->queues[prio];
+               struct sk_buff *skb = qdisc->ops->peek(qdisc);
+               if (skb)
+                       return skb;
+       }
+       return NULL;
+}
 
 static struct sk_buff *prio_dequeue(struct Qdisc* sch)
 {
@@ -421,6 +434,7 @@ static struct Qdisc_ops prio_qdisc_ops __read_mostly = {
        .priv_size      =       sizeof(struct prio_sched_data),
        .enqueue        =       prio_enqueue,
        .dequeue        =       prio_dequeue,
+       .peek           =       prio_peek,
        .requeue        =       prio_requeue,
        .drop           =       prio_drop,
        .init           =       prio_init,
index fe1508ef0d3d51e7d552a88e253a1d4b0b82fec6..198b83d42ba8159044420896b7ee4e89fe7d48c6 100644 (file)
@@ -391,8 +391,19 @@ sfq_requeue(struct sk_buff *skb, struct Qdisc *sch)
        return NET_XMIT_CN;
 }
 
+static struct sk_buff *
+sfq_peek(struct Qdisc *sch)
+{
+       struct sfq_sched_data *q = qdisc_priv(sch);
+       sfq_index a;
 
+       /* No active slots */
+       if (q->tail == SFQ_DEPTH)
+               return NULL;
 
+       a = q->next[q->tail];
+       return skb_peek(&q->qs[a]);
+}
 
 static struct sk_buff *
 sfq_dequeue(struct Qdisc *sch)
@@ -624,6 +635,7 @@ static struct Qdisc_ops sfq_qdisc_ops __read_mostly = {
        .priv_size      =       sizeof(struct sfq_sched_data),
        .enqueue        =       sfq_enqueue,
        .dequeue        =       sfq_dequeue,
+       .peek           =       sfq_peek,
        .requeue        =       sfq_requeue,
        .drop           =       sfq_drop,
        .init           =       sfq_init,