Re: [PATCH 4/6 v2] IB: address translation to map IP toIB addresses (GIDs)

2006-03-21 Thread Roland Dreier
  +struct workqueue_struct *rdma_wq;
  +EXPORT_SYMBOL(rdma_wq);

Sean, I don't think I saw an answer when I asked you this before.  Why
is ib_addr exporting a workqueue?  Is there some sort of ordering
constraint that is forcing other modules to go through the same
workqueue for things?

This seems like a very fragile internal thing to be exposing, and I'm
wondering if there's a better way to handle it.

 - R.
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [openib-general] Re: [PATCH 4/6 v2] IB: address translation to map IP toIB addresses (GIDs)

2006-03-21 Thread Sean Hefty

Roland Dreier wrote:

  +struct workqueue_struct *rdma_wq;
  +EXPORT_SYMBOL(rdma_wq);

Sean, I don't think I saw an answer when I asked you this before.  Why
is ib_addr exporting a workqueue?  Is there some sort of ordering
constraint that is forcing other modules to go through the same
workqueue for things?

This seems like a very fragile internal thing to be exposing, and I'm
wondering if there's a better way to handle it.


I responded in a different thread, but here's what I wrote:

This is simply an attempt to reduce/combine work queues used by the Infiniband 
code.  This keeps the threading a little simpler in the rdma_cm, since all 
callbacks are invoked using the same work queue.  (I'm also using this with the 
local SA/multicast code, but that's not ready for merging.)


There's no specific ordering constraint that's required.  We're just ending up 
with several Infiniband modules creating their own work queues (ib_mad, ib_cm, 
ib_addr, rdma_cm, plus a couple more in modules under development), and this is 
an attempt to reduce that.  If having separate work queues would work better, 
there shouldn't be anything that prevents this.


- Sean
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/6 v2] IB: address translation to map IP toIB addresses (GIDs)

2006-03-10 Thread Roland Dreier
The ib_addr module depends on CONFIG_INET, because it uses symbols
like arp_tbl, which are only exported if INET is enabled.

I fixed this up by creating a new (non-user-visible) config symbol to
control when ib_addr is built -- I put the following diff on top of
your patch in my tree:

diff --git a/drivers/infiniband/Kconfig b/drivers/infiniband/Kconfig
index bdf0891..48c8bb5 100644
--- a/drivers/infiniband/Kconfig
+++ b/drivers/infiniband/Kconfig
@@ -29,6 +29,11 @@ config INFINIBAND_USER_ACCESS
  libibverbs, libibcm and a hardware driver library from
  http://www.openib.org.
 
+config INFINIBAND_ADDR_TRANS
+   tristate
+   depends on INFINIBAND  INET
+   default y
+
 source drivers/infiniband/hw/mthca/Kconfig
 
 source drivers/infiniband/ulp/ipoib/Kconfig
diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
index 2393e9d..935851d 100644
--- a/drivers/infiniband/core/Makefile
+++ b/drivers/infiniband/core/Makefile
@@ -1,7 +1,8 @@
 obj-$(CONFIG_INFINIBAND) +=ib_core.o ib_mad.o ib_sa.o \
-   ib_cm.o ib_addr.o
+   ib_cm.o 
 obj-$(CONFIG_INFINIBAND_USER_MAD) +=   ib_umad.o
 obj-$(CONFIG_INFINIBAND_USER_ACCESS) +=ib_uverbs.o ib_ucm.o
+obj-$(CONFIG_INFINIBAND_ADDR_TRANS) += ib_addr.o
 
 ib_core-y :=   packer.o ud_header.o verbs.o sysfs.o \
device.o fmr_pool.o cache.o
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 4/6 v2] IB: address translation to map IP toIB addresses (GIDs)

2006-03-10 Thread Sean Hefty
The ib_addr module depends on CONFIG_INET, because it uses symbols
like arp_tbl, which are only exported if INET is enabled.

I fixed this up by creating a new (non-user-visible) config symbol to
control when ib_addr is built -- I put the following diff on top of
your patch in my tree:

