Commit 23624935 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net_sched: TCQ_F_CAN_BYPASS generalization

Now qdisc stab is handled before TCQ_F_CAN_BYPASS test in
__dev_xmit_skb(), we can generalize TCQ_F_CAN_BYPASS to other qdiscs
than pfifo_fast : pfifo, bfifo, pfifo_head_drop and sfq

SFQ is special because it can have external classifiers, and in these
cases, we cannot bypass queue discipline (packet could be dropped by
classifier) without admin asking it, or further changes.

Its worth doing this, especially for SFQ, avoiding dirtying memory in
case no packets are already waiting in queue.
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bb134d22
...@@ -64,11 +64,13 @@ static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch) ...@@ -64,11 +64,13 @@ static int pfifo_tail_enqueue(struct sk_buff *skb, struct Qdisc *sch)
static int fifo_init(struct Qdisc *sch, struct nlattr *opt) static int fifo_init(struct Qdisc *sch, struct nlattr *opt)
{ {
struct fifo_sched_data *q = qdisc_priv(sch); struct fifo_sched_data *q = qdisc_priv(sch);
bool bypass;
bool is_bfifo = sch->ops == &bfifo_qdisc_ops;
if (opt == NULL) { if (opt == NULL) {
u32 limit = qdisc_dev(sch)->tx_queue_len ? : 1; u32 limit = qdisc_dev(sch)->tx_queue_len ? : 1;
if (sch->ops == &bfifo_qdisc_ops) if (is_bfifo)
limit *= psched_mtu(qdisc_dev(sch)); limit *= psched_mtu(qdisc_dev(sch));
q->limit = limit; q->limit = limit;
...@@ -81,6 +83,15 @@ static int fifo_init(struct Qdisc *sch, struct nlattr *opt) ...@@ -81,6 +83,15 @@ static int fifo_init(struct Qdisc *sch, struct nlattr *opt)
q->limit = ctl->limit; q->limit = ctl->limit;
} }
if (is_bfifo)
bypass = q->limit >= psched_mtu(qdisc_dev(sch));
else
bypass = q->limit >= 1;
if (bypass)
sch->flags |= TCQ_F_CAN_BYPASS;
else
sch->flags &= ~TCQ_F_CAN_BYPASS;
return 0; return 0;
} }
......
...@@ -527,6 +527,8 @@ static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt) ...@@ -527,6 +527,8 @@ static int pfifo_fast_init(struct Qdisc *qdisc, struct nlattr *opt)
for (prio = 0; prio < PFIFO_FAST_BANDS; prio++) for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
skb_queue_head_init(band2list(priv, prio)); skb_queue_head_init(band2list(priv, prio));
/* Can by-pass the queue discipline */
qdisc->flags |= TCQ_F_CAN_BYPASS;
return 0; return 0;
} }
...@@ -691,9 +693,6 @@ static void attach_one_default_qdisc(struct net_device *dev, ...@@ -691,9 +693,6 @@ static void attach_one_default_qdisc(struct net_device *dev,
netdev_info(dev, "activation failed\n"); netdev_info(dev, "activation failed\n");
return; return;
} }
/* Can by-pass the queue discipline for default qdisc */
qdisc->flags |= TCQ_F_CAN_BYPASS;
} }
dev_queue->qdisc_sleeping = qdisc; dev_queue->qdisc_sleeping = qdisc;
} }
......
...@@ -61,7 +61,6 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt) ...@@ -61,7 +61,6 @@ static int mq_init(struct Qdisc *sch, struct nlattr *opt)
TC_H_MIN(ntx + 1))); TC_H_MIN(ntx + 1)));
if (qdisc == NULL) if (qdisc == NULL)
goto err; goto err;
qdisc->flags |= TCQ_F_CAN_BYPASS;
priv->qdiscs[ntx] = qdisc; priv->qdiscs[ntx] = qdisc;
} }
......
...@@ -130,7 +130,6 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt) ...@@ -130,7 +130,6 @@ static int mqprio_init(struct Qdisc *sch, struct nlattr *opt)
err = -ENOMEM; err = -ENOMEM;
goto err; goto err;
} }
qdisc->flags |= TCQ_F_CAN_BYPASS;
priv->qdiscs[i] = qdisc; priv->qdiscs[i] = qdisc;
} }
......
...@@ -560,6 +560,10 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt) ...@@ -560,6 +560,10 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt)
slot_queue_init(&q->slots[i]); slot_queue_init(&q->slots[i]);
sfq_link(q, i); sfq_link(q, i);
} }
if (q->limit >= 1)
sch->flags |= TCQ_F_CAN_BYPASS;
else
sch->flags &= ~TCQ_F_CAN_BYPASS;
return 0; return 0;
} }
...@@ -611,6 +615,8 @@ static unsigned long sfq_get(struct Qdisc *sch, u32 classid) ...@@ -611,6 +615,8 @@ static unsigned long sfq_get(struct Qdisc *sch, u32 classid)
static unsigned long sfq_bind(struct Qdisc *sch, unsigned long parent, static unsigned long sfq_bind(struct Qdisc *sch, unsigned long parent,
u32 classid) u32 classid)
{ {
/* we cannot bypass queue discipline anymore */
sch->flags &= ~TCQ_F_CAN_BYPASS;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment