[patch v2 00/37] add rxe (soft RoCE)

2011-07-25 Thread rpearson
Changes in v2 include:

- Updated to Roland's tree as of 7/24/2011

- Moved the crc32 algorithm into a patch (slice-by-8-for_crc32.c.diff)
  that goes into the mainline kernel. It has been submitted upstream
  but is also included in here since it is required to build the driver.

- renamed rxe_sb8.c rxe_icrc.c since that is all it now does.

- Cleaned up warnings from checkpatch, C=2 and __CHECK_ENDIAN__.

- moved small .h files into rxe_loc.h

- rewrote the Kconfig text to be a little friendlier

- Changed the patch names to make them easier to handle.

- the quilt patch series is online at:
  http://support.systemfabricworks.com/downloads/rxe/patches-v2.tgz

- librxe is online at:
  http://support.systemfabricworks.com/downloads/rxe/librxe-1.0.0.tar.gz

Thanks to Roland Dreier, Bart van Assche and David Dillow for helpful
suggestions.

Introduction:

This patch set implements a software emulation of RoCE or InfiniBand transport.
It consists of two kernel modules. The first, ib_rxe, implements the RDMA
transport and registers with the RDMA core as a kernel verbs provider. The
second, ib_rxe_net or ib_sample, implement the packet IO layer. ib_rxe_net
attaches to the Linux netdev stack as a network protocol and can send and
receive packets over any Ethernet device. It uses the RoCE protocol to handle
RDMA transport. ib_sample is a pure loopback device that uses the InfiniBand
transport i.e. it includes the LRH header while RoCE only includes the GRH
header.

The modules are configured by entries in /sys. There is a configuration script
(rxe_cfg) that simplifies the use of this interface. Rxe_cfg is part of the
rxe user space code, librxe.

The use of rxe verbs in user space requires the inclusion of librxe as a device
specific plug-in to libibverbs. Librxe is packaged separately.


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 02/37] add opcodes to ib_pack.h

2011-07-25 Thread rpearson
Bring up to date with the current version of the IBTA spec.
- add new opcodes for RC and RD
- add new groups of opcodes for CN and XRC

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 include/rdma/ib_pack.h |   39 ++-
 1 file changed, 38 insertions(+), 1 deletion(-)

