string: factorize skip_spaces and export it to be generally available
[safe/jmp/linux-2.6] / net / sched / sch_atm.c
index 68ed35e..ab82f14 100644 (file)
@@ -49,7 +49,7 @@ struct atm_flow_data {
        struct socket           *sock;          /* for closing */
        u32                     classid;        /* x:y type ID */
        int                     ref;            /* reference count */
-       struct gnet_stats_basic bstats;
+       struct gnet_stats_basic_packed  bstats;
        struct gnet_stats_queue qstats;
        struct atm_flow_data    *next;
        struct atm_flow_data    *excess;        /* flow for excess traffic;
@@ -62,7 +62,7 @@ struct atm_qdisc_data {
        struct atm_flow_data    link;           /* unclassified skbs go here */
        struct atm_flow_data    *flows;         /* NB: "link" is also on this
                                                   list */
-       struct tasklet_struct   task;           /* requeue tasklet */
+       struct tasklet_struct   task;           /* dequeue tasklet */
 };
 
 /* ------------------------- Class/flow operations ------------------------- */
@@ -102,7 +102,8 @@ static int atm_tc_graft(struct Qdisc *sch, unsigned long arg,
                return -EINVAL;
        if (!new)
                new = &noop_qdisc;
-       *old = xchg(&flow->q, new);
+       *old = flow->q;
+       flow->q = new;
        if (*old)
                qdisc_reset(*old);
        return 0;
@@ -162,7 +163,7 @@ static void atm_tc_put(struct Qdisc *sch, unsigned long cl)
        qdisc_destroy(flow->q);
        tcf_destroy_chain(&flow->filter_list);
        if (flow->sock) {
-               pr_debug("atm_tc_put: f_count %d\n",
+               pr_debug("atm_tc_put: f_count %ld\n",
                        file_count(flow->sock->file));
                flow->vcc->pop = flow->old_pop;
                sockfd_put(flow->sock);
@@ -259,7 +260,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
        sock = sockfd_lookup(fd, &error);
        if (!sock)
                return error;   /* f_count++ */
-       pr_debug("atm_tc_change: f_count %d\n", file_count(sock->file));
+       pr_debug("atm_tc_change: f_count %ld\n", file_count(sock->file));
        if (sock->ops->family != PF_ATMSVC && sock->ops->family != PF_ATMPVC) {
                error = -EPROTOTYPE;
                goto err_out;
@@ -415,7 +416,7 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
                case TC_ACT_QUEUED:
                case TC_ACT_STOLEN:
                        kfree_skb(skb);
-                       return NET_XMIT_SUCCESS;
+                       return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
                case TC_ACT_SHOT:
                        kfree_skb(skb);
                        goto drop;
@@ -432,14 +433,16 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch)
        ret = qdisc_enqueue(skb, flow->q);
        if (ret != 0) {
 drop: __maybe_unused
-               sch->qstats.drops++;
-               if (flow)
-                       flow->qstats.drops++;
+               if (net_xmit_drop_count(ret)) {
+                       sch->qstats.drops++;
+                       if (flow)
+                               flow->qstats.drops++;
+               }
                return ret;
        }
-       sch->bstats.bytes += skb->len;
+       sch->bstats.bytes += qdisc_pkt_len(skb);
        sch->bstats.packets++;
-       flow->bstats.bytes += skb->len;
+       flow->bstats.bytes += qdisc_pkt_len(skb);
        flow->bstats.packets++;
        /*
         * Okay, this may seem weird. We pretend we've dropped the packet if
@@ -455,7 +458,7 @@ drop: __maybe_unused
                return 0;
        }
        tasklet_schedule(&p->task);
-       return NET_XMIT_BYPASS;
+       return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
 }
 
 /*
@@ -478,11 +481,14 @@ static void sch_atm_dequeue(unsigned long data)
                 * If traffic is properly shaped, this won't generate nasty
                 * little bursts. Otherwise, it may ... (but that's okay)
                 */
-               while ((skb = flow->q->dequeue(flow->q))) {
-                       if (!atm_may_send(flow->vcc, skb->truesize)) {
-                               (void)flow->q->ops->requeue(skb, flow->q);
+               while ((skb = flow->q->ops->peek(flow->q))) {
+                       if (!atm_may_send(flow->vcc, skb->truesize))
                                break;
-                       }
+
+                       skb = qdisc_dequeue_peeked(flow->q);
+                       if (unlikely(!skb))
+                               break;
+
                        pr_debug("atm_tc_dequeue: sending on class %p\n", flow);
                        /* remove any LL header somebody else has attached */
                        skb_pull(skb, skb_network_offset(skb));
@@ -514,27 +520,19 @@ static struct sk_buff *atm_tc_dequeue(struct Qdisc *sch)
 
        pr_debug("atm_tc_dequeue(sch %p,[qdisc %p])\n", sch, p);
        tasklet_schedule(&p->task);
-       skb = p->link.q->dequeue(p->link.q);
+       skb = qdisc_dequeue_peeked(p->link.q);
        if (skb)
                sch->q.qlen--;
        return skb;
 }
 
-static int atm_tc_requeue(struct sk_buff *skb, struct Qdisc *sch)
+static struct sk_buff *atm_tc_peek(struct Qdisc *sch)
 {
        struct atm_qdisc_data *p = qdisc_priv(sch);
-       int ret;
 
-       pr_debug("atm_tc_requeue(skb %p,sch %p,[qdisc %p])\n", skb, sch, p);
-       ret = p->link.q->ops->requeue(skb, p->link.q);
-       if (!ret) {
-               sch->q.qlen++;
-               sch->qstats.requeues++;
-       } else {
-               sch->qstats.drops++;
-               p->link.qstats.drops++;
-       }
-       return ret;
+       pr_debug("atm_tc_peek(sch %p,[qdisc %p])\n", sch, p);
+
+       return p->link.q->ops->peek(p->link.q);
 }
 
 static unsigned int atm_tc_drop(struct Qdisc *sch)
@@ -692,7 +690,7 @@ static struct Qdisc_ops atm_qdisc_ops __read_mostly = {
        .priv_size      = sizeof(struct atm_qdisc_data),
        .enqueue        = atm_tc_enqueue,
        .dequeue        = atm_tc_dequeue,
-       .requeue        = atm_tc_requeue,
+       .peek           = atm_tc_peek,
        .drop           = atm_tc_drop,
        .init           = atm_tc_init,
        .reset          = atm_tc_reset,