| .. | .. |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | #ifndef SVC_RDMA_H |
|---|
| 44 | 44 | #define SVC_RDMA_H |
|---|
| 45 | +#include <linux/llist.h> |
|---|
| 45 | 46 | #include <linux/sunrpc/xdr.h> |
|---|
| 46 | 47 | #include <linux/sunrpc/svcsock.h> |
|---|
| 47 | 48 | #include <linux/sunrpc/rpc_rdma.h> |
|---|
| 49 | +#include <linux/sunrpc/rpc_rdma_cid.h> |
|---|
| 48 | 50 | #include <rdma/ib_verbs.h> |
|---|
| 49 | 51 | #include <rdma/rdma_cm.h> |
|---|
| 50 | | -#define SVCRDMA_DEBUG |
|---|
| 51 | 52 | |
|---|
| 52 | 53 | /* Default and maximum inline threshold sizes */ |
|---|
| 53 | 54 | enum { |
|---|
| 55 | + RPCRDMA_PULLUP_THRESH = RPCRDMA_V1_DEF_INLINE_SIZE >> 1, |
|---|
| 54 | 56 | RPCRDMA_DEF_INLINE_THRESH = 4096, |
|---|
| 55 | 57 | RPCRDMA_MAX_INLINE_THRESH = 65536 |
|---|
| 56 | 58 | }; |
|---|
| .. | .. |
|---|
| 107 | 109 | struct list_head sc_read_complete_q; |
|---|
| 108 | 110 | struct work_struct sc_work; |
|---|
| 109 | 111 | |
|---|
| 110 | | - spinlock_t sc_recv_lock; |
|---|
| 111 | | - struct list_head sc_recv_ctxts; |
|---|
| 112 | + struct llist_head sc_recv_ctxts; |
|---|
| 113 | + |
|---|
| 114 | + atomic_t sc_completion_ids; |
|---|
| 112 | 115 | }; |
|---|
| 113 | 116 | /* sc_flags */ |
|---|
| 114 | 117 | #define RDMAXPRT_CONN_PENDING 3 |
|---|
| 115 | 118 | |
|---|
| 116 | | -#define RPCRDMA_LISTEN_BACKLOG 10 |
|---|
| 117 | | -#define RPCRDMA_MAX_REQUESTS 32 |
|---|
| 118 | | - |
|---|
| 119 | | -/* Typical ULP usage of BC requests is NFSv4.1 backchannel. Our |
|---|
| 120 | | - * current NFSv4.1 implementation supports one backchannel slot. |
|---|
| 119 | +/* |
|---|
| 120 | + * Default connection parameters |
|---|
| 121 | 121 | */ |
|---|
| 122 | | -#define RPCRDMA_MAX_BC_REQUESTS 2 |
|---|
| 122 | +enum { |
|---|
| 123 | + RPCRDMA_LISTEN_BACKLOG = 10, |
|---|
| 124 | + RPCRDMA_MAX_REQUESTS = 64, |
|---|
| 125 | + RPCRDMA_MAX_BC_REQUESTS = 2, |
|---|
| 126 | +}; |
|---|
| 123 | 127 | |
|---|
| 124 | 128 | #define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD |
|---|
| 125 | 129 | |
|---|
| 126 | 130 | struct svc_rdma_recv_ctxt { |
|---|
| 131 | + struct llist_node rc_node; |
|---|
| 127 | 132 | struct list_head rc_list; |
|---|
| 128 | 133 | struct ib_recv_wr rc_recv_wr; |
|---|
| 129 | 134 | struct ib_cqe rc_cqe; |
|---|
| 135 | + struct rpc_rdma_cid rc_cid; |
|---|
| 130 | 136 | struct ib_sge rc_recv_sge; |
|---|
| 131 | 137 | void *rc_recv_buf; |
|---|
| 132 | 138 | struct xdr_buf rc_arg; |
|---|
| 139 | + struct xdr_stream rc_stream; |
|---|
| 133 | 140 | bool rc_temp; |
|---|
| 134 | 141 | u32 rc_byte_len; |
|---|
| 135 | 142 | unsigned int rc_page_count; |
|---|
| 136 | 143 | unsigned int rc_hdr_count; |
|---|
| 144 | + u32 rc_inv_rkey; |
|---|
| 145 | + __be32 *rc_write_list; |
|---|
| 146 | + __be32 *rc_reply_chunk; |
|---|
| 147 | + unsigned int rc_read_payload_offset; |
|---|
| 148 | + unsigned int rc_read_payload_length; |
|---|
| 137 | 149 | struct page *rc_pages[RPCSVC_MAXPAGES]; |
|---|
| 138 | 150 | }; |
|---|
| 139 | 151 | |
|---|
| 140 | 152 | struct svc_rdma_send_ctxt { |
|---|
| 141 | 153 | struct list_head sc_list; |
|---|
| 154 | + struct rpc_rdma_cid sc_cid; |
|---|
| 155 | + |
|---|
| 142 | 156 | struct ib_send_wr sc_send_wr; |
|---|
| 143 | 157 | struct ib_cqe sc_cqe; |
|---|
| 158 | + struct xdr_buf sc_hdrbuf; |
|---|
| 159 | + struct xdr_stream sc_stream; |
|---|
| 144 | 160 | void *sc_xprt_buf; |
|---|
| 145 | 161 | int sc_page_count; |
|---|
| 146 | 162 | int sc_cur_sge_no; |
|---|
| .. | .. |
|---|
| 149 | 165 | }; |
|---|
| 150 | 166 | |
|---|
| 151 | 167 | /* svc_rdma_backchannel.c */ |
|---|
| 152 | | -extern int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt, |
|---|
| 153 | | - __be32 *rdma_resp, |
|---|
| 154 | | - struct xdr_buf *rcvbuf); |
|---|
| 168 | +extern void svc_rdma_handle_bc_reply(struct svc_rqst *rqstp, |
|---|
| 169 | + struct svc_rdma_recv_ctxt *rctxt); |
|---|
| 155 | 170 | |
|---|
| 156 | 171 | /* svc_rdma_recvfrom.c */ |
|---|
| 157 | 172 | extern void svc_rdma_recv_ctxts_destroy(struct svcxprt_rdma *rdma); |
|---|
| .. | .. |
|---|
| 168 | 183 | struct svc_rqst *rqstp, |
|---|
| 169 | 184 | struct svc_rdma_recv_ctxt *head, __be32 *p); |
|---|
| 170 | 185 | extern int svc_rdma_send_write_chunk(struct svcxprt_rdma *rdma, |
|---|
| 171 | | - __be32 *wr_ch, struct xdr_buf *xdr); |
|---|
| 186 | + __be32 *wr_ch, struct xdr_buf *xdr, |
|---|
| 187 | + unsigned int offset, |
|---|
| 188 | + unsigned long length); |
|---|
| 172 | 189 | extern int svc_rdma_send_reply_chunk(struct svcxprt_rdma *rdma, |
|---|
| 173 | | - __be32 *rp_ch, bool writelist, |
|---|
| 190 | + const struct svc_rdma_recv_ctxt *rctxt, |
|---|
| 174 | 191 | struct xdr_buf *xdr); |
|---|
| 175 | 192 | |
|---|
| 176 | 193 | /* svc_rdma_sendto.c */ |
|---|
| .. | .. |
|---|
| 179 | 196 | svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma); |
|---|
| 180 | 197 | extern void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma, |
|---|
| 181 | 198 | struct svc_rdma_send_ctxt *ctxt); |
|---|
| 182 | | -extern int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr); |
|---|
| 183 | | -extern void svc_rdma_sync_reply_hdr(struct svcxprt_rdma *rdma, |
|---|
| 184 | | - struct svc_rdma_send_ctxt *ctxt, |
|---|
| 185 | | - unsigned int len); |
|---|
| 199 | +extern int svc_rdma_send(struct svcxprt_rdma *rdma, |
|---|
| 200 | + struct svc_rdma_send_ctxt *ctxt); |
|---|
| 186 | 201 | extern int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma, |
|---|
| 187 | | - struct svc_rdma_send_ctxt *ctxt, |
|---|
| 188 | | - struct xdr_buf *xdr, __be32 *wr_lst); |
|---|
| 202 | + struct svc_rdma_send_ctxt *sctxt, |
|---|
| 203 | + const struct svc_rdma_recv_ctxt *rctxt, |
|---|
| 204 | + struct xdr_buf *xdr); |
|---|
| 205 | +extern void svc_rdma_send_error_msg(struct svcxprt_rdma *rdma, |
|---|
| 206 | + struct svc_rdma_send_ctxt *sctxt, |
|---|
| 207 | + struct svc_rdma_recv_ctxt *rctxt, |
|---|
| 208 | + int status); |
|---|
| 189 | 209 | extern int svc_rdma_sendto(struct svc_rqst *); |
|---|
| 210 | +extern int svc_rdma_read_payload(struct svc_rqst *rqstp, unsigned int offset, |
|---|
| 211 | + unsigned int length); |
|---|
| 190 | 212 | |
|---|
| 191 | 213 | /* svc_rdma_transport.c */ |
|---|
| 192 | | -extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *); |
|---|
| 193 | | -extern void svc_sq_reap(struct svcxprt_rdma *); |
|---|
| 194 | | -extern void svc_rq_reap(struct svcxprt_rdma *); |
|---|
| 195 | | -extern void svc_rdma_prep_reply_hdr(struct svc_rqst *); |
|---|
| 196 | | - |
|---|
| 197 | 214 | extern struct svc_xprt_class svc_rdma_class; |
|---|
| 198 | 215 | #ifdef CONFIG_SUNRPC_BACKCHANNEL |
|---|
| 199 | 216 | extern struct svc_xprt_class svc_rdma_bc_class; |
|---|
| 200 | 217 | #endif |
|---|
| 201 | 218 | |
|---|
| 202 | 219 | /* svc_rdma.c */ |
|---|
| 203 | | -extern struct workqueue_struct *svc_rdma_wq; |
|---|
| 204 | 220 | extern int svc_rdma_init(void); |
|---|
| 205 | 221 | extern void svc_rdma_cleanup(void); |
|---|
| 206 | 222 | |
|---|