2018-05-08 03:26:55 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
|
2007-12-13 06:13:17 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the BSD-type
|
|
|
|
* license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* Neither the name of the Network Appliance, Inc. nor the names of
|
|
|
|
* its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Author: Tom Tucker <tom@opengridcomputing.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SVC_RDMA_H
|
|
|
|
#define SVC_RDMA_H
|
|
|
|
#include <linux/sunrpc/xdr.h>
|
|
|
|
#include <linux/sunrpc/svcsock.h>
|
|
|
|
#include <linux/sunrpc/rpc_rdma.h>
|
|
|
|
#include <rdma/ib_verbs.h>
|
|
|
|
#include <rdma/rdma_cm.h>
|
|
|
|
#define SVCRDMA_DEBUG
|
|
|
|
|
2017-04-10 01:06:57 +08:00
|
|
|
/* Default and maximum inline threshold sizes */
|
|
|
|
enum {
|
|
|
|
RPCRDMA_DEF_INLINE_THRESH = 4096,
|
|
|
|
RPCRDMA_MAX_INLINE_THRESH = 65536
|
|
|
|
};
|
|
|
|
|
2007-12-13 06:13:17 +08:00
|
|
|
/* RPC/RDMA parameters and stats */
|
|
|
|
extern unsigned int svcrdma_ord;
|
|
|
|
extern unsigned int svcrdma_max_requests;
|
2016-01-08 03:50:02 +08:00
|
|
|
extern unsigned int svcrdma_max_bc_requests;
|
2007-12-13 06:13:17 +08:00
|
|
|
extern unsigned int svcrdma_max_req_size;
|
|
|
|
|
|
|
|
extern atomic_t rdma_stat_recv;
|
|
|
|
extern atomic_t rdma_stat_read;
|
|
|
|
extern atomic_t rdma_stat_write;
|
|
|
|
extern atomic_t rdma_stat_sq_starve;
|
|
|
|
extern atomic_t rdma_stat_rq_starve;
|
|
|
|
extern atomic_t rdma_stat_rq_poll;
|
|
|
|
extern atomic_t rdma_stat_rq_prod;
|
|
|
|
extern atomic_t rdma_stat_sq_poll;
|
|
|
|
extern atomic_t rdma_stat_sq_prod;
|
|
|
|
|
|
|
|
struct svcxprt_rdma {
|
|
|
|
struct svc_xprt sc_xprt; /* SVC transport structure */
|
|
|
|
struct rdma_cm_id *sc_cm_id; /* RDMA connection id */
|
|
|
|
struct list_head sc_accept_q; /* Conn. waiting accept */
|
|
|
|
int sc_ord; /* RDMA read limit */
|
2018-05-08 03:28:09 +08:00
|
|
|
int sc_max_send_sges;
|
2016-09-13 22:53:23 +08:00
|
|
|
bool sc_snd_w_inv; /* OK to use Send With Invalidate */
|
2007-12-13 06:13:17 +08:00
|
|
|
|
2016-11-30 00:04:50 +08:00
|
|
|
atomic_t sc_sq_avail; /* SQEs ready to be consumed */
|
2016-01-08 03:50:02 +08:00
|
|
|
unsigned int sc_sq_depth; /* Depth of SQ */
|
2017-02-08 00:58:23 +08:00
|
|
|
__be32 sc_fc_credits; /* Forward credits */
|
|
|
|
u32 sc_max_requests; /* Max requests */
|
2016-01-08 03:50:02 +08:00
|
|
|
u32 sc_max_bc_requests;/* Backward credits */
|
2007-12-13 06:13:17 +08:00
|
|
|
int sc_max_req_size; /* Size of each RQ WR buf */
|
2017-04-10 01:06:16 +08:00
|
|
|
u8 sc_port_num;
|
2007-12-13 06:13:17 +08:00
|
|
|
|
|
|
|
struct ib_pd *sc_pd;
|
|
|
|
|
2018-05-08 03:28:04 +08:00
|
|
|
spinlock_t sc_send_lock;
|
|
|
|
struct list_head sc_send_ctxts;
|
2017-04-10 01:06:16 +08:00
|
|
|
spinlock_t sc_rw_ctxt_lock;
|
|
|
|
struct list_head sc_rw_ctxts;
|
2016-01-08 03:49:12 +08:00
|
|
|
|
2007-12-13 06:13:17 +08:00
|
|
|
struct list_head sc_rq_dto_q;
|
|
|
|
spinlock_t sc_rq_dto_lock;
|
|
|
|
struct ib_qp *sc_qp;
|
|
|
|
struct ib_cq *sc_rq_cq;
|
|
|
|
struct ib_cq *sc_sq_cq;
|
|
|
|
|
|
|
|
spinlock_t sc_lock; /* transport lock */
|
|
|
|
|
|
|
|
wait_queue_head_t sc_send_wait; /* SQ exhaustion waitlist */
|
|
|
|
unsigned long sc_flags;
|
|
|
|
struct list_head sc_read_complete_q;
|
2008-05-01 11:00:46 +08:00
|
|
|
struct work_struct sc_work;
|
2018-05-08 03:27:21 +08:00
|
|
|
|
|
|
|
spinlock_t sc_recv_lock;
|
|
|
|
struct list_head sc_recv_ctxts;
|
2007-12-13 06:13:17 +08:00
|
|
|
};
|
|
|
|
/* sc_flags */
|
|
|
|
#define RDMAXPRT_CONN_PENDING 3
|
|
|
|
|
2018-10-02 02:16:11 +08:00
|
|
|
/*
|
|
|
|
* Default connection parameters
|
2016-01-08 03:50:02 +08:00
|
|
|
*/
|
2018-10-02 02:16:11 +08:00
|
|
|
enum {
|
|
|
|
RPCRDMA_LISTEN_BACKLOG = 10,
|
|
|
|
RPCRDMA_MAX_REQUESTS = 64,
|
|
|
|
RPCRDMA_MAX_BC_REQUESTS = 2,
|
|
|
|
};
|
2016-01-08 03:50:02 +08:00
|
|
|
|
2015-08-08 04:55:46 +08:00
|
|
|
#define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD
|
|
|
|
|
2018-05-08 03:27:21 +08:00
|
|
|
struct svc_rdma_recv_ctxt {
|
|
|
|
struct list_head rc_list;
|
|
|
|
struct ib_recv_wr rc_recv_wr;
|
|
|
|
struct ib_cqe rc_cqe;
|
2018-05-08 03:27:43 +08:00
|
|
|
struct ib_sge rc_recv_sge;
|
|
|
|
void *rc_recv_buf;
|
2018-05-08 03:27:21 +08:00
|
|
|
struct xdr_buf rc_arg;
|
2018-05-08 03:27:48 +08:00
|
|
|
bool rc_temp;
|
2018-05-08 03:27:21 +08:00
|
|
|
u32 rc_byte_len;
|
|
|
|
unsigned int rc_page_count;
|
|
|
|
unsigned int rc_hdr_count;
|
2018-11-28 00:11:35 +08:00
|
|
|
u32 rc_inv_rkey;
|
2018-05-08 03:27:21 +08:00
|
|
|
struct page *rc_pages[RPCSVC_MAXPAGES];
|
|
|
|
};
|
|
|
|
|
2018-05-08 03:28:04 +08:00
|
|
|
struct svc_rdma_send_ctxt {
|
|
|
|
struct list_head sc_list;
|
|
|
|
struct ib_send_wr sc_send_wr;
|
|
|
|
struct ib_cqe sc_cqe;
|
2018-05-08 03:28:25 +08:00
|
|
|
void *sc_xprt_buf;
|
2018-05-08 03:28:04 +08:00
|
|
|
int sc_page_count;
|
2018-05-08 03:28:09 +08:00
|
|
|
int sc_cur_sge_no;
|
2018-05-08 03:28:04 +08:00
|
|
|
struct page *sc_pages[RPCSVC_MAXPAGES];
|
2018-05-08 03:28:09 +08:00
|
|
|
struct ib_sge sc_sges[];
|
2018-05-08 03:28:04 +08:00
|
|
|
};
|
|
|
|
|
2016-01-08 03:50:10 +08:00
|
|
|
/* svc_rdma_backchannel.c */
|
|
|
|
extern int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt,
|
2017-04-10 01:06:49 +08:00
|
|
|
__be32 *rdma_resp,
|
2016-01-08 03:50:10 +08:00
|
|
|
struct xdr_buf *rcvbuf);
|
|
|
|
|
2007-12-13 06:13:17 +08:00
|
|
|
/* svc_rdma_recvfrom.c */
|
2018-05-08 03:27:21 +08:00
|
|
|
extern void svc_rdma_recv_ctxts_destroy(struct svcxprt_rdma *rdma);
|
|
|
|
extern bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma);
|
|
|
|
extern void svc_rdma_recv_ctxt_put(struct svcxprt_rdma *rdma,
|
2018-05-08 03:27:32 +08:00
|
|
|
struct svc_rdma_recv_ctxt *ctxt);
|
2018-05-08 03:27:21 +08:00
|
|
|
extern void svc_rdma_flush_recv_queues(struct svcxprt_rdma *rdma);
|
2007-12-13 06:13:17 +08:00
|
|
|
extern int svc_rdma_recvfrom(struct svc_rqst *);
|
|
|
|
|
2017-04-10 01:06:16 +08:00
|
|
|
/* svc_rdma_rw.c */
|
|
|
|
extern void svc_rdma_destroy_rw_ctxts(struct svcxprt_rdma *rdma);
|
2017-06-24 05:18:24 +08:00
|
|
|
extern int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma,
|
|
|
|
struct svc_rqst *rqstp,
|
2018-05-08 03:27:21 +08:00
|
|
|
struct svc_rdma_recv_ctxt *head, __be32 *p);
|
2017-04-10 01:06:16 +08:00
|
|
|
extern int svc_rdma_send_write_chunk(struct svcxprt_rdma *rdma,
|
|
|
|
__be32 *wr_ch, struct xdr_buf *xdr);
|
|
|
|
extern int svc_rdma_send_reply_chunk(struct svcxprt_rdma *rdma,
|
|
|
|
__be32 *rp_ch, bool writelist,
|
|
|
|
struct xdr_buf *xdr);
|
|
|
|
|
2007-12-13 06:13:17 +08:00
|
|
|
/* svc_rdma_sendto.c */
|
2018-05-08 03:28:04 +08:00
|
|
|
extern void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma);
|
|
|
|
extern struct svc_rdma_send_ctxt *
|
|
|
|
svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma);
|
|
|
|
extern void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
|
|
|
|
struct svc_rdma_send_ctxt *ctxt);
|
|
|
|
extern int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr);
|
2018-05-08 03:28:25 +08:00
|
|
|
extern void svc_rdma_sync_reply_hdr(struct svcxprt_rdma *rdma,
|
|
|
|
struct svc_rdma_send_ctxt *ctxt,
|
|
|
|
unsigned int len);
|
|
|
|
extern int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
|
2018-05-08 03:28:04 +08:00
|
|
|
struct svc_rdma_send_ctxt *ctxt,
|
2018-05-08 03:28:25 +08:00
|
|
|
struct xdr_buf *xdr, __be32 *wr_lst);
|
2007-12-13 06:13:17 +08:00
|
|
|
extern int svc_rdma_sendto(struct svc_rqst *);
|
|
|
|
|
|
|
|
/* svc_rdma_transport.c */
|
|
|
|
extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
|
|
|
|
extern void svc_sq_reap(struct svcxprt_rdma *);
|
|
|
|
extern void svc_rq_reap(struct svcxprt_rdma *);
|
|
|
|
|
2015-10-25 05:28:16 +08:00
|
|
|
extern struct svc_xprt_class svc_rdma_class;
|
|
|
|
#ifdef CONFIG_SUNRPC_BACKCHANNEL
|
|
|
|
extern struct svc_xprt_class svc_rdma_bc_class;
|
|
|
|
#endif
|
|
|
|
|
2007-12-13 06:13:17 +08:00
|
|
|
/* svc_rdma.c */
|
2016-01-08 03:49:28 +08:00
|
|
|
extern struct workqueue_struct *svc_rdma_wq;
|
2007-12-13 06:13:17 +08:00
|
|
|
extern int svc_rdma_init(void);
|
|
|
|
extern void svc_rdma_cleanup(void);
|
|
|
|
|
|
|
|
#endif
|