2007-09-10 18:04:44

by Talpey, Thomas

[permalink] [raw]
Subject: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

This file implements the configuration target, protocol template and
constants for the rpcrdma transport framing, for use by the xprtrdma
rpc transport implementation.

Signed-off-by: Tom Talpey <[email protected]>

---

fs/Kconfig | 8 ++
include/linux/sunrpc/rpc_rdma.h | 116 ++++++++++++++++++++++++++++++++++++++++
include/linux/sunrpc/xprtrdma.h | 85 +++++++++++++++++++++++++++++
3 files changed, 209 insertions(+)

Index: kernel/include/linux/sunrpc/rpc_rdma.h
===================================================================
--- /dev/null
+++ kernel/include/linux/sunrpc/rpc_rdma.h
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2003-2007 Network Appliance, 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 BSD-type
+ * 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.
+ *
+ * Neither the name of the Network Appliance, Inc. nor the names of
+ * its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LINUX_SUNRPC_RPC_RDMA_H
+#define _LINUX_SUNRPC_RPC_RDMA_H
+
+struct rpcrdma_segment {
+ uint32_t rs_handle; /* Registered memory handle */
+ uint32_t rs_length; /* Length of the chunk in bytes */
+ uint64_t rs_offset; /* Chunk virtual address or offset */
+};
+
+/*
+ * read chunk(s), encoded as a linked list.
+ */
+struct rpcrdma_read_chunk {
+ uint32_t rc_discrim; /* 1 indicates presence */
+ uint32_t rc_position; /* Position in XDR stream */
+ struct rpcrdma_segment rc_target;
+};
+
+/*
+ * write chunk, and reply chunk.
+ */
+struct rpcrdma_write_chunk {
+ struct rpcrdma_segment wc_target;
+};
+
+/*
+ * write chunk(s), encoded as a counted array.
+ */
+struct rpcrdma_write_array {
+ uint32_t wc_discrim; /* 1 indicates presence */
+ uint32_t wc_nchunks; /* Array count */
+ struct rpcrdma_write_chunk wc_array[0];
+};
+
+struct rpcrdma_msg {
+ uint32_t rm_xid; /* Mirrors the RPC header xid */
+ uint32_t rm_vers; /* Version of this protocol */
+ uint32_t rm_credit; /* Buffers requested/granted */
+ uint32_t rm_type; /* Type of message (enum rpcrdma_proc) */
+ union {
+
+ struct { /* no chunks */
+ uint32_t rm_empty[3]; /* 3 empty chunk lists */
+ } rm_nochunks;
+
+ struct { /* no chunks and padded */
+ uint32_t rm_align; /* Padding alignment */
+ uint32_t rm_thresh; /* Padding threshold */
+ uint32_t rm_pempty[3]; /* 3 empty chunk lists */
+ } rm_padded;
+
+ uint32_t rm_chunks[0]; /* read, write and reply chunks */
+
+ } rm_body;
+};
+
+#define RPCRDMA_HDRLEN_MIN 28
+
+enum rpcrdma_errcode {
+ ERR_VERS = 1,
+ ERR_CHUNK = 2
+};
+
+struct rpcrdma_err_vers {
+ uint32_t rdma_vers_low; /* Version range supported by peer */
+ uint32_t rdma_vers_high;
+};
+
+enum rpcrdma_proc {
+ RDMA_MSG = 0, /* An RPC call or reply msg */
+ RDMA_NOMSG = 1, /* An RPC call or reply msg - separate body */
+ RDMA_MSGP = 2, /* An RPC call or reply msg with padding */
+ RDMA_DONE = 3, /* Client signals reply completion */
+ RDMA_ERROR = 4 /* An RPC RDMA encoding error */
+};
+
+#endif /* _LINUX_SUNRPC_RPC_RDMA_H */
Index: kernel/include/linux/sunrpc/xprtrdma.h
===================================================================
--- /dev/null
+++ kernel/include/linux/sunrpc/xprtrdma.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2003-2007 Network Appliance, 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 BSD-type
+ * 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.
+ *
+ * Neither the name of the Network Appliance, Inc. nor the names of
+ * its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LINUX_SUNRPC_XPRTRDMA_H
+#define _LINUX_SUNRPC_XPRTRDMA_H
+
+/*
+ * RPC transport identifier for RDMA
+ */
+#define XPRT_TRANSPORT_RDMA 256
+
+/*
+ * rpcbind (v3+) RDMA netid.
+ */
+#define RPCBIND_NETID_RDMA "rdma"
+
+/*
+ * Constants. Max RPC/NFS header is big enough to account for
+ * additional marshaling buffers passed down by Linux client.
+ *
+ * RDMA header is currently fixed max size, and is big enough for a
+ * fully-chunked NFS message (read chunks are the largest). Note only
+ * a single chunk type per message is supported currently.
+ */
+#define RPCRDMA_MIN_SLOT_TABLE (2U)
+#define RPCRDMA_DEF_SLOT_TABLE (32U)
+#define RPCRDMA_MAX_SLOT_TABLE (256U)
+
+#define RPCRDMA_DEF_INLINE (1024) /* default inline max */
+
+#define RPCRDMA_INLINE_PAD_THRESH (512)/* payload threshold to pad (bytes) */
+
+#define RDMA_RESOLVE_TIMEOUT (5*HZ) /* TBD 5 seconds */
+#define RDMA_CONNECT_RETRY_MAX (2) /* retries if no listener backlog */
+
+/* memory registration strategies */
+#define RPCRDMA_PERSISTENT_REGISTRATION (1)
+
+enum rpcrdma_memreg {
+ RPCRDMA_BOUNCEBUFFERS = 0,
+ RPCRDMA_REGISTER,
+ RPCRDMA_MEMWINDOWS,
+ RPCRDMA_MEMWINDOWS_ASYNC,
+ RPCRDMA_MTHCAFMR,
+ RPCRDMA_ALLPHYSICAL,
+ RPCRDMA_LAST
+};
+
+#endif /* _LINUX_SUNRPC_XPRTRDMA_H */
Index: kernel/fs/Kconfig
===================================================================
--- kernel.orig/fs/Kconfig
+++ kernel/fs/Kconfig
@@ -1731,6 +1731,14 @@ config SUNRPC
config SUNRPC_GSS
tristate

