diff options
Diffstat (limited to 'net/sched/sch_fifo.c')
-rw-r--r-- | net/sched/sch_fifo.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c index 69188e8358b4..4b0a6cc44c77 100644 --- a/net/sched/sch_fifo.c +++ b/net/sched/sch_fifo.c | |||
@@ -43,6 +43,26 @@ static int pfifo_enqueue(struct sk_buff *skb, struct Qdisc* sch) | |||
43 | return qdisc_reshape_fail(skb, sch); | 43 | return qdisc_reshape_fail(skb, sch); |
44 | } | 44 | } |
45 | 45 | ||
46 | static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc* sch) | ||
47 | { | ||
48 | struct sk_buff *skb_head; | ||
49 | struct fifo_sched_data *q = qdisc_priv(sch); | ||
50 | |||
51 | if (likely(skb_queue_len(&sch->q) < q->limit)) | ||
52 | return qdisc_enqueue_tail(skb, sch); | ||
53 | |||
54 | /* queue full, remove one skb to fulfill the limit */ | ||
55 | skb_head = qdisc_dequeue_head(sch); | ||
56 | sch->bstats.bytes -= qdisc_pkt_len(skb_head); | ||
57 | sch->bstats.packets--; | ||
58 | sch->qstats.drops++; | ||
59 | kfree_skb(skb_head); | ||
60 | |||
61 | qdisc_enqueue_tail(skb, sch); | ||
62 | |||
63 | return NET_XMIT_CN; | ||
64 | } | ||
65 | |||
46 | static int fifo_init(struct Qdisc *sch, struct nlattr *opt) | 66 | static int fifo_init(struct Qdisc *sch, struct nlattr *opt) |
47 | { | 67 | { |
48 | struct fifo_sched_data *q = qdisc_priv(sch); | 68 | struct fifo_sched_data *q = qdisc_priv(sch); |
@@ -108,6 +128,20 @@ struct Qdisc_ops bfifo_qdisc_ops __read_mostly = { | |||
108 | }; | 128 | }; |
109 | EXPORT_SYMBOL(bfifo_qdisc_ops); | 129 | EXPORT_SYMBOL(bfifo_qdisc_ops); |
110 | 130 | ||
131 | struct Qdisc_ops pfifo_head_drop_qdisc_ops __read_mostly = { | ||
132 | .id = "pfifo_head_drop", | ||
133 | .priv_size = sizeof(struct fifo_sched_data), | ||
134 | .enqueue = pfifo_tail_enqueue, | ||
135 | .dequeue = qdisc_dequeue_head, | ||
136 | .peek = qdisc_peek_head, | ||
137 | .drop = qdisc_queue_drop_head, | ||
138 | .init = fifo_init, | ||
139 | .reset = qdisc_reset_queue, | ||
140 | .change = fifo_init, | ||
141 | .dump = fifo_dump, | ||
142 | .owner = THIS_MODULE, | ||
143 | }; | ||
144 | |||
111 | /* Pass size change message down to embedded FIFO */ | 145 | /* Pass size change message down to embedded FIFO */ |
112 | int fifo_set_limit(struct Qdisc *q, unsigned int limit) | 146 | int fifo_set_limit(struct Qdisc *q, unsigned int limit) |
113 | { | 147 | { |