Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[safe/jmp/linux-2.6] / net / atm / clip.c
index 2ab1e36..64629c3 100644 (file)
@@ -214,15 +214,15 @@ static void clip_push(struct atm_vcc *vcc, struct sk_buff *skb)
                skb->protocol = ((__be16 *) skb->data)[3];
                skb_pull(skb, RFC1483LLC_LEN);
                if (skb->protocol == htons(ETH_P_ARP)) {
-                       PRIV(skb->dev)->stats.rx_packets++;
-                       PRIV(skb->dev)->stats.rx_bytes += skb->len;
+                       skb->dev->stats.rx_packets++;
+                       skb->dev->stats.rx_bytes += skb->len;
                        clip_arp_rcv(skb);
                        return;
                }
        }
        clip_vcc->last_use = jiffies;
-       PRIV(skb->dev)->stats.rx_packets++;
-       PRIV(skb->dev)->stats.rx_bytes += skb->len;
+       skb->dev->stats.rx_packets++;
+       skb->dev->stats.rx_bytes += skb->len;
        memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data));
        netif_rx(skb);
 }
@@ -267,7 +267,7 @@ static void clip_neigh_error(struct neighbour *neigh, struct sk_buff *skb)
        kfree_skb(skb);
 }
 
-static struct neigh_ops clip_neigh_ops = {
+static const struct neigh_ops clip_neigh_ops = {
        .family =               AF_INET,
        .solicit =              clip_neigh_solicit,
        .error_report =         clip_neigh_error,
@@ -360,7 +360,8 @@ static int clip_encap(struct atm_vcc *vcc, int mode)
        return 0;
 }
 
-static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t clip_start_xmit(struct sk_buff *skb,
+                                  struct net_device *dev)
 {
        struct clip_priv *clip_priv = PRIV(dev);
        struct atmarp_entry *entry;
@@ -369,27 +370,27 @@ static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev)
        unsigned long flags;
 
        pr_debug("clip_start_xmit (skb %p)\n", skb);
-       if (!skb->dst) {
-               printk(KERN_ERR "clip_start_xmit: skb->dst == NULL\n");
+       if (!skb_dst(skb)) {
+               printk(KERN_ERR "clip_start_xmit: skb_dst(skb) == NULL\n");
                dev_kfree_skb(skb);
-               clip_priv->stats.tx_dropped++;
-               return 0;
+               dev->stats.tx_dropped++;
+               return NETDEV_TX_OK;
        }
-       if (!skb->dst->neighbour) {
+       if (!skb_dst(skb)->neighbour) {
 #if 0
-               skb->dst->neighbour = clip_find_neighbour(skb->dst, 1);
-               if (!skb->dst->neighbour) {
+               skb_dst(skb)->neighbour = clip_find_neighbour(skb_dst(skb), 1);
+               if (!skb_dst(skb)->neighbour) {
                        dev_kfree_skb(skb);     /* lost that one */
-                       clip_priv->stats.tx_dropped++;
+                       dev->stats.tx_dropped++;
                        return 0;
                }
 #endif
                printk(KERN_ERR "clip_start_xmit: NO NEIGHBOUR !\n");
                dev_kfree_skb(skb);
-               clip_priv->stats.tx_dropped++;
-               return 0;
+               dev->stats.tx_dropped++;
+               return NETDEV_TX_OK;
        }
-       entry = NEIGH2ENTRY(skb->dst->neighbour);
+       entry = NEIGH2ENTRY(skb_dst(skb)->neighbour);
        if (!entry->vccs) {
                if (time_after(jiffies, entry->expires)) {
                        /* should be resolved */
@@ -400,13 +401,13 @@ static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev)
                        skb_queue_tail(&entry->neigh->arp_queue, skb);
                else {
                        dev_kfree_skb(skb);
-                       clip_priv->stats.tx_dropped++;
+                       dev->stats.tx_dropped++;
                }
-               return 0;
+               return NETDEV_TX_OK;
        }
        pr_debug("neigh %p, vccs %p\n", entry, entry->vccs);
        ATM_SKB(skb)->vcc = vcc = entry->vccs->vcc;
-       pr_debug("using neighbour %p, vcc %p\n", skb->dst->neighbour, vcc);
+       pr_debug("using neighbour %p, vcc %p\n", skb_dst(skb)->neighbour, vcc);
        if (entry->vccs->encap) {
                void *here;
 
@@ -421,14 +422,14 @@ static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev)
        old = xchg(&entry->vccs->xoff, 1);      /* assume XOFF ... */
        if (old) {
                printk(KERN_WARNING "clip_start_xmit: XOFF->XOFF transition\n");
-               return 0;
+               return NETDEV_TX_OK;
        }
-       clip_priv->stats.tx_packets++;
-       clip_priv->stats.tx_bytes += skb->len;
+       dev->stats.tx_packets++;
+       dev->stats.tx_bytes += skb->len;
        vcc->send(vcc, skb);
        if (atm_may_send(vcc, 0)) {
                entry->vccs->xoff = 0;
-               return 0;
+               return NETDEV_TX_OK;
        }
        spin_lock_irqsave(&clip_priv->xoff_lock, flags);
        netif_stop_queue(dev);  /* XOFF -> throttle immediately */
@@ -440,19 +441,14 @@ static int clip_start_xmit(struct sk_buff *skb, struct net_device *dev)
           of the brief netif_stop_queue. If this isn't true or if it
           changes, use netif_wake_queue instead. */
        spin_unlock_irqrestore(&clip_priv->xoff_lock, flags);
-       return 0;
-}
-
-static struct net_device_stats *clip_get_stats(struct net_device *dev)
-{
-       return &PRIV(dev)->stats;
+       return NETDEV_TX_OK;
 }
 
 static int clip_mkip(struct atm_vcc *vcc, int timeout)
 {
+       struct sk_buff_head *rq, queue;
        struct clip_vcc *clip_vcc;
-       struct sk_buff *skb;
-       struct sk_buff_head *rq;
+       struct sk_buff *skb, *tmp;
        unsigned long flags;
 
        if (!vcc->push)
@@ -474,39 +470,28 @@ static int clip_mkip(struct atm_vcc *vcc, int timeout)
        vcc->push = clip_push;
        vcc->pop = clip_pop;
 
+       __skb_queue_head_init(&queue);
        rq = &sk_atm(vcc)->sk_receive_queue;
 
        spin_lock_irqsave(&rq->lock, flags);
-       if (skb_queue_empty(rq)) {
-               skb = NULL;
-       } else {
-               /* NULL terminate the list.  */
-               rq->prev->next = NULL;
-               skb = rq->next;
-       }
-       rq->prev = rq->next = (struct sk_buff *)rq;
-       rq->qlen = 0;
+       skb_queue_splice_init(rq, &queue);
        spin_unlock_irqrestore(&rq->lock, flags);
 
        /* re-process everything received between connection setup and MKIP */
-       while (skb) {
-               struct sk_buff *next = skb->next;
-
-               skb->next = skb->prev = NULL;
+       skb_queue_walk_safe(&queue, skb, tmp) {
                if (!clip_devs) {
                        atm_return(vcc, skb->truesize);
                        kfree_skb(skb);
                } else {
+                       struct net_device *dev = skb->dev;
                        unsigned int len = skb->len;
 
                        skb_get(skb);
                        clip_push(vcc, skb);
-                       PRIV(skb->dev)->stats.rx_packets--;
-                       PRIV(skb->dev)->stats.rx_bytes -= len;
+                       dev->stats.rx_packets--;
+                       dev->stats.rx_bytes -= len;
                        kfree_skb(skb);
                }
-
-               skb = next;
        }
        return 0;
 }
@@ -557,11 +542,13 @@ static int clip_setentry(struct atm_vcc *vcc, __be32 ip)
        return error;
 }
 
+static const struct net_device_ops clip_netdev_ops = {
+       .ndo_start_xmit = clip_start_xmit,
+};
+
 static void clip_setup(struct net_device *dev)
 {
-       dev->hard_start_xmit = clip_start_xmit;
-       /* sg_xmit ... */
-       dev->get_stats = clip_get_stats;
+       dev->netdev_ops = &clip_netdev_ops;
        dev->type = ARPHRD_ATM;
        dev->hard_header_len = RFC1483LLC_LEN;
        dev->mtu = RFC1626_MTU;
@@ -571,6 +558,7 @@ static void clip_setup(struct net_device *dev)
        /* without any more elaborate queuing. 100 is a reasonable */
        /* compromise between decent burst-tolerance and protection */
        /* against memory hogs. */
+       dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
 }
 
 static int clip_create(int number)
@@ -612,7 +600,7 @@ static int clip_device_event(struct notifier_block *this, unsigned long event,
 {
        struct net_device *dev = arg;
 
-       if (dev->nd_net != &init_net)
+       if (!net_eq(dev_net(dev), &init_net))
                return NOTIFY_DONE;
 
        if (event == NETDEV_UNREGISTER) {
@@ -621,7 +609,7 @@ static int clip_device_event(struct notifier_block *this, unsigned long event,
        }
 
        /* ignore non-CLIP devices */
-       if (dev->type != ARPHRD_ATM || dev->hard_start_xmit != clip_start_xmit)
+       if (dev->type != ARPHRD_ATM || dev->netdev_ops != &clip_netdev_ops)
                return NOTIFY_DONE;
 
        switch (event) {
@@ -648,10 +636,6 @@ static int clip_inet_event(struct notifier_block *this, unsigned long event,
        struct in_device *in_dev;
 
        in_dev = ((struct in_ifaddr *)ifa)->ifa_dev;
-       if (!in_dev || !in_dev->dev) {
-               printk(KERN_WARNING "clip_inet_event: no device\n");
-               return NOTIFY_DONE;
-       }
        /*
         * Transitions are of the down-change-up type, so it's sufficient to
         * handle the change on up.
@@ -826,8 +810,8 @@ static void atmarp_info(struct seq_file *seq, struct net_device *dev,
        seq_printf(seq, "%-6s%-4s%-4s%5ld ",
                   dev->name, svc ? "SVC" : "PVC", llc ? "LLC" : "NULL", exp);
 
-       off = scnprintf(buf, sizeof(buf) - 1, "%d.%d.%d.%d",
-                       NIPQUAD(entry->ip));
+       off = scnprintf(buf, sizeof(buf) - 1, "%pI4",
+                       &entry->ip);
        while (off < 16)
                buf[off++] = ' ';
        buf[off] = '\0';