xprtrdma: Fall back to MTHCAFMR when FRMR is not supported
authorChuck Lever <chuck.lever@oracle.com>
Wed, 28 May 2014 14:32:51 +0000 (10:32 -0400)
committerAnna Schumaker <Anna.Schumaker@Netapp.com>
Wed, 4 Jun 2014 12:56:39 +0000 (08:56 -0400)
An audit of in-kernel RDMA providers that do not support the FRMR
memory registration shows that several of them support MTHCAFMR.
Prefer MTHCAFMR when FRMR is not supported.

If MTHCAFMR is not supported, only then choose ALLPHYSICAL.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
net/sunrpc/xprtrdma/verbs.c

index 6bb9a07f7d491959043997e9a6daab3f47336dfc..a3527989f5b3edeb106a4be210c4b40fd8741a38 100644 (file)
@@ -491,33 +491,32 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
                ia->ri_dma_lkey = ia->ri_id->device->local_dma_lkey;
        }
 
-       switch (memreg) {
-       case RPCRDMA_MTHCAFMR:
-               if (!ia->ri_id->device->alloc_fmr) {
-                       dprintk("RPC:       %s: MTHCAFMR registration "
-                               "specified but not supported by adapter, "
-                               "using riskier RPCRDMA_ALLPHYSICAL\n",
-                               __func__);
-                       memreg = RPCRDMA_ALLPHYSICAL;
-               }
-               break;
-       case RPCRDMA_FRMR:
+       if (memreg == RPCRDMA_FRMR) {
                /* Requires both frmr reg and local dma lkey */
                if ((devattr.device_cap_flags &
                     (IB_DEVICE_MEM_MGT_EXTENSIONS|IB_DEVICE_LOCAL_DMA_LKEY)) !=
                    (IB_DEVICE_MEM_MGT_EXTENSIONS|IB_DEVICE_LOCAL_DMA_LKEY)) {
                        dprintk("RPC:       %s: FRMR registration "
-                               "specified but not supported by adapter, "
-                               "using riskier RPCRDMA_ALLPHYSICAL\n",
-                               __func__);
-                       memreg = RPCRDMA_ALLPHYSICAL;
+                               "not supported by HCA\n", __func__);
+                       memreg = RPCRDMA_MTHCAFMR;
                } else {
                        /* Mind the ia limit on FRMR page list depth */
                        ia->ri_max_frmr_depth = min_t(unsigned int,
                                RPCRDMA_MAX_DATA_SEGS,
                                devattr.max_fast_reg_page_list_len);
                }
-               break;
+       }
+       if (memreg == RPCRDMA_MTHCAFMR) {
+               if (!ia->ri_id->device->alloc_fmr) {
+                       dprintk("RPC:       %s: MTHCAFMR registration "
+                               "not supported by HCA\n", __func__);
+#if RPCRDMA_PERSISTENT_REGISTRATION
+                       memreg = RPCRDMA_ALLPHYSICAL;
+#else
+                       rc = -EINVAL;
+                       goto out2;
+#endif
+               }
        }
 
        /*