Blackfin arch: update cache flush prototypes with argument names to make them less...
[safe/jmp/linux-2.6] / drivers / infiniband / core / addr.c
index a68d7c7..09a2bec 100644 (file)
@@ -4,28 +4,33 @@
  * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
  * Copyright (c) 2005 Intel Corporation.  All rights reserved.
  *
- * This Software is licensed under one of the following licenses:
+ * This software is available to you under a choice of one of two
+ * licenses.  You may choose to be licensed under the terms of the GNU
+ * General Public License (GPL) Version 2, available from the file
+ * COPYING in the main directory of this source tree, or the
+ * OpenIB.org BSD license below:
  *
- * 1) under the terms of the "Common Public License 1.0" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/cpl.php.
+ *     Redistribution and use in source and binary forms, with or
+ *     without modification, are permitted provided that the following
+ *     conditions are met:
  *
- * 2) under the terms of the "The BSD License" a copy of which is
- *    available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/bsd-license.php.
+ *      - Redistributions of source code must retain the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer.
  *
- * 3) under the terms of the "GNU General Public License (GPL) Version 2" a
- *    copy of which is available from the Open Source Initiative, see
- *    http://www.opensource.org/licenses/gpl-license.php.
+ *      - Redistributions in binary form must reproduce the above
+ *        copyright notice, this list of conditions and the following
+ *        disclaimer in the documentation and/or other materials
+ *        provided with the distribution.
  *
- * Licensee has the right to choose one of the above licenses.
- *
- * Redistributions of source code must retain the above copyright
- * notice and one of the license notices.
- *
- * Redistributions in binary form must reproduce both the above copyright
- * notice, one of the license notices in the documentation
- * and/or other materials provided with the distribution.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
  */
 
 #include <linux/mutex.h>
@@ -55,11 +60,11 @@ struct addr_req {
        int status;
 };
 
-static void process_req(void *data);
+static void process_req(struct work_struct *work);
 
 static DEFINE_MUTEX(lock);
 static LIST_HEAD(req_list);
-static DECLARE_WORK(work, process_req, NULL);
+static DECLARE_DELAYED_WORK(work, process_req);
 static struct workqueue_struct *addr_wq;
 
 void rdma_addr_register_client(struct rdma_addr_client *client)
@@ -100,6 +105,7 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
        memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
        if (dst_dev_addr)
                memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
+       dev_addr->src_dev = dev;
        return 0;
 }
 EXPORT_SYMBOL(rdma_copy_addr);
@@ -110,7 +116,7 @@ int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
        __be32 ip = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
        int ret;
 
-       dev = ip_dev_find(ip);
+       dev = ip_dev_find(&init_net, ip);
        if (!dev)
                return -EADDRNOTAVAIL;
 
@@ -154,15 +160,14 @@ static void addr_send_arp(struct sockaddr_in *dst_in)
 {
        struct rtable *rt;
        struct flowi fl;
-       u32 dst_ip = dst_in->sin_addr.s_addr;
+       __be32 dst_ip = dst_in->sin_addr.s_addr;
 
        memset(&fl, 0, sizeof fl);
        fl.nl_u.ip4_u.daddr = dst_ip;
-       if (ip_route_output_key(&rt, &fl))
+       if (ip_route_output_key(&init_net, &rt, &fl))
                return;
 
-       arp_send(ARPOP_REQUEST, ETH_P_ARP, rt->rt_gateway, rt->idev->dev,
-                rt->rt_src, NULL, rt->idev->dev->dev_addr, NULL);
+       neigh_event_send(rt->u.dst.neighbour, NULL);
        ip_rt_put(rt);
 }
 
