[NET_SCHED]: Add accessor function for packet length for qdiscs Signed-off-by: Patrick McHardy --- commit 2a6508576111d82246ee018edbcc4b0f0d18acad tree 8be27ab6040ea90ed11728763e5b8fcf9e221b67 parent 31304c909e6945b005af62cd55a582e9c010a0b4 author Patrick McHardy Tue, 04 Jul 2006 15:03:01 +0200 committer Patrick McHardy Tue, 04 Jul 2006 15:03:01 +0200 include/net/sch_generic.h | 9 +++++++-- net/sched/sch_atm.c | 4 ++-- net/sched/sch_cbq.c | 12 ++++++------ net/sched/sch_dsmark.c | 2 +- net/sched/sch_fifo.c | 2 +- net/sched/sch_gred.c | 12 ++++++------ net/sched/sch_hfsc.c | 8 ++++---- net/sched/sch_htb.c | 8 ++++---- net/sched/sch_netem.c | 6 +++--- net/sched/sch_prio.c | 2 +- net/sched/sch_red.c | 2 +- net/sched/sch_sfq.c | 14 +++++++------- net/sched/sch_tbf.c | 6 +++--- net/sched/sch_teql.c | 4 ++-- 14 files changed, 48 insertions(+), 43 deletions(-) diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index b0e9108..75d7a55 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h @@ -184,12 +184,17 @@ tcf_destroy(struct tcf_proto *tp) kfree(tp); } +static inline unsigned int qdisc_tx_len(struct sk_buff *skb) +{ + return skb->len; +} + static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff_head *list) { __skb_queue_tail(list, skb); - sch->qstats.backlog += skb->len; - sch->bstats.bytes += skb->len; + sch->qstats.backlog += qdisc_tx_len(skb); + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; return NET_XMIT_SUCCESS; diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index dbf44da..4df305e 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c @@ -453,9 +453,9 @@ #endif if (flow) flow->qstats.drops++; return ret; } - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; - flow->bstats.bytes += skb->len; + flow->bstats.bytes += qdisc_tx_len(skb); flow->bstats.packets++; /* * Okay, this may seem weird. We pretend we've dropped the packet if diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 80b7f6a..5d705e2 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c @@ -404,7 +404,7 @@ static int cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch) { struct cbq_sched_data *q = qdisc_priv(sch); - int len = skb->len; + int len = qdisc_tx_len(skb); int ret; struct cbq_class *cl = cbq_classify(skb, sch, &ret); @@ -688,7 +688,7 @@ #ifdef CONFIG_NET_CLS_POLICE static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child) { - int len = skb->len; + int len = qdisc_tx_len(skb); struct Qdisc *sch = child->__parent; struct cbq_sched_data *q = qdisc_priv(sch); struct cbq_class *cl = q->rx_class; @@ -915,7 +915,7 @@ cbq_dequeue_prio(struct Qdisc *sch, int if (skb == NULL) goto skip_class; - cl->deficit -= skb->len; + cl->deficit -= qdisc_tx_len(skb); q->tx_class = cl; q->tx_borrowed = borrow; if (borrow != cl) { @@ -923,11 +923,11 @@ #ifndef CBQ_XSTATS_BORROWS_BYTES borrow->xstats.borrows++; cl->xstats.borrows++; #else - borrow->xstats.borrows += skb->len; - cl->xstats.borrows += skb->len; + borrow->xstats.borrows += qdisc_tx_len(skb); + cl->xstats.borrows += qdisc_tx_len(skb); #endif } - q->tx_len = skb->len; + q->tx_len = qdisc_tx_len(skb); if (cl->deficit <= 0) { q->active[prio] = cl; diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index 11c8a21..53346c6 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c @@ -265,7 +265,7 @@ #endif return err; } - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; sch->q.qlen++; diff --git a/net/sched/sch_fifo.c b/net/sched/sch_fifo.c index c2689f4..ec99321 100644 --- a/net/sched/sch_fifo.c +++ b/net/sched/sch_fifo.c @@ -28,7 +28,7 @@ static int bfifo_enqueue(struct sk_buff { struct fifo_sched_data *q = qdisc_priv(sch); - if (likely(sch->qstats.backlog + skb->len <= q->limit)) + if (likely(sch->qstats.backlog + qdisc_tx_len(skb) <= q->limit)) return qdisc_enqueue_tail(skb, sch); return qdisc_reshape_fail(skb, sch); diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c index 0cafdd5..f0bf5d7 100644 --- a/net/sched/sch_gred.c +++ b/net/sched/sch_gred.c @@ -189,7 +189,7 @@ static int gred_enqueue(struct sk_buff * } q->packetsin++; - q->bytesin += skb->len; + q->bytesin += qdisc_tx_len(skb); if (gred_wred_mode(t)) gred_load_wred_set(t, q); @@ -227,8 +227,8 @@ static int gred_enqueue(struct sk_buff * break; } - if (q->backlog + skb->len <= q->limit) { - q->backlog += skb->len; + if (q->backlog + qdisc_tx_len(skb) <= q->limit) { + q->backlog += qdisc_tx_len(skb); return qdisc_enqueue_tail(skb, sch); } @@ -255,7 +255,7 @@ static int gred_requeue(struct sk_buff * } else { if (red_is_idling(&q->parms)) red_end_of_idle_period(&q->parms); - q->backlog += skb->len; + q->backlog += qdisc_tx_len(skb); } return qdisc_requeue(skb, sch); @@ -278,7 +278,7 @@ static struct sk_buff *gred_dequeue(stru "VQ 0x%x after dequeue, screwing up " "backlog.\n", tc_index_to_dp(skb)); } else { - q->backlog -= skb->len; + q->backlog -= qdisc_tx_len(skb); if (!q->backlog && !gred_wred_mode(t)) red_start_of_idle_period(&q->parms); @@ -300,7 +300,7 @@ static unsigned int gred_drop(struct Qdi skb = qdisc_dequeue_tail(sch); if (skb) { - unsigned int len = skb->len; + unsigned int len = qdisc_tx_len(skb); struct gred_sched_data *q; u16 dp = tc_index_to_dp(skb); diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 6b1b4a9..3fc8351 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -942,7 +942,7 @@ qdisc_peek_len(struct Qdisc *sch) printk("qdisc_peek_len: non work-conserving qdisc ?\n"); return 0; } - len = skb->len; + len = qdisc_tx_len(skb); if (unlikely(sch->ops->requeue(skb, sch) != NET_XMIT_SUCCESS)) { if (net_ratelimit()) printk("qdisc_peek_len: failed to requeue\n"); @@ -1648,7 +1648,7 @@ hfsc_enqueue(struct sk_buff *skb, struct return err; } - len = skb->len; + len = qdisc_tx_len(skb); err = cl->qdisc->enqueue(skb, cl->qdisc); if (unlikely(err != NET_XMIT_SUCCESS)) { cl->qstats.drops++; @@ -1712,9 +1712,9 @@ hfsc_dequeue(struct Qdisc *sch) return NULL; } - update_vf(cl, skb->len, cur_time); + update_vf(cl, qdisc_tx_len(skb), cur_time); if (realtime) - cl->cl_cumul += skb->len; + cl->cl_cumul += qdisc_tx_len(skb); if (cl->qdisc->q.qlen != 0) { if (cl->cl_flags & HFSC_RSC) { diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 34afe41..b26fa9a 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c @@ -733,12 +733,12 @@ #endif cl->qstats.drops++; return NET_XMIT_DROP; } else { - cl->bstats.packets++; cl->bstats.bytes += skb->len; + cl->bstats.packets++; cl->bstats.bytes += qdisc_tx_len(skb); htb_activate (q,cl); } sch->q.qlen++; - sch->bstats.packets++; sch->bstats.bytes += skb->len; + sch->bstats.packets++; sch->bstats.bytes += qdisc_tx_len(skb); HTB_DBG(1,1,"htb_enq_ok cl=%X skb=%p\n",(cl && cl != HTB_DIRECT)?cl->classid:0,skb); return NET_XMIT_SUCCESS; } @@ -1067,7 +1067,7 @@ next: } while (cl != start); if (likely(skb != NULL)) { - if ((cl->un.leaf.deficit[level] -= skb->len) < 0) { + if ((cl->un.leaf.deficit[level] -= qdisc_tx_len(skb)) < 0) { HTB_DBG(4,2,"htb_next_cl oldptr=%p quant_add=%d\n", level?cl->parent->un.inner.ptr[prio]:q->ptr[0][prio],cl->un.leaf.quantum); cl->un.leaf.deficit[level] += cl->un.leaf.quantum; @@ -1077,7 +1077,7 @@ next: gives us slightly better performance */ if (!cl->un.leaf.q->q.qlen) htb_deactivate (q,cl); - htb_charge_class (q,cl,level,skb->len); + htb_charge_class (q,cl,level,qdisc_tx_len(skb)); } return skb; } diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index c5bd806..aa97ecb 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -225,7 +225,7 @@ static int netem_enqueue(struct sk_buff if (likely(ret == NET_XMIT_SUCCESS)) { sch->q.qlen++; - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; } else sch->qstats.drops++; @@ -507,8 +507,8 @@ static int tfifo_enqueue(struct sk_buff __skb_queue_after(list, skb, nskb); - sch->qstats.backlog += nskb->len; - sch->bstats.bytes += nskb->len; + sch->qstats.backlog += qdisc_tx_len(nskb); + sch->bstats.bytes += qdisc_tx_len(nskb); sch->bstats.packets++; return NET_XMIT_SUCCESS; diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index a5fa03c..2175732 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c @@ -99,7 +99,7 @@ #ifdef CONFIG_NET_CLS_ACT #endif if ((ret = qdisc->enqueue(skb, qdisc)) == NET_XMIT_SUCCESS) { - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; sch->q.qlen++; return NET_XMIT_SUCCESS; diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index d65cadd..24ec0b2 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c @@ -95,7 +95,7 @@ static int red_enqueue(struct sk_buff *s ret = child->enqueue(skb, child); if (likely(ret == NET_XMIT_SUCCESS)) { - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; sch->q.qlen++; } else { diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index d0d6e59..2a57d0d 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c @@ -225,7 +225,7 @@ static unsigned int sfq_drop(struct Qdis if (d > 1) { sfq_index x = q->dep[d+SFQ_DEPTH].next; skb = q->qs[x].prev; - len = skb->len; + len = qdisc_tx_len(skb); __skb_unlink(skb, &q->qs[x]); kfree_skb(skb); sfq_dec(q, x); @@ -241,7 +241,7 @@ static unsigned int sfq_drop(struct Qdis q->next[q->tail] = q->next[d]; q->allot[q->next[d]] += q->quantum; skb = q->qs[d].prev; - len = skb->len; + len = qdisc_tx_len(skb); __skb_unlink(skb, &q->qs[d]); kfree_skb(skb); sfq_dec(q, d); @@ -267,7 +267,7 @@ sfq_enqueue(struct sk_buff *skb, struct q->ht[hash] = x = q->dep[SFQ_DEPTH].next; q->hash[x] = hash; } - sch->qstats.backlog += skb->len; + sch->qstats.backlog += qdisc_tx_len(skb); __skb_queue_tail(&q->qs[x], skb); sfq_inc(q, x); if (q->qs[x].qlen == 1) { /* The flow is new */ @@ -282,7 +282,7 @@ sfq_enqueue(struct sk_buff *skb, struct } } if (++sch->q.qlen < q->limit-1) { - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; return 0; } @@ -303,7 +303,7 @@ sfq_requeue(struct sk_buff *skb, struct q->ht[hash] = x = q->dep[SFQ_DEPTH].next; q->hash[x] = hash; } - sch->qstats.backlog += skb->len; + sch->qstats.backlog += qdisc_tx_len(skb); __skb_queue_head(&q->qs[x], skb); sfq_inc(q, x); if (q->qs[x].qlen == 1) { /* The flow is new */ @@ -347,7 +347,7 @@ sfq_dequeue(struct Qdisc* sch) skb = __skb_dequeue(&q->qs[a]); sfq_dec(q, a); sch->q.qlen--; - sch->qstats.backlog -= skb->len; + sch->qstats.backlog -= qdisc_tx_len(skb); /* Is the slot empty? */ if (q->qs[a].qlen == 0) { @@ -359,7 +359,7 @@ sfq_dequeue(struct Qdisc* sch) } q->next[q->tail] = a; q->allot[a] += q->quantum; - } else if ((q->allot[a] -= skb->len) <= 0) { + } else if ((q->allot[a] -= qdisc_tx_len(skb)) <= 0) { q->tail = a; a = q->next[a]; q->allot[a] += q->quantum; diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index d9a5d29..c87b0e6 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -139,7 +139,7 @@ static int tbf_enqueue(struct sk_buff *s struct tbf_sched_data *q = qdisc_priv(sch); int ret; - if (skb->len > q->max_size) { + if (qdisc_tx_len(skb) > q->max_size) { sch->qstats.drops++; #ifdef CONFIG_NET_CLS_POLICE if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch)) @@ -155,7 +155,7 @@ #endif } sch->q.qlen++; - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; return 0; } @@ -204,7 +204,7 @@ static struct sk_buff *tbf_dequeue(struc psched_time_t now; long toks, delay; long ptoks = 0; - unsigned int len = skb->len; + unsigned int len = qdisc_tx_len(skb); PSCHED_GET_TIME(now); diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c index 4c16ad5..538f63f 100644 --- a/net/sched/sch_teql.c +++ b/net/sched/sch_teql.c @@ -97,7 +97,7 @@ teql_enqueue(struct sk_buff *skb, struct __skb_queue_tail(&q->q, skb); if (q->q.qlen <= dev->tx_queue_len) { - sch->bstats.bytes += skb->len; + sch->bstats.bytes += qdisc_tx_len(skb); sch->bstats.packets++; return 0; } @@ -278,7 +278,7 @@ static int teql_master_xmit(struct sk_bu struct Qdisc *start, *q; int busy; int nores; - int len = skb->len; + int len = qdisc_tx_len(skb); struct sk_buff *skb_res = NULL; start = master->slaves;