aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorJarek Poplawski <jarkao2@gmail.com>2008-10-31 03:45:27 -0400
committerDavid S. Miller <davem@davemloft.net>2008-10-31 03:45:27 -0400
commit99c0db26797edb39cf83c8c5f8972067f5426b4e (patch)
tree918b933d2ac5f0579b24636274c4394c17011d0d /net/sched
parent48a8f519e0fe22a5c98523286b2a120841a11dd5 (diff)
pkt_sched: sch_generic: Add generic qdisc->ops->peek() implementation.
With feedback from Patrick McHardy. Signed-off-by: Jarek Poplawski <jarkao2@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/sch_api.c12
-rw-r--r--net/sched/sch_generic.c16
2 files changed, 28 insertions, 0 deletions
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index b16ad2972c6b..e5646614e88d 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -102,6 +102,10 @@ static int tclass_notify(struct sk_buff *oskb, struct nlmsghdr *n,
102 requeues once dequeued packet. It is used for non-standard or 102 requeues once dequeued packet. It is used for non-standard or
103 just buggy devices, which can defer output even if netif_queue_stopped()=0. 103 just buggy devices, which can defer output even if netif_queue_stopped()=0.
104 104
105 ---peek
106
107 like dequeue but without removing a packet from the queue
108
105 ---reset 109 ---reset
106 110
107 returns qdisc to initial state: purge all buffers, clear all 111 returns qdisc to initial state: purge all buffers, clear all
@@ -149,6 +153,14 @@ int register_qdisc(struct Qdisc_ops *qops)
149 qops->enqueue = noop_qdisc_ops.enqueue; 153 qops->enqueue = noop_qdisc_ops.enqueue;
150 if (qops->requeue == NULL) 154 if (qops->requeue == NULL)
151 qops->requeue = noop_qdisc_ops.requeue; 155 qops->requeue = noop_qdisc_ops.requeue;
156 if (qops->peek == NULL) {
157 if (qops->dequeue == NULL) {
158 qops->peek = noop_qdisc_ops.peek;
159 } else {
160 rc = -EINVAL;
161 goto out;
162 }
163 }
152 if (qops->dequeue == NULL) 164 if (qops->dequeue == NULL)
153 qops->dequeue = noop_qdisc_ops.dequeue; 165 qops->dequeue = noop_qdisc_ops.dequeue;
154 166
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c
index 93cd30ce6501..318c9f656e8e 100644
--- a/net/sched/sch_generic.c
+++ b/net/sched/sch_generic.c
@@ -320,6 +320,7 @@ struct Qdisc_ops noop_qdisc_ops __read_mostly = {
320 .priv_size = 0, 320 .priv_size = 0,
321 .enqueue = noop_enqueue, 321 .enqueue = noop_enqueue,
322 .dequeue = noop_dequeue, 322 .dequeue = noop_dequeue,
323 .peek = noop_dequeue,
323 .requeue = noop_requeue, 324 .requeue = noop_requeue,
324 .owner = THIS_MODULE, 325 .owner = THIS_MODULE,
325}; 326};
@@ -346,6 +347,7 @@ static struct Qdisc_ops noqueue_qdisc_ops __read_mostly = {
346 .priv_size = 0, 347 .priv_size = 0,
347 .enqueue = noop_enqueue, 348 .enqueue = noop_enqueue,
348 .dequeue = noop_dequeue, 349 .dequeue = noop_dequeue,
350 .peek = noop_dequeue,
349 .requeue = noop_requeue, 351 .requeue = noop_requeue,
350 .owner = THIS_MODULE, 352 .owner = THIS_MODULE,
351}; 353};
@@ -411,6 +413,19 @@ static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
411 return NULL; 413 return NULL;
412} 414}
413 415
416static struct sk_buff *pfifo_fast_peek(struct Qdisc* qdisc)
417{
418 int prio;
419 struct sk_buff_head *list = qdisc_priv(qdisc);
420
421 for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) {
422 if (!skb_queue_empty(list + prio))
423 return skb_peek(list + prio);
424 }
425
426 return NULL;
427}
428
414static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc) 429static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
415{ 430{
416 qdisc->q.qlen++; 431 qdisc->q.qlen++;
@@ -457,6 +472,7 @@ static struct Qdisc_ops pfifo_fast_ops __read_mostly = {
457 .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head), 472 .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head),
458 .enqueue = pfifo_fast_enqueue, 473 .enqueue = pfifo_fast_enqueue,
459 .dequeue = pfifo_fast_dequeue, 474 .dequeue = pfifo_fast_dequeue,
475 .peek = pfifo_fast_peek,
460 .requeue = pfifo_fast_requeue, 476 .requeue = pfifo_fast_requeue,
461 .init = pfifo_fast_init, 477 .init = pfifo_fast_init,
462 .reset = pfifo_fast_reset, 478 .reset = pfifo_fast_reset,