]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/infiniband/ulp/ipoib/ipoib_main.c
Merge branch 'master' of /home/trondmy/kernel/linux-2.6/
[linux-2.6-omap-h63xx.git] / drivers / infiniband / ulp / ipoib / ipoib_main.c
index 1eaf00e9862c5a4a0381d0570b5ac7ee0723f93c..af5ee2ec4499799a80b8e98f4a7a7a02628fbb93 100644 (file)
@@ -49,6 +49,8 @@
 
 #include <net/dst.h>
 
+#define IPOIB_QPN(ha) (be32_to_cpup((__be32 *) ha) & 0xffffff)
+
 MODULE_AUTHOR("Roland Dreier");
 MODULE_DESCRIPTION("IP-over-InfiniBand net driver");
 MODULE_LICENSE("Dual BSD/GPL");
@@ -262,7 +264,7 @@ static void path_free(struct net_device *dev, struct ipoib_path *path)
                if (neigh->ah)
                        ipoib_put_ah(neigh->ah);
 
-               ipoib_neigh_free(neigh);
+               ipoib_neigh_free(dev, neigh);
        }
 
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -495,8 +497,6 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
                return;
        }
 
-       skb_queue_head_init(&neigh->queue);
-
        /*
         * We can only be called from ipoib_start_xmit, so we're
         * inside tx_lock -- no need to save/restore flags.
@@ -520,14 +520,14 @@ static void neigh_add_path(struct sk_buff *skb, struct net_device *dev)
                memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
                       sizeof(union ib_gid));
 
-               ipoib_send(dev, skb, path->ah,
-                          be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
+               ipoib_send(dev, skb, path->ah, IPOIB_QPN(skb->dst->neighbour->ha));
        } else {
                neigh->ah  = NULL;
-               __skb_queue_tail(&neigh->queue, skb);
 
                if (!path->query && path_rec_start(dev, path))
                        goto err_list;
+
+               __skb_queue_tail(&neigh->queue, skb);
        }
 
        spin_unlock(&priv->lock);
@@ -537,7 +537,7 @@ err_list:
        list_del(&neigh->list);
 
 err_path:
-       ipoib_neigh_free(neigh);
+       ipoib_neigh_free(dev, neigh);
        ++priv->stats.tx_dropped;
        dev_kfree_skb_any(skb);
 
@@ -599,8 +599,7 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
                ipoib_dbg(priv, "Send unicast ARP to %04x\n",
                          be16_to_cpu(path->pathrec.dlid));
 
-               ipoib_send(dev, skb, path->ah,
-                          be32_to_cpup((__be32 *) phdr->hwaddr));
+               ipoib_send(dev, skb, path->ah, IPOIB_QPN(phdr->hwaddr));
        } else if ((path->query || !path_rec_start(dev, path)) &&
                   skb_queue_len(&path->queue) < IPOIB_MAX_PATH_REC_QUEUE) {
                /* put pseudoheader back on for next time */
@@ -655,14 +654,13 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
                                 */
                                ipoib_put_ah(neigh->ah);
                                list_del(&neigh->list);
-                               ipoib_neigh_free(neigh);
+                               ipoib_neigh_free(dev, neigh);
                                spin_unlock(&priv->lock);
                                ipoib_path_lookup(skb, dev);
                                goto out;
                        }
 
-                       ipoib_send(dev, skb, neigh->ah,
-                                  be32_to_cpup((__be32 *) skb->dst->neighbour->ha));
+                       ipoib_send(dev, skb, neigh->ah, IPOIB_QPN(skb->dst->neighbour->ha));
                        goto out;
                }
 
@@ -694,7 +692,7 @@ static int ipoib_start_xmit(struct sk_buff *skb, struct net_device *dev)
                                           IPOIB_GID_FMT "\n",
                                           skb->dst ? "neigh" : "dst",
                                           be16_to_cpup((__be16 *) skb->data),
-                                          be32_to_cpup((__be32 *) phdr->hwaddr),
+                                          IPOIB_QPN(phdr->hwaddr),
                                           IPOIB_GID_RAW_ARG(phdr->hwaddr + 4));
                                dev_kfree_skb_any(skb);
                                ++priv->stats.tx_dropped;
@@ -777,7 +775,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
 
        ipoib_dbg(priv,
                  "neigh_destructor for %06x " IPOIB_GID_FMT "\n",
-                 be32_to_cpup((__be32 *) n->ha),
+                 IPOIB_QPN(n->ha),
                  IPOIB_GID_RAW_ARG(n->ha + 4));
 
        spin_lock_irqsave(&priv->lock, flags);
@@ -787,7 +785,7 @@ static void ipoib_neigh_destructor(struct neighbour *n)
                if (neigh->ah)
                        ah = neigh->ah;
                list_del(&neigh->list);
-               ipoib_neigh_free(neigh);
+               ipoib_neigh_free(n->dev, neigh);
        }
 
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -806,13 +804,20 @@ struct ipoib_neigh *ipoib_neigh_alloc(struct neighbour *neighbour)
 
        neigh->neighbour = neighbour;
        *to_ipoib_neigh(neighbour) = neigh;
