Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.8-rc2 216 lines 7.6 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ 2/* 3 * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved. 4 * 5 * This software is available to you under a choice of one of two 6 * licenses. You may choose to be licensed under the terms of the GNU 7 * General Public License (GPL) Version 2, available from the file 8 * COPYING in the main directory of this source tree, or the BSD-type 9 * license below: 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 15 * Redistributions of source code must retain the above copyright 16 * notice, this list of conditions and the following disclaimer. 17 * 18 * Redistributions in binary form must reproduce the above 19 * copyright notice, this list of conditions and the following 20 * disclaimer in the documentation and/or other materials provided 21 * with the distribution. 22 * 23 * Neither the name of the Network Appliance, Inc. nor the names of 24 * its contributors may be used to endorse or promote products 25 * derived from this software without specific prior written 26 * permission. 27 * 28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 * 40 * Author: Tom Tucker <tom@opengridcomputing.com> 41 */ 42 43#ifndef SVC_RDMA_H 44#define SVC_RDMA_H 45#include <linux/llist.h> 46#include <linux/sunrpc/xdr.h> 47#include <linux/sunrpc/svcsock.h> 48#include <linux/sunrpc/rpc_rdma.h> 49#include <rdma/ib_verbs.h> 50#include <rdma/rdma_cm.h> 51 52/* Default and maximum inline threshold sizes */ 53enum { 54 RPCRDMA_PULLUP_THRESH = RPCRDMA_V1_DEF_INLINE_SIZE >> 1, 55 RPCRDMA_DEF_INLINE_THRESH = 4096, 56 RPCRDMA_MAX_INLINE_THRESH = 65536 57}; 58 59/* RPC/RDMA parameters and stats */ 60extern unsigned int svcrdma_ord; 61extern unsigned int svcrdma_max_requests; 62extern unsigned int svcrdma_max_bc_requests; 63extern unsigned int svcrdma_max_req_size; 64 65extern atomic_t rdma_stat_recv; 66extern atomic_t rdma_stat_read; 67extern atomic_t rdma_stat_write; 68extern atomic_t rdma_stat_sq_starve; 69extern atomic_t rdma_stat_rq_starve; 70extern atomic_t rdma_stat_rq_poll; 71extern atomic_t rdma_stat_rq_prod; 72extern atomic_t rdma_stat_sq_poll; 73extern atomic_t rdma_stat_sq_prod; 74 75struct svcxprt_rdma { 76 struct svc_xprt sc_xprt; /* SVC transport structure */ 77 struct rdma_cm_id *sc_cm_id; /* RDMA connection id */ 78 struct list_head sc_accept_q; /* Conn. waiting accept */ 79 int sc_ord; /* RDMA read limit */ 80 int sc_max_send_sges; 81 bool sc_snd_w_inv; /* OK to use Send With Invalidate */ 82 83 atomic_t sc_sq_avail; /* SQEs ready to be consumed */ 84 unsigned int sc_sq_depth; /* Depth of SQ */ 85 __be32 sc_fc_credits; /* Forward credits */ 86 u32 sc_max_requests; /* Max requests */ 87 u32 sc_max_bc_requests;/* Backward credits */ 88 int sc_max_req_size; /* Size of each RQ WR buf */ 89 u8 sc_port_num; 90 91 struct ib_pd *sc_pd; 92 93 spinlock_t sc_send_lock; 94 struct list_head sc_send_ctxts; 95 spinlock_t sc_rw_ctxt_lock; 96 struct list_head sc_rw_ctxts; 97 98 struct list_head sc_rq_dto_q; 99 spinlock_t sc_rq_dto_lock; 100 struct ib_qp *sc_qp; 101 struct ib_cq *sc_rq_cq; 102 struct ib_cq *sc_sq_cq; 103 104 spinlock_t sc_lock; /* transport lock */ 105 106 wait_queue_head_t sc_send_wait; /* SQ exhaustion waitlist */ 107 unsigned long sc_flags; 108 struct list_head sc_read_complete_q; 109 struct work_struct sc_work; 110 111 struct llist_head sc_recv_ctxts; 112}; 113/* sc_flags */ 114#define RDMAXPRT_CONN_PENDING 3 115 116/* 117 * Default connection parameters 118 */ 119enum { 120 RPCRDMA_LISTEN_BACKLOG = 10, 121 RPCRDMA_MAX_REQUESTS = 64, 122 RPCRDMA_MAX_BC_REQUESTS = 2, 123}; 124 125#define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD 126 127struct svc_rdma_recv_ctxt { 128 struct llist_node rc_node; 129 struct list_head rc_list; 130 struct ib_recv_wr rc_recv_wr; 131 struct ib_cqe rc_cqe; 132 struct ib_sge rc_recv_sge; 133 void *rc_recv_buf; 134 struct xdr_buf rc_arg; 135 struct xdr_stream rc_stream; 136 bool rc_temp; 137 u32 rc_byte_len; 138 unsigned int rc_page_count; 139 unsigned int rc_hdr_count; 140 u32 rc_inv_rkey; 141 __be32 *rc_write_list; 142 __be32 *rc_reply_chunk; 143 unsigned int rc_read_payload_offset; 144 unsigned int rc_read_payload_length; 145 struct page *rc_pages[RPCSVC_MAXPAGES]; 146}; 147 148struct svc_rdma_send_ctxt { 149 struct list_head sc_list; 150 struct ib_send_wr sc_send_wr; 151 struct ib_cqe sc_cqe; 152 struct xdr_buf sc_hdrbuf; 153 struct xdr_stream sc_stream; 154 void *sc_xprt_buf; 155 int sc_page_count; 156 int sc_cur_sge_no; 157 struct page *sc_pages[RPCSVC_MAXPAGES]; 158 struct ib_sge sc_sges[]; 159}; 160 161/* svc_rdma_backchannel.c */ 162extern void svc_rdma_handle_bc_reply(struct svc_rqst *rqstp, 163 struct svc_rdma_recv_ctxt *rctxt); 164 165/* svc_rdma_recvfrom.c */ 166extern void svc_rdma_recv_ctxts_destroy(struct svcxprt_rdma *rdma); 167extern bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma); 168extern void svc_rdma_recv_ctxt_put(struct svcxprt_rdma *rdma, 169 struct svc_rdma_recv_ctxt *ctxt); 170extern void svc_rdma_flush_recv_queues(struct svcxprt_rdma *rdma); 171extern void svc_rdma_release_rqst(struct svc_rqst *rqstp); 172extern int svc_rdma_recvfrom(struct svc_rqst *); 173 174/* svc_rdma_rw.c */ 175extern void svc_rdma_destroy_rw_ctxts(struct svcxprt_rdma *rdma); 176extern int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, 177 struct svc_rqst *rqstp, 178 struct svc_rdma_recv_ctxt *head, __be32 *p); 179extern int svc_rdma_send_write_chunk(struct svcxprt_rdma *rdma, 180 __be32 *wr_ch, struct xdr_buf *xdr, 181 unsigned int offset, 182 unsigned long length); 183extern int svc_rdma_send_reply_chunk(struct svcxprt_rdma *rdma, 184 const struct svc_rdma_recv_ctxt *rctxt, 185 struct xdr_buf *xdr); 186 187/* svc_rdma_sendto.c */ 188extern void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma); 189extern struct svc_rdma_send_ctxt * 190 svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma); 191extern void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma, 192 struct svc_rdma_send_ctxt *ctxt); 193extern int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr); 194extern int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma, 195 struct svc_rdma_send_ctxt *sctxt, 196 const struct svc_rdma_recv_ctxt *rctxt, 197 struct xdr_buf *xdr); 198extern int svc_rdma_sendto(struct svc_rqst *); 199extern int svc_rdma_read_payload(struct svc_rqst *rqstp, unsigned int offset, 200 unsigned int length); 201 202/* svc_rdma_transport.c */ 203extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *); 204extern void svc_sq_reap(struct svcxprt_rdma *); 205extern void svc_rq_reap(struct svcxprt_rdma *); 206 207extern struct svc_xprt_class svc_rdma_class; 208#ifdef CONFIG_SUNRPC_BACKCHANNEL 209extern struct svc_xprt_class svc_rdma_bc_class; 210#endif 211 212/* svc_rdma.c */ 213extern int svc_rdma_init(void); 214extern void svc_rdma_cleanup(void); 215 216#endif