+config SUNRPC_XPRT_RDMA
+ tristate "RDMA transport for sunrpc (EXPERIMENTAL)"
+ depends on SUNRPC && EXPERIMENTAL
+ default m
+ help
+ Adds a client RPC transport for supporting kernel NFS over RDMA
+ mounts, including Infiniband and iWARP. Experimental.
+
config SUNRPC_BIND34
bool "Support for rpcbind versions 3 & 4 (EXPERIMENTAL)"
depends on SUNRPC && EXPERIMENTAL

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs


2007-09-20 20:55:31

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

On Mon, 2007-09-10 at 13:49 -0400, Talpey, Thomas wrote:

> +config SUNRPC_XPRT_RDMA
> + tristate "RDMA transport for sunrpc (EXPERIMENTAL)"
> + depends on SUNRPC && EXPERIMENTAL
> + default m
> + help
> + Adds a client RPC transport for supporting kernel NFS over RDMA
> + mounts, including Infiniband and iWARP. Experimental.
> +

Hmm... There is a dependency on the Infiniband code that is missing
here. I'm getting the following compile errors:

ERROR: "ib_dealloc_pd" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_dealloc_mw" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_destroy_id" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_alloc_mw" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_modify_qp" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_connect" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_unmap_fmr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_alloc_pd" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_get_dma_mr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_query_device" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_destroy_qp" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_create_id" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_destroy_cq" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_create_qp" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_resolve_route" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_dealloc_fmr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_disconnect" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_alloc_fmr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_query_qp" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_dereg_mr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_reg_phys_mr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "rdma_resolve_addr" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
ERROR: "ib_create_cq" [net/sunrpc/xprtrdma/xprtrdma.ko] undefined!
make[2]: *** [__modpost] Error 1
make[1]: *** [modules] Error 2
make: *** [modules] Error 2

Cheers
Trond


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-09-20 21:04:56

by Talpey, Thomas

[permalink] [raw]
Subject: Re: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