+       skb_queue_head_init(&neigh->queue);
 
        return neigh;
 }
 
-void ipoib_neigh_free(struct ipoib_neigh *neigh)
+void ipoib_neigh_free(struct net_device *dev, struct ipoib_neigh *neigh)
 {
+       struct ipoib_dev_priv *priv = netdev_priv(dev);
+       struct sk_buff *skb;
        *to_ipoib_neigh(neigh->neighbour) = NULL;
+       while ((skb = __skb_dequeue(&neigh->queue))) {
+               ++priv->stats.tx_dropped;
+               dev_kfree_skb_any(skb);
+       }
        kfree(neigh);
 }
 
@@ -934,11 +939,11 @@ static void ipoib_setup(struct net_device *dev)
        INIT_LIST_HEAD(&priv->dead_ahs);
        INIT_LIST_HEAD(&priv->multicast_list);
 
-       INIT_WORK(&priv->pkey_task,    ipoib_pkey_poll,          priv->dev);
-       INIT_WORK(&priv->mcast_task,   ipoib_mcast_join_task,    priv->dev);
-       INIT_WORK(&priv->flush_task,   ipoib_ib_dev_flush,       priv->dev);
-       INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task, priv->dev);
-       INIT_WORK(&priv->ah_reap_task, ipoib_reap_ah,            priv->dev);
+       INIT_DELAYED_WORK(&priv->pkey_task,    ipoib_pkey_poll);
+       INIT_DELAYED_WORK(&priv->mcast_task,   ipoib_mcast_join_task);
+       INIT_WORK(&priv->flush_task,   ipoib_ib_dev_flush);
+       INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
+       INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
 }
 
 struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
@@ -953,16 +958,17 @@ struct ipoib_dev_priv *ipoib_intf_alloc(const char *name)
        return netdev_priv(dev);
 }
 
-static ssize_t show_pkey(struct class_device *cdev, char *buf)
+static ssize_t show_pkey(struct device *dev,
+                        struct device_attribute *attr, char *buf)
 {
-       struct ipoib_dev_priv *priv =
-               netdev_priv(container_of(cdev, struct net_device, class_dev));
+       struct ipoib_dev_priv *priv = netdev_priv(to_net_dev(dev));
 
        return sprintf(buf, "0x%04x\n", priv->pkey);
 }
-static CLASS_DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
+static DEVICE_ATTR(pkey, S_IRUGO, show_pkey, NULL);
 
-static ssize_t create_child(struct class_device *cdev,
+static ssize_t create_child(struct device *dev,
+                           struct device_attribute *attr,
                            const char *buf, size_t count)
 {
        int pkey;
@@ -980,14 +986,14 @@ static ssize_t create_child(struct class_device *cdev,
         */
        pkey |= 0x8000;
 
-       ret = ipoib_vlan_add(container_of(cdev, struct net_device, class_dev),
-                            pkey);
+       ret = ipoib_vlan_add(to_net_dev(dev), pkey);
 
        return ret ? ret : count;
 }
-static CLASS_DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child);
+static DEVICE_ATTR(create_child, S_IWUGO, NULL, create_child);
 
-static ssize_t delete_child(struct class_device *cdev,
+static ssize_t delete_child(struct device *dev,
+                           struct device_attribute *attr,
                            const char *buf, size_t count)
 {
        int pkey;
@@ -999,18 +1005,16 @@ static ssize_t delete_child(struct class_device *cdev,
        if (pkey < 0 || pkey > 0xffff)
                return -EINVAL;
 
-       ret = ipoib_vlan_delete(container_of(cdev, struct net_device, class_dev),
-                               pkey);
+       ret = ipoib_vlan_delete(to_net_dev(dev), pkey);
 
        return ret ? ret : count;
 
 }
-static CLASS_DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child);
+static DEVICE_ATTR(delete_child, S_IWUGO, NULL, delete_child);
 
 int ipoib_add_pkey_attr(struct net_device *dev)
 {
-       return class_device_create_file(&dev->class_dev,
-                                       &class_device_attr_pkey);
+       return device_create_file(&dev->dev, &dev_attr_pkey);
 }
 
 static struct net_device *ipoib_add_port(const char *format,
@@ -1078,11 +1082,9 @@ static struct net_device *ipoib_add_port(const char *format,
 
        if (ipoib_add_pkey_attr(priv->dev))
                goto sysfs_failed;
-       if (class_device_create_file(&priv->dev->class_dev,
-                                    &class_device_attr_create_child))
+       if (device_create_file(&priv->dev->dev, &dev_attr_create_child))
                goto sysfs_failed;
-       if (class_device_create_file(&priv->dev->class_dev,
-                                    &class_device_attr_delete_child))
+       if (device_create_file(&priv->dev->dev, &dev_attr_delete_child))
                goto sysfs_failed;
 
        return priv->dev;