Index: infiniband/include/rdma/ib_pack.h
===
--- infiniband.orig/include/rdma/ib_pack.h
+++ infiniband/include/rdma/ib_pack.h
@@ -75,6 +75,8 @@ enum {
IB_OPCODE_UC= 0x20,
IB_OPCODE_RD= 0x40,
IB_OPCODE_UD= 0x60,
+   IB_OPCODE_CN= 0x80,
+   IB_OPCODE_XRC   = 0xA0,
 
/* operations -- just used to define real constants */
IB_OPCODE_SEND_FIRST= 0x00,
@@ -98,6 +100,10 @@ enum {
IB_OPCODE_ATOMIC_ACKNOWLEDGE= 0x12,
IB_OPCODE_COMPARE_SWAP  = 0x13,
IB_OPCODE_FETCH_ADD = 0x14,
+   IB_OPCODE_CNP   = 0x00,
+   IB_OPCODE_RESYNC= 0x15,
+   IB_OPCODE_SEND_LAST_INV = 0x16,
+   IB_OPCODE_SEND_ONLY_INV = 0x17,
 
/* real constants follow -- see comment about above IB_OPCODE()
   macro for more details */
@@ -124,6 +130,8 @@ enum {
IB_OPCODE(RC, ATOMIC_ACKNOWLEDGE),
IB_OPCODE(RC, COMPARE_SWAP),
IB_OPCODE(RC, FETCH_ADD),
+   IB_OPCODE(RC, SEND_LAST_INV),
+   IB_OPCODE(RC, SEND_ONLY_INV),
 
/* UC */
IB_OPCODE(UC, SEND_FIRST),
@@ -161,10 +169,39 @@ enum {
IB_OPCODE(RD, ATOMIC_ACKNOWLEDGE),
IB_OPCODE(RD, COMPARE_SWAP),
IB_OPCODE(RD, FETCH_ADD),
+   IB_OPCODE(RD, RESYNC),
 
/* UD */
IB_OPCODE(UD, SEND_ONLY),
-   IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE)
+   IB_OPCODE(UD, SEND_ONLY_WITH_IMMEDIATE),
+
+   /* CN */
+   IB_OPCODE(CN, CNP),
+
+   /* XRC */
+   IB_OPCODE(XRC, SEND_FIRST),
+   IB_OPCODE(XRC, SEND_MIDDLE),
+   IB_OPCODE(XRC, SEND_LAST),
+   IB_OPCODE(XRC, SEND_LAST_WITH_IMMEDIATE),
+   IB_OPCODE(XRC, SEND_ONLY),
+   IB_OPCODE(XRC, SEND_ONLY_WITH_IMMEDIATE),
+   IB_OPCODE(XRC, RDMA_WRITE_FIRST),
+   IB_OPCODE(XRC, RDMA_WRITE_MIDDLE),
+   IB_OPCODE(XRC, RDMA_WRITE_LAST),
+   IB_OPCODE(XRC, RDMA_WRITE_LAST_WITH_IMMEDIATE),
+   IB_OPCODE(XRC, RDMA_WRITE_ONLY),
+   IB_OPCODE(XRC, RDMA_WRITE_ONLY_WITH_IMMEDIATE),
+   IB_OPCODE(XRC, RDMA_READ_REQUEST),
+   IB_OPCODE(XRC, RDMA_READ_RESPONSE_FIRST),
+   IB_OPCODE(XRC, RDMA_READ_RESPONSE_MIDDLE),
+   IB_OPCODE(XRC, RDMA_READ_RESPONSE_LAST),
+   IB_OPCODE(XRC, RDMA_READ_RESPONSE_ONLY),
+   IB_OPCODE(XRC, ACKNOWLEDGE),
+   IB_OPCODE(XRC, ATOMIC_ACKNOWLEDGE),
+   IB_OPCODE(XRC, COMPARE_SWAP),
+   IB_OPCODE(XRC, FETCH_ADD),
+   IB_OPCODE(XRC, SEND_LAST_INV),
+   IB_OPCODE(XRC, SEND_ONLY_INV),
 };
 
 enum {


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 01/37] add slice by 8 algorithm to crc32.c

2011-07-25 Thread rpearson
Added support for slice by 8 to existing crc32 algorithm. Also
modified gen_crc32table.c to only produce table entries that are
actually used. The parameters CRC_LE_BITS and CRC_BE_BITS determine
the number of bits in the input array that are processed during each
step. Generally the more bits the faster the algorithm is but the
more table data required.

Using an x86_64 Opteron machine running at 2100MHz the following table
was collected with a pre-warmed cache by computing the crc 1000 times
on a buffer of 4096 bytes.

BITSSizeLE Cycles/byte  BE Cycles/byte
--
1   873 41.65   34.60
2   109725.43   29.61
4   105713.29   15.28
8   29137.138.19
32  96842.802.82
64  18178   1.531.53

BITS is the value of CRC_LE_BITS or CRC_BE_BITS. The old
default was 8 which actually selected the 32 bit algorithm. In
this version the value 8 is used to select the standard
8 bit algorithm and two new values: 32 and 64 are introduced
to select the slice by 4 and slice by 8 algorithms respectively.

Where Size is the size of crc32.o's text segment which includes
code and table data when both LE and BE versions are set to BITS.

The current version of crc32.c by default uses the slice by 4 algorithm
which requires about 2.8 cycles per byte. The slice by 8 algorithm is
roughly 2X faster and enables packet processing at over 1GB/sec on a typical
2-3GHz system.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 lib/crc32.c  |  372 +++
 lib/crc32defs.h  |   16 +-
 lib/gen_crc32table.c |   59 +---
 3 files changed, 310 insertions(+), 137 deletions(-)

Index: infiniband/lib/crc32.c
===
--- infiniband.orig/lib/crc32.c
+++ infiniband/lib/crc32.c
@@ -1,4 +1,8 @@
 /*
+ * July 20, 2011 Bob Pearson rpearson at systemfabricworks.com
+ * added slice by 8 algorithm to the existing conventional and
+ * slice by 4 algorithms.
+ *
  * Oct 15, 2000 Matt Domsch matt_dom...@dell.com
  * Nicer crc32 functions/docs submitted by li...@horizon.com.  Thanks!
  * Code was from the public domain, copyright abandoned.  Code was
@@ -19,7 +23,6 @@
  * This source code is licensed under the GNU General Public License,
  * Version 2.  See the file COPYING for more details.
  */
-
 #include linux/crc32.h
 #include linux/kernel.h
 #include linux/module.h
@@ -28,14 +31,15 @@
 #include linux/init.h
 #include asm/atomic.h
 #include crc32defs.h
-#if CRC_LE_BITS == 8
-# define tole(x) __constant_cpu_to_le32(x)
+
+#if CRC_LE_BITS  8
+# define tole(x) (__force u32) __constant_cpu_to_le32(x)
 #else
 # define tole(x) (x)
 #endif
 
-#if CRC_BE_BITS == 8
-# define tobe(x) __constant_cpu_to_be32(x)
+#if CRC_BE_BITS  8
+# define tobe(x) (__force u32) __constant_cpu_to_be32(x)
 #else
 # define tobe(x) (x)
 #endif
@@ -45,54 +49,228 @@ MODULE_AUTHOR(Matt Domsch Matt_Domsch@
 MODULE_DESCRIPTION(Ethernet CRC32 calculations);
 MODULE_LICENSE(GPL);
 
-#if CRC_LE_BITS == 8 || CRC_BE_BITS == 8
+#if CRC_LE_BITS  8
+static inline u32 crc32_le_body(u32 crc, u8 const *buf, size_t len)
+{
+   const u8 *p8;
+   const u32 *p32;
+   int init_bytes, end_bytes;
+   size_t words;
+   int i;
+   u32 q;
+   u8 i0, i1, i2, i3;
+
+   crc = (__force u32) __cpu_to_le32(crc);
+
+#if CRC_LE_BITS == 64
+   p8 = buf;
+   p32 = (u32 *)(((uintptr_t)p8 + 7)  ~7);
+
+   init_bytes = (uintptr_t)p32 - (uintptr_t)p8;
+   if (init_bytes  len)
+   init_bytes = len;
+   words = (len - init_bytes)  3;
+   end_bytes = (len - init_bytes)  7;
+#else
+   p8 = buf;
+   p32 = (u32 *)(((uintptr_t)p8 + 3)  ~3);
+
+   init_bytes = (uintptr_t)p32 - (uintptr_t)p8;
+   if (init_bytes  len)
+   init_bytes = len;
+   words = (len - init_bytes)  2;
+   end_bytes = (len - init_bytes)  3;
+#endif
+
+   for (i = 0; i  init_bytes; i++) {
+#ifdef __LITTLE_ENDIAN
+   i0 = *p8++ ^ crc;
+   crc = t0_le[i0] ^ (crc  8);
+#else
+   i0 = *p8++ ^ (crc  24);
+   crc = t0_le[i0] ^ (crc  8);
+#endif
+   }
+
+   for (i = 0; i  words; i++) {
+#ifdef __LITTLE_ENDIAN
+#  if CRC_LE_BITS == 64
+   /* slice by 8 algorithm */
+   q = *p32++ ^ crc;
+   i3 = q;
+   i2 = q  8;
+   i1 = q  16;
+   i0 = q  24;
+   crc = t7_le[i3] ^ t6_le[i2] ^ t5_le[i1] ^ t4_le[i0];
+
+   q = *p32++;
+   i3 = q;
+   i2 = q  8;
+   i1 = q  16;
+   i0 = q  24;
+   crc ^= t3_le[i3] ^ t2_le[i2] ^ t1_le[i1] ^ t0_le[i0];
+#  else
+   /* slice

[patch v2 05/37] add rxe_opcode.c

2011-07-25 Thread rpearson
Add data structures used to hold per opcode
and per work request opcode tables.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_opcode.c |  982 +
 1 file changed, 982 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_opcode.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_opcode.c
@@ -0,0 +1,982 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rdma/ib_pack.h
+#include rxe_opcode.h
+#include rxe_hdr.h
+
+/* useful information about work request opcodes and pkt opcodes
+   in table form */
+
+struct rxe_wr_opcode_info rxe_wr_opcode_info[] = {
+   [IB_WR_RDMA_WRITE]  = {
+   .name   = IB_WR_RDMA_WRITE,
+   .mask   = {
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   },
+   },
+   [IB_WR_RDMA_WRITE_WITH_IMM] = {
+   .name   = IB_WR_RDMA_WRITE_WITH_IMM,
+   .mask   = {
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   },
+   },
+   [IB_WR_SEND]= {
+   .name   = IB_WR_SEND,
+   .mask   = {
+   [IB_QPT_SMI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_GSI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UD] = WR_INLINE_MASK | WR_SEND_MASK,
+   },
+   },
+   [IB_WR_SEND_WITH_IMM]   = {
+   .name   = IB_WR_SEND_WITH_IMM,
+   .mask   = {
+   [IB_QPT_SMI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_GSI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UD] = WR_INLINE_MASK | WR_SEND_MASK,
+   },
+   },
+   [IB_WR_RDMA_READ]   = {
+   .name   = IB_WR_RDMA_READ,
+   .mask   = {
+   [IB_QPT_RC] = WR_READ_MASK,
+   },
+   },
+   [IB_WR_ATOMIC_CMP_AND_SWP]  = {
+   .name   = IB_WR_ATOMIC_CMP_AND_SWP,
+   .mask   = {
+   [IB_QPT_RC] = WR_ATOMIC_MASK,
+   },
+   },
+   [IB_WR_ATOMIC_FETCH_AND_ADD]= {
+   .name   = IB_WR_ATOMIC_FETCH_AND_ADD,
+   .mask   = {
+   [IB_QPT_RC] = WR_ATOMIC_MASK,
+   },
+   },
+   [IB_WR_LSO] = {
+   .name   = IB_WR_LSO,
+   .mask   = {
+   /* not supported */
+   },
+   },
+   [IB_WR_SEND_WITH_INV]   = {
+   .name   = IB_WR_SEND_WITH_INV,
+   .mask   = {
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_SEND_MASK,
+

[patch v2 06/37] add rxe_param.h

2011-07-25 Thread rpearson
default rxe device and port parameters

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_param.h |  212 ++
 1 file changed, 212 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_param.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_param.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_PARAM_H
+#define RXE_PARAM_H
+
+enum rxe_mtu {
+   RXE_MTU_INVALID = 0,
+   RXE_MTU_256 = 1,
+   RXE_MTU_512 = 2,
+   RXE_MTU_1024= 3,
+   RXE_MTU_2048= 4,
+   RXE_MTU_4096= 5,
+   RXE_MTU_8192= 6,
+};
+
+static inline int rxe_mtu_enum_to_int(enum rxe_mtu mtu)
+{
+   switch (mtu) {
+   case RXE_MTU_256:   return  256;
+   case RXE_MTU_512:   return  512;
+   case RXE_MTU_1024:  return  1024;
+   case RXE_MTU_2048:  return  2048;
+   case RXE_MTU_4096:  return  4096;
+   case RXE_MTU_8192:  return  8192;
+   default:return  -1;
+   }
+}
+
+static inline enum rxe_mtu rxe_mtu_int_to_enum(int mtu)
+{
+   if (mtu  256)
+   return 0;
+   else if (mtu  512)
+   return RXE_MTU_256;
+   else if (mtu  1024)
+   return RXE_MTU_512;
+   else if (mtu  2048)
+   return RXE_MTU_1024;
+   else if (mtu  4096)
+   return RXE_MTU_2048;
+   else if (mtu  8192)
+   return RXE_MTU_4096;
+   else
+   return RXE_MTU_8192;
+}
+
+/* Find the IB mtu for a given network MTU. */
+static inline enum rxe_mtu eth_mtu_int_to_enum(int mtu)
+{
+   mtu -= RXE_MAX_HDR_LENGTH;
+
+   return rxe_mtu_int_to_enum(mtu);
+}
+
+/*
+ * default/initial rxe device parameter settings
+ */
+enum rxe_device_param {
+   RXE_FW_VER  = 0,
+   RXE_MAX_MR_SIZE = -1ull,
+   RXE_PAGE_SIZE_CAP   = 0xf000,
+   RXE_VENDOR_ID   = 0,
+   RXE_VENDOR_PART_ID  = 0,
+   RXE_HW_VER  = 0,
+   RXE_MAX_QP  = 0x1,
+   RXE_MAX_QP_WR   = 0x4000,
+   RXE_MAX_INLINE_DATA = 400,
+   RXE_DEVICE_CAP_FLAGS= IB_DEVICE_BAD_PKEY_CNTR
+   | IB_DEVICE_BAD_QKEY_CNTR
+   | IB_DEVICE_AUTO_PATH_MIG
+   | IB_DEVICE_CHANGE_PHY_PORT
+   | IB_DEVICE_UD_AV_PORT_ENFORCE
+   | IB_DEVICE_PORT_ACTIVE_EVENT
+   | IB_DEVICE_SYS_IMAGE_GUID
+   | IB_DEVICE_RC_RNR_NAK_GEN
+   | IB_DEVICE_SRQ_RESIZE,
+   RXE_MAX_SGE = 27,
+   RXE_MAX_SGE_RD  = 0,
+   RXE_MAX_CQ  = 16384,
+   RXE_MAX_LOG_CQE = 13,
+   RXE_MAX_MR  = 2*1024,
+   RXE_MAX_PD  = 0x7ffc,
+   RXE_MAX_QP_RD_ATOM  = 128,
+   RXE_MAX_EE_RD_ATOM  = 0,
+   RXE_MAX_RES_RD_ATOM = 0x3f000,
+   RXE_MAX_QP_INIT_RD_ATOM = 128,
+   RXE_MAX_EE_INIT_RD_ATOM = 0,
+   RXE_ATOMIC_CAP 

[patch v2 07/37] add rxe.h

2011-07-25 Thread rpearson
ib_rxe external interface to lower level modules

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe.h |   64 
 1 file changed, 64 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_H
+#define RXE_H
+
+#include linux/skbuff.h
+#include linux/crc32.h
+
+#include rdma/ib_verbs.h
+#include rdma/ib_user_verbs.h
+#include rdma/ib_pack.h
+#include rdma/ib_smi.h
+#include rdma/ib_umem.h
+
+#include rxe_opcode.h
+#include rxe_hdr.h
+#include rxe_param.h
+#include rxe_verbs.h
+
+#define RXE_UVERBS_ABI_VERSION (1)
+
+#define IB_PHYS_STATE_LINK_UP  (5)
+
+int rxe_set_mtu(struct rxe_dev *rxe, unsigned int dev_mtu,
+   unsigned int port_num);
+
+int rxe_add(struct rxe_dev *rxe, unsigned int mtu);
+
+void rxe_remove(struct rxe_dev *rxe);
+
+int rxe_rcv(struct sk_buff *skb);
+
+#endif /* RXE_H */


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 08/37] add rxe_loc.h

2011-07-25 Thread rpearson
misc local interfaces between files in ib_rxe.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_loc.h |  261 
 1 file changed, 261 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_loc.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_loc.h
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_LOC_H
+#define RXE_LOC_H
+
+/* local declarations shared between rxe files */
+
+/* rxe_v.c */
+int rxe_av_chk_attr(struct rxe_dev *rxe, struct ib_ah_attr *attr);
+
+int rxe_av_from_attr(struct rxe_dev *rxe, u8 port_num,
+struct rxe_av *av, struct ib_ah_attr *attr);
+
+int rxe_av_to_attr(struct rxe_dev *rxe, struct rxe_av *av,
+  struct ib_ah_attr *attr);
+
+/* rxe_cq.c */
+int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
+   int cqe, int comp_vector, struct ib_udata *udata);
+
+int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
+int comp_vector, struct ib_ucontext *context,
+struct ib_udata *udata);
+
+int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe, struct ib_udata 
*udata);
+
+int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
+
+void rxe_cq_cleanup(void *arg);
+
+/* rxe_mcast.c */
+int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, u16 mlid,
+ struct rxe_mc_grp **grp_p);
+
+int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
+  struct rxe_mc_grp *grp);
+
+int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
+   union ib_gid *mgid, u16 mlid);
+
+void rxe_drop_all_mcast_groups(struct rxe_qp *qp);
+
+void rxe_mc_cleanup(void *arg);
+
+/* rxe_mmap.c */
+
+/* must match struct in librxe */
+struct mminfo {
+   __u64   offset;
+   __u32   size;
+   __u32   pad;
+};
+
+struct rxe_mmap_info {
+   struct list_headpending_mmaps;
+   struct ib_ucontext  *context;
+   struct kref ref;
+   void*obj;
+
+   struct mminfo info;
+};
+
+void rxe_mmap_release(struct kref *ref);
+
+struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev,
+  u32 size,
+  struct ib_ucontext *context,
+  void *obj);
+
+int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
+
+/* rxe_mr.c */
+enum copy_direction {
+   direction_in,
+   direction_out,
+};
+
+int rxe_mem_init_dma(struct rxe_dev *rxe, struct rxe_pd *pd,
+int access, struct rxe_mem *mem);
+
+int rxe_mem_init_phys(struct rxe_dev *rxe, struct rxe_pd *pd,
+ int access, u64 iova, struct ib_phys_buf *buf,
+ int num_buf, struct rxe_mem *mem);
+
+int rxe_mem_init_user(struct rxe_dev *rxe, struct rxe_pd *pd, u64 start,
+ u64 length, u64 iova, int access, struct ib_udata *udata,
+ struct rxe_mem *mr);
+
+int rxe_mem_init_fast(struct rxe_dev *rxe, struct rxe_pd *pd,
+ int max_pages, struct rxe_mem *mem);
+
+int rxe_mem_init_mw(struct rxe_dev *rxe, struct rxe_pd *pd,
+   struct 

[patch v2 09/37] add rxe_mmap.c

2011-07-25 Thread rpearson
mmap routines.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_mmap.c |  171 +++
 1 file changed, 171 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_mmap.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_mmap.c
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/module.h
+#include linux/vmalloc.h
+#include linux/mm.h
+#include linux/errno.h
+#include asm/pgtable.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+void rxe_mmap_release(struct kref *ref)
+{
+   struct rxe_mmap_info *ip = container_of(ref,
+   struct rxe_mmap_info, ref);
+   struct rxe_dev *rxe = to_rdev(ip-context-device);
+
+   spin_lock_bh(rxe-pending_lock);
+
+   if (!list_empty(ip-pending_mmaps))
+   list_del(ip-pending_mmaps);
+
+   spin_unlock_bh(rxe-pending_lock);
+
+   vfree(ip-obj); /* buf */
+   kfree(ip);
+}
+
+/*
+ * open and close keep track of how many times the CQ is mapped,
+ * to avoid releasing it.
+ */
+static void rxe_vma_open(struct vm_area_struct *vma)
+{
+   struct rxe_mmap_info *ip = vma-vm_private_data;
+
+   kref_get(ip-ref);
+}
+
+static void rxe_vma_close(struct vm_area_struct *vma)
+{
+   struct rxe_mmap_info *ip = vma-vm_private_data;
+
+   kref_put(ip-ref, rxe_mmap_release);
+
+}
+
+static struct vm_operations_struct rxe_vm_ops = {
+   .open = rxe_vma_open,
+   .close = rxe_vma_close,
+};
+
+/**
+ * rxe_mmap - create a new mmap region
+ * @context: the IB user context of the process making the mmap() call
+ * @vma: the VMA to be initialized
+ * Return zero if the mmap is OK. Otherwise, return an errno.
+ */
+int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
+{
+   struct rxe_dev *rxe = to_rdev(context-device);
+   unsigned long offset = vma-vm_pgoff  PAGE_SHIFT;
+   unsigned long size = vma-vm_end - vma-vm_start;
+   struct rxe_mmap_info *ip, *pp;
+   int ret;
+
+   /*
+* Search the device's list of objects waiting for a mmap call.
+* Normally, this list is very short since a call to create a
+* CQ, QP, or SRQ is soon followed by a call to mmap().
+*/
+   spin_lock_bh(rxe-pending_lock);
+   list_for_each_entry_safe(ip, pp, rxe-pending_mmaps, pending_mmaps) {
+   if (context != ip-context || (__u64)offset != ip-info.offset)
+   continue;
+
+   /* Don't allow a mmap larger than the object. */
+   if (size  ip-info.size)
+   break;
+
+   goto found_it;
+   }
+   pr_warning(unable to find pending mmap info\n);
+   spin_unlock_bh(rxe-pending_lock);
+   ret = -EINVAL;
+   goto done;
+
+found_it:
+   list_del_init(ip-pending_mmaps);
+   spin_unlock_bh(rxe-pending_lock);
+
+   ret = remap_vmalloc_range(vma, ip-obj, 0);
+   if (ret) {
+   pr_info(rxe: err %d from remap_vmalloc_range\n, ret);
+   goto done;
+   }
+
+   vma-vm_ops = rxe_vm_ops;
+   vma-vm_private_data = ip;
+   rxe_vma_open(vma);
+done:
+   return ret;
+}
+
+/*
+ * Allocate information for rxe_mmap
+ */
+struct rxe_mmap_info *rxe_create_mmap_info(struct 

[patch v2 10/37] add rxe_queue.h

2011-07-25 Thread rpearson
declarations for common work and completion queue.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_queue.h |  174 ++
 1 file changed, 174 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_queue.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_queue.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_QUEUE_H
+#define RXE_QUEUE_H
+
+/* implements a simple circular buffer that can optionally be
+   shared between user space and the kernel and can be resized
+
+   the requested element size is rounded up to a power of 2
+   and the number of elements in the buffer is also rounded
+   up to a power of 2. Since the queue is empty when the
+   producer and consumer indices match the maximum capacity
+   of the queue is one less than the number of element slots */
+
+/* this data structure is shared between user space and kernel
+   space for those cases where the queue is shared. It contains
+   the producer and consumer indices. Is also contains a copy
+   of the queue size parameters for user space to use but the
+   kernel must use the parameters in the rxe_queue struct
+   this MUST MATCH the corresponding librxe struct
+   for performance reasons arrange to have producer and consumer
+   pointers in separate cache lines
+   the kernel should always mask the indices to avoid accessing
+   memory outside of the data area */
+struct rxe_queue_buf {
+   __u32   log2_elem_size;
+   __u32   index_mask;
+   __u32   pad_1[30];
+   __u32   producer_index;
+   __u32   pad_2[31];
+   __u32   consumer_index;
+   __u32   pad_3[31];
+   __u8data[0];
+};
+
+struct rxe_queue {
+   struct rxe_dev  *rxe;
+   struct rxe_queue_buf*buf;
+   struct rxe_mmap_info*ip;
+   size_t  buf_size;
+   size_t  elem_size;
+   unsigned intlog2_elem_size;
+   unsigned intindex_mask;
+};
+
+int do_mmap_info(struct rxe_dev *rxe,
+struct ib_udata *udata,
+int offset,
+struct ib_ucontext *context,
+struct rxe_queue_buf *buf,
+size_t buf_size,
+struct rxe_mmap_info **ip_p);
+
+struct rxe_queue *rxe_queue_init(struct rxe_dev *rxe,
+unsigned int *num_elem,
+unsigned int elem_size);
+
+int rxe_queue_resize(struct rxe_queue *q,
+unsigned int *num_elem_p,
+unsigned int elem_size,
+struct ib_ucontext *context,
+struct ib_udata *udata,
+spinlock_t *producer_lock,
+spinlock_t *consumer_lock);
+
+void rxe_queue_cleanup(struct rxe_queue *queue);
+
+static inline int next_index(struct rxe_queue *q, int index)
+{
+   return (index + 1)  q-buf-index_mask;
+}
+
+static inline int queue_empty(struct rxe_queue *q)
+{
+   return ((q-buf-producer_index - q-buf-consumer_index)
+q-index_mask) == 0;
+}
+
+static inline int queue_full(struct rxe_queue *q)
+{
+   return ((q-buf-producer_index + 1 - q-buf-consumer_index)
+

[patch v2 12/37] add rxe_verbs.h

2011-07-25 Thread rpearson
declarations for rxe interface to rdma/core

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_verbs.h |  571 ++
 1 file changed, 571 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_verbs.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_verbs.h
@@ -0,0 +1,571 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_VERBS_H
+#define RXE_VERBS_H
+
+#include linux/interrupt.h
+#include rxe_pool.h
+#include rxe_task.h
+
+static inline int pkey_match(u16 key1, u16 key2)
+{
+   return (((key1  0x7fff) != 0) 
+   ((key1  0x7fff) == (key2  0x7fff)) 
+   ((key1  0x8000) || (key2  0x8000))) ? 1 : 0;
+}
+
+/* Return 0 if psn_a  psn_b
+ *0 if psn_a == psn_b
+ *   0 if psn_a  psn_b
+ */
+static inline int psn_compare(u32 psn_a, u32 psn_b)
+{
+   s32 diff;
+   diff = (psn_a - psn_b)  8;
+   return diff;
+}
+
+struct rxe_ucontext {
+   struct rxe_pool_entry   pelem;
+   struct ib_ucontext  ibuc;
+};
+
+struct rxe_pd {
+   struct rxe_pool_entry   pelem;
+   struct ib_pdibpd;
+};
+
+#define RXE_LL_ADDR_LEN(16)
+
+struct rxe_av {
+   struct ib_ah_attr   attr;
+   u8  ll_addr[RXE_LL_ADDR_LEN];
+
+};
+
+struct rxe_ah {
+   struct rxe_pool_entry   pelem;
+   struct ib_ahibah;
+   struct rxe_pd   *pd;
+   struct rxe_av   av;
+};
+
+struct rxe_cqe {
+   union {
+   struct ib_wcibwc;
+   struct ib_uverbs_wc uibwc;
+   };
+};
+
+struct rxe_cq {
+   struct rxe_pool_entry   pelem;
+   struct ib_cqibcq;
+   struct rxe_queue*queue;
+   spinlock_t  cq_lock;
+   u8  notify;
+   u8  special;
+   int is_user;
+   struct tasklet_struct   comp_task;
+};
+
+struct rxe_dma_info {
+   __u32   length;
+   __u32   resid;
+   __u32   cur_sge;
+   __u32   num_sge;
+   __u32   sge_offset;
+   union {
+   u8  inline_data[0];
+   struct ib_sge   sge[0];
+   };
+};
+
+enum wqe_state {
+   wqe_state_posted,
+   wqe_state_processing,
+   wqe_state_pending,
+   wqe_state_done,
+   wqe_state_error,
+};
+
+/* must match corresponding data structure in librxe */
+struct rxe_send_wqe {
+   struct ib_send_wr   ibwr;
+   struct rxe_av   av; /* UD only */
+   u32 status;
+   u32 state;
+   u64 iova;
+   u32 mask;
+   u32 first_psn;
+   u32 last_psn;
+   u32 ack_length;
+   u32 ssn;
+   u32 has_rd_atomic;
+   struct rxe_dma_info dma;/* must go last */
+};
+
+struct rxe_recv_wqe {
+   __u64   wr_id;
+   __u32   num_sge;
+   __u32   padding;
+   struct rxe_dma_info dma;
+};
+
+struct rxe_sq {
+   int max_wr;
+   int max_sge;
+   int  

[patch v2 13/37] add rxe_verbs.c

2011-07-25 Thread rpearson
rxe interface to rdma/core

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_verbs.c | 1344 ++
 1 file changed, 1344 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_verbs.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_verbs.c
@@ -0,0 +1,1344 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+static int rxe_query_device(struct ib_device *dev, struct ib_device_attr *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+
+   *attr = rxe-attr;
+   return 0;
+}
+
+static int rxe_query_port(struct ib_device *dev,
+ u8 port_num, struct ib_port_attr *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_number %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   *attr = port-attr;
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int rxe_query_gid(struct ib_device *device,
+u8 port_num, int index, union ib_gid *gid)
+{
+   struct rxe_dev *rxe = to_rdev(device);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_num = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   if (unlikely(index  0 || index = port-attr.gid_tbl_len)) {
+   pr_warn(invalid index = %d\n, index);
+   goto err1;
+   }
+
+   gid-global.subnet_prefix = port-subnet_prefix;
+   gid-global.interface_id = port-guid_tbl[index];
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int rxe_query_pkey(struct ib_device *device,
+ u8 port_num, u16 index, u16 *pkey)
+{
+   struct rxe_dev *rxe = to_rdev(device);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_num = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   if (unlikely(index = port-attr.pkey_tbl_len)) {
+   pr_warn(invalid index = %d\n, index);
+   goto err1;
+   }
+
+   *pkey = port-pkey_tbl[index];
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int rxe_modify_device(struct ib_device *dev,
+int mask, struct ib_device_modify *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+
+   if (mask  IB_DEVICE_MODIFY_SYS_IMAGE_GUID)
+   rxe-attr.sys_image_guid = cpu_to_be64(attr-sys_image_guid);
+
+   if (mask  IB_DEVICE_MODIFY_NODE_DESC) {
+   memcpy(rxe-ib_dev.node_desc,
+  attr-node_desc, sizeof(rxe-ib_dev.node_desc));
+   }
+
+   return 0;
+}
+
+static int rxe_modify_port(struct ib_device *dev,
+  u8 port_num, int mask, struct ib_port_modify *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_num = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   

[patch v2 11/37] add rxe_queue.c

2011-07-25 Thread rpearson
common work and completion queue implementation.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_queue.c |  209 ++
 1 file changed, 209 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_queue.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_queue.c
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - Redistributions in binary form must retailuce the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer 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/vmalloc.h
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+int do_mmap_info(struct rxe_dev *rxe,
+struct ib_udata *udata,
+int offset,
+struct ib_ucontext *context,
+struct rxe_queue_buf *buf,
+size_t buf_size,
+struct rxe_mmap_info **ip_p)
+{
+   int err;
+   struct rxe_mmap_info *ip = NULL;
+
+   if (udata) {
+   if ((udata-outlen - offset)  sizeof(struct mminfo))
+   goto err1;
+
+   ip = rxe_create_mmap_info(rxe, buf_size, context, buf);
+   if (!ip)
+   goto err1;
+
+   err = copy_to_user(udata-outbuf + offset, ip-info,
+  sizeof(ip-info));
+   if (err)
+   goto err2;
+
+   spin_lock_bh(rxe-pending_lock);
+   list_add(ip-pending_mmaps, rxe-pending_mmaps);
+   spin_unlock_bh(rxe-pending_lock);
+   }
+
+   *ip_p = ip;
+
+   return 0;
+
+err2:
+   kfree(ip);
+err1:
+   return -EINVAL;
+}
+
+struct rxe_queue *rxe_queue_init(struct rxe_dev *rxe,
+unsigned int *num_elem,
+unsigned int elem_size)
+{
+   struct rxe_queue *q;
+   size_t buf_size;
+   unsigned int num_slots;
+
+   /* num_elem == 0 is allowed, but uninteresting */
+   if (*num_elem  0)
+   goto err1;
+
+   q = kmalloc(sizeof(*q), GFP_KERNEL);
+   if (!q)
+   goto err1;
+
+   q-rxe = rxe;
+
+   q-elem_size = elem_size;
+   elem_size = roundup_pow_of_two(elem_size);
+   q-log2_elem_size = order_base_2(elem_size);
+
+   num_slots = *num_elem + 1;
+   num_slots = roundup_pow_of_two(num_slots);
+   q-index_mask = num_slots - 1;
+
+   buf_size = sizeof(struct rxe_queue_buf) + num_slots*elem_size;
+
+   q-buf = vmalloc_user(buf_size);
+   if (!q-buf)
+   goto err2;
+
+   q-buf-log2_elem_size = q-log2_elem_size;
+   q-buf-index_mask = q-index_mask;
+
+   q-buf-producer_index = 0;
+   q-buf-consumer_index = 0;
+
+   q-buf_size = buf_size;
+
+   *num_elem = num_slots - 1;
+   return q;
+
+err2:
+   kfree(q);
+err1:
+   return NULL;
+}
+
+/* copies elements from original q to new q and then
+   swaps the contents of the two q headers. This is
+   so that if anyone is holding a pointer to q it will
+   still work */
+static int resize_finish(struct rxe_queue *q, struct rxe_queue *new_q,
+unsigned int num_elem)
+{
+   struct rxe_queue temp;
+
+   if (!queue_empty(q)  (num_elem  queue_count(q)))
+   return -EINVAL;
+
+   while (!queue_empty(q)) {
+   memcpy(producer_addr(new_q), consumer_addr(q),
+  new_q-elem_size);
+   advance_producer(new_q);
+   advance_consumer(q);
+   

[patch v2 14/37] add rxe_pool.h

2011-07-25 Thread rpearson
declarations for rdma objects

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_pool.h |  163 +++
 1 file changed, 163 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_pool.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_pool.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_POOL_H
+#define RXE_POOL_H
+
+/* declarations for pools of managed objects */
+
+#define RXE_POOL_ALIGN (16)
+#define RXE_POOL_CACHE_FLAGS   (0)
+
+enum rxe_pool_flags {
+   RXE_POOL_ATOMIC = (1  0),
+   RXE_POOL_INDEX  = (1  1),
+   RXE_POOL_KEY= (1  2),
+};
+
+enum rxe_elem_type {
+   RXE_TYPE_UC,
+   RXE_TYPE_PD,
+   RXE_TYPE_AH,
+   RXE_TYPE_SRQ,
+   RXE_TYPE_QP,
+   RXE_TYPE_CQ,
+   RXE_TYPE_MR,
+   RXE_TYPE_MW,
+   RXE_TYPE_FMR,
+   RXE_TYPE_MC_GRP,
+   RXE_TYPE_MC_ELEM,
+   RXE_NUM_TYPES,  /* keep me last */
+};
+
+struct rxe_type_info {
+   char*name;
+   size_t  size;
+   void(*cleanup)(void *obj);
+   enum rxe_pool_flags flags;
+   u32 max_index;
+   u32 min_index;
+   size_t  key_offset;
+   size_t  key_size;
+   struct kmem_cache   *cache;
+};
+
+extern struct rxe_type_info rxe_type_info[];
+
+enum rxe_pool_state {
+   rxe_pool_invalid,
+   rxe_pool_valid,
+};
+
+struct rxe_pool_entry {
+   struct rxe_pool *pool;
+   struct kref ref_cnt;
+   struct list_headlist;
+
+   /* only used if index'ed or key'ed */
+   struct rb_node  node;
+   u32 index;
+};
+
+struct rxe_pool {
+   struct rxe_dev  *rxe;
+   spinlock_t  pool_lock;
+   size_t  elem_size;
+   struct kref ref_cnt;
+   void(*cleanup)(void *obj);
+   enum rxe_pool_state state;
+   enum rxe_pool_flags flags;
+   enum rxe_elem_type  type;
+
+   unsigned intmax_elem;
+   atomic_tnum_elem;
+
+   /* only used if index'ed or key'ed */
+   struct rb_root  tree;
+   unsigned long   *table;
+   size_t  table_size;
+   u32 max_index;
+   u32 min_index;
+   u32 last;
+   size_t  key_offset;
+   size_t  key_size;
+};
+
+/* initialize slab caches for managed objects */
+int __init rxe_cache_init(void);
+
+/* cleanup slab caches for managed objects */
+void __exit rxe_cache_exit(void);
+
+/* initialize a pool of objects with given limit on
+   number of elements. gets parameters from rxe_type_info
+   pool elements will be allocated out of a slab cache */
+int rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool,
+ enum rxe_elem_type type, u32 max_elem);
+
+/* free resources from object pool */
+int rxe_pool_cleanup(struct rxe_pool *pool);
+
+/* allocate an object from pool */
+void *rxe_alloc(struct rxe_pool *pool);
+
+/* assign an index to an indexed object and insert object 

[patch v2 16/37] add rxe_task.h

2011-07-25 Thread rpearson
Declarations for tasklet handling.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_task.h |  107 +++
 1 file changed, 107 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_task.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_task.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_TASK_H
+#define RXE_TASK_H
+
+enum {
+   TASK_STATE_START= 0,
+   TASK_STATE_BUSY = 1,
+   TASK_STATE_ARMED= 2,
+};
+
+/*
+ * data structure to describe a 'task' which is a short
+ * function that returns 0 as long as it needs to be
+ * called again.
+ */
+struct rxe_task {
+   void*obj;
+   int *fast;
+   struct tasklet_struct   tasklet;
+   int state;
+   spinlock_t  state_lock;
+   void*arg;
+   int (*func)(void *arg);
+   int ret;
+   charname[16];
+};
+
+/*
+ * init rxe_task structure
+ * fast = address of control flag, likely a module parameter
+ * arg  = parameter to pass to fcn
+ * fcn  = function to call until it returns != 0
+ */
+int rxe_init_task(void *obj, struct rxe_task *task, int *fast,
+ void *arg, int (*func)(void *), char *name);
+
+/*
+ * cleanup task
+ */
+void rxe_cleanup_task(struct rxe_task *task);
+
+/*
+ * raw call to func in loop without any checking
+ * can call when tasklets are disabled
+ */
+int __rxe_do_task(struct rxe_task *task);
+
+/*
+ * common function called by any of the main tasklets
+ * if someone is calling the function on its own
+ * thread (fast path) then they must increment busy
+ * If there is any chance that there is additional
+ * work to do someone must reschedule the task before
+ * leaving
+ */
+void rxe_do_task(unsigned long data);
+
+/*
+ * run a task, use fast path if no one else
+ * is currently running it and fast path is ok
+ * else schedule it to run as a tasklet
+ */
+void rxe_run_task(struct rxe_task *task, int sched);
+
+/*
+ * keep a task from scheduling
+ */
+void rxe_disable_task(struct rxe_task *task);
+
+/*
+ * allow task to run
+ */
+void rxe_enable_task(struct rxe_task *task);
+
+#endif /* RXE_TASK_H */


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 17/37] add rxe_task.c

2011-07-25 Thread rpearson
Tasklet handling details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_task.c |  169 +++
 1 file changed, 169 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_task.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_task.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/kernel.h
+#include linux/interrupt.h
+#include linux/hardirq.h
+
+#include rxe_task.h
+
+int __rxe_do_task(struct rxe_task *task)
+
+{
+   int ret;
+
+   while ((ret = task-func(task-arg)) == 0)
+   ;
+
+   task-ret = ret;
+
+   return ret;
+}
+
+/*
+ * this locking is due to a potential race where
+ * a second caller finds the task already running
+ * but looks just after the last call to func
+ */
+void rxe_do_task(unsigned long data)
+{
+   int cont;
+   int ret;
+   unsigned long flags;
+   struct rxe_task *task = (struct rxe_task *)data;
+
+   spin_lock_irqsave(task-state_lock, flags);
+   switch (task-state) {
+   case TASK_STATE_START:
+   task-state = TASK_STATE_BUSY;
+   spin_unlock_irqrestore(task-state_lock, flags);
+   break;
+
+   case TASK_STATE_BUSY:
+   task-state = TASK_STATE_ARMED;
+   /* fall through to */
+   case TASK_STATE_ARMED:
+   spin_unlock_irqrestore(task-state_lock, flags);
+   return;
+
+   default:
+   spin_unlock_irqrestore(task-state_lock, flags);
+   pr_warn(bad state = %d in rxe_do_task\n, task-state);
+   return;
+   }
+
+   do {
+   cont = 0;
+   ret = task-func(task-arg);
+
+   spin_lock_irqsave(task-state_lock, flags);
+   switch (task-state) {
+   case TASK_STATE_BUSY:
+   if (ret)
+   task-state = TASK_STATE_START;
+   else
+   cont = 1;
+   break;
+
+   /* soneone tried to run the task since the
+  last time we called func, so we will call
+  one more time regardless of the return value */
+   case TASK_STATE_ARMED:
+   task-state = TASK_STATE_BUSY;
+   cont = 1;
+   break;
+
+   default:
+   pr_warn(bad state = %d in rxe_do_task\n,
+   task-state);
+   }
+   spin_unlock_irqrestore(task-state_lock, flags);
+   } while (cont);
+
+   task-ret = ret;
+}
+
+int rxe_init_task(void *obj, struct rxe_task *task, int *fast,
+ void *arg, int (*func)(void *), char *name)
+{
+   task-obj   = obj;
+   task-fast  = fast;
+   task-arg   = arg;
+   task-func  = func;
+   snprintf(task-name, sizeof(task-name), %s, name);
+
+   tasklet_init(task-tasklet, rxe_do_task, (unsigned long)task);
+
+   task-state = TASK_STATE_START;
+   spin_lock_init(task-state_lock);
+
+   return 0;
+}
+
+void rxe_cleanup_task(struct rxe_task *task)
+{
+   tasklet_kill(task-tasklet);
+}
+
+/*
+ * depending on value of fast allow bypassing
+ * tasklet call or not
+ *  0 = never
+ *  1 = only if not in interrupt level

[patch v2 19/37] add rxe_srq.c

2011-07-25 Thread rpearson
Shared receive queue implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_srq.c |  213 
 1 file changed, 213 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_srq.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_srq.c
@@ -0,0 +1,213 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* srq implementation details */
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
+struct ib_srq_attr *attr, enum ib_srq_attr_mask mask)
+{
+   if (srq  srq-error) {
+   pr_warn(srq in error state\n);
+   goto err1;
+   }
+
+   if (mask  IB_SRQ_MAX_WR) {
+   if (attr-max_wr  rxe-attr.max_srq_wr) {
+   pr_warn(max_wr(%d)  max_srq_wr(%d)\n,
+attr-max_wr, rxe-attr.max_srq_wr);
+   goto err1;
+   }
+
+   if (attr-max_wr = 0) {
+   pr_warn(max_wr(%d) = 0\n, attr-max_wr);
+   goto err1;
+   }
+
+   if (srq  !(rxe-attr.device_cap_flags 
+   IB_DEVICE_SRQ_RESIZE)) {
+   pr_warn(srq resize not supported\n);
+   goto err1;
+   }
+
+   if (srq  srq-limit  (attr-max_wr  srq-limit)) {
+   pr_warn(max_wr (%d)  srq-limit (%d)\n,
+ attr-max_wr, srq-limit);
+   goto err1;
+   }
+
+   if (attr-max_wr  RXE_MIN_SRQ_WR)
+   attr-max_wr = RXE_MIN_SRQ_WR;
+   }
+
+   if (mask  IB_SRQ_LIMIT) {
+   if (attr-srq_limit  rxe-attr.max_srq_wr) {
+   pr_warn(srq_limit(%d)  max_srq_wr(%d)\n,
+attr-srq_limit, rxe-attr.max_srq_wr);
+   goto err1;
+   }
+
+   if (attr-srq_limit  srq-rq.queue-buf-index_mask) {
+   pr_warn(srq_limit (%d)  cur limit(%d)\n,
+attr-srq_limit,
+srq-rq.queue-buf-index_mask);
+   goto err1;
+   }
+   }
+
+   if (mask == IB_SRQ_INIT_MASK) {
+   if (attr-max_sge  rxe-attr.max_srq_sge) {
+   pr_warn(max_sge(%d)  max_srq_sge(%d)\n,
+attr-max_sge, rxe-attr.max_srq_sge);
+   goto err1;
+   }
+
+   if (attr-max_sge  RXE_MIN_SRQ_SGE)
+   attr-max_sge = RXE_MIN_SRQ_SGE;
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
+ struct ib_srq_init_attr *init,
+ struct ib_ucontext *context, struct ib_udata *udata)
+{
+   int err;
+   int srq_wqe_size;
+   struct rxe_queue *q;
+
+   srq-event_handler  = init-event_handler;
+   srq-context= init-srq_context;
+   srq-limit  = init-attr.srq_limit;
+   srq-srq_num= srq-pelem.index;
+   srq-rq.max_wr  = init-attr.max_wr;
+   srq-rq.max_sge = init-attr.max_sge;
+
+   srq_wqe_size  

[patch v2 20/37] add rxe_cq.c

2011-07-25 Thread rpearson
Completion queue implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_cq.c |  177 +
 1 file changed, 177 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_cq.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_cq.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* cq implementation details */
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
+   int cqe, int comp_vector, struct ib_udata *udata)
+{
+   int count;
+
+   if (cqe = 0) {
+   pr_warn(cqe(%d) = 0\n, cqe);
+   goto err1;
+   }
+
+   if (cqe  rxe-attr.max_cqe) {
+   pr_warn(cqe(%d)  max_cqe(%d)\n,
+cqe, rxe-attr.max_cqe);
+   goto err1;
+   }
+
+   if (cq) {
+   count = queue_count(cq-queue);
+   if (cqe  count) {
+   pr_warn(cqe(%d)  current # elements in queue (%d),
+   cqe, count);
+   goto err1;
+   }
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static void rxe_send_complete(unsigned long data)
+{
+   struct rxe_cq *cq = (struct rxe_cq *)data;
+
+   while (1) {
+   u8 notify = cq-notify;
+
+   cq-ibcq.comp_handler(cq-ibcq, cq-ibcq.cq_context);
+
+   /* See if anything was added to the CQ during the
+* comp_handler call.  If so, go around again because we
+* won't be rescheduled.
+* XXX: is there a race on enqueue right after this test
+* but before we're out? */
+   if (notify == cq-notify)
+   return;
+   }
+}
+
+int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
+int comp_vector, struct ib_ucontext *context,
+struct ib_udata *udata)
+{
+   int err;
+
+   cq-queue = rxe_queue_init(rxe, (unsigned int *)cqe,
+  sizeof(struct rxe_cqe));
+   if (!cq-queue) {
+   pr_warn(unable to create cq\n);
+   return -ENOMEM;
+   }
+
+   err = do_mmap_info(rxe, udata, 0, context, cq-queue-buf,
+  cq-queue-buf_size, cq-queue-ip);
+   if (err) {
+   vfree(cq-queue-buf);
+   kfree(cq-queue);
+   }
+
+   if (udata)
+   cq-is_user = 1;
+
+   tasklet_init(cq-comp_task, rxe_send_complete, (unsigned long)cq);
+
+   spin_lock_init(cq-cq_lock);
+   cq-ibcq.cqe = cqe;
+   return 0;
+}
+
+int rxe_cq_resize_queue(struct rxe_cq *cq, int cqe, struct ib_udata *udata)
+{
+   int err;
+
+   err = rxe_queue_resize(cq-queue, (unsigned int *)cqe,
+  sizeof(struct rxe_cqe),
+  cq-queue-ip ? cq-queue-ip-context : NULL,
+  udata, NULL, cq-cq_lock);
+   if (!err)
+   cq-ibcq.cqe = cqe;
+
+   return err;
+}
+
+int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited)
+{
+   struct ib_event ev;
+   unsigned long flags;
+
+   spin_lock_irqsave(cq-cq_lock, flags);
+
+   if 

[patch v2 21/37] add rxe_qp.c

2011-07-25 Thread rpearson
Queue pair implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_qp.c |  821 +
 1 file changed, 821 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_qp.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_qp.c
@@ -0,0 +1,821 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* qp implementation details */
+
+#include linux/skbuff.h
+#include linux/delay.h
+#include linux/sched.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+#include rxe_task.h
+
+char *rxe_qp_state_name[] = {
+   [QP_STATE_RESET]= RESET,
+   [QP_STATE_INIT] = INIT,
+   [QP_STATE_READY]= READY,
+   [QP_STATE_DRAIN]= DRAIN,
+   [QP_STATE_DRAINED]  = DRAINED,
+   [QP_STATE_ERROR]= ERROR,
+};
+
+static int rxe_qp_chk_cap(struct rxe_dev *rxe, struct ib_qp_cap *cap,
+ int has_srq)
+{
+   if (cap-max_send_wr  rxe-attr.max_qp_wr) {
+   pr_warn(invalid send wr = %d  %d\n,
+   cap-max_send_wr, rxe-attr.max_qp_wr);
+   goto err1;
+   }
+
+   if (cap-max_send_sge  rxe-attr.max_sge) {
+   pr_warn(invalid send sge = %d  %d\n,
+   cap-max_send_sge, rxe-attr.max_sge);
+   goto err1;
+   }
+
+   if (!has_srq) {
+   if (cap-max_recv_wr  rxe-attr.max_qp_wr) {
+   pr_warn(invalid recv wr = %d  %d\n,
+   cap-max_recv_wr, rxe-attr.max_qp_wr);
+   goto err1;
+   }
+
+   if (cap-max_recv_sge  rxe-attr.max_sge) {
+   pr_warn(invalid recv sge = %d  %d\n,
+ cap-max_recv_sge, rxe-attr.max_sge);
+   goto err1;
+   }
+   }
+
+   if (cap-max_inline_data  rxe-max_inline_data) {
+   pr_warn(invalid max inline data = %d  %d\n,
+   cap-max_inline_data, rxe-max_inline_data);
+   goto err1;
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init)
+{
+   struct ib_qp_cap *cap = init-cap;
+   struct rxe_port *port;
+   int port_num = init-port_num;
+
+   if (!init-recv_cq || !init-send_cq) {
+   pr_warn(missing cq\n);
+   goto err1;
+   }
+
+   if (rxe_qp_chk_cap(rxe, cap, init-srq != NULL))
+   goto err1;
+
+   if (init-qp_type == IB_QPT_SMI || init-qp_type == IB_QPT_GSI) {
+   if (port_num  1 || port_num  rxe-num_ports) {
+   pr_warn(invalid port = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   if (init-qp_type == IB_QPT_SMI  port-qp_smi_index) {
+   pr_warn(SMI QP exists for port %d\n, port_num);
+   goto err1;
+   }
+
+   if (init-qp_type == IB_QPT_GSI  port-qp_gsi_index) {
+   pr_warn(GSI QP exists for port %d\n, port_num);
+   goto err1;
+   }
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int 

[patch v2 23/37] add rxe_mcast.c

2011-07-25 Thread rpearson
Multicast implemtation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_mcast.c |  192 ++
 1 file changed, 192 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_mcast.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_mcast.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* multicast implemtation details */
+
+#include rxe.h
+#include rxe_loc.h
+
+int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, u16 mlid,
+ struct rxe_mc_grp **grp_p)
+{
+   int err;
+   struct rxe_mc_grp *grp;
+
+   if (rxe-attr.max_mcast_qp_attach == 0) {
+   err = -EINVAL;
+   goto err1;
+   }
+
+   grp = rxe_pool_get_key(rxe-mc_grp_pool, mgid);
+   if (grp)
+   goto done;
+
+   grp = rxe_alloc(rxe-mc_grp_pool);
+   if (!grp) {
+   err = -ENOMEM;
+   goto err1;
+   }
+
+   INIT_LIST_HEAD(grp-qp_list);
+   spin_lock_init(grp-mcg_lock);
+   grp-mlid = mlid;
+   grp-rxe = rxe;
+
+   err = rxe-ifc_ops-mcast_add(rxe, mgid);
+   if (err)
+   goto err2;
+
+   rxe_add_key(grp, mgid);
+done:
+   *grp_p = grp;
+   return 0;
+
+err2:
+   rxe_drop_ref(grp);
+err1:
+   return err;
+}
+
+int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
+  struct rxe_mc_grp *grp)
+{
+   int err;
+   struct rxe_mc_elem *elem;
+
+   /* check to see of the qp is already a member of the group */
+   spin_lock_bh(qp-grp_lock);
+   spin_lock_bh(grp-mcg_lock);
+   list_for_each_entry(elem, grp-qp_list, qp_list) {
+   if (elem-qp == qp) {
+   err = 0;
+   goto out;
+   }
+   }
+
+   if (grp-num_qp = rxe-attr.max_mcast_qp_attach) {
+   err = -ENOMEM;
+   goto out;
+   }
+
+   elem = rxe_alloc(rxe-mc_elem_pool);
+   if (!elem) {
+   err = -ENOMEM;
+   goto out;
+   }
+
+   /* each qp holds a ref on the grp */
+   rxe_add_ref(grp);
+
+   grp-num_qp++;
+   elem-qp = qp;
+   elem-grp = grp;
+
+   list_add(elem-qp_list, grp-qp_list);
+   list_add(elem-grp_list, qp-grp_list);
+
+   err = 0;
+out:
+   spin_unlock_bh(grp-mcg_lock);
+   spin_unlock_bh(qp-grp_lock);
+   return err;
+}
+
+int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
+   union ib_gid *mgid, u16 mlid)
+{
+   struct rxe_mc_grp *grp;
+   struct rxe_mc_elem *elem, *tmp;
+
+   grp = rxe_pool_get_key(rxe-mc_grp_pool, mgid);
+   if (!grp)
+   goto err1;
+
+   spin_lock_bh(qp-grp_lock);
+   spin_lock_bh(grp-mcg_lock);
+
+   list_for_each_entry_safe(elem, tmp, grp-qp_list, qp_list) {
+   if (elem-qp == qp) {
+   list_del(elem-qp_list);
+   list_del(elem-grp_list);
+   grp-num_qp--;
+
+   spin_unlock_bh(grp-mcg_lock);
+   spin_unlock_bh(qp-grp_lock);
+   rxe_drop_ref(elem);
+   rxe_drop_ref(grp);  /* ref held by QP */
+   

[patch v2 24/37] add rxe_recv.c

2011-07-25 Thread rpearson
handles receiving new packets which are
sent to either request or response processing.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_recv.c |  425 +++
 1 file changed, 425 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_recv.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_recv.c
@@ -0,0 +1,425 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+
+static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
+   struct rxe_qp *qp)
+{
+   if (unlikely(!qp-valid))
+   goto err1;
+
+   switch (qp_type(qp)) {
+   case IB_QPT_RC:
+   if (unlikely((pkt-opcode  5) != 0)) {
+   pr_warn(bad qp type\n);
+   goto err1;
+   }
+   break;
+   case IB_QPT_UC:
+   if (unlikely((pkt-opcode  5) != 1)) {
+   pr_warn(bad qp type\n);
+   goto err1;
+   }
+   break;
+   case IB_QPT_UD:
+   case IB_QPT_SMI:
+   case IB_QPT_GSI:
+   if (unlikely((pkt-opcode  5) != 3)) {
+   pr_warn(bad qp type\n);
+   goto err1;
+   }
+   break;
+   default:
+   pr_warn(unsupported qp type\n);
+   goto err1;
+   }
+
+   if (pkt-mask  RXE_REQ_MASK) {
+   if (unlikely(qp-resp.state != QP_STATE_READY))
+   goto err1;
+   } else if (unlikely(qp-req.state  QP_STATE_READY ||
+   qp-req.state  QP_STATE_DRAINED))
+   goto err1;
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int check_keys(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
+ u32 qpn, struct rxe_qp *qp)
+{
+   int i;
+   int found_pkey = 0;
+   struct rxe_port *port = rxe-port[pkt-port_num - 1];
+   u16 pkey = bth_pkey(pkt);
+
+   pkt-pkey_index = 0;
+
+   if (qpn == 1) {
+   for (i = 0; i  port-attr.pkey_tbl_len; i++) {
+   if (pkey_match(pkey, port-pkey_tbl[i])) {
+   pkt-pkey_index = i;
+   found_pkey = 1;
+   break;
+   }
+   }
+
+   if (!found_pkey) {
+   pr_warn(bad pkey = 0x%x\n, pkey);
+   spin_lock_bh(port-port_lock);
+   port-attr.bad_pkey_cntr
+   = (port-attr.bad_pkey_cntr = 0x) ?
+  0x :
+  port-attr.bad_pkey_cntr + 1;
+   spin_unlock_bh(port-port_lock);
+   goto err1;
+   }
+   } else if (qpn != 0) {
+   if (unlikely(!pkey_match(pkey,
+   port-pkey_tbl[qp-attr.pkey_index]))) {
+   pr_warn(bad pkey = 0x%0x\n, pkey);
+   spin_lock_bh(port-port_lock);
+   port-attr.bad_pkey_cntr
+   = (port-attr.bad_pkey_cntr = 0x) ?
+  0x :
+  port-attr.bad_pkey_cntr + 1;
+   

[patch v2 25/37] add rxe_comp.c

2011-07-25 Thread rpearson
completion processing.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_comp.c |  731 +++
 1 file changed, 731 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_comp.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_comp.c
@@ -0,0 +1,731 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+#include rxe_task.h
+
+enum comp_state {
+   COMPST_GET_ACK,
+   COMPST_GET_WQE,
+   COMPST_COMP_WQE,
+   COMPST_COMP_ACK,
+   COMPST_CHECK_PSN,
+   COMPST_CHECK_ACK,
+   COMPST_READ,
+   COMPST_ATOMIC,
+   COMPST_WRITE_SEND,
+   COMPST_UPDATE_COMP,
+   COMPST_ERROR_RETRY,
+   COMPST_RNR_RETRY,
+   COMPST_ERROR,
+   COMPST_EXIT,
+   COMPST_DONE,
+};
+
+static char *comp_state_name[] =  {
+   [COMPST_GET_ACK]= GET ACK,
+   [COMPST_GET_WQE]= GET WQE,
+   [COMPST_COMP_WQE]   = COMP WQE,
+   [COMPST_COMP_ACK]   = COMP ACK,
+   [COMPST_CHECK_PSN]  = CHECK PSN,
+   [COMPST_CHECK_ACK]  = CHECK ACK,
+   [COMPST_READ]   = READ,
+   [COMPST_ATOMIC] = ATOMIC,
+   [COMPST_WRITE_SEND] = WRITE/SEND,
+   [COMPST_UPDATE_COMP]= UPDATE COMP,
+   [COMPST_ERROR_RETRY]= ERROR RETRY,
+   [COMPST_RNR_RETRY]  = RNR RETRY,
+   [COMPST_ERROR]  = ERROR,
+   [COMPST_EXIT]   = EXIT,
+   [COMPST_DONE]   = DONE,
+};
+
+static unsigned long rnrnak_usec[32] = {
+   [IB_RNR_TIMER_655_36] = 655360,
+   [IB_RNR_TIMER_000_01] = 10,
+   [IB_RNR_TIMER_000_02] = 20,
+   [IB_RNR_TIMER_000_03] = 30,
+   [IB_RNR_TIMER_000_04] = 40,
+   [IB_RNR_TIMER_000_06] = 60,
+   [IB_RNR_TIMER_000_08] = 80,
+   [IB_RNR_TIMER_000_12] = 120,
+   [IB_RNR_TIMER_000_16] = 160,
+   [IB_RNR_TIMER_000_24] = 240,
+   [IB_RNR_TIMER_000_32] = 320,
+   [IB_RNR_TIMER_000_48] = 480,
+   [IB_RNR_TIMER_000_64] = 640,
+   [IB_RNR_TIMER_000_96] = 960,
+   [IB_RNR_TIMER_001_28] = 1280,
+   [IB_RNR_TIMER_001_92] = 1920,
+   [IB_RNR_TIMER_002_56] = 2560,
+   [IB_RNR_TIMER_003_84] = 3840,
+   [IB_RNR_TIMER_005_12] = 5120,
+   [IB_RNR_TIMER_007_68] = 7680,
+   [IB_RNR_TIMER_010_24] = 10240,
+   [IB_RNR_TIMER_015_36] = 15360,
+   [IB_RNR_TIMER_020_48] = 20480,
+   [IB_RNR_TIMER_030_72] = 30720,
+   [IB_RNR_TIMER_040_96] = 40960,
+   [IB_RNR_TIMER_061_44] = 61410,
+   [IB_RNR_TIMER_081_92] = 81920,
+   [IB_RNR_TIMER_122_88] = 122880,
+   [IB_RNR_TIMER_163_84] = 163840,
+   [IB_RNR_TIMER_245_76] = 245760,
+   [IB_RNR_TIMER_327_68] = 327680,
+   [IB_RNR_TIMER_491_52] = 491520,
+};
+
+static inline unsigned long rnrnak_jiffies(u8 timeout)
+{
+   return max_t(unsigned long,
+   usecs_to_jiffies(rnrnak_usec[timeout]), 1);
+}
+
+static enum ib_wc_opcode wr_to_wc_opcode(enum ib_wr_opcode opcode)
+{
+   switch (opcode) {
+   case IB_WR_RDMA_WRITE:  return IB_WC_RDMA_WRITE;
+   case IB_WR_RDMA_WRITE_WITH_IMM: return IB_WC_RDMA_WRITE;
+   case IB_WR_SEND:return 

[patch v2 26/37] add rxe_req.c

2011-07-25 Thread rpearson
QP request logic.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_req.c |  711 
 1 file changed, 711 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_req.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_req.c
@@ -0,0 +1,711 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+static int next_opcode(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
+  unsigned opcode);
+
+static inline void retry_first_write_send(struct rxe_qp *qp,
+ struct rxe_send_wqe *wqe,
+ unsigned mask, int npsn)
+{
+   int i;
+
+   for (i = 0; i  npsn; i++) {
+   int to_send = (wqe-dma.resid  qp-mtu) ?
+   qp-mtu : wqe-dma.resid;
+
+   qp-req.opcode = next_opcode(qp, wqe,
+wqe-ibwr.opcode);
+
+   if (wqe-ibwr.send_flags  IB_SEND_INLINE) {
+   wqe-dma.resid -= to_send;
+   wqe-dma.sge_offset += to_send;
+   } else
+   advance_dma_data(wqe-dma, to_send);
+
+   if (mask  WR_WRITE_MASK)
+   wqe-iova += qp-mtu;
+   }
+}
+
+static void req_retry(struct rxe_qp *qp)
+{
+   struct rxe_send_wqe *wqe;
+   unsigned int wqe_index;
+   unsigned int mask;
+   int npsn;
+   int first = 1;
+
+   wqe = queue_head(qp-sq.queue);
+   npsn = (qp-comp.psn - wqe-first_psn)  BTH_PSN_MASK;
+
+   qp-req.wqe_index   = consumer_index(qp-sq.queue);
+   qp-req.psn = qp-comp.psn;
+   qp-req.opcode  = -1;
+
+   for (wqe_index = consumer_index(qp-sq.queue);
+   wqe_index != producer_index(qp-sq.queue);
+   wqe_index = next_index(qp-sq.queue, wqe_index)) {
+
+   wqe = addr_from_index(qp-sq.queue, wqe_index);
+   mask = wr_opcode_mask(wqe-ibwr.opcode, qp);
+
+   if (wqe-state == wqe_state_posted)
+   break;
+
+   if (wqe-state == wqe_state_done)
+   continue;
+
+   wqe-iova = (mask  WR_ATOMIC_MASK) ?
+   wqe-ibwr.wr.atomic.remote_addr :
+   wqe-ibwr.wr.rdma.remote_addr;
+
+   if (!first || (mask  WR_READ_MASK) == 0) {
+   wqe-dma.resid = wqe-dma.length;
+   wqe-dma.cur_sge = 0;
+   wqe-dma.sge_offset = 0;
+   }
+
+   if (first) {
+   first = 0;
+
+   if (mask  WR_WRITE_OR_SEND_MASK)
+   retry_first_write_send(qp, wqe, mask, npsn);
+
+   if (mask  WR_READ_MASK)
+   wqe-iova += npsn*qp-mtu;
+   }
+
+   wqe-state = wqe_state_posted;
+   }
+}
+
+void rnr_nak_timer(unsigned long data)
+{
+   struct rxe_qp *qp = (struct rxe_qp *)data;
+   pr_debug(rnr nak timer fired\n);
+   rxe_run_task(qp-req.task, 1);
+}
+
+static struct rxe_send_wqe *req_next_wqe(struct rxe_qp *qp)
+{
+   struct rxe_send_wqe *wqe = queue_head(qp-sq.queue);
+   unsigned long flags;
+
+   

[patch v2 27/37] add rxe_resp.c

2011-07-25 Thread rpearson
QP response logic.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_resp.c | 1366 +++
 1 file changed, 1366 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_resp.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_resp.c
@@ -0,0 +1,1366 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/*
+ * implements the qp responder
+ */
+
+#include linux/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+
+enum resp_states {
+   RESPST_NONE,
+   RESPST_GET_REQ,
+   RESPST_CHK_PSN,
+   RESPST_CHK_OP_SEQ,
+   RESPST_CHK_OP_VALID,
+   RESPST_CHK_RESOURCE,
+   RESPST_CHK_LENGTH,
+   RESPST_CHK_RKEY,
+   RESPST_EXECUTE,
+   RESPST_READ_REPLY,
+   RESPST_COMPLETE,
+   RESPST_ACKNOWLEDGE,
+   RESPST_CLEANUP,
+   RESPST_DUPLICATE_REQUEST,
+   RESPST_ERR_MALFORMED_WQE,
+   RESPST_ERR_UNSUPPORTED_OPCODE,
+   RESPST_ERR_MISALIGNED_ATOMIC,
+   RESPST_ERR_PSN_OUT_OF_SEQ,
+   RESPST_ERR_MISSING_OPCODE_FIRST,
+   RESPST_ERR_MISSING_OPCODE_LAST_C,
+   RESPST_ERR_MISSING_OPCODE_LAST_D1E,
+   RESPST_ERR_TOO_MANY_RDMA_ATM_REQ,
+   RESPST_ERR_RNR,
+   RESPST_ERR_RKEY_VIOLATION,
+   RESPST_ERR_LENGTH,
+   RESPST_ERR_CQ_OVERFLOW,
+   RESPST_ERROR,
+   RESPST_RESET,
+   RESPST_DONE,
+   RESPST_EXIT,
+};
+
+static char *resp_state_name[] = {
+   [RESPST_NONE]   = NONE,
+   [RESPST_GET_REQ]= GET_REQ,
+   [RESPST_CHK_PSN]= CHK_PSN,
+   [RESPST_CHK_OP_SEQ] = CHK_OP_SEQ,
+   [RESPST_CHK_OP_VALID]   = CHK_OP_VALID,
+   [RESPST_CHK_RESOURCE]   = CHK_RESOURCE,
+   [RESPST_CHK_LENGTH] = CHK_LENGTH,
+   [RESPST_CHK_RKEY]   = CHK_RKEY,
+   [RESPST_EXECUTE]= EXECUTE,
+   [RESPST_READ_REPLY] = READ_REPLY,
+   [RESPST_COMPLETE]   = COMPLETE,
+   [RESPST_ACKNOWLEDGE]= ACKNOWLEDGE,
+   [RESPST_CLEANUP]= CLEANUP,
+   [RESPST_DUPLICATE_REQUEST]  = DUPLICATE_REQUEST,
+   [RESPST_ERR_MALFORMED_WQE]  = ERR_MALFORMED_WQE,
+   [RESPST_ERR_UNSUPPORTED_OPCODE] = ERR_UNSUPPORTED_OPCODE,
+   [RESPST_ERR_MISALIGNED_ATOMIC]  = ERR_MISALIGNED_ATOMIC,
+   [RESPST_ERR_PSN_OUT_OF_SEQ] = ERR_PSN_OUT_OF_SEQ,
+   [RESPST_ERR_MISSING_OPCODE_FIRST]   = ERR_MISSING_OPCODE_FIRST,
+   [RESPST_ERR_MISSING_OPCODE_LAST_C]  = ERR_MISSING_OPCODE_LAST_C,
+   [RESPST_ERR_MISSING_OPCODE_LAST_D1E]= ERR_MISSING_OPCODE_LAST_D1E,
+   [RESPST_ERR_TOO_MANY_RDMA_ATM_REQ]  = ERR_TOO_MANY_RDMA_ATM_REQ,
+   [RESPST_ERR_RNR]= ERR_RNR,
+   [RESPST_ERR_RKEY_VIOLATION] = ERR_RKEY_VIOLATION,
+   [RESPST_ERR_LENGTH] = ERR_LENGTH,
+   [RESPST_ERR_CQ_OVERFLOW]= ERR_CQ_OVERFLOW,
+   [RESPST_ERROR]  = ERROR,
+   [RESPST_RESET]  = RESET,
+   [RESPST_DONE]   = DONE,
+   [RESPST_EXIT]   = EXIT,
+};
+
+/* rxe_recv calls here to 

[patch v2 28/37] add rxe_arbiter.c

2011-07-25 Thread rpearson
packet output arbitration.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_arbiter.c |  190 
 1 file changed, 190 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_arbiter.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_arbiter.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+
+static inline void account_skb(struct rxe_dev *rxe, struct rxe_qp *qp,
+  int is_request)
+{
+   if (is_request  RXE_REQ_MASK) {
+   atomic_dec(rxe-req_skb_out);
+   atomic_dec(qp-req_skb_out);
+   if (qp-need_req_skb) {
+   if (atomic_read(qp-req_skb_out)  rxe_max_skb_per_qp)
+   rxe_run_task(qp-req.task, 1);
+   }
+   } else {
+   atomic_dec(rxe-resp_skb_out);
+   atomic_dec(qp-resp_skb_out);
+   }
+}
+
+static int xmit_one_packet(struct rxe_dev *rxe, struct rxe_qp *qp,
+  struct sk_buff *skb)
+{
+   int err;
+   struct timespec time;
+   long new_delay;
+   struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+   int is_request = pkt-mask  RXE_REQ_MASK;
+
+   /* drop pkt if qp is in wrong state to send */
+   if (!qp-valid)
+   goto drop;
+
+   if (is_request) {
+   if (qp-req.state != QP_STATE_READY)
+   goto drop;
+   } else {
+   if (qp-resp.state != QP_STATE_READY)
+   goto drop;
+   }
+
+   /* busy wait for static rate control
+  we could refine this by yielding the tasklet
+  for larger delays and waiting out the small ones */
+   if (rxe-arbiter.delay)
+   do {
+   getnstimeofday(time);
+   } while (timespec_compare(time, rxe-arbiter.time)  0);
+
+   new_delay = (skb-len*rxe_nsec_per_kbyte)  10;
+   if (new_delay  rxe_nsec_per_packet)
+   new_delay = rxe_nsec_per_packet;
+
+   if (pkt-mask  RXE_LOOPBACK_MASK)
+   err = rxe-ifc_ops-loopback(rxe, skb);
+   else
+   err = rxe-ifc_ops-send(rxe, skb);
+
+   /* we can recover from RXE_QUEUE_STOPPED errors
+  by retrying the packet. In other cases
+  the packet is consumed so move on */
+   if (err == RXE_QUEUE_STOPPED)
+   return err;
+   else if (err)
+   rxe-xmit_errors++;
+
+   rxe-arbiter.delay = new_delay  0;
+   if (rxe-arbiter.delay) {
+   getnstimeofday(time);
+   time.tv_nsec += new_delay;
+   while (time.tv_nsec  NSEC_PER_SEC) {
+   time.tv_sec += 1;
+   time.tv_nsec -= NSEC_PER_SEC;
+   }
+   rxe-arbiter.time = time;
+   }
+
+   goto done;
+
+drop:
+   kfree_skb(skb);
+   err = 0;
+done:
+   account_skb(rxe, qp, is_request);
+   return err;
+}
+
+/*
+ * choose one packet for sending
+ */
+int rxe_arbiter(void *arg)
+{
+   int err;
+   unsigned long flags;
+   struct rxe_dev *rxe = (struct rxe_dev *)arg;
+   struct sk_buff *skb;
+   struct list_head *qpl;
+   struct rxe_qp *qp;
+
+   /* get the next qp's send queue */
+   

[patch v2 29/37] add rxe_dma.c

2011-07-25 Thread rpearson
Dummy dma processing for rxe device.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_dma.c |  178 
 1 file changed, 178 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_dma.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_dma.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2006 QLogic, Corporation. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+
+static int rxe_mapping_error(struct ib_device *dev, u64 dma_addr)
+{
+   return dma_addr == 0;
+}
+
+static u64 rxe_dma_map_single(struct ib_device *dev,
+ void *cpu_addr, size_t size,
+ enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   return (u64) (uintptr_t) cpu_addr;
+}
+
+static void rxe_dma_unmap_single(struct ib_device *dev,
+u64 addr, size_t size,
+enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+}
+
+static u64 rxe_dma_map_page(struct ib_device *dev,
+   struct page *page,
+   unsigned long offset,
+   size_t size, enum dma_data_direction direction)
+{
+   u64 addr = 0;
+
+   BUG_ON(!valid_dma_direction(direction));
+
+   if (offset + size  PAGE_SIZE)
+   goto out;
+
+   addr = (uintptr_t) page_address(page);
+   if (addr)
+   addr += offset;
+
+out:
+   return addr;
+}
+
+static void rxe_dma_unmap_page(struct ib_device *dev,
+  u64 addr, size_t size,
+  enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+}
+
+static int rxe_map_sg(struct ib_device *dev, struct scatterlist *sgl,
+ int nents, enum dma_data_direction direction)
+{
+   struct scatterlist *sg;
+   u64 addr;
+   int i;
+   int ret = nents;
+
+   BUG_ON(!valid_dma_direction(direction));
+
+   for_each_sg(sgl, sg, nents, i) {
+   addr = (uintptr_t) page_address(sg_page(sg));
+   /* TODO: handle highmem pages */
+   if (!addr) {
+   ret = 0;
+   break;
+   }
+   }
+
+   return ret;
+}
+
+static void rxe_unmap_sg(struct ib_device *dev,
+struct scatterlist *sg, int nents,
+enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+}
+
+static u64 rxe_sg_dma_address(struct ib_device *dev, struct scatterlist *sg)
+{
+   u64 addr = (uintptr_t) page_address(sg_page(sg));
+
+   if (addr)
+   addr += sg-offset;
+
+   return addr;
+}
+
+static unsigned int rxe_sg_dma_len(struct ib_device *dev,
+  struct scatterlist *sg)
+{
+   return sg-length;
+}
+
+static void rxe_sync_single_for_cpu(struct ib_device *dev,
+   u64 addr,
+   size_t size, enum dma_data_direction dir)
+{
+}
+
+static void rxe_sync_single_for_device(struct ib_device *dev,
+  u64 addr,
+  size_t size, enum dma_data_direction dir)
+{
+}
+

[patch v2 30/37] add rxe_icrc.c

2011-07-25 Thread rpearson
Compute ICRC

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_icrc.c |   99 +++
 1 file changed, 99 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_icrc.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_icrc.c
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+
+/* Compute a partial ICRC for all the IB transport headers. */
+u32 rxe_icrc_hdr(struct rxe_pkt_info *pkt)
+{
+   u32 crc;
+   unsigned int length;
+   unsigned int grh_offset;
+   unsigned int bth_offset;
+   u8 tmp[RXE_LRH_BYTES + RXE_GRH_BYTES + RXE_BTH_BYTES];
+
+   /* This seed is the result of computing a CRC with a seed of
+* 0xfff and 8 bytes of 0xff representing a masked LRH. */
+   crc = 0xdebb20e3;
+
+   length = RXE_BTH_BYTES;
+   grh_offset = 0;
+   bth_offset = 0;
+
+   if (pkt-mask  RXE_LRH_MASK) {
+   length += RXE_LRH_BYTES;
+   grh_offset += RXE_LRH_BYTES;
+   bth_offset += RXE_LRH_BYTES;
+   }
+   if (pkt-mask  RXE_GRH_MASK) {
+   length += RXE_GRH_BYTES;
+   bth_offset += RXE_GRH_BYTES;
+   }
+
+   memcpy(tmp, pkt-hdr, length);
+
+   if (pkt-mask  RXE_GRH_MASK) {
+   tmp[grh_offset + 0] |= 0x0f;/* GRH: tclass */
+   tmp[grh_offset + 1] = 0xff;
+   tmp[grh_offset + 2] = 0xff;
+   tmp[grh_offset + 3] = 0xff;
+   tmp[grh_offset + 7] = 0xff;
+   }
+
+   tmp[bth_offset + 4] = 0xff; /* BTH: resv8a */
+
+   crc = crc32_le(crc, tmp + grh_offset, length - grh_offset);
+
+   /* And finish to compute the CRC on the remainder of the headers. */
+   crc = crc32_le(crc, pkt-hdr + length,
+  rxe_opcode[pkt-opcode].length - RXE_BTH_BYTES);
+
+   return crc;
+}
+
+/* Compute the ICRC for a packet (incoming or outgoing). */
+u32 rxe_icrc_pkt(struct rxe_pkt_info *pkt)
+{
+   u32 crc;
+   int size;
+
+   crc = rxe_icrc_hdr(pkt);
+
+   /* And finish to compute the CRC on the remainder. */
+   size = pkt-paylen - rxe_opcode[pkt-opcode].length - RXE_ICRC_SIZE;
+   crc = crc32_le(crc, payload_addr(pkt), size);
+   crc = ~crc;
+
+   return crc;
+}


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 32/37] add rxe_net.h

2011-07-25 Thread rpearson
Common declarations for ib_rxe_net module.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_net.h |   86 
 1 file changed, 86 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_net.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_net.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_NET_H
+#define RXE_NET_H
+
+#include net/sock.h
+#include net/if_inet6.h
+
+/*
+ * this should be defined in .../include/linux/if_ether.h
+ */
+#define ETH_P_RXE  (0x8915)
+
+/*
+ * this should be defined in .../include/linux/netfilter.h
+ * to a specific value
+ */
+#define NFPROTO_RXE(0)
+
+/*
+ * these should be defined in .../include/linux/netfilter_rxe.h
+ */
+#define NF_RXE_IN  (0)
+#define NF_RXE_OUT (1)
+
+/* Should probably move to something other than an array...these can be big */
+#define RXE_MAX_IF_INDEX   (384)
+
+struct rxe_net_info {
+   struct rxe_dev  *rxe;
+   u8  port;
+   struct net_device   *ndev;
+   int status;
+};
+
+extern struct rxe_net_info net_info[RXE_MAX_IF_INDEX];
+extern spinlock_t net_info_lock;
+
+/* caller must hold net_dev_lock */
+static inline struct rxe_dev *net_to_rxe(struct net_device *ndev)
+{
+   return (ndev-ifindex = RXE_MAX_IF_INDEX) ?
+   NULL : net_info[ndev-ifindex].rxe;
+}
+
+static inline u8 net_to_port(struct net_device *ndev)
+{
+   return net_info[ndev-ifindex].port;
+}
+
+void rxe_net_add(struct net_device *ndev);
+void rxe_net_up(struct net_device *ndev);
+void rxe_net_down(struct net_device *ndev);
+
+#endif /* RXE_NET_H */


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 33/37] add rxe_net.c

2011-07-25 Thread rpearson
implements kernel module that implements an interface between
ib_rxe and the netdev stack.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_net.c |  580 
 1 file changed, 580 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_net.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_net.c
@@ -0,0 +1,580 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+#include linux/netdevice.h
+#include linux/if.h
+#include linux/if_vlan.h
+#include net/sch_generic.h
+#include linux/netfilter.h
+#include rdma/ib_addr.h
+
+#include rxe.h
+#include rxe_net.h
+
+MODULE_AUTHOR(Bob Pearson, Frank Zago, John Groves);
+MODULE_DESCRIPTION(RDMA transport over Converged Enhanced Ethernet);
+MODULE_LICENSE(Dual BSD/GPL);
+
+static int rxe_eth_proto_id = ETH_P_RXE;
+module_param_named(eth_proto_id, rxe_eth_proto_id, int, 0644);
+MODULE_PARM_DESC(eth_proto_id, Ethernet protocol ID 
(default/correct=0x8915));
+
+static int rxe_xmit_shortcut;
+module_param_named(xmit_shortcut, rxe_xmit_shortcut, int, 0644);
+MODULE_PARM_DESC(xmit_shortcut,
+Shortcut transmit (EXPERIMENTAL));
+
+static int rxe_loopback_mad_grh_fix = 1;
+module_param_named(loopback_mad_grh_fix, rxe_loopback_mad_grh_fix, int, 0644);
+MODULE_PARM_DESC(loopback_mad_grh_fix, Allow MADs to self without GRH);
+
+/*
+ * note: this table is a replacement for a protocol specific pointer
+ * in struct net_device which exists for other ethertypes
+ * this allows us to not have to patch that data structure
+ * eventually we want to get our own when we're famous
+ */
+struct rxe_net_info net_info[RXE_MAX_IF_INDEX];
+spinlock_t net_info_lock;
+
+static int rxe_net_rcv(struct sk_buff *skb,
+  struct net_device *ndev,
+  struct packet_type *ptype,
+  struct net_device *orig_dev);
+
+static __be64 rxe_mac_to_eui64(struct net_device *ndev)
+{
+   unsigned char *mac_addr = ndev-dev_addr;
+   __be64 eui64;
+   unsigned char *dst = (unsigned char *)eui64;
+
+   dst[0] = mac_addr[0] ^ 2;
+   dst[1] = mac_addr[1];
+   dst[2] = mac_addr[2];
+   dst[3] = 0xff;
+   dst[4] = 0xfe;
+   dst[5] = mac_addr[3];
+   dst[6] = mac_addr[4];
+   dst[7] = mac_addr[5];
+
+   return eui64;
+}
+
+/* callback when rxe gets released */
+static void release(struct rxe_dev *rxe)
+{
+   module_put(THIS_MODULE);
+}
+
+static __be64 node_guid(struct rxe_dev *rxe)
+{
+   return rxe_mac_to_eui64(rxe-ndev);
+}
+
+static __be64 port_guid(struct rxe_dev *rxe, unsigned int port_num)
+{
+   return rxe_mac_to_eui64(rxe-ndev);
+}
+
+static struct device *dma_device(struct rxe_dev *rxe)
+{
+   struct net_device *ndev;
+
+   ndev = rxe-ndev;
+
+   if (ndev-priv_flags  IFF_802_1Q_VLAN)
+   ndev = vlan_dev_real_dev(ndev);
+
+   return ndev-dev.parent;
+}
+
+static int mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+   int err;
+   unsigned char ll_addr[ETH_ALEN];
+
+   ipv6_eth_mc_map((struct in6_addr *)mgid-raw, ll_addr);
+   err = dev_mc_add(rxe-ndev, ll_addr);
+
+   return err;
+}
+
+static int mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+   int err;
+   unsigned char ll_addr[ETH_ALEN];
+
+   ipv6_eth_mc_map((struct in6_addr *)mgid-raw, ll_addr);
+   err 

[patch v2 34/37] add rxe_net_sysfs.c

2011-07-25 Thread rpearson
sysfs interface for ib_rxe_net.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_net_sysfs.c |  229 ++
 1 file changed, 229 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_net_sysfs.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_net_sysfs.c
@@ -0,0 +1,229 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_net.h
+
+/* Copy argument and remove trailing CR. Return the new length. */
+static int sanitize_arg(const char *val, char *intf, int intf_len)
+{
+   int len;
+
+   if (!val)
+   return 0;
+
+   /* Remove newline. */
+   for (len = 0; len  intf_len - 1  val[len]  val[len] != '\n'; len++)
+   intf[len] = val[len];
+   intf[len] = 0;
+
+   if (len == 0 || (val[len] != 0  val[len] != '\n'))
+   return 0;
+
+   return len;
+}
+
+/* Caller must hold net_info_lock */
+static void rxe_set_port_state(struct net_device *ndev)
+{
+   struct rxe_dev *rxe;
+
+   if (ndev-ifindex = RXE_MAX_IF_INDEX)
+   goto out;
+
+   rxe = net_to_rxe(ndev);
+   if (!rxe)
+   goto out;
+
+   if (net_info[ndev-ifindex].status == IB_PORT_ACTIVE)
+   rxe_net_up(ndev);
+   else
+   rxe_net_down(ndev); /* down for unknown state */
+out:
+   return;
+}
+
+static int rxe_param_set_add(const char *val, struct kernel_param *kp)
+{
+   int i, len;
+   char intf[32];
+
+   len = sanitize_arg(val, intf, sizeof(intf));
+   if (!len) {
+   pr_err(rxe_net: add: invalid interface name\n);
+   return -EINVAL;
+   }
+
+   spin_lock_bh(net_info_lock);
+   for (i = 0; i  RXE_MAX_IF_INDEX; i++) {
+   struct net_device *ndev = net_info[i].ndev;
+
+   if (ndev  (0 == strncmp(intf, ndev-name, len))) {
+   spin_unlock_bh(net_info_lock);
+   if (net_info[i].rxe)
+   pr_info(rxe_net: already configured on %s\n,
+   intf);
+   else {
+   rxe_net_add(ndev);
+   if (net_info[i].rxe) {
+   rxe_set_port_state(ndev);
+   } else
+   pr_err(rxe_net: add appears to have 
+  failed for %s (index %d)\n,
+  intf, i);
+   }
+   return 0;
+   }
+   }
+   spin_unlock_bh(net_info_lock);
+
+   pr_warning(interface %s not found\n, intf);
+
+   return 0;
+}
+
+static void rxe_remove_all(void)
+{
+   int i;
+   struct rxe_dev *rxe;
+
+   for (i = 0; i  RXE_MAX_IF_INDEX; i++) {
+   if (net_info[i].rxe) {
+   spin_lock_bh(net_info_lock);
+   rxe = net_info[i].rxe;
+   net_info[i].rxe = NULL;
+   spin_unlock_bh(net_info_lock);
+
+   rxe_remove(rxe);
+   }
+   }
+}
+
+static int rxe_param_set_remove(const char *val, struct kernel_param *kp)
+{
+   int i, len;
+   char intf[32];
+   struct rxe_dev *rxe;
+
+   len = 

[patch v2 35/37] add rxe_sample.c

2011-07-25 Thread rpearson
module that implements a soft IB device using ib_rxe in loopback.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_sample.c |  226 +
 1 file changed, 226 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_sample.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_sample.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/*
+ * sample driver for IB transport over rxe
+ * implements a simple loopback device on module load
+ */
+
+#include linux/skbuff.h
+
+#include linux/device.h
+
+#include rxe.h
+
+MODULE_AUTHOR(Bob Pearson);
+MODULE_DESCRIPTION(RDMA transport over Converged Enhanced Ethernet);
+MODULE_LICENSE(Dual BSD/GPL);
+
+static __be64 node_guid(struct rxe_dev *rxe)
+{
+   return cpu_to_be64(0xULL);
+}
+
+static __be64 port_guid(struct rxe_dev *rxe, unsigned int port_num)
+{
+   return cpu_to_be64(0xULL);
+}
+
+/*
+ * the ofed core requires that we provide a valid device
+ * object for registration
+ */
+static struct class *my_class;
+static struct device *my_dev;
+
+static struct device *dma_device(struct rxe_dev *rxe)
+{
+   return my_dev;
+}
+
+static int mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+   return 0;
+}
+
+static int mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+   return 0;
+}
+
+/* just loopback packet */
+static int send(struct rxe_dev *rxe, struct sk_buff *skb)
+{
+   struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+
+   pkt-rxe = rxe;
+   pkt-mask = RXE_LRH_MASK;
+
+   return rxe_rcv(skb);
+}
+
+static struct sk_buff *init_packet(struct rxe_dev *rxe, struct rxe_av *av,
+  int paylen)
+{
+   struct sk_buff *skb;
+   struct rxe_pkt_info *pkt;
+
+   paylen += RXE_LRH_BYTES;
+
+   if (av-attr.ah_flags  IB_AH_GRH)
+   paylen += RXE_GRH_BYTES;
+
+   skb = alloc_skb(paylen, GFP_ATOMIC);
+   if (!skb)
+   return NULL;
+
+   skb-dev= NULL;
+   skb-protocol   = 0;
+
+   pkt = SKB_TO_PKT(skb);
+   pkt-rxe= rxe;
+   pkt-port_num   = 1;
+   pkt-hdr= skb_put(skb, paylen);
+   pkt-mask   = RXE_LRH_MASK;
+   if (av-attr.ah_flags  IB_AH_GRH)
+   pkt-mask   |= RXE_GRH_MASK;
+
+   return skb;
+}
+
+static int init_av(struct rxe_dev *rxe, struct ib_ah_attr *attr,
+  struct rxe_av *av)
+{
+   if (!av-attr.dlid)
+   av-attr.dlid = 1;
+   return 0;
+}
+
+static char *parent_name(struct rxe_dev *rxe, unsigned int port_num)
+{
+   return sample;
+}
+
+static enum rdma_link_layer link_layer(struct rxe_dev *rxe,
+  unsigned int port_num)
+{
+   return IB_LINK_LAYER_INFINIBAND;
+}
+
+static struct rxe_ifc_ops ifc_ops = {
+   .node_guid  = node_guid,
+   .port_guid  = port_guid,
+   .dma_device = dma_device,
+   .mcast_add  = mcast_add,
+   .mcast_delete   = mcast_delete,
+   .send   = send,
+   .init_packet= init_packet,
+   .init_av= init_av,
+   .parent_name= parent_name,
+   .link_layer = link_layer,
+};
+
+static struct rxe_dev *rxe_sample;
+
+static int rxe_sample_add(void)
+{
+   int err;
+   struct rxe_port *port;
+
+   rxe_sample = (struct rxe_dev *)ib_alloc_device(sizeof(*rxe_sample));
+   if 

[patch v2 36/37] add Makefile

2011-07-25 Thread rpearson
Makefile

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/Makefile |   30 ++
 1 file changed, 30 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/Makefile
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/Makefile
@@ -0,0 +1,30 @@
+obj-$(CONFIG_INFINIBAND_RXE) += ib_rxe.o ib_rxe_net.o ib_rxe_sample.o
+
+ib_rxe-y := \
+   rxe.o \
+   rxe_comp.o \
+   rxe_req.o \
+   rxe_resp.o \
+   rxe_recv.o \
+   rxe_pool.o \
+   rxe_queue.o \
+   rxe_verbs.o \
+   rxe_av.o \
+   rxe_srq.o \
+   rxe_qp.o \
+   rxe_cq.o \
+   rxe_mr.o \
+   rxe_dma.o \
+   rxe_opcode.o \
+   rxe_mmap.o \
+   rxe_arbiter.o \
+   rxe_icrc.o \
+   rxe_mcast.o \
+   rxe_task.o
+
+ib_rxe_net-y := \
+   rxe_net.o \
+   rxe_net_sysfs.o
+
+ib_rxe_sample-y := \
+   rxe_sample.o


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch v2 37/37] add Kconfig

2011-07-25 Thread rpearson
Kconfig file

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/Kconfig|1 +
 drivers/infiniband/Makefile   |1 +
 drivers/infiniband/hw/rxe/Kconfig |   28 
 3 files changed, 30 insertions(+)

Index: infiniband/drivers/infiniband/Kconfig
===
--- infiniband.orig/drivers/infiniband/Kconfig
+++ infiniband/drivers/infiniband/Kconfig
@@ -51,6 +51,7 @@ source drivers/infiniband/hw/cxgb3/Kcon
 source drivers/infiniband/hw/cxgb4/Kconfig
 source drivers/infiniband/hw/mlx4/Kconfig
 source drivers/infiniband/hw/nes/Kconfig
+source drivers/infiniband/hw/rxe/Kconfig
 
 source drivers/infiniband/ulp/ipoib/Kconfig
 
Index: infiniband/drivers/infiniband/Makefile
===
--- infiniband.orig/drivers/infiniband/Makefile
+++ infiniband/drivers/infiniband/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_INFINIBAND_CXGB3)  += hw/cx
 obj-$(CONFIG_INFINIBAND_CXGB4) += hw/cxgb4/
 obj-$(CONFIG_MLX4_INFINIBAND)  += hw/mlx4/
 obj-$(CONFIG_INFINIBAND_NES)   += hw/nes/
+obj-$(CONFIG_INFINIBAND_RXE)   += hw/rxe/
 obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/
 obj-$(CONFIG_INFINIBAND_SRP)   += ulp/srp/
 obj-$(CONFIG_INFINIBAND_ISER)  += ulp/iser/
Index: infiniband/drivers/infiniband/hw/rxe/Kconfig
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/Kconfig
@@ -0,0 +1,28 @@
+config INFINIBAND_RXE
+   tristate Software RDMA over Ethernet (RoCE) driver
+   depends on INET  PCI  INFINIBAND
+   ---help---
+   This driver implements the InfiniBand RDMA transport over
+   the Linux network stack. It enables a system with a
+   standard Ethernet adapter to interoperate with a RoCE
+   adapter or with another system running the RXE driver.
+   Documentation on InfiniBand and RoCE can be downloaded at
+   www.infinibandta.org and www.openfabrics.org. (See also
+   siw which is a similar software driver for iWARP.)
+
+   The driver is split into two layers, one interfaces with the
+   Linux RDMA stack and implements a kernel or user space
+   verbs API. The user space verbs API requires a support
+   library named librxe which is loaded by the generic user
+   space verbs API, libibverbs. The other layer interfaces
+   with the Linux network stack at layer 3.
+
+   There are three kernel modules provided with RXE.
+
+   ib_rxe  - attaches to the Linux RDMA stack
+   ib_rxe_net  - attaches to the Linux network stack
+   ib_rxe_sample   - provides a simple sample network layer
+ driver that provides a loopback interface.
+
+   Rxe_cfg provided with librxe is a configuration tool that
+   loads and unloads the ib_rxe and ib_rxe_net kernel modules


--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 41/44] rxe_net_sysfs.c

2011-07-01 Thread rpearson
sysfs interface for ib_rxe_net.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_net_sysfs.c |  220 ++
 1 file changed, 220 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_net_sysfs.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_net_sysfs.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_net.h
+
+/* Copy argument and remove trailing CR. Return the new length. */
+static int sanitize_arg(const char *val, char *intf, int intf_len)
+{
+   int len;
+
+   if (!val)
+   return 0;
+
+   /* Remove newline. */
+   for (len = 0; len  intf_len - 1  val[len]  val[len] != '\n'; len++)
+   intf[len] = val[len];
+   intf[len] = 0;
+
+   if (len == 0 || (val[len] != 0  val[len] != '\n'))
+   return 0;
+
+   return len;
+}
+
+/* Caller must hold net_info_lock */
+static void rxe_set_port_state(struct net_device *ndev)
+{
+   struct rxe_dev *rxe;
+
+   if (ndev-ifindex = RXE_MAX_IF_INDEX)
+   goto out;
+
+   rxe = net_to_rxe(ndev);
+   if (!rxe)
+   goto out;
+
+   if (net_info[ndev-ifindex].status == IB_PORT_ACTIVE)
+   rxe_net_up(ndev);
+   else
+   rxe_net_down(ndev); /* down for unknown state */
+out:
+   return;
+}
+
+static int rxe_param_set_add(const char *val, struct kernel_param *kp)
+{
+   int i, len;
+   char intf[32];
+
+   len = sanitize_arg(val, intf, sizeof(intf));
+   if (!len) {
+   pr_err(rxe_net: add: invalid interface name\n);
+   return -EINVAL;
+   }
+
+   spin_lock_bh(net_info_lock);
+   for (i = 0; i  RXE_MAX_IF_INDEX; i++) {
+   struct net_device *ndev = net_info[i].ndev;
+
+   if (ndev  (0 == strncmp(intf, ndev-name, len))) {
+   spin_unlock_bh(net_info_lock);
+   if (net_info[i].rxe)
+   pr_info(rxe_net: already configured on %s\n,
+   intf);
+   else {
+   rxe_net_add(ndev);
+   if (net_info[i].rxe) {
+   rxe_set_port_state(ndev);
+   } else
+   pr_err(rxe_net: add appears to have 
+  failed for %s (index %d)\n,
+  intf, i);
+   }
+   return 0;
+   }
+   }
+   spin_unlock_bh(net_info_lock);
+
+   pr_warning(interface %s not found\n, intf);
+
+   return 0;
+}
+
+static void rxe_remove_all(void)
+{
+   int i;
+
+   spin_lock_bh(net_info_lock);
+   for (i = 0; i  RXE_MAX_IF_INDEX; i++) {
+   if (net_info[i].rxe)
+   rxe_net_remove(i);
+   }
+   spin_unlock_bh(net_info_lock);
+}
+
+static int rxe_param_set_remove(const char *val, struct kernel_param *kp)
+{
+   int i, len;
+   char intf[32];
+
+   len = sanitize_arg(val, intf, sizeof(intf));
+   if (!len) {
+   pr_err(rxe_net: remove: invalid interface name\n);
+   return -EINVAL;
+   }
+
+   if (strncmp(all, intf, len) == 0) {
+ 

[patch 42/44] rxe_sample.c

2011-07-01 Thread rpearson
module that implements a soft IB device using ib_rxe in loopback.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_sample.c |  226 +
 1 file changed, 226 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_sample.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_sample.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/*
+ * sample driver for IB transport over rxe
+ * implements a simple loopback device on module load
+ */
+
+#include linux/skbuff.h
+
+#include linux/device.h
+
+#include rxe.h
+
+MODULE_AUTHOR(Bob Pearson);
+MODULE_DESCRIPTION(RDMA transport over Converged Enhanced Ethernet);
+MODULE_LICENSE(Dual BSD/GPL);
+
+static __be64 node_guid(struct rxe_dev *rxe)
+{
+   return 0xULL;
+}
+
+static __be64 port_guid(struct rxe_dev *rxe, unsigned int port_num)
+{
+   return 0xULL;
+}
+
+/*
+ * the ofed core requires that we provide a valid device
+ * object for registration
+ */
+static struct class *my_class;
+static struct device *my_dev;
+
+static struct device *dma_device(struct rxe_dev *rxe)
+{
+   return my_dev;
+}
+
+static int mcast_add(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+   return 0;
+}
+
+static int mcast_delete(struct rxe_dev *rxe, union ib_gid *mgid)
+{
+   return 0;
+}
+
+/* just loopback packet */
+static int send(struct rxe_dev *rxe, struct sk_buff *skb)
+{
+   struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+
+   pkt-rxe = rxe;
+   pkt-mask = RXE_LRH_MASK;
+
+   return rxe_rcv(skb);
+}
+
+static struct sk_buff *init_packet(struct rxe_dev *rxe, struct rxe_av *av,
+  int paylen)
+{
+   struct sk_buff *skb;
+   struct rxe_pkt_info *pkt;
+
+   paylen += RXE_LRH_BYTES;
+
+   if (av-attr.ah_flags  IB_AH_GRH)
+   paylen += RXE_GRH_BYTES;
+
+   skb = alloc_skb(paylen, GFP_ATOMIC);
+   if (!skb)
+   return NULL;
+
+   skb-dev= NULL;
+   skb-protocol   = 0;
+
+   pkt = SKB_TO_PKT(skb);
+   pkt-rxe= rxe;
+   pkt-port_num   = 1;
+   pkt-hdr= skb_put(skb, paylen);
+   pkt-mask   = RXE_LRH_MASK;
+   if (av-attr.ah_flags  IB_AH_GRH)
+   pkt-mask   |= RXE_GRH_MASK;
+
+   return skb;
+}
+
+static int init_av(struct rxe_dev *rxe, struct ib_ah_attr *attr,
+  struct rxe_av *av)
+{
+   if (!av-attr.dlid)
+   av-attr.dlid = 1;
+   return 0;
+}
+
+static char *parent_name(struct rxe_dev *rxe, unsigned int port_num)
+{
+   return sample;
+}
+
+static enum rdma_link_layer link_layer(struct rxe_dev *rxe,
+  unsigned int port_num)
+{
+   return IB_LINK_LAYER_INFINIBAND;
+}
+
+static struct rxe_ifc_ops ifc_ops = {
+   .node_guid  = node_guid,
+   .port_guid  = port_guid,
+   .dma_device = dma_device,
+   .mcast_add  = mcast_add,
+   .mcast_delete   = mcast_delete,
+   .send   = send,
+   .init_packet= init_packet,
+   .init_av= init_av,
+   .parent_name= parent_name,
+   .link_layer = link_layer,
+};
+
+static struct rxe_dev *rxe_sample;
+
+static int rxe_sample_add(void)
+{
+   int err;
+   struct rxe_port *port;
+
+   rxe_sample = (struct rxe_dev *)ib_alloc_device(sizeof(*rxe_sample));
+   if (!rxe_sample) {
+  

[patch 43/44] Makefile

2011-07-01 Thread rpearson
Makefile

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/Makefile |   46 +
 1 file changed, 46 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/Makefile
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/Makefile
@@ -0,0 +1,46 @@
+
+EXTRA_PRE_CFLAGS := -D__KERNEL__ $(BACKPORTS) $(DEBUG) \
+   -I/usr/src/ofa_kernel/include
+
+obj-m += ib_rxe.o ib_rxe_net.o ib_rxe_sample.o
+
+ib_rxe-y := \
+   rxe.o \
+   rxe_comp.o \
+   rxe_req.o \
+   rxe_resp.o \
+   rxe_recv.o \
+   rxe_pool.o \
+   rxe_queue.o \
+   rxe_verbs.o \
+   rxe_av.o \
+   rxe_srq.o \
+   rxe_qp.o \
+   rxe_cq.o \
+   rxe_mr.o \
+   rxe_dma.o \
+   rxe_opcode.o \
+   rxe_mmap.o \
+   rxe_arbiter.o \
+   rxe_sb8.o \
+   rxe_mcast.o \
+   rxe_task.o
+
+ib_rxe_net-y := \
+   rxe_net.o \
+   rxe_net_sysfs.o
+
+ib_rxe_sample-y := \
+   rxe_sample.o
+
+# Generation of SB8 tables for Ethernet CRC32
+hostprogs-y := gen_sb8tables
+clean-files := sb8_tables.h
+
+$(obj)/rxe_sb8.o: $(obj)/sb8_tables.h
+
+quiet_cmd_sb8 = GEN $@
+   cmd_sb8 = $ --flop --swip --flip --swap --poly=0xedb88320  $@
+
+$(obj)/sb8_tables.h: $(obj)/gen_sb8tables
+   $(call cmd,sb8)

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 03/44] rxe_opcode.h

2011-07-01 Thread rpearson
Add declarations for data structures used to hold per opcode
and per work request opcode tables.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_opcode.h |  130 +
 1 file changed, 130 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_opcode.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_opcode.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_OPCODE_H
+#define RXE_OPCODE_H
+
+/*
+ * contains header bit mask definitions and header lengths
+ * declaration of the rxe_opcode_info struct and
+ * rxe_wr_opcode_info struct
+ */
+
+enum rxe_wr_mask {
+   WR_INLINE_MASK  = (1  0),
+   WR_ATOMIC_MASK  = (1  1),
+   WR_SEND_MASK= (1  2),
+   WR_READ_MASK= (1  3),
+   WR_WRITE_MASK   = (1  4),
+   WR_LOCAL_MASK   = (1  5),
+
+   WR_READ_OR_WRITE_MASK   = WR_READ_MASK | WR_WRITE_MASK,
+   WR_READ_WRITE_OR_SEND_MASK  = WR_READ_OR_WRITE_MASK | WR_SEND_MASK,
+   WR_WRITE_OR_SEND_MASK   = WR_WRITE_MASK | WR_SEND_MASK,
+   WR_ATOMIC_OR_READ_MASK  = WR_ATOMIC_MASK | WR_READ_MASK,
+};
+
+#define WR_MAX_QPT (8)
+
+struct rxe_wr_opcode_info {
+   char*name;
+   enum rxe_wr_maskmask[WR_MAX_QPT];
+};
+
+extern struct rxe_wr_opcode_info rxe_wr_opcode_info[];
+
+enum rxe_hdr_type {
+   RXE_LRH,
+   RXE_GRH,
+   RXE_BTH,
+   RXE_RETH,
+   RXE_AETH,
+   RXE_ATMETH,
+   RXE_ATMACK,
+   RXE_IETH,
+   RXE_RDETH,
+   RXE_DETH,
+   RXE_IMMDT,
+   RXE_PAYLOAD,
+   NUM_HDR_TYPES
+};
+
+enum rxe_hdr_mask {
+   RXE_LRH_MASK= (1  RXE_LRH),
+   RXE_GRH_MASK= (1  RXE_GRH),
+   RXE_BTH_MASK= (1  RXE_BTH),
+   RXE_IMMDT_MASK  = (1  RXE_IMMDT),
+   RXE_RETH_MASK   = (1  RXE_RETH),
+   RXE_AETH_MASK   = (1  RXE_AETH),
+   RXE_ATMETH_MASK = (1  RXE_ATMETH),
+   RXE_ATMACK_MASK = (1  RXE_ATMACK),
+   RXE_IETH_MASK   = (1  RXE_IETH),
+   RXE_RDETH_MASK  = (1  RXE_RDETH),
+   RXE_DETH_MASK   = (1  RXE_DETH),
+   RXE_PAYLOAD_MASK= (1  RXE_PAYLOAD),
+
+   RXE_REQ_MASK= (1  (NUM_HDR_TYPES+0)),
+   RXE_ACK_MASK= (1  (NUM_HDR_TYPES+1)),
+   RXE_SEND_MASK   = (1  (NUM_HDR_TYPES+2)),
+   RXE_WRITE_MASK  = (1  (NUM_HDR_TYPES+3)),
+   RXE_READ_MASK   = (1  (NUM_HDR_TYPES+4)),
+   RXE_ATOMIC_MASK = (1  (NUM_HDR_TYPES+5)),
+
+   RXE_RWR_MASK= (1  (NUM_HDR_TYPES+6)),
+   RXE_COMP_MASK   = (1  (NUM_HDR_TYPES+7)),
+
+   RXE_START_MASK  = (1  (NUM_HDR_TYPES+8)),
+   RXE_MIDDLE_MASK = (1  (NUM_HDR_TYPES+9)),
+   RXE_END_MASK= (1  (NUM_HDR_TYPES+10)),
+
+   RXE_CNP_MASK= (1  (NUM_HDR_TYPES+11)),
+
+   RXE_LOOPBACK_MASK   = (1  (NUM_HDR_TYPES+12)),
+
+   RXE_READ_OR_ATOMIC  = (RXE_READ_MASK | RXE_ATOMIC_MASK),
+   RXE_WRITE_OR_SEND   = (RXE_WRITE_MASK | RXE_SEND_MASK),
+};
+
+#define OPCODE_NONE(-1)
+#define RXE_NUM_OPCODE 256
+
+struct rxe_opcode_info {
+   char

[patch 05/44] rxe_param.h

2011-07-01 Thread rpearson
default rxe device and port parameters

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_param.h |  212 ++
 1 file changed, 212 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_param.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_param.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_PARAM_H
+#define RXE_PARAM_H
+
+enum rxe_mtu {
+   RXE_MTU_INVALID = 0,
+   RXE_MTU_256 = 1,
+   RXE_MTU_512 = 2,
+   RXE_MTU_1024= 3,
+   RXE_MTU_2048= 4,
+   RXE_MTU_4096= 5,
+   RXE_MTU_8192= 6,
+};
+
+static inline int rxe_mtu_enum_to_int(enum rxe_mtu mtu)
+{
+   switch (mtu) {
+   case RXE_MTU_256:   return  256;
+   case RXE_MTU_512:   return  512;
+   case RXE_MTU_1024:  return  1024;
+   case RXE_MTU_2048:  return  2048;
+   case RXE_MTU_4096:  return  4096;
+   case RXE_MTU_8192:  return  8192;
+   default:return  -1;
+   }
+}
+
+static inline enum rxe_mtu rxe_mtu_int_to_enum(int mtu)
+{
+   if (mtu  256)
+   return 0;
+   else if (mtu  512)
+   return RXE_MTU_256;
+   else if (mtu  1024)
+   return RXE_MTU_512;
+   else if (mtu  2048)
+   return RXE_MTU_1024;
+   else if (mtu  4096)
+   return RXE_MTU_2048;
+   else if (mtu  8192)
+   return RXE_MTU_4096;
+   else
+   return RXE_MTU_8192;
+}
+
+/* Find the IB mtu for a given network MTU. */
+static inline enum rxe_mtu eth_mtu_int_to_enum(int mtu)
+{
+   mtu -= RXE_MAX_HDR_LENGTH;
+
+   return rxe_mtu_int_to_enum(mtu);
+}
+
+/*
+ * default/initial rxe device parameter settings
+ */
+enum rxe_device_param {
+   RXE_FW_VER  = 0,
+   RXE_MAX_MR_SIZE = -1ull,
+   RXE_PAGE_SIZE_CAP   = 0xf000,
+   RXE_VENDOR_ID   = 0,
+   RXE_VENDOR_PART_ID  = 0,
+   RXE_HW_VER  = 0,
+   RXE_MAX_QP  = 0x1,
+   RXE_MAX_QP_WR   = 0x4000,
+   RXE_MAX_INLINE_DATA = 400,
+   RXE_DEVICE_CAP_FLAGS= IB_DEVICE_BAD_PKEY_CNTR
+   | IB_DEVICE_BAD_QKEY_CNTR
+   | IB_DEVICE_AUTO_PATH_MIG
+   | IB_DEVICE_CHANGE_PHY_PORT
+   | IB_DEVICE_UD_AV_PORT_ENFORCE
+   | IB_DEVICE_PORT_ACTIVE_EVENT
+   | IB_DEVICE_SYS_IMAGE_GUID
+   | IB_DEVICE_RC_RNR_NAK_GEN
+   | IB_DEVICE_SRQ_RESIZE,
+   RXE_MAX_SGE = 27,
+   RXE_MAX_SGE_RD  = 0,
+   RXE_MAX_CQ  = 16384,
+   RXE_MAX_LOG_CQE = 13,
+   RXE_MAX_MR  = 2*1024,
+   RXE_MAX_PD  = 0x7ffc,
+   RXE_MAX_QP_RD_ATOM  = 128,
+   RXE_MAX_EE_RD_ATOM  = 0,
+   RXE_MAX_RES_RD_ATOM = 0x3f000,
+   RXE_MAX_QP_INIT_RD_ATOM = 128,
+   RXE_MAX_EE_INIT_RD_ATOM = 0,
+   RXE_ATOMIC_CAP 

[patch 10/44] rxe_queue.h

2011-07-01 Thread rpearson
declarations for common work and completion queue.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_queue.h |  174 ++
 1 file changed, 174 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_queue.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_queue.h
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_QUEUE_H
+#define RXE_QUEUE_H
+
+/* implements a simple circular buffer that can optionally be
+   shared between user space and the kernel and can be resized
+
+   the requested element size is rounded up to a power of 2
+   and the number of elements in the buffer is also rounded
+   up to a power of 2. Since the queue is empty when the
+   producer and consumer indices match the maximum capacity
+   of the queue is one less than the number of element slots */
+
+/* this data structure is shared between user space and kernel
+   space for those cases where the queue is shared. It contains
+   the producer and consumer indices. Is also contains a copy
+   of the queue size parameters for user space to use but the
+   kernel must use the parameters in the rxe_queue struct
+   this MUST MATCH the corresponding librxe struct
+   for performance reasons arrange to have producer and consumer
+   pointers in separate cache lines
+   the kernel should always mask the indices to avoid accessing
+   memory outside of the data area */
+struct rxe_queue_buf {
+   __u32   log2_elem_size;
+   __u32   index_mask;
+   __u32   pad_1[30];
+   __u32   producer_index;
+   __u32   pad_2[31];
+   __u32   consumer_index;
+   __u32   pad_3[31];
+   __u8data[0];
+};
+
+struct rxe_queue {
+   struct rxe_dev  *rxe;
+   struct rxe_queue_buf*buf;
+   struct rxe_mmap_info*ip;
+   size_t  buf_size;
+   size_t  elem_size;
+   unsigned intlog2_elem_size;
+   unsigned intindex_mask;
+};
+
+int do_mmap_info(struct rxe_dev *rxe,
+struct ib_udata *udata,
+int offset,
+struct ib_ucontext *context,
+struct rxe_queue_buf *buf,
+size_t buf_size,
+struct rxe_mmap_info **ip_p);
+
+struct rxe_queue *rxe_queue_init(struct rxe_dev *rxe,
+unsigned int *num_elem,
+unsigned int elem_size);
+
+int rxe_queue_resize(struct rxe_queue *q,
+unsigned int *num_elem_p,
+unsigned int elem_size,
+struct ib_ucontext *context,
+struct ib_udata *udata,
+spinlock_t *producer_lock,
+spinlock_t *consumer_lock);
+
+void rxe_queue_cleanup(struct rxe_queue *queue);
+
+static inline int next_index(struct rxe_queue *q, int index)
+{
+   return (index + 1)  q-buf-index_mask;
+}
+
+static inline int queue_empty(struct rxe_queue *q)
+{
+   return ((q-buf-producer_index - q-buf-consumer_index)
+q-index_mask) == 0;
+}
+
+static inline int queue_full(struct rxe_queue *q)
+{
+   return ((q-buf-producer_index + 1 - q-buf-consumer_index)
+

[patch 14/44] rxe_pool.h

2011-07-01 Thread rpearson
declarations for rdma objects

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_pool.h |  163 +++
 1 file changed, 163 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_pool.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_pool.h
@@ -0,0 +1,163 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_POOL_H
+#define RXE_POOL_H
+
+/* declarations for pools of managed objects */
+
+#define RXE_POOL_ALIGN (16)
+#define RXE_POOL_CACHE_FLAGS   (0)
+
+enum rxe_pool_flags {
+   RXE_POOL_ATOMIC = (1  0),
+   RXE_POOL_INDEX  = (1  1),
+   RXE_POOL_KEY= (1  2),
+};
+
+enum rxe_elem_type {
+   RXE_TYPE_UC,
+   RXE_TYPE_PD,
+   RXE_TYPE_AH,
+   RXE_TYPE_SRQ,
+   RXE_TYPE_QP,
+   RXE_TYPE_CQ,
+   RXE_TYPE_MR,
+   RXE_TYPE_MW,
+   RXE_TYPE_FMR,
+   RXE_TYPE_MC_GRP,
+   RXE_TYPE_MC_ELEM,
+   RXE_NUM_TYPES,  /* keep me last */
+};
+
+struct rxe_type_info {
+   char*name;
+   size_t  size;
+   void(*cleanup)(void *obj);
+   enum rxe_pool_flags flags;
+   u32 max_index;
+   u32 min_index;
+   size_t  key_offset;
+   size_t  key_size;
+   struct kmem_cache   *cache;
+};
+
+extern struct rxe_type_info rxe_type_info[];
+
+enum rxe_pool_state {
+   rxe_pool_invalid,
+   rxe_pool_valid,
+};
+
+struct rxe_pool_entry {
+   struct rxe_pool *pool;
+   struct kref ref_cnt;
+   struct list_headlist;
+
+   /* only used if index'ed or key'ed */
+   struct rb_node  node;
+   u32 index;
+};
+
+struct rxe_pool {
+   struct rxe_dev  *rxe;
+   spinlock_t  pool_lock;
+   size_t  elem_size;
+   struct kref ref_cnt;
+   void(*cleanup)(void *obj);
+   enum rxe_pool_state state;
+   enum rxe_pool_flags flags;
+   enum rxe_elem_type  type;
+
+   unsigned intmax_elem;
+   atomic_tnum_elem;
+
+   /* only used if index'ed or key'ed */
+   struct rb_root  tree;
+   unsigned long   *table;
+   size_t  table_size;
+   u32 max_index;
+   u32 min_index;
+   u32 last;
+   size_t  key_offset;
+   size_t  key_size;
+};
+
+/* initialize slab caches for managed objects */
+int __init rxe_cache_init(void);
+
+/* cleanup slab caches for managed objects */
+void __exit rxe_cache_exit(void);
+
+/* initialize a pool of objects with given limit on
+   number of elements. gets parameters from rxe_type_info
+   pool elements will be allocated out of a slab cache */
+int rxe_pool_init(struct rxe_dev *rxe, struct rxe_pool *pool,
+ enum rxe_elem_type type, u32 max_elem);
+
+/* free resources from object pool */
+int rxe_pool_cleanup(struct rxe_pool *pool);
+
+/* allocate an object from pool */
+void *rxe_alloc(struct rxe_pool *pool);
+
+/* assign an index to an indexed object and insert object 

[patch 13/44] rxe_verbs.c

2011-07-01 Thread rpearson
rxe interface to rdma/core

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_verbs.c | 1351 ++
 1 file changed, 1351 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_verbs.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_verbs.c
@@ -0,0 +1,1351 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+#include rxe_av.h
+#include rxe_mmap.h
+#include rxe_srq.h
+#include rxe_cq.h
+#include rxe_qp.h
+#include rxe_mr.h
+#include rxe_mcast.h
+
+static int rxe_query_device(struct ib_device *dev, struct ib_device_attr *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+
+   *attr = rxe-attr;
+   return 0;
+}
+
+static int rxe_query_port(struct ib_device *dev,
+ u8 port_num, struct ib_port_attr *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_number %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   *attr = port-attr;
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int rxe_query_gid(struct ib_device *device,
+u8 port_num, int index, union ib_gid *gid)
+{
+   struct rxe_dev *rxe = to_rdev(device);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_num = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   if (unlikely(index  0 || index = port-attr.gid_tbl_len)) {
+   pr_warn(invalid index = %d\n, index);
+   goto err1;
+   }
+
+   gid-global.subnet_prefix = port-subnet_prefix;
+   gid-global.interface_id = port-guid_tbl[index];
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int rxe_query_pkey(struct ib_device *device,
+ u8 port_num, u16 index, u16 *pkey)
+{
+   struct rxe_dev *rxe = to_rdev(device);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid port_num = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   if (unlikely(index = port-attr.pkey_tbl_len)) {
+   pr_warn(invalid index = %d\n, index);
+   goto err1;
+   }
+
+   *pkey = port-pkey_tbl[index];
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int rxe_modify_device(struct ib_device *dev,
+int mask, struct ib_device_modify *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+
+   if (mask  IB_DEVICE_MODIFY_SYS_IMAGE_GUID)
+   rxe-attr.sys_image_guid = attr-sys_image_guid;
+
+   if (mask  IB_DEVICE_MODIFY_NODE_DESC) {
+   memcpy(rxe-ib_dev.node_desc,
+  attr-node_desc, sizeof(rxe-ib_dev.node_desc));
+   }
+
+   return 0;
+}
+
+static int rxe_modify_port(struct ib_device *dev,
+  u8 port_num, int mask, struct ib_port_modify *attr)
+{
+   struct rxe_dev *rxe = to_rdev(dev);
+   struct rxe_port *port;
+
+   if (unlikely(port_num  1 || port_num  rxe-num_ports)) {
+   pr_warn(invalid 

[patch 08/44] rxe_mmap.h

2011-07-01 Thread rpearson
declarations for mmap routines.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_mmap.h |   63 +++
 1 file changed, 63 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_mmap.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_mmap.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_MMAP_H
+#define RXE_MMAP_H
+
+/* This info has to be copied to user space so that it can call mmap
+ * and get the right stuff mapped */
+struct mminfo {
+   __u64   offset;
+   __u32   size;
+   __u32   pad;
+};
+
+struct rxe_mmap_info {
+   struct list_headpending_mmaps;
+   struct ib_ucontext  *context;
+   struct kref ref;
+   void*obj;
+
+   struct mminfo info;
+};
+
+void rxe_mmap_release(struct kref *ref);
+
+struct rxe_mmap_info *rxe_create_mmap_info(struct rxe_dev *dev,
+  u32 size,
+  struct ib_ucontext *context,
+  void *obj);
+
+int rxe_mmap(struct ib_ucontext *context, struct vm_area_struct *vma);
+
+#endif /* RXE_MMAP_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 17/44] rxe_task.c

2011-07-01 Thread rpearson
Tasklet handling details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_task.c |  169 +++
 1 file changed, 169 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_task.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_task.c
@@ -0,0 +1,169 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/kernel.h
+#include linux/interrupt.h
+#include linux/hardirq.h
+
+#include rxe_task.h
+
+int __rxe_do_task(struct rxe_task *task)
+
+{
+   int ret;
+
+   while ((ret = task-func(task-arg)) == 0)
+   ;
+
+   task-ret = ret;
+
+   return ret;
+}
+
+/*
+ * this locking is due to a potential race where
+ * a second caller finds the task already running
+ * but looks just after the last call to func
+ */
+void rxe_do_task(unsigned long data)
+{
+   int cont;
+   int ret;
+   unsigned long flags;
+   struct rxe_task *task = (struct rxe_task *)data;
+
+   spin_lock_irqsave(task-state_lock, flags);
+   switch (task-state) {
+   case TASK_STATE_START:
+   task-state = TASK_STATE_BUSY;
+   spin_unlock_irqrestore(task-state_lock, flags);
+   break;
+
+   case TASK_STATE_BUSY:
+   task-state = TASK_STATE_ARMED;
+   /* fall through to */
+   case TASK_STATE_ARMED:
+   spin_unlock_irqrestore(task-state_lock, flags);
+   return;
+
+   default:
+   spin_unlock_irqrestore(task-state_lock, flags);
+   pr_warn(bad state = %d in rxe_do_task\n, task-state);
+   return;
+   }
+
+   do {
+   cont = 0;
+   ret = task-func(task-arg);
+
+   spin_lock_irqsave(task-state_lock, flags);
+   switch (task-state) {
+   case TASK_STATE_BUSY:
+   if (ret)
+   task-state = TASK_STATE_START;
+   else
+   cont = 1;
+   break;
+
+   /* soneone tried to run the task since the
+  last time we called func, so we will call
+  one more time regardless of the return value */
+   case TASK_STATE_ARMED:
+   task-state = TASK_STATE_BUSY;
+   cont = 1;
+   break;
+
+   default:
+   pr_warn(bad state = %d in rxe_do_task\n,
+   task-state);
+   }
+   spin_unlock_irqrestore(task-state_lock, flags);
+   } while (cont);
+
+   task-ret = ret;
+}
+
+int rxe_init_task(void *obj, struct rxe_task *task, unsigned int *fast,
+ void *arg, int (*func)(void *), char *name)
+{
+   task-obj   = obj;
+   task-fast  = fast;
+   task-arg   = arg;
+   task-func  = func;
+   snprintf(task-name, sizeof(task-name), %s, name);
+
+   tasklet_init(task-tasklet, rxe_do_task, (unsigned long)task);
+
+   task-state = TASK_STATE_START;
+   spin_lock_init(task-state_lock);
+
+   return 0;
+}
+
+void rxe_cleanup_task(struct rxe_task *task)
+{
+   tasklet_kill(task-tasklet);
+}
+
+/*
+ * depending on value of fast allow bypassing
+ * tasklet call or not
+ *  0 = never
+ *  1 = only if not in 

[patch 19/44] rxe_av.c

2011-07-01 Thread rpearson
Address vector implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_av.c |   75 +
 1 file changed, 75 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_av.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_av.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* address handle implementation shared by ah and qp verbs */
+
+#include rxe.h
+#include rxe_av.h
+
+int rxe_av_chk_attr(struct rxe_dev *rxe, struct ib_ah_attr *attr)
+{
+   struct rxe_port *port;
+
+   if (attr-port_num  1 || attr-port_num  rxe-num_ports) {
+   pr_info(rxe: invalid port_num = %d\n, attr-port_num);
+   return -EINVAL;
+   }
+
+   port = rxe-port[attr-port_num - 1];
+
+   if (attr-ah_flags  IB_AH_GRH) {
+   if (attr-grh.sgid_index  port-attr.gid_tbl_len) {
+   pr_info(rxe: invalid sgid index = %d\n,
+attr-grh.sgid_index);
+   return -EINVAL;
+   }
+   }
+
+   return 0;
+}
+
+int rxe_av_from_attr(struct rxe_dev *rxe, u8 port_num,
+struct rxe_av *av, struct ib_ah_attr *attr)
+{
+   memset(av, 0, sizeof(*av));
+   av-attr = *attr;
+   av-attr.port_num = port_num;
+   return rxe-ifc_ops-init_av(rxe, attr, av);
+}
+
+int rxe_av_to_attr(struct rxe_dev *rxe, struct rxe_av *av,
+  struct ib_ah_attr *attr)
+{
+   *attr = av-attr;
+   return 0;
+}

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 21/44] rxe_srq.c

2011-07-01 Thread rpearson
Shared receive queue implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_srq.c |  215 
 1 file changed, 215 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_srq.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_srq.c
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* srq implementation details */
+
+#include rxe.h
+#include rxe_queue.h
+#include rxe_mmap.h
+#include rxe_srq.h
+#include rxe_qp.h
+
+int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
+struct ib_srq_attr *attr, enum ib_srq_attr_mask mask)
+{
+   if (srq  srq-error) {
+   pr_warn(srq in error state\n);
+   goto err1;
+   }
+
+   if (mask  IB_SRQ_MAX_WR) {
+   if (attr-max_wr  rxe-attr.max_srq_wr) {
+   pr_warn(max_wr(%d)  max_srq_wr(%d)\n,
+attr-max_wr, rxe-attr.max_srq_wr);
+   goto err1;
+   }
+
+   if (attr-max_wr = 0) {
+   pr_warn(max_wr(%d) = 0\n, attr-max_wr);
+   goto err1;
+   }
+
+   if (srq  !(rxe-attr.device_cap_flags 
+   IB_DEVICE_SRQ_RESIZE)) {
+   pr_warn(srq resize not supported\n);
+   goto err1;
+   }
+
+   if (srq  srq-limit  (attr-max_wr  srq-limit)) {
+   pr_warn(max_wr (%d)  srq-limit (%d)\n,
+ attr-max_wr, srq-limit);
+   goto err1;
+   }
+
+   if (attr-max_wr  RXE_MIN_SRQ_WR)
+   attr-max_wr = RXE_MIN_SRQ_WR;
+   }
+
+   if (mask  IB_SRQ_LIMIT) {
+   if (attr-srq_limit  rxe-attr.max_srq_wr) {
+   pr_warn(srq_limit(%d)  max_srq_wr(%d)\n,
+attr-srq_limit, rxe-attr.max_srq_wr);
+   goto err1;
+   }
+
+   if (attr-srq_limit  srq-rq.queue-buf-index_mask) {
+   pr_warn(srq_limit (%d)  cur limit(%d)\n,
+attr-srq_limit,
+srq-rq.queue-buf-index_mask);
+   goto err1;
+   }
+   }
+
+   if (mask == IB_SRQ_INIT_MASK) {
+   if (attr-max_sge  rxe-attr.max_srq_sge) {
+   pr_warn(max_sge(%d)  max_srq_sge(%d)\n,
+attr-max_sge, rxe-attr.max_srq_sge);
+   goto err1;
+   }
+
+   if (attr-max_sge  RXE_MIN_SRQ_SGE)
+   attr-max_sge = RXE_MIN_SRQ_SGE;
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
+ struct ib_srq_init_attr *init,
+ struct ib_ucontext *context, struct ib_udata *udata)
+{
+   int err;
+   int srq_wqe_size;
+   struct rxe_queue *q;
+
+   srq-event_handler  = init-event_handler;
+   srq-context= init-srq_context;
+   srq-limit  = init-attr.srq_limit;
+   srq-srq_num= srq-pelem.index;
+   srq-rq.max_wr  = init-attr.max_wr;
+   srq-rq.max_sge = 

[patch 22/44] rxe_cq.h

2011-07-01 Thread rpearson
Declarations for completion queue details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_cq.h |   52 +
 1 file changed, 52 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_cq.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_cq.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* cq implementation details */
+
+#ifndef RXE_CQ_H
+#define RXE_CQ_H
+
+int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
+   int cqe, int comp_vector, struct ib_udata *udata);
+
+int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
+int comp_vector, struct ib_ucontext *context,
+struct ib_udata *udata);
+
+int rxe_cq_resize_queue(struct rxe_cq *cq, int new_cqe, struct ib_udata 
*udata);
+
+int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited);
+
+void rxe_cq_cleanup(void *arg);
+
+#endif /* RXE_CQ_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 23/44] rxe_cq.c

2011-07-01 Thread rpearson
Completion queue implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_cq.c |  178 +
 1 file changed, 178 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_cq.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_cq.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* cq implementation details */
+
+#include rxe.h
+#include rxe_queue.h
+#include rxe_cq.h
+#include rxe_mmap.h
+
+int rxe_cq_chk_attr(struct rxe_dev *rxe, struct rxe_cq *cq,
+   int cqe, int comp_vector, struct ib_udata *udata)
+{
+   int count;
+
+   if (cqe = 0) {
+   pr_warn(cqe(%d) = 0\n, cqe);
+   goto err1;
+   }
+
+   if (cqe  rxe-attr.max_cqe) {
+   pr_warn(cqe(%d)  max_cqe(%d)\n,
+cqe, rxe-attr.max_cqe);
+   goto err1;
+   }
+
+   if (cq) {
+   count = queue_count(cq-queue);
+   if (cqe  count) {
+   pr_warn(cqe(%d)  current # elements in queue (%d),
+   cqe, count);
+   goto err1;
+   }
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static void rxe_send_complete(unsigned long data)
+{
+   struct rxe_cq *cq = (struct rxe_cq *)data;
+
+   while (1) {
+   u8 notify = cq-notify;
+
+   cq-ibcq.comp_handler(cq-ibcq, cq-ibcq.cq_context);
+
+   /* See if anything was added to the CQ during the
+* comp_handler call.  If so, go around again because we
+* won't be rescheduled.
+* XXX: is there a race on enqueue right after this test
+* but before we're out? */
+   if (notify == cq-notify)
+   return;
+   }
+}
+
+int rxe_cq_from_init(struct rxe_dev *rxe, struct rxe_cq *cq, int cqe,
+int comp_vector, struct ib_ucontext *context,
+struct ib_udata *udata)
+{
+   int err;
+
+   cq-queue = rxe_queue_init(rxe, (unsigned int *)cqe,
+  sizeof(struct rxe_cqe));
+   if (!cq-queue) {
+   pr_warn(unable to create cq\n);
+   return -ENOMEM;
+   }
+
+   err = do_mmap_info(rxe, udata, 0, context, cq-queue-buf,
+  cq-queue-buf_size, cq-queue-ip);
+   if (err) {
+   vfree(cq-queue-buf);
+   kfree(cq-queue);
+   }
+
+   if (udata)
+   cq-is_user = 1;
+
+   tasklet_init(cq-comp_task, rxe_send_complete, (unsigned long)cq);
+
+   spin_lock_init(cq-cq_lock);
+   cq-ibcq.cqe = cqe;
+   return 0;
+}
+
+int rxe_cq_resize_queue(struct rxe_cq *cq, int cqe, struct ib_udata *udata)
+{
+   int err;
+
+   err = rxe_queue_resize(cq-queue, (unsigned int *)cqe,
+  sizeof(struct rxe_cqe),
+  cq-queue-ip ? cq-queue-ip-context : NULL,
+  udata, NULL, cq-cq_lock);
+   if (!err)
+   cq-ibcq.cqe = cqe;
+
+   return err;
+}
+
+int rxe_cq_post(struct rxe_cq *cq, struct rxe_cqe *cqe, int solicited)
+{
+   struct ib_event ev;
+   unsigned long flags;
+
+   spin_lock_irqsave(cq-cq_lock, flags);
+
+   if 

[patch 25/44] rxe_qp.c

2011-07-01 Thread rpearson
Queue pair implementation details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_qp.c |  821 +
 1 file changed, 821 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_qp.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_qp.c
@@ -0,0 +1,821 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* qp implementation details */
+
+#include linux/skbuff.h
+#include linux/delay.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_mcast.h
+#include rxe_queue.h
+#include rxe_av.h
+#include rxe_qp.h
+#include rxe_mmap.h
+#include rxe_task.h
+
+char *rxe_qp_state_name[] = {
+   [QP_STATE_RESET]= RESET,
+   [QP_STATE_INIT] = INIT,
+   [QP_STATE_READY]= READY,
+   [QP_STATE_DRAIN]= DRAIN,
+   [QP_STATE_DRAINED]  = DRAINED,
+   [QP_STATE_ERROR]= ERROR,
+};
+
+static int rxe_qp_chk_cap(struct rxe_dev *rxe, struct ib_qp_cap *cap,
+ int has_srq)
+{
+   if (cap-max_send_wr  rxe-attr.max_qp_wr) {
+   pr_warn(invalid send wr = %d  %d\n,
+   cap-max_send_wr, rxe-attr.max_qp_wr);
+   goto err1;
+   }
+
+   if (cap-max_send_sge  rxe-attr.max_sge) {
+   pr_warn(invalid send sge = %d  %d\n,
+   cap-max_send_sge, rxe-attr.max_sge);
+   goto err1;
+   }
+
+   if (!has_srq) {
+   if (cap-max_recv_wr  rxe-attr.max_qp_wr) {
+   pr_warn(invalid recv wr = %d  %d\n,
+   cap-max_recv_wr, rxe-attr.max_qp_wr);
+   goto err1;
+   }
+
+   if (cap-max_recv_sge  rxe-attr.max_sge) {
+   pr_warn(invalid recv sge = %d  %d\n,
+ cap-max_recv_sge, rxe-attr.max_sge);
+   goto err1;
+   }
+   }
+
+   if (cap-max_inline_data  rxe-max_inline_data) {
+   pr_warn(invalid max inline data = %d  %d\n,
+   cap-max_inline_data, rxe-max_inline_data);
+   goto err1;
+   }
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init)
+{
+   struct ib_qp_cap *cap = init-cap;
+   struct rxe_port *port;
+   int port_num = init-port_num;
+
+   if (!init-recv_cq || !init-send_cq) {
+   pr_warn(missing cq\n);
+   goto err1;
+   }
+
+   if (rxe_qp_chk_cap(rxe, cap, init-srq != NULL))
+   goto err1;
+
+   if (init-qp_type == IB_QPT_SMI || init-qp_type == IB_QPT_GSI) {
+   if (port_num  1 || port_num  rxe-num_ports) {
+   pr_warn(invalid port = %d\n, port_num);
+   goto err1;
+   }
+
+   port = rxe-port[port_num - 1];
+
+   if (init-qp_type == IB_QPT_SMI  port-qp_smi_index) {
+   pr_warn(SMI QP exists for port %d\n, port_num);
+   goto err1;
+   }
+
+   if (init-qp_type == IB_QPT_GSI  port-qp_gsi_index) {
+   pr_warn(GSI QP exists for port %d\n, port_num);
+   goto err1;
+   }
+   }
+
+   return 0;
+

[patch 32/44] rxe_req.c

2011-07-01 Thread rpearson
QP request logic.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_req.c |  712 
 1 file changed, 712 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_req.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_req.c
@@ -0,0 +1,712 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+#include rxe_qp.h
+#include rxe_mr.h
+
+static int next_opcode(struct rxe_qp *qp, struct rxe_send_wqe *wqe,
+  unsigned opcode);
+
+static inline void retry_first_write_send(struct rxe_qp *qp,
+ struct rxe_send_wqe *wqe,
+ unsigned mask, int npsn)
+{
+   int i;
+
+   for (i = 0; i  npsn; i++) {
+   int to_send = (wqe-dma.resid  qp-mtu) ?
+   qp-mtu : wqe-dma.resid;
+
+   qp-req.opcode = next_opcode(qp, wqe,
+wqe-ibwr.opcode);
+
+   if (wqe-ibwr.send_flags  IB_SEND_INLINE) {
+   wqe-dma.resid -= to_send;
+   wqe-dma.sge_offset += to_send;
+   } else
+   advance_dma_data(wqe-dma, to_send);
+
+   if (mask  WR_WRITE_MASK)
+   wqe-iova += qp-mtu;
+   }
+}
+
+static void req_retry(struct rxe_qp *qp)
+{
+   struct rxe_send_wqe *wqe;
+   unsigned int wqe_index;
+   unsigned int mask;
+   int npsn;
+   int first = 1;
+
+   wqe = queue_head(qp-sq.queue);
+   npsn = (qp-comp.psn - wqe-first_psn)  BTH_PSN_MASK;
+
+   qp-req.wqe_index   = consumer_index(qp-sq.queue);
+   qp-req.psn = qp-comp.psn;
+   qp-req.opcode  = -1;
+
+   for (wqe_index = consumer_index(qp-sq.queue);
+   wqe_index != producer_index(qp-sq.queue);
+   wqe_index = next_index(qp-sq.queue, wqe_index)) {
+
+   wqe = addr_from_index(qp-sq.queue, wqe_index);
+   mask = wr_opcode_mask(wqe-ibwr.opcode, qp);
+
+   if (wqe-state == wqe_state_posted)
+   break;
+
+   if (wqe-state == wqe_state_done)
+   continue;
+
+   wqe-iova = (mask  WR_ATOMIC_MASK) ?
+   wqe-ibwr.wr.atomic.remote_addr :
+   wqe-ibwr.wr.rdma.remote_addr;
+
+   if (!first || (mask  WR_READ_MASK) == 0) {
+   wqe-dma.resid = wqe-dma.length;
+   wqe-dma.cur_sge = 0;
+   wqe-dma.sge_offset = 0;
+   }
+
+   if (first) {
+   first = 0;
+
+   if (mask  WR_WRITE_OR_SEND_MASK)
+   retry_first_write_send(qp, wqe, mask, npsn);
+
+   if (mask  WR_READ_MASK)
+   wqe-iova += npsn*qp-mtu;
+   }
+
+   wqe-state = wqe_state_posted;
+   }
+}
+
+void rnr_nak_timer(unsigned long data)
+{
+   struct rxe_qp *qp = (struct rxe_qp *)data;
+   pr_debug(rnr nak timer fired\n);
+   rxe_run_task(qp-req.task, 1);
+}
+
+static struct rxe_send_wqe *req_next_wqe(struct rxe_qp *qp)
+{
+   struct rxe_send_wqe *wqe = 

[patch 34/44] rxe_arbiter.c

2011-07-01 Thread rpearson
packet output arbitration.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_arbiter.c |  192 
 1 file changed, 192 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_arbiter.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_arbiter.c
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_qp.h
+
+static inline void account_skb(struct rxe_dev *rxe, struct rxe_qp *qp,
+  int is_request)
+{
+   if (is_request  RXE_REQ_MASK) {
+   atomic_dec(rxe-req_skb_out);
+   atomic_dec(qp-req_skb_out);
+   if (qp-need_req_skb) {
+   if (atomic_read(qp-req_skb_out)  rxe_max_skb_per_qp)
+   rxe_run_task(qp-req.task, 1);
+   }
+   } else {
+   atomic_dec(rxe-resp_skb_out);
+   atomic_dec(qp-resp_skb_out);
+   }
+}
+
+static int xmit_one_packet(struct rxe_dev *rxe, struct rxe_qp *qp,
+  struct sk_buff *skb)
+{
+   int err;
+   struct timespec time;
+   long new_delay;
+   struct rxe_pkt_info *pkt = SKB_TO_PKT(skb);
+   int is_request = pkt-mask  RXE_REQ_MASK;
+
+   /* drop pkt if qp is in wrong state to send */
+   if (!qp-valid)
+   goto drop;
+
+   if (is_request) {
+ if (qp-req.state != QP_STATE_READY)
+   goto drop;
+   } else {
+ if (qp-resp.state != QP_STATE_READY)
+   goto drop;
+   }
+
+   /* busy wait for static rate control
+  we could refine this by yielding the tasklet
+  for larger delays and waiting out the small ones */
+   if (rxe-arbiter.delay)
+   do {
+   getnstimeofday(time);
+   } while (timespec_compare(time, rxe-arbiter.time)  0);
+
+   new_delay = (skb-len*rxe_nsec_per_kbyte)  10;
+   if (new_delay  rxe_nsec_per_packet)
+   new_delay = rxe_nsec_per_packet;
+
+   if (pkt-mask  RXE_LOOPBACK_MASK)
+   err = rxe-ifc_ops-loopback(rxe, skb);
+   else
+   err = rxe-ifc_ops-send(rxe, skb);
+
+   /* we can recover from RXE_QUEUE_STOPPED errors
+  by retrying the packet. In other cases
+  the packet is consumed so move on */
+   if (err == RXE_QUEUE_STOPPED)
+   return err;
+   else if (err)
+   rxe-xmit_errors++;
+
+   rxe-arbiter.delay = new_delay  0;
+   if (rxe-arbiter.delay) {
+   getnstimeofday(time);
+   time.tv_nsec += new_delay;
+   while (time.tv_nsec  NSEC_PER_SEC) {
+   time.tv_sec += 1;
+   time.tv_nsec -= NSEC_PER_SEC;
+   }
+   rxe-arbiter.time = time;
+   }
+
+   goto done;
+
+drop:
+   kfree_skb(skb);
+   err = 0;
+done:
+   account_skb(rxe, qp, is_request);
+   return err;
+}
+
+/*
+ * choose one packet for sending
+ */
+int rxe_arbiter(void *arg)
+{
+   int err;
+   unsigned long flags;
+   struct rxe_dev *rxe = (struct rxe_dev *)arg;
+   struct sk_buff *skb;
+   struct list_head *qpl;
+   struct rxe_qp *qp;
+
+   /* get the next qp's send queue */
+   

[patch 36/44] gen_sb8tables.c

2011-07-01 Thread rpearson
Program to create slice by 8 tables for the CRC32 calculation.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/gen_sb8tables.c |  242 ++
 1 file changed, 242 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/gen_sb8tables.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/gen_sb8tables.c
@@ -0,0 +1,242 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 stdio.h
+#include stdint.h
+#include unistd.h
+#include stdlib.h
+#include byteswap.h
+
+#define _GNU_SOURCE
+#include getopt.h
+
+static int flip;
+static int swap;
+static int swip;
+static int flop;
+
+static uint32_t poly = 0xedb88320; /* crc32 */
+
+static uint32_t t[256];
+
+static int reverse[] = { 7, 6, 5, 4, 3, 2, 1, 0};
+
+static uint8_t flip8(uint8_t x)
+{
+   uint8_t y = 0;
+   int i;
+
+   for (i = 0; i  8; i++) {
+   if (x  (1  i))
+   y |= 1  reverse[i];
+   }
+
+   return y;
+}
+
+static uint32_t flip32(uint32_t x)
+{
+   uint32_t y;
+   uint8_t *p = (uint8_t *)x;
+   uint8_t *q = (uint8_t *)y;
+   int i;
+
+   for (i = 0; i  4; i++)
+   q[i] = flip8(p[i]);
+
+   return y;
+}
+
+static void compute(int n)
+{
+   uint64_t rem;
+   uint64_t p, m;
+   int i;
+   int j;
+   int k;
+   uint32_t ply = poly;
+
+   if (flop)
+   ply = flip32(ply);
+   if (swip)
+   ply = bswap_32(ply);
+
+   for (i = 0; i  256; i++) {
+   if (flip)
+   rem = flip8(i);
+   else
+   rem = i;
+   rem = 32;
+
+   for (k = 0; k = n; k++) {
+   for (j = 7; j = 0; j--) {
+   m = 1ULL  (32 + j);
+
+   if (rem  m) {
+   p = ((1ULL  32) + ply)  j;
+   rem ^= p;
+   }
+   }
+
+   rem = 8;
+   }
+
+   rem = 8;
+
+   if (flip) {
+   if (swap)
+   t[i] = bswap_32(flip32(rem));
+   else
+   t[i] = flip32(rem);
+   } else {
+   if (swap)
+   t[i] = bswap_32(rem);
+   else
+   t[i] = rem;
+   }
+   }
+}
+
+static void print_table(char *name)
+{
+   int i;
+
+   printf(\nstatic u32 %s[] = {\n, name);
+   for (i = 0; i  256; i++) {
+   printf(0x%08x,, t[i]);
+   if ((i % 4) == 3)
+   printf(\n);
+   else
+   printf( );
+   }
+   printf(};\n);
+}
+
+static void usage(void)
+{
+   printf(usage:\n);
+}
+
+static int arg_process(int argc, char *argv[])
+{
+   int c;
+   char *opt_string = sfFShp:;
+   struct option opt_long[] = {
+   {help, 0, 0, 'h'},
+   {poly, 1, 0, 'p'},
+   {flip, 0, 0, 'f'},
+   {swap, 0, 0, 's'},
+   {swip, 0, 0, 'S'},
+   {flop, 0, 0, 'F'},
+   };
+
+   while (1) {
+   c = getopt_long(argc, argv, opt_string, opt_long, NULL);
+
+  

[patch 35/44] rxe_dma.c

2011-07-01 Thread rpearson
Dummy dma processing for rxe device.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_dma.c |  178 
 1 file changed, 178 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_dma.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_dma.c
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ * Copyright (c) 2006 QLogic, Corporation. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+
+static int rxe_mapping_error(struct ib_device *dev, u64 dma_addr)
+{
+   return dma_addr == 0;
+}
+
+static u64 rxe_dma_map_single(struct ib_device *dev,
+ void *cpu_addr, size_t size,
+ enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+   return (u64) (uintptr_t) cpu_addr;
+}
+
+static void rxe_dma_unmap_single(struct ib_device *dev,
+u64 addr, size_t size,
+enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+}
+
+static u64 rxe_dma_map_page(struct ib_device *dev,
+   struct page *page,
+   unsigned long offset,
+   size_t size, enum dma_data_direction direction)
+{
+   u64 addr = 0;
+
+   BUG_ON(!valid_dma_direction(direction));
+
+   if (offset + size  PAGE_SIZE)
+   goto out;
+
+   addr = (uintptr_t) page_address(page);
+   if (addr)
+   addr += offset;
+
+out:
+   return addr;
+}
+
+static void rxe_dma_unmap_page(struct ib_device *dev,
+  u64 addr, size_t size,
+  enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+}
+
+static int rxe_map_sg(struct ib_device *dev, struct scatterlist *sgl,
+ int nents, enum dma_data_direction direction)
+{
+   struct scatterlist *sg;
+   u64 addr;
+   int i;
+   int ret = nents;
+
+   BUG_ON(!valid_dma_direction(direction));
+
+   for_each_sg(sgl, sg, nents, i) {
+   addr = (uintptr_t) page_address(sg_page(sg));
+   /* TODO: handle highmem pages */
+   if (!addr) {
+   ret = 0;
+   break;
+   }
+   }
+
+   return ret;
+}
+
+static void rxe_unmap_sg(struct ib_device *dev,
+struct scatterlist *sg, int nents,
+enum dma_data_direction direction)
+{
+   BUG_ON(!valid_dma_direction(direction));
+}
+
+static u64 rxe_sg_dma_address(struct ib_device *dev, struct scatterlist *sg)
+{
+   u64 addr = (uintptr_t) page_address(sg_page(sg));
+
+   if (addr)
+   addr += sg-offset;
+
+   return addr;
+}
+
+static unsigned int rxe_sg_dma_len(struct ib_device *dev,
+  struct scatterlist *sg)
+{
+   return sg-length;
+}
+
+static void rxe_sync_single_for_cpu(struct ib_device *dev,
+   u64 addr,
+   size_t size, enum dma_data_direction dir)
+{
+}
+
+static void rxe_sync_single_for_device(struct ib_device *dev,
+  u64 addr,
+  size_t size, enum dma_data_direction dir)
+{
+}
+

[patch 39/44] rxe_net.h

2011-07-01 Thread rpearson
Common declarations for ib_rxe_net module.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_net.h |   87 
 1 file changed, 87 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_net.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_net.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_NET_H
+#define RXE_NET_H
+
+#include net/sock.h
+#include net/if_inet6.h
+
+/*
+ * this should be defined in .../include/linux/if_ether.h
+ */
+#define ETH_P_RXE  (0x8915)
+
+/*
+ * this should be defined in .../include/linux/netfilter.h
+ * to a specific value
+ */
+#define NFPROTO_RXE(0)
+
+/*
+ * these should be defined in .../include/linux/netfilter_rxe.h
+ */
+#define NF_RXE_IN  (0)
+#define NF_RXE_OUT (1)
+
+/* Should probably move to something other than an array...these can be big */
+#define RXE_MAX_IF_INDEX   (384)
+
+struct rxe_net_info {
+   struct rxe_dev  *rxe;
+   u8  port;
+   struct net_device   *ndev;
+   int status;
+};
+
+extern struct rxe_net_info net_info[RXE_MAX_IF_INDEX];
+extern spinlock_t net_info_lock;
+
+/* caller must hold net_dev_lock */
+static inline struct rxe_dev *net_to_rxe(struct net_device *ndev)
+{
+   return (ndev-ifindex = RXE_MAX_IF_INDEX) ?
+   NULL : net_info[ndev-ifindex].rxe;
+}
+
+static inline u8 net_to_port(struct net_device *ndev)
+{
+   return net_info[ndev-ifindex].port;
+}
+
+void rxe_net_add(struct net_device *ndev);
+void rxe_net_remove(int net_index);
+void rxe_net_up(struct net_device *ndev);
+void rxe_net_down(struct net_device *ndev);
+
+#endif /* RXE_NET_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 44/44] Kconfig

2011-07-01 Thread rpearson
Kconfig file

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/Kconfig|1 +
 drivers/infiniband/Makefile   |1 +
 drivers/infiniband/hw/rxe/Kconfig |   26 ++
 3 files changed, 28 insertions(+)
Index: infiniband/drivers/infiniband/hw/rxe/Kconfig
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/Kconfig
@@ -0,0 +1,26 @@
+config INFINIBAND_RXE
+   tristate Software RDMA driver
+   depends on 64BIT  NET
+   ---help---
+   This is a driver for a software implementation of IBTA
+   RDMA transport.
+
+   There are three kernel modules:
+
+   ib_rxe  - device independant transport driver.
+   ib_rxe_net  - connects transport to the netdev stack
+ and runs on Ethernet devices. Follows the
+ RoCE protocol i.e. GRH and no LRH.
+   ib_rxe_sample   - sample module that connects the transport
+ to itself as a loopback and follows the
+ InfiniBand protocol i.e. uses LRH. This
+ could be used as a start for other experimantal
+ software implementations of InfiniBand.
+
+   Normal use is to load ib_rxe and ib_rxe_net after loading ib_core.
+   There is a script rxe_cfg that automates the configuration of rxe.
+
+   This driver supports kernel and user space ULPs. For user space
+   verbs applications you must install librxe with libibverbs.
+
+   If you don't know what to use this for, you don't need it.
Index: infiniband/drivers/infiniband/Kconfig
===
--- infiniband.orig/drivers/infiniband/Kconfig
+++ infiniband/drivers/infiniband/Kconfig
@@ -51,6 +51,7 @@ source drivers/infiniband/hw/cxgb3/Kcon
 source drivers/infiniband/hw/cxgb4/Kconfig
 source drivers/infiniband/hw/mlx4/Kconfig
 source drivers/infiniband/hw/nes/Kconfig
+source drivers/infiniband/hw/rxe/Kconfig
 
 source drivers/infiniband/ulp/ipoib/Kconfig
 
Index: infiniband/drivers/infiniband/Makefile
===
--- infiniband.orig/drivers/infiniband/Makefile
+++ infiniband/drivers/infiniband/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_INFINIBAND_CXGB3)  += hw/cx
 obj-$(CONFIG_INFINIBAND_CXGB4) += hw/cxgb4/
 obj-$(CONFIG_MLX4_INFINIBAND)  += hw/mlx4/
 obj-$(CONFIG_INFINIBAND_NES)   += hw/nes/
+obj-$(CONFIG_INFINIBAND_RXE)   += hw/rxe/
 obj-$(CONFIG_INFINIBAND_IPOIB) += ulp/ipoib/
 obj-$(CONFIG_INFINIBAND_SRP)   += ulp/srp/
 obj-$(CONFIG_INFINIBAND_ISER)  += ulp/iser/

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 00/44] RDMA over Ethernet

2011-07-01 Thread rpearson
This patch set implements a software emulation of RoCE or InfiniBand transport.
It consists of two kernel modules. The first, ib_rxe, implements the RDMA
transport and registers with the RDMA core as a kernel verbs provider. The
second, ib_rxe_net or ib_sample, implement the packet IO layer. ib_rxe_net
attaches to the Linux netdev stack as a network protocol and can send and
receive packets over any Ethernet device. It uses the RoCE protocol to handle
RDMA transport. ib_sample is a pure loopback device that uses the InfiniBand
transport i.e. it includes the LRH header while RoCE only includes the GRH
header.

The modules are configured by entries in /sys. There is a configuration script
(rxe_cfg) that simplifies the use of this interface. Rxe_cfg is part of the
rxe user space code, librxe.

The use of rxe verbs in user space requires the inclusion of librxe as a device
specific plug-in to libibverbs. Librxe is packaged separately.

Copies of the user space library and tools for 'upstream' and a tar file of
these patches are available at support.systemfabricworks.com/downloads/rxe.
-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 04/44] rxe_opcode.c

2011-07-01 Thread rpearson
Add data structures used to hold per opcode
and per work request opcode tables.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_opcode.c |  982 +
 1 file changed, 982 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_opcode.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_opcode.c
@@ -0,0 +1,982 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rdma/ib_pack.h
+#include rxe_opcode.h
+#include rxe_hdr.h
+
+/* useful information about work request opcodes and pkt opcodes
+   in table form */
+
+struct rxe_wr_opcode_info rxe_wr_opcode_info[] = {
+   [IB_WR_RDMA_WRITE]  = {
+   .name   = IB_WR_RDMA_WRITE,
+   .mask   = {
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   },
+   },
+   [IB_WR_RDMA_WRITE_WITH_IMM] = {
+   .name   = IB_WR_RDMA_WRITE_WITH_IMM,
+   .mask   = {
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_WRITE_MASK,
+   },
+   },
+   [IB_WR_SEND]= {
+   .name   = IB_WR_SEND,
+   .mask   = {
+   [IB_QPT_SMI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_GSI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UD] = WR_INLINE_MASK | WR_SEND_MASK,
+   },
+   },
+   [IB_WR_SEND_WITH_IMM]   = {
+   .name   = IB_WR_SEND_WITH_IMM,
+   .mask   = {
+   [IB_QPT_SMI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_GSI]= WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UC] = WR_INLINE_MASK | WR_SEND_MASK,
+   [IB_QPT_UD] = WR_INLINE_MASK | WR_SEND_MASK,
+   },
+   },
+   [IB_WR_RDMA_READ]   = {
+   .name   = IB_WR_RDMA_READ,
+   .mask   = {
+   [IB_QPT_RC] = WR_READ_MASK,
+   },
+   },
+   [IB_WR_ATOMIC_CMP_AND_SWP]  = {
+   .name   = IB_WR_ATOMIC_CMP_AND_SWP,
+   .mask   = {
+   [IB_QPT_RC] = WR_ATOMIC_MASK,
+   },
+   },
+   [IB_WR_ATOMIC_FETCH_AND_ADD]= {
+   .name   = IB_WR_ATOMIC_FETCH_AND_ADD,
+   .mask   = {
+   [IB_QPT_RC] = WR_ATOMIC_MASK,
+   },
+   },
+   [IB_WR_LSO] = {
+   .name   = IB_WR_LSO,
+   .mask   = {
+   /* not supported */
+   },
+   },
+   [IB_WR_SEND_WITH_INV]   = {
+   .name   = IB_WR_SEND_WITH_INV,
+   .mask   = {
+   [IB_QPT_RC] = WR_INLINE_MASK | WR_SEND_MASK,
+

[patch 02/44] rxe_hdr.h

2011-07-01 Thread rpearson
Add declarations for data structures used to hold per opcode
and per work request opcode tables.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_hdr.h | 1294 
 1 file changed, 1294 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_hdr.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_hdr.h
@@ -0,0 +1,1294 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_HDR_H
+#define RXE_HDR_H
+
+/* extracted information about a packet carried in an sk_buff struct
+   fits in the skbuff cb array. Must be at most 48 bytes. */
+struct rxe_pkt_info {
+   struct rxe_dev  *rxe;   /* device that owns packet */
+   struct rxe_qp   *qp;/* qp that owns packet */
+   u8  *hdr;   /* points to grh or bth */
+   u32 mask;   /* useful info about pkt */
+   u32 psn;/* bth psn of packet */
+   u16 pkey_index; /* partition of pkt */
+   u16 paylen; /* length of bth - icrc */
+   u8  port_num;   /* port pkt received on */
+   u8  opcode; /* bth opcode of packet */
+   u8  offset; /* bth offset from pkt-hdr */
+};
+
+#define SKB_TO_PKT(skb) ((struct rxe_pkt_info *)(skb)-cb)
+#define PKT_TO_SKB(pkt) ((struct sk_buff *)((char *)(pkt)  \
+   - offsetof(struct sk_buff, cb)))
+
+/*
+ * IBA header types and methods
+ *
+ * Some of these are for reference and completeness only since
+ * rxe does not currently support RD transport
+ * most of this could be moved into OFED core. ib_pack.h has
+ * part of this but is incomplete
+ *
+ * Header specific routines to insert/extract values to/from headers
+ * the routines that are named __hhh_(set_)fff() take a pointer to a
+ * hhh header and get(set) the fff field. The routines named
+ * hhh_(set_)fff take a packet info struct and find the
+ * header and field based on the opcode in the packet.
+ * Conversion to/from network byte order from cpu order is also done.
+ */
+
+#define RXE_ICRC_SIZE  (4)
+#define RXE_MAX_HDR_LENGTH (80)
+
+/**
+ * Local Route Header
+ 
**/
+struct rxe_lrh {
+   u8  vlver;  /* vl and lver */
+   u8  slnh;   /* sl and lnh */
+   __be16  dlid;
+   __be16  length;
+   __be16  slid;
+};
+
+#define LRH_LVER   (0)
+
+#define LRH_VL_MASK(0xf0)
+#define LRH_LVER_MASK  (0x0f)
+#define LRH_SL_MASK(0xf0)
+#define LRH_RESV2_MASK (0x0c)
+#define LRH_LNH_MASK   (0x03)
+#define LRH_RESV5_MASK (0xf800)
+#define LRH_LENGTH_MASK(0x07ff)
+
+enum lrh_lnh {
+   LRH_LNH_RAW = 0,
+   LRH_LNH_IP  = 1,
+   LRH_LNH_IBA_LOC = 2,
+   LRH_LNH_IBA_GBL = 3,
+};
+
+static inline u8 __lrh_vl(void *arg)
+{
+   struct rxe_lrh *lrh = arg;
+   return lrh-vlver  4;
+}
+
+static inline void __lrh_set_vl(void *arg, u8 vl)
+{

[patch 16/44] rxe_task.h

2011-07-01 Thread rpearson
Declarations for tasklet handling.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_task.h |  107 +++
 1 file changed, 107 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_task.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_task.h
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_TASK_H
+#define RXE_TASK_H
+
+enum {
+   TASK_STATE_START= 0,
+   TASK_STATE_BUSY = 1,
+   TASK_STATE_ARMED= 2,
+};
+
+/*
+ * data structure to describe a 'task' which is a short
+ * function that returns 0 as long as it needs to be
+ * called again.
+ */
+struct rxe_task {
+   void*obj;
+   unsigned int*fast;
+   struct tasklet_struct   tasklet;
+   int state;
+   spinlock_t  state_lock;
+   void*arg;
+   int (*func)(void *arg);
+   int ret;
+   charname[16];
+};
+
+/*
+ * init rxe_task structure
+ * fast = address of control flag, likely a module parameter
+ * arg  = parameter to pass to fcn
+ * fcn  = function to call until it returns != 0
+ */
+int rxe_init_task(void *obj, struct rxe_task *task, unsigned int *fast,
+ void *arg, int (*func)(void *), char *name);
+
+/*
+ * cleanup task
+ */
+void rxe_cleanup_task(struct rxe_task *task);
+
+/*
+ * raw call to func in loop without any checking
+ * can call when tasklets are disabled
+ */
+int __rxe_do_task(struct rxe_task *task);
+
+/*
+ * common function called by any of the main tasklets
+ * if someone is calling the function on its own
+ * thread (fast path) then they must increment busy
+ * If there is any chance that there is additional
+ * work to do someone must reschedule the task before
+ * leaving
+ */
+void rxe_do_task(unsigned long data);
+
+/*
+ * run a task, use fast path if no one else
+ * is currently running it and fast path is ok
+ * else schedule it to run as a tasklet
+ */
+void rxe_run_task(struct rxe_task *task, int sched);
+
+/*
+ * keep a task from scheduling
+ */
+void rxe_disable_task(struct rxe_task *task);
+
+/*
+ * allow task to run
+ */
+void rxe_enable_task(struct rxe_task *task);
+
+#endif /* RXE_TASK_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 15/44] rxe_pool.c

2011-07-01 Thread rpearson
rdma objects

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_pool.c |  524 +++
 1 file changed, 524 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_pool.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_pool.c
@@ -0,0 +1,524 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+#include rxe_srq.h
+#include rxe_cq.h
+#include rxe_qp.h
+#include rxe_mr.h
+
+/* info about object pools
+   note that mr, fmr and mw share a single index space
+   so that one can map an lkey to the correct type of object */
+struct rxe_type_info rxe_type_info[RXE_NUM_TYPES] = {
+   [RXE_TYPE_UC] = {
+   .name   = rxe_uc,
+   .size   = sizeof(struct rxe_ucontext),
+   },
+   [RXE_TYPE_PD] = {
+   .name   = rxe_pd,
+   .size   = sizeof(struct rxe_pd),
+   },
+   [RXE_TYPE_AH] = {
+   .name   = rxe_ah,
+   .size   = sizeof(struct rxe_ah),
+   .flags  = RXE_POOL_ATOMIC,
+   },
+   [RXE_TYPE_SRQ] = {
+   .name   = rxe_srq,
+   .size   = sizeof(struct rxe_srq),
+   .flags  = RXE_POOL_INDEX,
+   .min_index  = RXE_MIN_SRQ_INDEX,
+   .max_index  = RXE_MAX_SRQ_INDEX,
+   .cleanup= rxe_srq_cleanup,
+   },
+   [RXE_TYPE_QP] = {
+   .name   = rxe_qp,
+   .size   = sizeof(struct rxe_qp),
+   .cleanup= rxe_qp_cleanup,
+   .flags  = RXE_POOL_INDEX,
+   .min_index  = RXE_MIN_QP_INDEX,
+   .max_index  = RXE_MAX_QP_INDEX,
+   },
+   [RXE_TYPE_CQ] = {
+   .name   = rxe_cq,
+   .size   = sizeof(struct rxe_cq),
+   .cleanup= rxe_cq_cleanup,
+   },
+   [RXE_TYPE_MR] = {
+   .name   = rxe_mr,
+   .size   = sizeof(struct rxe_mem),
+   .cleanup= rxe_mem_cleanup,
+   .flags  = RXE_POOL_INDEX,
+   .max_index  = RXE_MAX_MR_INDEX,
+   .min_index  = RXE_MIN_MR_INDEX,
+   },
+   [RXE_TYPE_FMR] = {
+   .name   = rxe_fmr,
+   .size   = sizeof(struct rxe_mem),
+   .cleanup= rxe_mem_cleanup,
+   .flags  = RXE_POOL_INDEX,
+   .max_index  = RXE_MAX_FMR_INDEX,
+   .min_index  = RXE_MIN_FMR_INDEX,
+   },
+   [RXE_TYPE_MW] = {
+   .name   = rxe_mw,
+   .size   = sizeof(struct rxe_mem),
+   .flags  = RXE_POOL_INDEX,
+   .max_index  = RXE_MAX_MW_INDEX,
+   .min_index  = RXE_MIN_MW_INDEX,
+   },
+   [RXE_TYPE_MC_GRP] = {
+   .name   = rxe_mc_grp,
+   .size   = sizeof(struct rxe_mc_grp),
+   .cleanup= rxe_mc_cleanup,
+   .flags  = RXE_POOL_KEY,
+   .key_offset = offsetof(struct rxe_mc_grp, mgid),
+   .key_size   = sizeof(union 

[patch 18/44] rxe_av.h

2011-07-01 Thread rpearson
Declarations for address vector details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_av.h |   45 +
 1 file changed, 45 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_av.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_av.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_AV_H
+#define RXE_AV_H
+
+int rxe_av_chk_attr(struct rxe_dev *rxe, struct ib_ah_attr *attr);
+
+int rxe_av_from_attr(struct rxe_dev *rxe, u8 port_num,
+struct rxe_av *av, struct ib_ah_attr *attr);
+
+int rxe_av_to_attr(struct rxe_dev *rxe, struct rxe_av *av,
+  struct ib_ah_attr *attr);
+
+#endif /* RXE_AV_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 20/44] rxe_srq.h

2011-07-01 Thread rpearson
Declarations for shared receive queue details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_srq.h |   54 
 1 file changed, 54 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_srq.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_srq.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* srq implementation details */
+
+#ifndef RXE_SRQ_H
+#define RXE_SRQ_H
+
+#define IB_SRQ_INIT_MASK (~IB_SRQ_LIMIT)
+
+int rxe_srq_chk_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
+struct ib_srq_attr *attr, enum ib_srq_attr_mask mask);
+
+int rxe_srq_from_init(struct rxe_dev *rxe, struct rxe_srq *srq,
+ struct ib_srq_init_attr *init,
+ struct ib_ucontext *context, struct ib_udata *udata);
+
+int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
+ struct ib_srq_attr *attr, enum ib_srq_attr_mask mask,
+ struct ib_udata *udata);
+
+void rxe_srq_cleanup(void *arg);
+
+#endif /* RXE_SRQ_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 24/44] rxe_qp.h

2011-07-01 Thread rpearson
Decarations for queue pair details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_qp.h |   99 +
 1 file changed, 99 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_qp.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_qp.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_QP_H
+#define RXE_QP_H
+
+int rxe_qp_chk_init(struct rxe_dev *rxe, struct ib_qp_init_attr *init);
+
+int rxe_qp_from_init(struct rxe_dev *rxe, struct rxe_qp *qp, struct rxe_pd *pd,
+struct ib_qp_init_attr *init, struct ib_udata *udata,
+struct ib_pd *ibpd);
+
+int rxe_qp_to_init(struct rxe_qp *qp, struct ib_qp_init_attr *init);
+
+int rxe_qp_chk_attr(struct rxe_dev *rxe, struct rxe_qp *qp,
+   struct ib_qp_attr *attr, int mask);
+
+int rxe_qp_from_attr(struct rxe_qp *qp, struct ib_qp_attr *attr,
+int mask, struct ib_udata *udata);
+
+int rxe_qp_to_attr(struct rxe_qp *qp, struct ib_qp_attr *attr, int mask);
+
+void rxe_qp_error(struct rxe_qp *qp);
+
+void rxe_qp_destroy(struct rxe_qp *qp);
+
+void rxe_qp_cleanup(void *arg);
+
+static inline int qp_num(struct rxe_qp *qp)
+{
+   return qp-ibqp.qp_num;
+}
+
+static inline enum ib_qp_type qp_type(struct rxe_qp *qp)
+{
+   return qp-ibqp.qp_type;
+}
+
+static inline enum ib_qp_state qp_state(struct rxe_qp *qp)
+{
+   return qp-attr.qp_state;
+}
+
+static inline int qp_mtu(struct rxe_qp *qp)
+{
+   if (qp-ibqp.qp_type == IB_QPT_RC || qp-ibqp.qp_type == IB_QPT_UC)
+   return qp-attr.path_mtu;
+   else
+   return RXE_PORT_MAX_MTU;
+}
+
+#define RCV_WQE_SIZE(max_sge) (sizeof(struct rxe_recv_wqe) + \
+  (max_sge)*sizeof(struct ib_sge))
+
+void free_rd_atomic_resource(struct rxe_qp *qp, struct resp_res *res);
+
+static inline void rxe_advance_resp_resource(struct rxe_qp *qp)
+{
+   qp-resp.res_head++;
+   if (unlikely(qp-resp.res_head == qp-attr.max_rd_atomic))
+   qp-resp.res_head = 0;
+}
+
+void retransmit_timer(unsigned long data);
+void rnr_nak_timer(unsigned long data);
+
+void dump_qp(struct rxe_qp *qp);
+
+#endif /* RXE_QP_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 26/44] rxe_mr.h

2011-07-01 Thread rpearson
Declarations for memory region details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_mr.h |   88 +
 1 file changed, 88 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_mr.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_mr.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+#ifndef RXE_MR_H
+#define RXE_MR_H
+
+enum copy_direction {
+   direction_in,
+   direction_out,
+};
+
+int rxe_mem_init_dma(struct rxe_dev *rxe, struct rxe_pd *pd,
+int access, struct rxe_mem *mem);
+
+int rxe_mem_init_phys(struct rxe_dev *rxe, struct rxe_pd *pd,
+ int access, u64 iova, struct ib_phys_buf *buf,
+ int num_buf, struct rxe_mem *mem);
+
+int rxe_mem_init_user(struct rxe_dev *rxe, struct rxe_pd *pd, u64 start,
+ u64 length, u64 iova, int access, struct ib_udata *udata,
+ struct rxe_mem *mr);
+
+int rxe_mem_init_fast(struct rxe_dev *rxe, struct rxe_pd *pd,
+ int max_pages, struct rxe_mem *mem);
+
+int rxe_mem_init_mw(struct rxe_dev *rxe, struct rxe_pd *pd,
+   struct rxe_mem *mw);
+
+int rxe_mem_init_fmr(struct rxe_dev *rxe, struct rxe_pd *pd, int access,
+struct ib_fmr_attr *attr, struct rxe_mem *fmr);
+
+int rxe_mem_copy(struct rxe_mem *mem, u64 iova, void *addr,
+int length, enum copy_direction dir, uint32_t *crcp);
+
+int copy_data(struct rxe_dev *rxe, struct rxe_pd *pd, int access,
+ struct rxe_dma_info *dma, void *addr, int length,
+ enum copy_direction dir, __be32 *crcp);
+
+void *iova_to_vaddr(struct rxe_mem *mem, u64 iova, int length);
+
+enum lookup_type {
+   lookup_local,
+   lookup_remote,
+};
+
+struct rxe_mem *lookup_mem(struct rxe_pd *pd, int access, u32 key,
+  enum lookup_type type);
+
+int mem_check_range(struct rxe_mem *mem, u64 iova, size_t length);
+
+int rxe_mem_map_pages(struct rxe_dev *rxe, struct rxe_mem *mem,
+ u64 *page, int num_pages, u64 iova);
+
+void rxe_mem_cleanup(void *arg);
+
+int advance_dma_data(struct rxe_dma_info *dma, unsigned int length);
+
+#endif /* RXE_MR_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 28/44] rxe_mcast.h

2011-07-01 Thread rpearson
Declarations for multicast details.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_mcast.h |   52 ++
 1 file changed, 52 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_mcast.h
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_mcast.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ *Redistribution and use in source and binary forms, with or
+ *without modification, are permitted provided that the following
+ *conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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.
+ */
+
+/* multicast implemtation details */
+
+#ifndef RXE_MCAST_H
+#define RXE_MCAST_H
+
+int rxe_mcast_get_grp(struct rxe_dev *rxe, union ib_gid *mgid, u16 mlid,
+ struct rxe_mc_grp **grp_p);
+
+int rxe_mcast_add_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
+  struct rxe_mc_grp *grp);
+
+int rxe_mcast_drop_grp_elem(struct rxe_dev *rxe, struct rxe_qp *qp,
+   union ib_gid *mgid, u16 mlid);
+
+void rxe_drop_all_mcast_groups(struct rxe_qp *qp);
+
+void rxe_mc_cleanup(void *arg);
+
+#endif /* RXE_MCAST_H */

-- 

--
To unsubscribe from this list: send the line unsubscribe linux-rdma in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 31/44] rxe_comp.c

2011-07-01 Thread rpearson
completion processing.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_comp.c |  734 +++
 1 file changed, 734 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_comp.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_comp.c
@@ -0,0 +1,734 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_queue.h
+#include rxe_cq.h
+#include rxe_qp.h
+#include rxe_mr.h
+#include rxe_task.h
+
+enum comp_state {
+   COMPST_GET_ACK,
+   COMPST_GET_WQE,
+   COMPST_COMP_WQE,
+   COMPST_COMP_ACK,
+   COMPST_CHECK_PSN,
+   COMPST_CHECK_ACK,
+   COMPST_READ,
+   COMPST_ATOMIC,
+   COMPST_WRITE_SEND,
+   COMPST_UPDATE_COMP,
+   COMPST_ERROR_RETRY,
+   COMPST_RNR_RETRY,
+   COMPST_ERROR,
+   COMPST_EXIT,
+   COMPST_DONE,
+};
+
+static char *comp_state_name[] =  {
+   [COMPST_GET_ACK]= GET ACK,
+   [COMPST_GET_WQE]= GET WQE,
+   [COMPST_COMP_WQE]   = COMP WQE,
+   [COMPST_COMP_ACK]   = COMP ACK,
+   [COMPST_CHECK_PSN]  = CHECK PSN,
+   [COMPST_CHECK_ACK]  = CHECK ACK,
+   [COMPST_READ]   = READ,
+   [COMPST_ATOMIC] = ATOMIC,
+   [COMPST_WRITE_SEND] = WRITE/SEND,
+   [COMPST_UPDATE_COMP]= UPDATE COMP,
+   [COMPST_ERROR_RETRY]= ERROR RETRY,
+   [COMPST_RNR_RETRY]  = RNR RETRY,
+   [COMPST_ERROR]  = ERROR,
+   [COMPST_EXIT]   = EXIT,
+   [COMPST_DONE]   = DONE,
+};
+
+static unsigned long rnrnak_usec[32] = {
+   [IB_RNR_TIMER_655_36] = 655360,
+   [IB_RNR_TIMER_000_01] = 10,
+   [IB_RNR_TIMER_000_02] = 20,
+   [IB_RNR_TIMER_000_03] = 30,
+   [IB_RNR_TIMER_000_04] = 40,
+   [IB_RNR_TIMER_000_06] = 60,
+   [IB_RNR_TIMER_000_08] = 80,
+   [IB_RNR_TIMER_000_12] = 120,
+   [IB_RNR_TIMER_000_16] = 160,
+   [IB_RNR_TIMER_000_24] = 240,
+   [IB_RNR_TIMER_000_32] = 320,
+   [IB_RNR_TIMER_000_48] = 480,
+   [IB_RNR_TIMER_000_64] = 640,
+   [IB_RNR_TIMER_000_96] = 960,
+   [IB_RNR_TIMER_001_28] = 1280,
+   [IB_RNR_TIMER_001_92] = 1920,
+   [IB_RNR_TIMER_002_56] = 2560,
+   [IB_RNR_TIMER_003_84] = 3840,
+   [IB_RNR_TIMER_005_12] = 5120,
+   [IB_RNR_TIMER_007_68] = 7680,
+   [IB_RNR_TIMER_010_24] = 10240,
+   [IB_RNR_TIMER_015_36] = 15360,
+   [IB_RNR_TIMER_020_48] = 20480,
+   [IB_RNR_TIMER_030_72] = 30720,
+   [IB_RNR_TIMER_040_96] = 40960,
+   [IB_RNR_TIMER_061_44] = 61410,
+   [IB_RNR_TIMER_081_92] = 81920,
+   [IB_RNR_TIMER_122_88] = 122880,
+   [IB_RNR_TIMER_163_84] = 163840,
+   [IB_RNR_TIMER_245_76] = 245760,
+   [IB_RNR_TIMER_327_68] = 327680,
+   [IB_RNR_TIMER_491_52] = 491520,
+};
+
+static inline unsigned long rnrnak_jiffies(u8 timeout)
+{
+   return max_t(unsigned long,
+   usecs_to_jiffies(rnrnak_usec[timeout]), 1);
+}
+
+static enum ib_wc_opcode wr_to_wc_opcode(enum ib_wr_opcode opcode)
+{
+   switch (opcode) {
+   case IB_WR_RDMA_WRITE:  return IB_WC_RDMA_WRITE;
+   case IB_WR_RDMA_WRITE_WITH_IMM: return IB_WC_RDMA_WRITE;
+   

[patch 30/44] rxe_recv.c

2011-07-01 Thread rpearson
handles receiving new packets which are
sent to either request or response processing.

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe_recv.c |  426 +++
 1 file changed, 426 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe_recv.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe_recv.c
@@ -0,0 +1,426 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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/skbuff.h
+
+#include rxe.h
+#include rxe_loc.h
+#include rxe_qp.h
+
+static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
+   struct rxe_qp *qp)
+{
+   if (unlikely(!qp-valid))
+   goto err1;
+
+   switch (qp_type(qp)) {
+   case IB_QPT_RC:
+   if (unlikely((pkt-opcode  5) != 0)) {
+   pr_warn(bad qp type\n);
+   goto err1;
+   }
+   break;
+   case IB_QPT_UC:
+   if (unlikely((pkt-opcode  5) != 1)) {
+   pr_warn(bad qp type\n);
+   goto err1;
+   }
+   break;
+   case IB_QPT_UD:
+   case IB_QPT_SMI:
+   case IB_QPT_GSI:
+   if (unlikely((pkt-opcode  5) != 3)) {
+   pr_warn(bad qp type\n);
+   goto err1;
+   }
+   break;
+   default:
+   pr_warn(unsupported qp type\n);
+   goto err1;
+   }
+
+   if (pkt-mask  RXE_REQ_MASK) {
+   if (unlikely(qp-resp.state != QP_STATE_READY))
+   goto err1;
+   } else if (unlikely(qp-req.state  QP_STATE_READY ||
+   qp-req.state  QP_STATE_DRAINED))
+   goto err1;
+
+   return 0;
+
+err1:
+   return -EINVAL;
+}
+
+static int check_keys(struct rxe_dev *rxe, struct rxe_pkt_info *pkt,
+ u32 qpn, struct rxe_qp *qp)
+{
+   int i;
+   int found_pkey = 0;
+   struct rxe_port *port = rxe-port[pkt-port_num - 1];
+   u16 pkey = bth_pkey(pkt);
+
+   pkt-pkey_index = 0;
+
+   if (qpn == 1) {
+   for (i = 0; i  port-attr.pkey_tbl_len; i++) {
+   if (pkey_match(pkey, port-pkey_tbl[i])) {
+   pkt-pkey_index = i;
+   found_pkey = 1;
+   break;
+   }
+   }
+
+   if (!found_pkey) {
+   pr_warn(bad pkey = 0x%x\n, pkey);
+   spin_lock_bh(port-port_lock);
+   port-attr.bad_pkey_cntr
+   = (port-attr.bad_pkey_cntr = 0x) ?
+  0x :
+  port-attr.bad_pkey_cntr + 1;
+   spin_unlock_bh(port-port_lock);
+   goto err1;
+   }
+   } else if (qpn != 0) {
+   if (unlikely(!pkey_match(pkey,
+   port-pkey_tbl[qp-attr.pkey_index]))) {
+   pr_warn(bad pkey = 0x%0x\n, pkey);
+   spin_lock_bh(port-port_lock);
+   port-attr.bad_pkey_cntr
+   = (port-attr.bad_pkey_cntr = 0x) ?
+  0x :
+  

[patch 38/44] rxe.c

2011-07-01 Thread rpearson
module main for ib_rxe

Signed-off-by: Bob Pearson rpear...@systemfabricworks.com

---
 drivers/infiniband/hw/rxe/rxe.c |  549 
 1 file changed, 549 insertions(+)

Index: infiniband/drivers/infiniband/hw/rxe/rxe.c
===
--- /dev/null
+++ infiniband/drivers/infiniband/hw/rxe/rxe.c
@@ -0,0 +1,549 @@
+/*
+ * Copyright (c) 2009-2011 Mellanox Technologies Ltd. All rights reserved.
+ * Copyright (c) 2009-2011 System Fabric Works, Inc. All rights reserved.
+ *
+ * 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:
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above
+ *   copyright notice, this list of conditions and the following
+ *   disclaimer.
+ *
+ * - 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.
+ *
+ * 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 rxe.h
+#include rxe_loc.h
+
+MODULE_AUTHOR(Bob Pearson, Frank Zago, John Groves);
+MODULE_DESCRIPTION(Soft RDMA transport);
+MODULE_LICENSE(Dual BSD/GPL);
+
+static int rxe_max_ucontext = RXE_MAX_UCONTEXT;
+module_param_named(max_ucontext, rxe_max_ucontext, int, 0644);
+MODULE_PARM_DESC(max_ucontext, max user contexts per device);
+
+static int rxe_max_qp = RXE_MAX_QP;
+module_param_named(max_qp, rxe_max_qp, int, 0444);
+MODULE_PARM_DESC(max_qp, max QPs per device);
+
+static int rxe_max_qp_wr = RXE_MAX_QP_WR;
+module_param_named(max_qp_wr, rxe_max_qp_wr, int, 0644);
+MODULE_PARM_DESC(max_qp_wr, max send or recv WR's per QP);
+
+static int rxe_max_inline_data = RXE_MAX_INLINE_DATA;
+module_param_named(max_inline_data, rxe_max_inline_data, int, 0644);
+MODULE_PARM_DESC(max_inline_data, max inline data per WR);
+
+static int rxe_max_cq = RXE_MAX_CQ;
+module_param_named(max_cq, rxe_max_cq, int, 0644);
+MODULE_PARM_DESC(max_cq, max CQs per device);
+
+static int rxe_max_mr = RXE_MAX_MR;
+module_param_named(max_mr, rxe_max_mr, int, 0644);
+MODULE_PARM_DESC(max_mr, max MRs per device);
+
+static int rxe_max_fmr = RXE_MAX_FMR;
+module_param_named(max_fmr, rxe_max_fmr, int, 0644);
+MODULE_PARM_DESC(max_fmr, max MRs per device);
+
+static int rxe_max_mw = RXE_MAX_MW;
+module_param_named(max_mw, rxe_max_mw, int, 0644);
+MODULE_PARM_DESC(max_mw, max MWs per device);
+
+static int rxe_max_log_cqe = RXE_MAX_LOG_CQE;
+module_param_named(max_log_cqe, rxe_max_log_cqe, int, 0644);
+MODULE_PARM_DESC(max_log_cqe, Log2 of max CQ entries per CQ);
+
+int rxe_fast_comp = 2;
+module_param_named(fast_comp, rxe_fast_comp, int, 0644);
+MODULE_PARM_DESC(fast_comp, fast path call to completer 
+(0=no, 1=no int context, 2=any context));
+
+int rxe_fast_resp = 2;
+module_param_named(fast_resp, rxe_fast_resp, int, 0644);
+MODULE_PARM_DESC(fast_resp, enable fast path call to responder 
+(0=no, 1=no int context, 2=any context));
+
+int rxe_fast_req = 2;
+module_param_named(fast_req, rxe_fast_req, int, 0644);
+MODULE_PARM_DESC(fast_req, enable fast path call to requester 
+(0=no, 1=no int context, 2=any context));
+
+int rxe_fast_arb = 2;
+module_param_named(fast_arb, rxe_fast_arb, int, 0644);
+MODULE_PARM_DESC(fast_arb, enable fast path call to arbiter 
+(0=no, 1=no int context, 2=any context));
+
+int rxe_crc_disable;
+EXPORT_SYMBOL(rxe_crc_disable);
+module_param_named(crc_disable, rxe_crc_disable, int, 0644);
+MODULE_PARM_DESC(rxe_crc_disable,
+Disable crc32 computation on outbound packets);
+
+int rxe_nsec_per_packet = 200;
+module_param_named(nsec_per_packet, rxe_nsec_per_packet, int, 0644);
+MODULE_PARM_DESC(nsec_per_packet,
+minimum output packet delay nsec);
+
+int rxe_nsec_per_kbyte = 700;
+module_param_named(nsec_per_kbyte, rxe_nsec_per_kbyte, int, 0644);
+MODULE_PARM_DESC(nsec_per_kbyte,
+minimum output packet delay per kbyte nsec);
+
+int rxe_max_skb_per_qp = 800;
+module_param_named(max_skb_per_qp,