Debian Codegraph @

ptl_ips/ips_expected_proto.h

raw
1 /*
2 * Copyright (c) 2013. Intel Corporation. All rights reserved.
3 * Copyright (c) 2006-2012. QLogic Corporation. All rights reserved.
4 * Copyright (c) 2003-2006, PathScale, Inc. All rights reserved.
5 *
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
11 *
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
14 * conditions are met:
15 *
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer.
19 *
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
24 *
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE.
33 */
34
35 /*
36 * Control and state structure for one instance of the expected protocol. The
37 * protocol depends on some upcalls from internal portions of the receive
38 * protocol (such as opcodes dedicated for expected protocol handling)
39 */
40
41 /* Generate an expected header every 16 packets */
42 #define PSM_DEFAULT_EXPECTED_HEADER 16
43
44 struct ips_protoexp {
45 const struct ptl *ptl;
46 struct ips_proto *proto;
47 struct psmi_timer_ctrl *timerq;
48 struct ips_tid tidc;
49 struct ips_tfctrl tfctrl;
50
51 unsigned int tidflow_seed;
52 ptl_epaddr_flow_t tid_ep_flow;
53 uint32_t tid_flags;
54 psm_transfer_type_t tid_xfer_type;
55 struct ips_scbctrl tid_scbc_rv;
56 mpool_t tid_desc_send_pool;
57 mpool_t tid_desc_recv_pool;
58 mpool_t tid_getreq_pool;
59 mpool_t tid_sreq_pool; /* backptr into proto->ep->mq */
60 mpool_t tid_rreq_pool; /* backptr into proto->ep->mq */
61 uint32_t tid_send_fragsize;
62 uint32_t tid_page_offset_mask;
63 uint64_t tid_page_mask;
64 uint64_t tid_to_cyc_min;
65 uint64_t tid_to_cyc_max;
66 uint32_t tid_to_intr;
67 uint32_t tid_min_expsend_cnt;
68 uint32_t hdr_pkt_interval;
69 struct ips_tidinfo *tid_info;
70
71 STAILQ_HEAD(ips_tid_send_pend, /* pending exp. sends */
72 ips_tid_send_desc) pend_sendq;
73 struct psmi_timer timer_send;
74
75 STAILQ_HEAD(ips_tid_get_pend,
76 ips_tid_get_request) pend_getreqsq; /* pending tid reqs */
77 struct psmi_timer timer_getreqs;
78
79 /* stats */
80 uint64_t tid_grant_resends;
81 uint64_t tid_release_resends;
82 uint64_t tid_intr_reqs;
83 };
84
85 /*
86 * TID member list format used in communication. The receiver associates
87 * physical pages to tids and communicates a list of tid,offset,length for
88 * each registered page.
89 *
90 * This format is currently the only one we support, although it is not as
91 * compact as we would like and other formats are planned in the near future
92 */
93 #define IPS_TID_SESSTYPE_MEMBER_LIST 1
94
95 typedef struct {
96 uint16_t tid;
97 uint16_t offset;
98 uint16_t length;
99 }
100 ips_tid_session_member;
101
102 typedef struct {
103 uint16_t tsess_type;
104 uint16_t tsess_tidcount;
105 uint16_t tsess_tidlist_length;
106 uint16_t tsess_unaligned_start;
107 uint16_t tsess_unaligned_end;
108
109 ptl_arg_t tsess_descid;
110 uint32_t tsess_seqno;
111 uint32_t tsess_srcoff;
112 uint32_t tsess_length;
113
114 ips_tid_session_member tsess_list[0]; /* must be last in struct */
115 }
116 ips_tid_session_list;
117
118 /*
119 * Send-side expected send descriptors.
120 *
121 * Descriptors are allocated when tid grant requests are received (the 'target'
122 * side of an RDMA get request). Descriptors are added to a pending queue of
123 * expected sends and processed one at a time (scb's are requested and messages
124 * sent until all fragments of the descriptor's length are put on the wire).
125 *
126 */
127 #define TIDSENDC_SDMA_VEC_DEFAULT 260
128
129 struct ips_tid_send_desc {
130 struct ips_protoexp *protoexp;
131 STAILQ_ENTRY(ips_tid_send_desc) next;
132
133 /* Filled in at allocation time */
134 ptl_arg_t descid;
135 uint32_t length;
136 ips_epaddr_t *ipsaddr;
137 psm_mq_req_t mqreq;
138 struct ips_flow tidflow;
139
140 uint32_t ctrl_msg_queued; /* bitmap of queued control messages for flow */
141 uint32_t completion_counter;
142
143 /* Iterated during send progress */
144 void *buffer;
145 void *bounce_buf;
146 int tid_idx;
147 int is_complete;
148 uint32_t remaining_bytes;
149 uint32_t remaining_bytes_in_page;
150 uint32_t frame_send;
151 uint32_t offset;
152 uint32_t iovec_cntr_last;
153 uint32_t release_cnt;
154 uint32_t unaligned_sent;
155 uint32_t pad;
156
157 psmi_timer timer_tidrelease;
158
159 union {
160 ips_tid_session_list tid_list;
161 uint8_t filler[2096];
162 };
163 };
164
165 #define TIDRECVC_STATE_FREE 0
166 #define TIDRECVC_STATE_GRANT 1
167 #define TIDRECVC_STATE_GRANT_ACK 2
168 #define TIDRECVC_STATE_DONE 3
169
170 struct ips_expected_recv_stats {
171 uint32_t nSeqErr;
172 uint32_t nGenErr;
173 uint32_t nReXmit;
174 uint32_t nErrChkReceived;
175 };
176
177 struct ips_tid_recv_desc {
178 const psmi_context_t *context;
179 struct ips_protoexp *protoexp;
180 ips_epaddr_t *ipsaddr;
181 STAILQ_ENTRY(ips_tid_recv_desc) next;
182
183 /* desc id held in tid_list below */
184 void *buffer;
185 uint32_t num_recv_hdrs;
186 uint32_t recv_msglen;
187 uint32_t grant_cnt;
188 uint32_t state;
189 uint32_t cksum;
190 uint16_t recv_framecnt;
191 uint16_t flags;
192
193 /* TF protocol state (recv) */
194 uint32_t tidflow_idx;
195 uint32_t tidflow_active_gen;
196
197 psmi_seqnum_t tidflow_genseq;
198 uint16_t tidflow_nswap_gen;
199 uint16_t pad;
200
201 uint32_t ctrl_msg_queued; /* bitmap of queued control messages for */
202 struct ips_expected_recv_stats stats;
203
204 struct ips_tid_get_request *getreq;
205 psmi_timer timer_tidreq;
206
207 ips_tidmap_t ts_map;
208 union {
209 ips_tid_session_list tid_list;
210 uint8_t filler[2096];
211 };
212 };
213
214 /*
215 * Get requests, issued by MQ when there's a match on a large message. Unlike
216 * an RDMA get, the initiator identifies the location of the data at the target
217 * using a 'send token' instead of a virtual address. This, of course, assumes
218 * that the target has already registered the token and communicated it to the
219 * initiator beforehand (it actually sends the token as part of the initial
220 * MQ message that contains the MQ tag).
221 *
222 * The operation is semantically a two-sided RDMA get.
223 */
224 struct ips_tid_get_request {
225 STAILQ_ENTRY(ips_tid_get_request) tidgr_next;
226 struct ips_protoexp *tidgr_protoexp;
227 psm_epaddr_t tidgr_epaddr;
228
229 void *tidgr_lbuf;
230 uint32_t tidgr_length;
231 uint32_t tidgr_rndv_winsz;
232 uint32_t tidgr_sendtoken;
233 ips_tid_completion_callback_t tidgr_callback;
234 void *tidgr_ucontext;
235
236 uint32_t tidgr_offset; /* offset in bytes */
237 uint32_t tidgr_bytesdone;
238 uint32_t tidgr_desc_seqno;
239 uint32_t tidgr_flags;
240 };
241
242 /*
243 * For debug and/or other reasons, we can log the state of each tid and
244 * optionally associate it to a particular receive descriptor
245 */
246
247 #define TIDSTATE_FREE 0
248 #define TIDSTATE_USED 1
249
250 struct ips_tidinfo {
251 uint16_t tid;
252 uint16_t state;
253 struct ips_tid_recv_desc *tidrecvc;
254 };
255
256 /*
257 * Descriptor limits, structure contents of struct psmi_rlimit_mpool for
258 * normal, min and large configurations.
259 */
260 #define TID_SENDSESSIONS_LIMITS { \
261 .env = "PSM_TID_SENDSESSIONS_MAX", \
262 .descr = "Tid max send session descriptors", \
263 .env_level = PSMI_ENVVAR_LEVEL_HIDDEN, \
264 .minval = 1, \
265 .maxval = 1<<30, \
266 .mode[PSMI_MEMMODE_NORMAL] = { 256, 4096 }, \
267 .mode[PSMI_MEMMODE_MINIMAL] = { 1, 1 }, \
268 .mode[PSMI_MEMMODE_LARGE] = { 512, 8192 } \
269 }
270
271 #define TID_RECVSESSIONS_LIMITS { \
272 .env = "PSM_TID_RECVSESSIONS_MAX", \
273 .descr = "Tid max receive session descriptors", \
274 .env_level = PSMI_ENVVAR_LEVEL_HIDDEN, \
275 .minval = 1, \
276 .maxval = 512, \
277 .mode[PSMI_MEMMODE_NORMAL] = { 32, 512 }, \
278 .mode[PSMI_MEMMODE_MINIMAL] = { 1, 1 }, \
279 .mode[PSMI_MEMMODE_LARGE] = { 32, 512 } \
280 }