aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2016-06-29 13:53:27 -0400
committerAnna Schumaker <Anna.Schumaker@Netapp.com>2016-07-11 15:50:43 -0400
commitb54054ca5590f59469437fc4a78a978edcb01c31 (patch)
tree2523f55eee453aa189fa0fa8a482ee1ab35f695c
parenta473018cfe0ef1e46c0ff9df3fa02afc23c9f1d2 (diff)
xprtrdma: Clean up device capability detection
Clean up: Move device capability detection into memreg-specific source files. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Tested-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
-rw-r--r--net/sunrpc/xprtrdma/fmr_ops.c11
-rw-r--r--net/sunrpc/xprtrdma/frwr_ops.c17
-rw-r--r--net/sunrpc/xprtrdma/verbs.c43
-rw-r--r--net/sunrpc/xprtrdma/xprt_rdma.h2
4 files changed, 44 insertions, 29 deletions
diff --git a/net/sunrpc/xprtrdma/fmr_ops.c b/net/sunrpc/xprtrdma/fmr_ops.c
index 6c4527b6c3ca..8b6ce8ebe60f 100644
--- a/net/sunrpc/xprtrdma/fmr_ops.c
+++ b/net/sunrpc/xprtrdma/fmr_ops.c
@@ -34,6 +34,17 @@ enum {
34 IB_ACCESS_REMOTE_READ, 34 IB_ACCESS_REMOTE_READ,
35}; 35};
36 36
37bool
38fmr_is_supported(struct rpcrdma_ia *ia)
39{
40 if (!ia->ri_device->alloc_fmr) {
41 pr_info("rpcrdma: 'fmr' mode is not supported by device %s\n",
42 ia->ri_device->name);
43 return false;
44 }
45 return true;
46}
47
37static int 48static int
38__fmr_init(struct rpcrdma_mw *mw, struct ib_pd *pd) 49__fmr_init(struct rpcrdma_mw *mw, struct ib_pd *pd)
39{ 50{
diff --git a/net/sunrpc/xprtrdma/frwr_ops.c b/net/sunrpc/xprtrdma/frwr_ops.c
index c9ead2b01b66..fc2826b3518c 100644
--- a/net/sunrpc/xprtrdma/frwr_ops.c
+++ b/net/sunrpc/xprtrdma/frwr_ops.c
@@ -73,6 +73,23 @@
73# define RPCDBG_FACILITY RPCDBG_TRANS 73# define RPCDBG_FACILITY RPCDBG_TRANS
74#endif 74#endif
75 75
76bool
77frwr_is_supported(struct rpcrdma_ia *ia)
78{
79 struct ib_device_attr *attrs = &ia->ri_device->attrs;
80
81 if (!(attrs->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS))
82 goto out_not_supported;
83 if (attrs->max_fast_reg_page_list_len == 0)
84 goto out_not_supported;
85 return true;
86
87out_not_supported:
88 pr_info("rpcrdma: 'frwr' mode is not supported by device %s\n",
89 ia->ri_device->name);
90 return false;
91}
92
76static int 93static int
77__frwr_init(struct rpcrdma_mw *r, struct ib_pd *pd, unsigned int depth) 94__frwr_init(struct rpcrdma_mw *r, struct ib_pd *pd, unsigned int depth)
78{ 95{
diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
index b80e767fe687..cd4c5f1d554a 100644
--- a/net/sunrpc/xprtrdma/verbs.c
+++ b/net/sunrpc/xprtrdma/verbs.c
@@ -389,44 +389,29 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
389 ia->ri_pd = ib_alloc_pd(ia->ri_device); 389 ia->ri_pd = ib_alloc_pd(ia->ri_device);
390 if (IS_ERR(ia->ri_pd)) { 390 if (IS_ERR(ia->ri_pd)) {
391 rc = PTR_ERR(ia->ri_pd); 391 rc = PTR_ERR(ia->ri_pd);
392 dprintk("RPC: %s: ib_alloc_pd() failed %i\n", 392 pr_err("rpcrdma: ib_alloc_pd() returned %d\n", rc);
393 __func__, rc);
394 goto out2; 393 goto out2;
395 } 394 }
396 395
397 if (memreg == RPCRDMA_FRMR) {
398 if (!(ia->ri_device->attrs.device_cap_flags &
399 IB_DEVICE_MEM_MGT_EXTENSIONS) ||
400 (ia->ri_device->attrs.max_fast_reg_page_list_len == 0)) {
401 dprintk("RPC: %s: FRMR registration "
402 "not supported by HCA\n", __func__);
403 memreg = RPCRDMA_MTHCAFMR;
404 }
405 }
406 if (memreg == RPCRDMA_MTHCAFMR) {
407 if (!ia->ri_device->alloc_fmr) {
408 dprintk("RPC: %s: MTHCAFMR registration "
409 "not supported by HCA\n", __func__);
410 rc = -EINVAL;
411 goto out3;
412 }
413 }
414
415 switch (memreg) { 396 switch (memreg) {
416 case RPCRDMA_FRMR: 397 case RPCRDMA_FRMR:
417 ia->ri_ops = &rpcrdma_frwr_memreg_ops; 398 if (frwr_is_supported(ia)) {
418 break; 399 ia->ri_ops = &rpcrdma_frwr_memreg_ops;
400 break;
401 }
402 /*FALLTHROUGH*/
419 case RPCRDMA_MTHCAFMR: 403 case RPCRDMA_MTHCAFMR:
420 ia->ri_ops = &rpcrdma_fmr_memreg_ops; 404 if (fmr_is_supported(ia)) {
421 break; 405 ia->ri_ops = &rpcrdma_fmr_memreg_ops;
406 break;
407 }
408 /*FALLTHROUGH*/
422 default: 409 default:
423 printk(KERN_ERR "RPC: Unsupported memory " 410 pr_err("rpcrdma: Unsupported memory registration mode: %d\n",
424 "registration mode: %d\n", memreg); 411 memreg);
425 rc = -ENOMEM; 412 rc = -EINVAL;
426 goto out3; 413 goto out3;
427 } 414 }
428 dprintk("RPC: %s: memory registration strategy is '%s'\n",
429 __func__, ia->ri_ops->ro_displayname);
430 415
431 return 0; 416 return 0;
432 417
diff --git a/net/sunrpc/xprtrdma/xprt_rdma.h b/net/sunrpc/xprtrdma/xprt_rdma.h
index f1b6f2fb5355..08d441d65a83 100644
--- a/net/sunrpc/xprtrdma/xprt_rdma.h
+++ b/net/sunrpc/xprtrdma/xprt_rdma.h
@@ -446,6 +446,8 @@ extern int xprt_rdma_pad_optimize;
446 */ 446 */
447int rpcrdma_ia_open(struct rpcrdma_xprt *, struct sockaddr *, int); 447int rpcrdma_ia_open(struct rpcrdma_xprt *, struct sockaddr *, int);
448void rpcrdma_ia_close(struct rpcrdma_ia *); 448void rpcrdma_ia_close(struct rpcrdma_ia *);
449bool frwr_is_supported(struct rpcrdma_ia *);
450bool fmr_is_supported(struct rpcrdma_ia *);
449 451
450/* 452/*
451 * Endpoint calls - xprtrdma/verbs.c 453 * Endpoint calls - xprtrdma/verbs.c