Commit 86c4ccd9 authored by Chuck Lever's avatar Chuck Lever Committed by Anna Schumaker

xprtrdma: Eliminate struct rpcrdma_create_data_internal

Clean up.

Move the remaining field in rpcrdma_create_data_internal so the
structure can be removed.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 94087e97
...@@ -194,12 +194,11 @@ int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr) ...@@ -194,12 +194,11 @@ int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr)
* frwr_open - Prepare an endpoint for use with FRWR * frwr_open - Prepare an endpoint for use with FRWR
* @ia: interface adapter this endpoint will use * @ia: interface adapter this endpoint will use
* @ep: endpoint to prepare * @ep: endpoint to prepare
* @cdata: transport parameters
* *
* On success, sets: * On success, sets:
* ep->rep_attr.cap.max_send_wr * ep->rep_attr.cap.max_send_wr
* ep->rep_attr.cap.max_recv_wr * ep->rep_attr.cap.max_recv_wr
* cdata->max_requests * ep->rep_max_requests
* ia->ri_max_segs * ia->ri_max_segs
* *
* And these FRWR-related fields: * And these FRWR-related fields:
...@@ -208,8 +207,7 @@ int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr) ...@@ -208,8 +207,7 @@ int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr)
* *
* On failure, a negative errno is returned. * On failure, a negative errno is returned.
*/ */
int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep)
struct rpcrdma_create_data_internal *cdata)
{ {
struct ib_device_attr *attrs = &ia->ri_id->device->attrs; struct ib_device_attr *attrs = &ia->ri_id->device->attrs;
int max_qp_wr, depth, delta; int max_qp_wr, depth, delta;
...@@ -258,19 +256,18 @@ int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, ...@@ -258,19 +256,18 @@ int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
max_qp_wr -= 1; max_qp_wr -= 1;
if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE) if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE)
return -ENOMEM; return -ENOMEM;
if (cdata->max_requests > max_qp_wr) if (ep->rep_max_requests > max_qp_wr)
cdata->max_requests = max_qp_wr; ep->rep_max_requests = max_qp_wr;
ep->rep_attr.cap.max_send_wr = cdata->max_requests * depth; ep->rep_attr.cap.max_send_wr = ep->rep_max_requests * depth;
if (ep->rep_attr.cap.max_send_wr > max_qp_wr) { if (ep->rep_attr.cap.max_send_wr > max_qp_wr) {
cdata->max_requests = max_qp_wr / depth; ep->rep_max_requests = max_qp_wr / depth;
if (!cdata->max_requests) if (!ep->rep_max_requests)
return -EINVAL; return -EINVAL;
ep->rep_attr.cap.max_send_wr = cdata->max_requests * ep->rep_attr.cap.max_send_wr = ep->rep_max_requests * depth;
depth;
} }
ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS; ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */ ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
ep->rep_attr.cap.max_recv_wr = cdata->max_requests; ep->rep_attr.cap.max_recv_wr = ep->rep_max_requests;
ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS; ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */ ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
* tunables * tunables
*/ */
static unsigned int xprt_rdma_slot_table_entries = RPCRDMA_DEF_SLOT_TABLE; unsigned int xprt_rdma_slot_table_entries = RPCRDMA_DEF_SLOT_TABLE;
unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE; unsigned int xprt_rdma_max_inline_read = RPCRDMA_DEF_INLINE;
unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE; unsigned int xprt_rdma_max_inline_write = RPCRDMA_DEF_INLINE;
unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRWR; unsigned int xprt_rdma_memreg_strategy = RPCRDMA_FRWR;
...@@ -288,7 +288,7 @@ xprt_rdma_destroy(struct rpc_xprt *xprt) ...@@ -288,7 +288,7 @@ xprt_rdma_destroy(struct rpc_xprt *xprt)
cancel_delayed_work_sync(&r_xprt->rx_connect_worker); cancel_delayed_work_sync(&r_xprt->rx_connect_worker);
rpcrdma_ep_destroy(&r_xprt->rx_ep, &r_xprt->rx_ia); rpcrdma_ep_destroy(r_xprt);
rpcrdma_buffer_destroy(&r_xprt->rx_buf); rpcrdma_buffer_destroy(&r_xprt->rx_buf);
rpcrdma_ia_close(&r_xprt->rx_ia); rpcrdma_ia_close(&r_xprt->rx_ia);
...@@ -311,10 +311,8 @@ static const struct rpc_timeout xprt_rdma_default_timeout = { ...@@ -311,10 +311,8 @@ static const struct rpc_timeout xprt_rdma_default_timeout = {
static struct rpc_xprt * static struct rpc_xprt *
xprt_setup_rdma(struct xprt_create *args) xprt_setup_rdma(struct xprt_create *args)
{ {
struct rpcrdma_create_data_internal cdata;
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
struct rpcrdma_xprt *new_xprt; struct rpcrdma_xprt *new_xprt;
struct rpcrdma_ep *new_ep;
struct sockaddr *sap; struct sockaddr *sap;
int rc; int rc;
...@@ -349,29 +347,12 @@ xprt_setup_rdma(struct xprt_create *args) ...@@ -349,29 +347,12 @@ xprt_setup_rdma(struct xprt_create *args)
xprt_set_bound(xprt); xprt_set_bound(xprt);
xprt_rdma_format_addresses(xprt, sap); xprt_rdma_format_addresses(xprt, sap);
cdata.max_requests = xprt_rdma_slot_table_entries;
/*
* Create new transport instance, which includes initialized
* o ia
* o endpoint
* o buffers
*/
new_xprt = rpcx_to_rdmax(xprt); new_xprt = rpcx_to_rdmax(xprt);
rc = rpcrdma_ia_open(new_xprt); rc = rpcrdma_ia_open(new_xprt);
if (rc) if (rc)
goto out1; goto out1;
/* rc = rpcrdma_ep_create(new_xprt);
* initialize and create ep
*/
new_xprt->rx_data = cdata;
new_ep = &new_xprt->rx_ep;
rc = rpcrdma_ep_create(&new_xprt->rx_ep,
&new_xprt->rx_ia, &new_xprt->rx_data);
if (rc) if (rc)
goto out2; goto out2;
...@@ -402,7 +383,7 @@ xprt_setup_rdma(struct xprt_create *args) ...@@ -402,7 +383,7 @@ xprt_setup_rdma(struct xprt_create *args)
rpcrdma_buffer_destroy(&new_xprt->rx_buf); rpcrdma_buffer_destroy(&new_xprt->rx_buf);
rc = -ENODEV; rc = -ENODEV;
out3: out3:
rpcrdma_ep_destroy(new_ep, &new_xprt->rx_ia); rpcrdma_ep_destroy(new_xprt);
out2: out2:
rpcrdma_ia_close(&new_xprt->rx_ia); rpcrdma_ia_close(&new_xprt->rx_ia);
out1: out1:
......
...@@ -476,18 +476,22 @@ rpcrdma_ia_close(struct rpcrdma_ia *ia) ...@@ -476,18 +476,22 @@ rpcrdma_ia_close(struct rpcrdma_ia *ia)
ia->ri_pd = NULL; ia->ri_pd = NULL;
} }
/* /**
* Create unconnected endpoint. * rpcrdma_ep_create - Create unconnected endpoint
* @r_xprt: transport to instantiate
*
* Returns zero on success, or a negative errno.
*/ */
int int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt)
rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
struct rpcrdma_create_data_internal *cdata)
{ {
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private; struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private;
struct ib_cq *sendcq, *recvcq; struct ib_cq *sendcq, *recvcq;
unsigned int max_sge; unsigned int max_sge;
int rc; int rc;
ep->rep_max_requests = xprt_rdma_slot_table_entries;
ep->rep_inline_send = xprt_rdma_max_inline_write; ep->rep_inline_send = xprt_rdma_max_inline_write;
ep->rep_inline_recv = xprt_rdma_max_inline_read; ep->rep_inline_recv = xprt_rdma_max_inline_read;
...@@ -499,7 +503,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia, ...@@ -499,7 +503,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
} }
ia->ri_max_send_sges = max_sge; ia->ri_max_send_sges = max_sge;
rc = frwr_open(ia, ep, cdata); rc = frwr_open(ia, ep);
if (rc) if (rc)
return rc; return rc;
...@@ -521,7 +525,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia, ...@@ -521,7 +525,7 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
ep->rep_attr.cap.max_send_sge, ep->rep_attr.cap.max_send_sge,
ep->rep_attr.cap.max_recv_sge); ep->rep_attr.cap.max_recv_sge);
ep->rep_send_batch = cdata->max_requests >> 3; ep->rep_send_batch = ep->rep_max_requests >> 3;
ep->rep_send_count = ep->rep_send_batch; ep->rep_send_count = ep->rep_send_batch;
init_waitqueue_head(&ep->rep_connect_wait); init_waitqueue_head(&ep->rep_connect_wait);
ep->rep_receive_count = 0; ep->rep_receive_count = 0;
...@@ -584,16 +588,16 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia, ...@@ -584,16 +588,16 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
return rc; return rc;
} }
/* /**
* rpcrdma_ep_destroy * rpcrdma_ep_destroy - Disconnect and destroy endpoint.
* @r_xprt: transport instance to shut down
* *
* Disconnect and destroy endpoint. After this, the only
* valid operations on the ep are to free it (if dynamically
* allocated) or re-create it.
*/ */
void void rpcrdma_ep_destroy(struct rpcrdma_xprt *r_xprt)
rpcrdma_ep_destroy(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
{ {
struct rpcrdma_ep *ep = &r_xprt->rx_ep;
struct rpcrdma_ia *ia = &r_xprt->rx_ia;
if (ia->ri_id && ia->ri_id->qp) { if (ia->ri_id && ia->ri_id->qp) {
rpcrdma_ep_disconnect(ep, ia); rpcrdma_ep_disconnect(ep, ia);
rdma_destroy_qp(ia->ri_id); rdma_destroy_qp(ia->ri_id);
...@@ -623,7 +627,7 @@ rpcrdma_ep_recreate_xprt(struct rpcrdma_xprt *r_xprt, ...@@ -623,7 +627,7 @@ rpcrdma_ep_recreate_xprt(struct rpcrdma_xprt *r_xprt,
goto out1; goto out1;
rc = -ENOMEM; rc = -ENOMEM;
err = rpcrdma_ep_create(ep, ia, &r_xprt->rx_data); err = rpcrdma_ep_create(r_xprt);
if (err) { if (err) {
pr_err("rpcrdma: rpcrdma_ep_create returned %d\n", err); pr_err("rpcrdma: rpcrdma_ep_create returned %d\n", err);
goto out2; goto out2;
...@@ -640,7 +644,7 @@ rpcrdma_ep_recreate_xprt(struct rpcrdma_xprt *r_xprt, ...@@ -640,7 +644,7 @@ rpcrdma_ep_recreate_xprt(struct rpcrdma_xprt *r_xprt,
return 0; return 0;
out3: out3:
rpcrdma_ep_destroy(ep, ia); rpcrdma_ep_destroy(r_xprt);
out2: out2:
rpcrdma_ia_close(ia); rpcrdma_ia_close(ia);
out1: out1:
...@@ -1082,14 +1086,19 @@ static bool rpcrdma_rep_create(struct rpcrdma_xprt *r_xprt, bool temp) ...@@ -1082,14 +1086,19 @@ static bool rpcrdma_rep_create(struct rpcrdma_xprt *r_xprt, bool temp)
return false; return false;
} }
int /**
rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt) * rpcrdma_buffer_create - Create initial set of req/rep objects
* @r_xprt: transport instance to (re)initialize
*
* Returns zero on success, otherwise a negative errno.
*/
int rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt)
{ {
struct rpcrdma_buffer *buf = &r_xprt->rx_buf; struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
int i, rc; int i, rc;
buf->rb_flags = 0; buf->rb_flags = 0;
buf->rb_max_requests = r_xprt->rx_data.max_requests; buf->rb_max_requests = r_xprt->rx_ep.rep_max_requests;
buf->rb_bc_srv_max_requests = 0; buf->rb_bc_srv_max_requests = 0;
spin_lock_init(&buf->rb_mrlock); spin_lock_init(&buf->rb_mrlock);
spin_lock_init(&buf->rb_lock); spin_lock_init(&buf->rb_lock);
......
...@@ -97,6 +97,7 @@ struct rpcrdma_ep { ...@@ -97,6 +97,7 @@ struct rpcrdma_ep {
wait_queue_head_t rep_connect_wait; wait_queue_head_t rep_connect_wait;
struct rpcrdma_connect_private rep_cm_private; struct rpcrdma_connect_private rep_cm_private;
struct rdma_conn_param rep_remote_cma; struct rdma_conn_param rep_remote_cma;
unsigned int rep_max_requests; /* set by /proc */
unsigned int rep_inline_send; /* negotiated */ unsigned int rep_inline_send; /* negotiated */
unsigned int rep_inline_recv; /* negotiated */ unsigned int rep_inline_recv; /* negotiated */
int rep_receive_count; int rep_receive_count;
...@@ -413,16 +414,6 @@ enum { ...@@ -413,16 +414,6 @@ enum {
RPCRDMA_BUF_F_EMPTY_SCQ = 0, RPCRDMA_BUF_F_EMPTY_SCQ = 0,
}; };
/*
* Internal structure for transport instance creation. This
* exists primarily for modularity.
*
* This data should be set with mount options
*/
struct rpcrdma_create_data_internal {
unsigned int max_requests; /* max requests (slots) in flight */
};
/* /*
* Statistics for RPCRDMA * Statistics for RPCRDMA
*/ */
...@@ -467,13 +458,11 @@ struct rpcrdma_xprt { ...@@ -467,13 +458,11 @@ struct rpcrdma_xprt {
struct rpcrdma_ia rx_ia; struct rpcrdma_ia rx_ia;
struct rpcrdma_ep rx_ep; struct rpcrdma_ep rx_ep;
struct rpcrdma_buffer rx_buf; struct rpcrdma_buffer rx_buf;
struct rpcrdma_create_data_internal rx_data;
struct delayed_work rx_connect_worker; struct delayed_work rx_connect_worker;
struct rpcrdma_stats rx_stats; struct rpcrdma_stats rx_stats;
}; };
#define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, rx_xprt) #define rpcx_to_rdmax(x) container_of(x, struct rpcrdma_xprt, rx_xprt)
#define rpcx_to_rdmad(x) (rpcx_to_rdmax(x)->rx_data)
static inline const char * static inline const char *
rpcrdma_addrstr(const struct rpcrdma_xprt *r_xprt) rpcrdma_addrstr(const struct rpcrdma_xprt *r_xprt)
...@@ -507,9 +496,8 @@ void rpcrdma_ia_close(struct rpcrdma_ia *); ...@@ -507,9 +496,8 @@ void rpcrdma_ia_close(struct rpcrdma_ia *);
/* /*
* Endpoint calls - xprtrdma/verbs.c * Endpoint calls - xprtrdma/verbs.c
*/ */
int rpcrdma_ep_create(struct rpcrdma_ep *, struct rpcrdma_ia *, int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt);
struct rpcrdma_create_data_internal *); void rpcrdma_ep_destroy(struct rpcrdma_xprt *r_xprt);
void rpcrdma_ep_destroy(struct rpcrdma_ep *, struct rpcrdma_ia *);
int rpcrdma_ep_connect(struct rpcrdma_ep *, struct rpcrdma_ia *); int rpcrdma_ep_connect(struct rpcrdma_ep *, struct rpcrdma_ia *);
void rpcrdma_ep_disconnect(struct rpcrdma_ep *, struct rpcrdma_ia *); void rpcrdma_ep_disconnect(struct rpcrdma_ep *, struct rpcrdma_ia *);
...@@ -583,8 +571,7 @@ rpcrdma_data_dir(bool writing) ...@@ -583,8 +571,7 @@ rpcrdma_data_dir(bool writing)
/* Memory registration calls xprtrdma/frwr_ops.c /* Memory registration calls xprtrdma/frwr_ops.c
*/ */
bool frwr_is_supported(struct ib_device *device); bool frwr_is_supported(struct ib_device *device);
int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep, int frwr_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep);
struct rpcrdma_create_data_internal *cdata);
int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr); int frwr_init_mr(struct rpcrdma_ia *ia, struct rpcrdma_mr *mr);
void frwr_release_mr(struct rpcrdma_mr *mr); void frwr_release_mr(struct rpcrdma_mr *mr);
size_t frwr_maxpages(struct rpcrdma_xprt *r_xprt); size_t frwr_maxpages(struct rpcrdma_xprt *r_xprt);
...@@ -630,6 +617,7 @@ static inline void rpcrdma_set_xdrlen(struct xdr_buf *xdr, size_t len) ...@@ -630,6 +617,7 @@ static inline void rpcrdma_set_xdrlen(struct xdr_buf *xdr, size_t len)
/* RPC/RDMA module init - xprtrdma/transport.c /* RPC/RDMA module init - xprtrdma/transport.c
*/ */
extern unsigned int xprt_rdma_slot_table_entries;
extern unsigned int xprt_rdma_max_inline_read; extern unsigned int xprt_rdma_max_inline_read;
extern unsigned int xprt_rdma_max_inline_write; extern unsigned int xprt_rdma_max_inline_write;
void xprt_rdma_format_addresses(struct rpc_xprt *xprt, struct sockaddr *sap); void xprt_rdma_format_addresses(struct rpc_xprt *xprt, struct sockaddr *sap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment