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>
This commit is contained in:
parent
a473018cfe
commit
b54054ca55
|
@ -34,6 +34,17 @@ enum {
|
||||||
IB_ACCESS_REMOTE_READ,
|
IB_ACCESS_REMOTE_READ,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool
|
||||||
|
fmr_is_supported(struct rpcrdma_ia *ia)
|
||||||
|
{
|
||||||
|
if (!ia->ri_device->alloc_fmr) {
|
||||||
|
pr_info("rpcrdma: 'fmr' mode is not supported by device %s\n",
|
||||||
|
ia->ri_device->name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__fmr_init(struct rpcrdma_mw *mw, struct ib_pd *pd)
|
__fmr_init(struct rpcrdma_mw *mw, struct ib_pd *pd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -73,6 +73,23 @@
|
||||||
# define RPCDBG_FACILITY RPCDBG_TRANS
|
# define RPCDBG_FACILITY RPCDBG_TRANS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool
|
||||||
|
frwr_is_supported(struct rpcrdma_ia *ia)
|
||||||
|
{
|
||||||
|
struct ib_device_attr *attrs = &ia->ri_device->attrs;
|
||||||
|
|
||||||
|
if (!(attrs->device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS))
|
||||||
|
goto out_not_supported;
|
||||||
|
if (attrs->max_fast_reg_page_list_len == 0)
|
||||||
|
goto out_not_supported;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
out_not_supported:
|
||||||
|
pr_info("rpcrdma: 'frwr' mode is not supported by device %s\n",
|
||||||
|
ia->ri_device->name);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
__frwr_init(struct rpcrdma_mw *r, struct ib_pd *pd, unsigned int depth)
|
__frwr_init(struct rpcrdma_mw *r, struct ib_pd *pd, unsigned int depth)
|
||||||
{
|
{
|
||||||
|
|
|
@ -389,44 +389,29 @@ rpcrdma_ia_open(struct rpcrdma_xprt *xprt, struct sockaddr *addr, int memreg)
|
||||||
ia->ri_pd = ib_alloc_pd(ia->ri_device);
|
ia->ri_pd = ib_alloc_pd(ia->ri_device);
|
||||||
if (IS_ERR(ia->ri_pd)) {
|
if (IS_ERR(ia->ri_pd)) {
|
||||||
rc = PTR_ERR(ia->ri_pd);
|
rc = PTR_ERR(ia->ri_pd);
|
||||||
dprintk("RPC: %s: ib_alloc_pd() failed %i\n",
|
pr_err("rpcrdma: ib_alloc_pd() returned %d\n", rc);
|
||||||
__func__, rc);
|
|
||||||
goto out2;
|
goto out2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memreg == RPCRDMA_FRMR) {
|
|
||||||
if (!(ia->ri_device->attrs.device_cap_flags &
|
|
||||||
IB_DEVICE_MEM_MGT_EXTENSIONS) ||
|
|
||||||
(ia->ri_device->attrs.max_fast_reg_page_list_len == 0)) {
|
|
||||||
dprintk("RPC: %s: FRMR registration "
|
|
||||||
"not supported by HCA\n", __func__);
|
|
||||||
memreg = RPCRDMA_MTHCAFMR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (memreg == RPCRDMA_MTHCAFMR) {
|
|
||||||
if (!ia->ri_device->alloc_fmr) {
|
|
||||||
dprintk("RPC: %s: MTHCAFMR registration "
|
|
||||||
"not supported by HCA\n", __func__);
|
|
||||||
rc = -EINVAL;
|
|
||||||
goto out3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (memreg) {
|
switch (memreg) {
|
||||||
case RPCRDMA_FRMR:
|
case RPCRDMA_FRMR:
|
||||||
ia->ri_ops = &rpcrdma_frwr_memreg_ops;
|
if (frwr_is_supported(ia)) {
|
||||||
break;
|
ia->ri_ops = &rpcrdma_frwr_memreg_ops;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*FALLTHROUGH*/
|
||||||
case RPCRDMA_MTHCAFMR:
|
case RPCRDMA_MTHCAFMR:
|
||||||
ia->ri_ops = &rpcrdma_fmr_memreg_ops;
|
if (fmr_is_supported(ia)) {
|
||||||
break;
|
ia->ri_ops = &rpcrdma_fmr_memreg_ops;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/*FALLTHROUGH*/
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR "RPC: Unsupported memory "
|
pr_err("rpcrdma: Unsupported memory registration mode: %d\n",
|
||||||
"registration mode: %d\n", memreg);
|
memreg);
|
||||||
rc = -ENOMEM;
|
rc = -EINVAL;
|
||||||
goto out3;
|
goto out3;
|
||||||
}
|
}
|
||||||
dprintk("RPC: %s: memory registration strategy is '%s'\n",
|
|
||||||
__func__, ia->ri_ops->ro_displayname);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -446,6 +446,8 @@ extern int xprt_rdma_pad_optimize;
|
||||||
*/
|
*/
|
||||||
int rpcrdma_ia_open(struct rpcrdma_xprt *, struct sockaddr *, int);
|
int rpcrdma_ia_open(struct rpcrdma_xprt *, struct sockaddr *, int);
|
||||||
void rpcrdma_ia_close(struct rpcrdma_ia *);
|
void rpcrdma_ia_close(struct rpcrdma_ia *);
|
||||||
|
bool frwr_is_supported(struct rpcrdma_ia *);
|
||||||
|
bool fmr_is_supported(struct rpcrdma_ia *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Endpoint calls - xprtrdma/verbs.c
|
* Endpoint calls - xprtrdma/verbs.c
|
||||||
|
|
Loading…
Reference in New Issue