@@ -170,8 +175,8 @@ static int addr_resolve_remote(struct sockaddr_in *src_in,
                               struct sockaddr_in *dst_in,
                               struct rdma_dev_addr *addr)
 {
-       u32 src_ip = src_in->sin_addr.s_addr;
-       u32 dst_ip = dst_in->sin_addr.s_addr;
+       __be32 src_ip = src_in->sin_addr.s_addr;
+       __be32 dst_ip = dst_in->sin_addr.s_addr;
        struct flowi fl;
        struct rtable *rt;
        struct neighbour *neigh;
@@ -180,7 +185,7 @@ static int addr_resolve_remote(struct sockaddr_in *src_in,
        memset(&fl, 0, sizeof fl);
        fl.nl_u.ip4_u.daddr = dst_ip;
        fl.nl_u.ip4_u.saddr = src_ip;
-       ret = ip_route_output_key(&rt, &fl);
+       ret = ip_route_output_key(&init_net, &rt, &fl);
        if (ret)
                goto out;
 
@@ -215,7 +220,7 @@ out:
        return ret;
 }
 
-static void process_req(void *data)
+static void process_req(struct work_struct *work)
 {
        struct addr_req *req, *temp_req;
        struct sockaddr_in *src_in, *dst_in;
@@ -225,19 +230,17 @@ static void process_req(void *data)
 
        mutex_lock(&lock);
        list_for_each_entry_safe(req, temp_req, &req_list, list) {
-               if (req->status) {
+               if (req->status == -ENODATA) {
                        src_in = (struct sockaddr_in *) &req->src_addr;
                        dst_in = (struct sockaddr_in *) &req->dst_addr;
                        req->status = addr_resolve_remote(src_in, dst_in,
                                                          req->addr);
+                       if (req->status && time_after_eq(jiffies, req->timeout))
+                               req->status = -ETIMEDOUT;
+                       else if (req->status == -ENODATA)
+                               continue;
                }
-               if (req->status && time_after(jiffies, req->timeout))
-                       req->status = -ETIMEDOUT;
-               else if (req->status == -ENODATA)
-                       continue;
-
-               list_del(&req->list);
-               list_add_tail(&req->list, &done_list);
+               list_move_tail(&req->list, &done_list);
        }
 
        if (!list_empty(&req_list)) {
@@ -260,19 +263,19 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
                              struct rdma_dev_addr *addr)
 {
        struct net_device *dev;
-       u32 src_ip = src_in->sin_addr.s_addr;
+       __be32 src_ip = src_in->sin_addr.s_addr;
        __be32 dst_ip = dst_in->sin_addr.s_addr;
        int ret;
 
-       dev = ip_dev_find(dst_ip);
+       dev = ip_dev_find(&init_net, dst_ip);
        if (!dev)
                return -EADDRNOTAVAIL;
 
-       if (ZERONET(src_ip)) {
+       if (ipv4_is_zeronet(src_ip)) {
                src_in->sin_family = dst_in->sin_family;
                src_in->sin_addr.s_addr = dst_ip;
                ret = rdma_copy_addr(addr, dev, dev->dev_addr);
-       } else if (LOOPBACK(src_ip)) {
+       } else if (ipv4_is_loopback(src_ip)) {
                ret = rdma_translate_ip((struct sockaddr *)dst_in, addr);
                if (!ret)
                        memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
@@ -297,10 +300,9 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
        struct addr_req *req;
        int ret = 0;
 
-       req = kmalloc(sizeof *req, GFP_KERNEL);
+       req = kzalloc(sizeof *req, GFP_KERNEL);
        if (!req)
                return -ENOMEM;
-       memset(req, 0, sizeof *req);
 
        if (src_addr)
                memcpy(&req->src_addr, src_addr, ip_addr_size(src_addr));
@@ -347,8 +349,7 @@ void rdma_addr_cancel(struct rdma_dev_addr *addr)
                if (req->addr == addr) {
                        req->status = -ECANCELED;
                        req->timeout = jiffies;
-                       list_del(&req->list);
-                       list_add(&req->list, &req_list);
+                       list_move(&req->list, &req_list);
                        set_timeout(req->timeout);
                        break;
                }
@@ -363,8 +364,7 @@ static int netevent_callback(struct notifier_block *self, unsigned long event,
        if (event == NETEVENT_NEIGH_UPDATE) {
                struct neighbour *neigh = ctx;
 
-               if (neigh->dev->type == ARPHRD_INFINIBAND &&
-                   (neigh->nud_state & NUD_VALID)) {
+               if (neigh->nud_state & NUD_VALID) {
                        set_timeout(jiffies);
                }
        }
@@ -377,7 +377,7 @@ static struct notifier_block nb = {
 
 static int addr_init(void)
 {
-       addr_wq = create_singlethread_workqueue("ib_addr_wq");
+       addr_wq = create_singlethread_workqueue("ib_addr");
        if (!addr_wq)
                return -ENOMEM;