Commit f87a9c3d authored by Thomas Graf's avatar Thomas Graf Committed by David S. Miller

[PKT_SCHED]: Cleanup pfifo_fast qdisc and remove unnecessary code

Removes the skb trimming code which is not needed since we never
touch the skb upon failure. Removes unnecessary initializers,
and simplifies the code a bit.
Signed-off-by: default avatarThomas Graf <tgraf@suug.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 321090e7
...@@ -311,6 +311,8 @@ static const u8 prio2band[TC_PRIO_MAX+1] = ...@@ -311,6 +311,8 @@ static const u8 prio2band[TC_PRIO_MAX+1] =
generic prio+fifo combination. generic prio+fifo combination.
*/ */
#define PFIFO_FAST_BANDS 3
static inline struct sk_buff_head *prio2list(struct sk_buff *skb, static inline struct sk_buff_head *prio2list(struct sk_buff *skb,
struct Qdisc *qdisc) struct Qdisc *qdisc)
{ {
...@@ -318,8 +320,7 @@ static inline struct sk_buff_head *prio2list(struct sk_buff *skb, ...@@ -318,8 +320,7 @@ static inline struct sk_buff_head *prio2list(struct sk_buff *skb,
return list + prio2band[skb->priority & TC_PRIO_MAX]; return list + prio2band[skb->priority & TC_PRIO_MAX];
} }
static int static int pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
{ {
struct sk_buff_head *list = prio2list(skb, qdisc); struct sk_buff_head *list = prio2list(skb, qdisc);
...@@ -331,36 +332,34 @@ pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc) ...@@ -331,36 +332,34 @@ pfifo_fast_enqueue(struct sk_buff *skb, struct Qdisc* qdisc)
return qdisc_drop(skb, qdisc); return qdisc_drop(skb, qdisc);
} }
static struct sk_buff * static struct sk_buff *pfifo_fast_dequeue(struct Qdisc* qdisc)
pfifo_fast_dequeue(struct Qdisc* qdisc)
{ {
int prio; int prio;
struct sk_buff_head *list = qdisc_priv(qdisc); struct sk_buff_head *list = qdisc_priv(qdisc);
for (prio = 0; prio < 3; prio++, list++) { for (prio = 0; prio < PFIFO_FAST_BANDS; prio++, list++) {
struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list); struct sk_buff *skb = __qdisc_dequeue_head(qdisc, list);
if (skb) { if (skb) {
qdisc->q.qlen--; qdisc->q.qlen--;
return skb; return skb;
} }
} }
return NULL; return NULL;
} }
static int static int pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
pfifo_fast_requeue(struct sk_buff *skb, struct Qdisc* qdisc)
{ {
qdisc->q.qlen++; qdisc->q.qlen++;
return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc)); return __qdisc_requeue(skb, qdisc, prio2list(skb, qdisc));
} }
static void static void pfifo_fast_reset(struct Qdisc* qdisc)
pfifo_fast_reset(struct Qdisc* qdisc)
{ {
int prio; int prio;
struct sk_buff_head *list = qdisc_priv(qdisc); struct sk_buff_head *list = qdisc_priv(qdisc);
for (prio=0; prio < 3; prio++) for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
__qdisc_reset_queue(qdisc, list + prio); __qdisc_reset_queue(qdisc, list + prio);
qdisc->qstats.backlog = 0; qdisc->qstats.backlog = 0;
...@@ -369,35 +368,30 @@ pfifo_fast_reset(struct Qdisc* qdisc) ...@@ -369,35 +368,30 @@ pfifo_fast_reset(struct Qdisc* qdisc)
static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb) static int pfifo_fast_dump(struct Qdisc *qdisc, struct sk_buff *skb)
{ {
unsigned char *b = skb->tail; struct tc_prio_qopt opt = { .bands = PFIFO_FAST_BANDS };
struct tc_prio_qopt opt;
opt.bands = 3;
memcpy(&opt.priomap, prio2band, TC_PRIO_MAX+1); memcpy(&opt.priomap, prio2band, TC_PRIO_MAX+1);
RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt); RTA_PUT(skb, TCA_OPTIONS, sizeof(opt), &opt);
return skb->len; return skb->len;
rtattr_failure: rtattr_failure:
skb_trim(skb, b - skb->data);
return -1; return -1;
} }
static int pfifo_fast_init(struct Qdisc *qdisc, struct rtattr *opt) static int pfifo_fast_init(struct Qdisc *qdisc, struct rtattr *opt)
{ {
int i; int prio;
struct sk_buff_head *list = qdisc_priv(qdisc); struct sk_buff_head *list = qdisc_priv(qdisc);
for (i=0; i<3; i++) for (prio = 0; prio < PFIFO_FAST_BANDS; prio++)
skb_queue_head_init(list+i); skb_queue_head_init(list + prio);
return 0; return 0;
} }
static struct Qdisc_ops pfifo_fast_ops = { static struct Qdisc_ops pfifo_fast_ops = {
.next = NULL,
.cl_ops = NULL,
.id = "pfifo_fast", .id = "pfifo_fast",
.priv_size = 3 * sizeof(struct sk_buff_head), .priv_size = PFIFO_FAST_BANDS * sizeof(struct sk_buff_head),
.enqueue = pfifo_fast_enqueue, .enqueue = pfifo_fast_enqueue,
.dequeue = pfifo_fast_dequeue, .dequeue = pfifo_fast_dequeue,
.requeue = pfifo_fast_requeue, .requeue = pfifo_fast_requeue,
......
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