Thanks!
-Sean

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6 v2] IB: address translation to map IP toIB addresses (GIDs)

2006-03-06 Thread Sean Hefty
Add an address translation service that maps IP addresses to Infiniband
GID addresses using IPoIB.

Signed-off-by: Sean Hefty [EMAIL PROTECTED]

---

This should be the correct patch.  The only difference between this and the 
mis-post
is the use of mutex_lock/unlock in place of up/down.


diff -uprN -X linux-2.6.git/Documentation/dontdiff 
linux-2.6.git/drivers/infiniband/core/addr.c 
linux-2.6.ib/drivers/infiniband/core/addr.c
--- linux-2.6.git/drivers/infiniband/core/addr.c1969-12-31 
16:00:00.0 -0800
+++ linux-2.6.ib/drivers/infiniband/core/addr.c 2006-01-16 16:14:24.0 
-0800
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 2005 Voltaire Inc.  All rights reserved.
+ * Copyright (c) 2002-2005, Network Appliance, Inc. All rights reserved.
+ * 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:
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ *
+ * 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.
+ */
+#include linux/inetdevice.h
+#include linux/workqueue.h
+#include net/arp.h
+#include net/neighbour.h
+#include net/route.h
+#include rdma/ib_addr.h
+
+MODULE_AUTHOR(Sean Hefty);
+MODULE_DESCRIPTION(IB Address Translation);
+MODULE_LICENSE(Dual BSD/GPL);
+
+struct addr_req {
+   struct list_head list;
+   struct sockaddr src_addr;
+   struct sockaddr dst_addr;
+   struct rdma_dev_addr *addr;
+   void *context;
+   void (*callback)(int status, struct sockaddr *src_addr,
+struct rdma_dev_addr *addr, void *context);
+   unsigned long timeout;
+   int status;
+};
+
+static void process_req(void *data);
+
+static DEFINE_MUTEX(lock);
+static LIST_HEAD(req_list);
+static DECLARE_WORK(work, process_req, NULL);
+struct workqueue_struct *rdma_wq;
+EXPORT_SYMBOL(rdma_wq);
+
+static int copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
+unsigned char *dst_dev_addr)
+{
+   switch (dev-type) {
+   case ARPHRD_INFINIBAND:
+   dev_addr-dev_type = IB_NODE_CA;
+   break;
+   default:
+   return -EADDRNOTAVAIL;
+   }
+
+   memcpy(dev_addr-src_dev_addr, dev-dev_addr, MAX_ADDR_LEN);
+   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);
+   return 0;
+}
+
+int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
+{
+   struct net_device *dev;
+   u32 ip = ((struct sockaddr_in *) addr)-sin_addr.s_addr;
+   int ret;
+
+   dev = ip_dev_find(ip);
+   if (!dev)
+   return -EADDRNOTAVAIL;
+
+   ret = copy_addr(dev_addr, dev, NULL);
+   dev_put(dev);
+   return ret;
+}
+EXPORT_SYMBOL(rdma_translate_ip);
+
+static void set_timeout(unsigned long time)
+{
+   unsigned long delay;
+
+   cancel_delayed_work(work);
+
+   delay = time - jiffies;
+   if ((long)delay = 0)
+   delay = 1;
+
+   queue_delayed_work(rdma_wq, work, delay);
+}
+
+static void queue_req(struct addr_req *req)
+{
+   struct addr_req *temp_req;
+
+   mutex_lock(lock);
+   list_for_each_entry_reverse(temp_req, req_list, list) {
+   if (time_after(req-timeout, temp_req-timeout))
+   break;
+   }
+
+   list_add(req-list, temp_req-list);
+
+   if (req_list.next == req-list)
+   set_timeout(req-timeout);
+   mutex_unlock(lock);
+}
+
+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;
+
+   memset(fl, 0, sizeof fl);
+   fl.nl_u.ip4_u.daddr = dst_ip;
+   if (ip_route_output_key(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);
+   ip_rt_put(rt);
+}
+
+static int addr_resolve_remote(struct sockaddr_in *src_in,
+