1 #ifndef DEF_RDMAVT_INCQP_H
2 #define DEF_RDMAVT_INCQP_H
5 * Copyright(c) 2015 Intel Corporation.
7 * This file is provided under a dual BSD/GPLv2 license. When using or
8 * redistributing this file, you may do so under either license.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as
14 * published by the Free Software Foundation.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
27 * - Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * - Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in
31 * the documentation and/or other materials provided with the
33 * - Neither the name of Intel Corporation nor the names of its
34 * contributors may be used to endorse or promote products derived
35 * from this software without specific prior written permission.
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
40 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
52 * Send work request queue entry.
53 * The size of the sg_list is determined when the QP is created and stored
58 struct ib_send_wr wr
; /* don't use wr.sg_list */
59 struct ib_ud_wr ud_wr
;
60 struct ib_reg_wr reg_wr
;
61 struct ib_rdma_wr rdma_wr
;
62 struct ib_atomic_wr atomic_wr
;
64 u32 psn
; /* first packet sequence number */
65 u32 lpsn
; /* last packet sequence number */
66 u32 ssn
; /* send sequence number */
67 u32 length
; /* total length of data in sg_list */
68 struct rvt_sge sg_list
[0];
72 * Receive work request queue entry.
73 * The size of the sg_list is determined when the QP (or SRQ) is created
74 * and stored in qp->r_rq.max_sge (or srq->rq.max_sge).
79 struct ib_sge sg_list
[0];
83 * This structure is used to contain the head pointer, tail pointer,
84 * and receive work queue entries as a single memory allocation so
85 * it can be mmap'ed into user space.
86 * Note that the wq array elements are variable size so you can't
87 * just index into the array to get the N'th element;
88 * use get_rwqe_ptr() instead.
91 u32 head
; /* new work requests posted to the head */
92 u32 tail
; /* receives pull requests from here. */
93 struct rvt_rwqe wq
[0];
98 u32 size
; /* size of RWQE array */
100 /* protect changes in this struct */
101 spinlock_t lock ____cacheline_aligned_in_smp
;
105 * This structure is used by rvt_mmap() to validate an offset
106 * when an mmap() request is made. The vm_area_struct then uses
107 * this as its vm_private_data.
109 struct rvt_mmap_info
{
110 struct list_head pending_mmaps
;
111 struct ib_ucontext
*context
;
118 #define RVT_MAX_RDMA_ATOMIC 16
121 * This structure holds the information that the send tasklet needs
122 * to send a RDMA read response or atomic operation.
124 struct rvt_ack_entry
{
130 struct rvt_sge rdma_sge
;
136 * Variables prefixed with s_ are for the requester (sender).
137 * Variables prefixed with r_ are for the responder (receiver).
138 * Variables prefixed with ack_ are for responder replies.
140 * Common variables are protected by both r_rq.lock and s_lock in that order
141 * which only happens in modify_qp() or changing the QP 'state'.
145 void *priv
; /* Driver private data */
146 /* read mostly fields above and below */
147 struct ib_ah_attr remote_ah_attr
;
148 struct ib_ah_attr alt_ah_attr
;
149 struct rvt_qp __rcu
*next
; /* link list for QPN hash table */
150 struct rvt_swqe
*s_wq
; /* send work queue */
151 struct rvt_mmap_info
*ip
;
153 unsigned long timeout_jiffies
; /* computed from timeout */
155 enum ib_mtu path_mtu
;
156 int srate_mbps
; /* s_srate (below) converted to Mbit/s */
158 u32 pmtu
; /* decoded from path_mtu */
159 u32 qkey
; /* QKEY for this QP (for UD or RD) */
160 u32 s_size
; /* send work queue size */
161 u32 s_rnr_timeout
; /* number of milliseconds for RNR timeout */
162 u32 s_ahgpsn
; /* set to the psn in the copy of the header */
164 u8 state
; /* QP state */
165 u8 allowed_ops
; /* high order bits of allowed opcodes */
167 u8 alt_timeout
; /* Alternate path timeout for this QP */
168 u8 timeout
; /* Timeout for this QP */
172 u8 s_pkey_index
; /* PKEY index to use */
173 u8 s_alt_pkey_index
; /* Alternate path PKEY index to use */
174 u8 r_max_rd_atomic
; /* max number of RDMA read/atomic to receive */
175 u8 s_max_rd_atomic
; /* max number of RDMA read/atomic to send */
176 u8 s_retry_cnt
; /* number of times to retry */
178 u8 r_min_rnr_timer
; /* retry timeout value for RNR NAKs */
179 u8 s_max_sge
; /* size of s_wq->sg_list */
182 /* start of read/write fields */
183 atomic_t refcount ____cacheline_aligned_in_smp
;
184 wait_queue_head_t wait
;
186 struct rvt_ack_entry s_ack_queue
[RVT_MAX_RDMA_ATOMIC
+ 1]
187 ____cacheline_aligned_in_smp
;
188 struct rvt_sge_state s_rdma_read_sge
;
190 spinlock_t r_lock ____cacheline_aligned_in_smp
; /* used for APM */
191 unsigned long r_aflags
;
192 u64 r_wr_id
; /* ID for current receive WQE */
193 u32 r_ack_psn
; /* PSN for next ACK or atomic ACK */
194 u32 r_len
; /* total length of r_sge */
195 u32 r_rcv_len
; /* receive data len processed */
196 u32 r_psn
; /* expected rcv packet sequence number */
197 u32 r_msn
; /* message sequence number */
199 u8 r_state
; /* opcode of last packet received */
201 u8 r_head_ack_queue
; /* index into s_ack_queue[] */
203 struct list_head rspwait
; /* link for waiting to respond */
205 struct rvt_sge_state r_sge
; /* current receive data */
206 struct rvt_rq r_rq
; /* receive work queue */
208 spinlock_t s_lock ____cacheline_aligned_in_smp
;
209 struct rvt_sge_state
*s_cur_sge
;
211 struct rvt_swqe
*s_wqe
;
212 struct rvt_sge_state s_sge
; /* current send request data */
213 struct rvt_mregion
*s_rdma_mr
;
214 struct sdma_engine
*s_sde
; /* current sde */
215 u32 s_cur_size
; /* size of send packet in bytes */
216 u32 s_len
; /* total length of s_sge */
217 u32 s_rdma_read_len
; /* total length of s_rdma_read_sge */
218 u32 s_next_psn
; /* PSN for next request */
219 u32 s_last_psn
; /* last response PSN processed */
220 u32 s_sending_psn
; /* lowest PSN that is being sent */
221 u32 s_sending_hpsn
; /* highest PSN that is being sent */
222 u32 s_psn
; /* current packet sequence number */
223 u32 s_ack_rdma_psn
; /* PSN for sending RDMA read responses */
224 u32 s_ack_psn
; /* PSN for acking sends and RDMA writes */
225 u32 s_head
; /* new entries added here */
226 u32 s_tail
; /* next entry to process */
227 u32 s_cur
; /* current work queue entry */
228 u32 s_acked
; /* last un-ACK'ed entry */
229 u32 s_last
; /* last completed entry */
230 u32 s_ssn
; /* SSN of tail entry */
231 u32 s_lsn
; /* limit sequence number (credit) */
232 u16 s_hdrwords
; /* size of s_hdr in 32 bit words */
235 u8 s_state
; /* opcode of last packet sent */
236 u8 s_ack_state
; /* opcode of packet to ACK */
237 u8 s_nak_state
; /* non-zero if NAK is pending */
238 u8 r_nak_state
; /* non-zero if NAK is pending */
239 u8 s_retry
; /* requester retry counter */
240 u8 s_rnr_retry
; /* requester RNR retry counter */
241 u8 s_num_rd_atomic
; /* number of RDMA read/atomic pending */
242 u8 s_tail_ack_queue
; /* index into s_ack_queue[] */
244 struct rvt_sge_state s_ack_rdma_sge
;
245 struct timer_list s_timer
;
248 * This sge list MUST be last. Do not add anything below here.
250 struct rvt_sge r_sg_list
[0] /* verified SGEs */
251 ____cacheline_aligned_in_smp
;
257 struct rvt_mmap_info
*ip
;
258 /* send signal when number of RWQEs < limit */
262 #endif /* DEF_RDMAVT_INCQP_H */