At 04:55 PM 9/20/2007, Trond Myklebust wrote:
>On Mon, 2007-09-10 at 13:49 -0400, Talpey, Thomas wrote:
>
>> +config SUNRPC_XPRT_RDMA
>> + tristate "RDMA transport for sunrpc (EXPERIMENTAL)"
>> + depends on SUNRPC && EXPERIMENTAL
>> + default m
>> + help
>> + Adds a client RPC transport for supporting kernel NFS over RDMA
>> + mounts, including Infiniband and iWARP. Experimental.
>> +
>
>Hmm... There is a dependency on the Infiniband code that is missing
>here. I'm getting the following compile errors:

Ah - yes, you must have Infiniband or iWARP configured.

Actually, I think the fix is maybe a "select INFINIBAND".
Similar to the way NFS_FS select's SUNRPC. Will correct
this in either case.

Tom.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-09-20 21:13:48

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

On Thu, 2007-09-20 at 17:03 -0400, Talpey, Thomas wrote:
> At 04:55 PM 9/20/2007, Trond Myklebust wrote:
> >On Mon, 2007-09-10 at 13:49 -0400, Talpey, Thomas wrote:
> >
> >> +config SUNRPC_XPRT_RDMA
> >> + tristate "RDMA transport for sunrpc (EXPERIMENTAL)"
> >> + depends on SUNRPC && EXPERIMENTAL
> >> + default m
> >> + help
> >> + Adds a client RPC transport for supporting kernel NFS over RDMA
> >> + mounts, including Infiniband and iWARP. Experimental.
> >> +
> >
> >Hmm... There is a dependency on the Infiniband code that is missing
> >here. I'm getting the following compile errors:
>
> Ah - yes, you must have Infiniband or iWARP configured.
>
> Actually, I think the fix is maybe a "select INFINIBAND".
> Similar to the way NFS_FS select's SUNRPC. Will correct
> this in either case.

Please send it as an incremental patch.

Note, however, that automatically selecting INFINIBAND is never going to
suffice to make RDMA work: the user needs to configure the correct
hardware support too.
That makes me tend to prefer making it a 'depends on'...

Cheers
Trond


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-09-20 21:18:50

by Talpey, Thomas

[permalink] [raw]
Subject: Re: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

At 05:13 PM 9/20/2007, Trond Myklebust wrote:
>Please send it as an incremental patch.

Will do - have to wait for later unfortunately.

>Note, however, that automatically selecting INFINIBAND is never going to
>suffice to make RDMA work: the user needs to configure the correct
>hardware support too.
>That makes me tend to prefer making it a 'depends on'...

One reason to prefer "select" is that the option will disappear if
it "depends on" and INFINIBAND isn't turned on. That's not the
way RPC over sockets transports is visible. For example, if TCP is
off you still get SUNRPC.

Tom.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-09-20 21:25:58

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

On Thu, 2007-09-20 at 17:18 -0400, Talpey, Thomas wrote:

> One reason to prefer "select" is that the option will disappear if
> it "depends on" and INFINIBAND isn't turned on. That's not the
> way RPC over sockets transports is visible. For example, if TCP is
> off you still get SUNRPC.

Not really. If networking isn't defined, then it disappears.

I'd think that it would be fairly obvious to most people that if they
want to see an option to use NFS over RDMA, then they also have to
select an RDMA-capable transport.

Trond


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

2007-09-20 21:28:19

by Talpey, Thomas

[permalink] [raw]
Subject: Re: [PATCH 15/19] RPCRDMA: Kconfig and header file with rpcrdma protocol definitions

At 05:25 PM 9/20/2007, Trond Myklebust wrote:
>On Thu, 2007-09-20 at 17:18 -0400, Talpey, Thomas wrote:
>
>> One reason to prefer "select" is that the option will disappear if
>> it "depends on" and INFINIBAND isn't turned on. That's not the
>> way RPC over sockets transports is visible. For example, if TCP is
>> off you still get SUNRPC.
>
>Not really. If networking isn't defined, then it disappears.
>
>I'd think that it would be fairly obvious to most people that if they
>want to see an option to use NFS over RDMA, then they also have to
>select an RDMA-capable transport.

Ok. I guess I think; select NFS first, RDMA second! :-)

Tom.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs