blob: 81d01f1e9eb6cc3e1c444bbdfff01d807e63f0c1 [file] [log] [blame]
Peng Taod7e09d02013-05-02 16:46:55 +08001/*
2 * GPL HEADER START
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
James Simmons4f3ca892015-06-11 15:18:15 -040018 * http://www.gnu.org/licenses/gpl-2.0.html
Peng Taod7e09d02013-05-02 16:46:55 +080019 *
20 * GPL HEADER END
21 */
22/*
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
25 *
James Simmons4f3ca892015-06-11 15:18:15 -040026 * Copyright (c) 2012 - 2015, Intel Corporation.
Peng Taod7e09d02013-05-02 16:46:55 +080027 */
28/*
29 * This file is part of Lustre, http://www.lustre.org/
James Simmons4f3ca892015-06-11 15:18:15 -040030 * Lustre is a trademark of Seagate, Inc.
Peng Taod7e09d02013-05-02 16:46:55 +080031 */
32
33#ifndef __LNET_TYPES_H__
34#define __LNET_TYPES_H__
35
James Simmonsdb18b8e2015-06-11 15:18:12 -040036#include <linux/types.h>
37
Peng Taod7e09d02013-05-02 16:46:55 +080038/** \addtogroup lnet
James Simmons4420cfd2016-02-12 12:06:00 -050039 * @{
40 */
Peng Taod7e09d02013-05-02 16:46:55 +080041
Peng Taod7e09d02013-05-02 16:46:55 +080042/** \addtogroup lnet_addr
James Simmons4420cfd2016-02-12 12:06:00 -050043 * @{
44 */
Peng Taod7e09d02013-05-02 16:46:55 +080045
46/** Portal reserved for LNet's own use.
47 * \see lustre/include/lustre/lustre_idl.h for Lustre portal assignments.
48 */
James Simmons188acc62015-06-11 15:18:14 -040049#define LNET_RESERVED_PORTAL 0
Peng Taod7e09d02013-05-02 16:46:55 +080050
51/**
52 * Address of an end-point in an LNet network.
53 *
54 * A node can have multiple end-points and hence multiple addresses.
55 * An LNet network can be a simple network (e.g. tcp0) or a network of
56 * LNet networks connected by LNet routers. Therefore an end-point address
57 * has two parts: network ID, and address within a network.
58 *
59 * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
60 */
61typedef __u64 lnet_nid_t;
62/**
63 * ID of a process in a node. Shortened as PID to distinguish from
64 * lnet_process_id_t, the global process ID.
65 */
66typedef __u32 lnet_pid_t;
67
68/** wildcard NID that matches any end-point address */
James Simmons188acc62015-06-11 15:18:14 -040069#define LNET_NID_ANY ((lnet_nid_t) -1)
Peng Taod7e09d02013-05-02 16:46:55 +080070/** wildcard PID that matches any lnet_pid_t */
James Simmons188acc62015-06-11 15:18:14 -040071#define LNET_PID_ANY ((lnet_pid_t) -1)
Peng Taod7e09d02013-05-02 16:46:55 +080072
73#define LNET_PID_RESERVED 0xf0000000 /* reserved bits in PID */
74#define LNET_PID_USERFLAG 0x80000000 /* set in userspace peers */
James Simmonsdb18b8e2015-06-11 15:18:12 -040075#define LNET_PID_LUSTRE 12345
Peng Taod7e09d02013-05-02 16:46:55 +080076
James Simmons188acc62015-06-11 15:18:14 -040077#define LNET_TIME_FOREVER (-1)
Peng Taod7e09d02013-05-02 16:46:55 +080078
James Simmonsbbf00c32015-06-11 15:18:11 -040079/* how an LNET NID encodes net:address */
80/** extract the address part of an lnet_nid_t */
81
82static inline __u32 LNET_NIDADDR(lnet_nid_t nid)
83{
84 return nid & 0xffffffff;
85}
86
87static inline __u32 LNET_NIDNET(lnet_nid_t nid)
88{
89 return (nid >> 32) & 0xffffffff;
90}
91
92static inline lnet_nid_t LNET_MKNID(__u32 net, __u32 addr)
93{
94 return (((__u64)net) << 32) | addr;
95}
96
97static inline __u32 LNET_NETNUM(__u32 net)
98{
99 return net & 0xffff;
100}
101
102static inline __u32 LNET_NETTYP(__u32 net)
103{
104 return (net >> 16) & 0xffff;
105}
106
107static inline __u32 LNET_MKNET(__u32 type, __u32 num)
108{
109 return (type << 16) | num;
110}
111
James Simmonsdb18b8e2015-06-11 15:18:12 -0400112#define WIRE_ATTR __packed
113
114/* Packed version of lnet_process_id_t to transfer via network */
115typedef struct {
116 /* node id / process id */
117 lnet_nid_t nid;
118 lnet_pid_t pid;
119} WIRE_ATTR lnet_process_id_packed_t;
120
James Simmons4420cfd2016-02-12 12:06:00 -0500121/*
122 * The wire handle's interface cookie only matches one network interface in
James Simmonsdb18b8e2015-06-11 15:18:12 -0400123 * one epoch (i.e. new cookie when the interface restarts or the node
124 * reboots). The object cookie only matches one object on that interface
James Simmons4420cfd2016-02-12 12:06:00 -0500125 * during that object's lifetime (i.e. no cookie re-use).
126 */
James Simmonsdb18b8e2015-06-11 15:18:12 -0400127typedef struct {
128 __u64 wh_interface_cookie;
129 __u64 wh_object_cookie;
130} WIRE_ATTR lnet_handle_wire_t;
131
132typedef enum {
133 LNET_MSG_ACK = 0,
134 LNET_MSG_PUT,
135 LNET_MSG_GET,
136 LNET_MSG_REPLY,
137 LNET_MSG_HELLO,
138} lnet_msg_type_t;
139
James Simmons4420cfd2016-02-12 12:06:00 -0500140/*
141 * The variant fields of the portals message header are aligned on an 8
James Simmonsdb18b8e2015-06-11 15:18:12 -0400142 * byte boundary in the message header. Note that all types used in these
143 * wire structs MUST be fixed size and the smaller types are placed at the
James Simmons4420cfd2016-02-12 12:06:00 -0500144 * end.
145 */
James Simmonsdb18b8e2015-06-11 15:18:12 -0400146typedef struct lnet_ack {
147 lnet_handle_wire_t dst_wmd;
148 __u64 match_bits;
149 __u32 mlength;
150} WIRE_ATTR lnet_ack_t;
151
152typedef struct lnet_put {
153 lnet_handle_wire_t ack_wmd;
154 __u64 match_bits;
155 __u64 hdr_data;
156 __u32 ptl_index;
157 __u32 offset;
158} WIRE_ATTR lnet_put_t;
159
160typedef struct lnet_get {
161 lnet_handle_wire_t return_wmd;
162 __u64 match_bits;
163 __u32 ptl_index;
164 __u32 src_offset;
165 __u32 sink_length;
166} WIRE_ATTR lnet_get_t;
167
168typedef struct lnet_reply {
169 lnet_handle_wire_t dst_wmd;
170} WIRE_ATTR lnet_reply_t;
171
172typedef struct lnet_hello {
173 __u64 incarnation;
174 __u32 type;
175} WIRE_ATTR lnet_hello_t;
176
177typedef struct {
178 lnet_nid_t dest_nid;
179 lnet_nid_t src_nid;
180 lnet_pid_t dest_pid;
181 lnet_pid_t src_pid;
182 __u32 type; /* lnet_msg_type_t */
183 __u32 payload_length; /* payload data to follow */
184 /*<------__u64 aligned------->*/
185 union {
186 lnet_ack_t ack;
187 lnet_put_t put;
188 lnet_get_t get;
189 lnet_reply_t reply;
190 lnet_hello_t hello;
191 } msg;
192} WIRE_ATTR lnet_hdr_t;
193
James Simmons4420cfd2016-02-12 12:06:00 -0500194/*
195 * A HELLO message contains a magic number and protocol version
James Simmonsdb18b8e2015-06-11 15:18:12 -0400196 * code in the header's dest_nid, the peer's NID in the src_nid, and
197 * LNET_MSG_HELLO in the type field. All other common fields are zero
198 * (including payload_size; i.e. no payload).
199 * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
200 * running the same protocol and to find out its NID. These LNDs should
201 * exchange HELLO messages when a connection is first established. Individual
202 * LNDs can put whatever else they fancy in lnet_hdr_t::msg.
203 */
204typedef struct {
205 __u32 magic; /* LNET_PROTO_TCP_MAGIC */
206 __u16 version_major; /* increment on incompatible change */
207 __u16 version_minor; /* increment on compatible change */
208} WIRE_ATTR lnet_magicversion_t;
209
210/* PROTO MAGIC for LNDs */
211#define LNET_PROTO_IB_MAGIC 0x0be91b91
212#define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */
213#define LNET_PROTO_TCP_MAGIC 0xeebc0ded
214#define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100
215#define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */
216
217/* Placeholder for a future "unified" protocol across all LNDs */
James Simmons4420cfd2016-02-12 12:06:00 -0500218/*
219 * Current LNDs that receive a request with this magic will respond with a
220 * "stub" reply using their current protocol
221 */
James Simmonsdb18b8e2015-06-11 15:18:12 -0400222#define LNET_PROTO_MAGIC 0x45726963 /* ! */
223
224#define LNET_PROTO_TCP_VERSION_MAJOR 1
225#define LNET_PROTO_TCP_VERSION_MINOR 0
226
227/* Acceptor connection request */
228typedef struct {
229 __u32 acr_magic; /* PTL_ACCEPTOR_PROTO_MAGIC */
230 __u32 acr_version; /* protocol version */
231 __u64 acr_nid; /* target NID */
232} WIRE_ATTR lnet_acceptor_connreq_t;
233
234#define LNET_PROTO_ACCEPTOR_VERSION 1
235
236typedef struct {
237 lnet_nid_t ns_nid;
238 __u32 ns_status;
239 __u32 ns_unused;
240} WIRE_ATTR lnet_ni_status_t;
241
242typedef struct {
243 __u32 pi_magic;
244 __u32 pi_features;
245 lnet_pid_t pi_pid;
246 __u32 pi_nnis;
247 lnet_ni_status_t pi_ni[0];
248} WIRE_ATTR lnet_ping_info_t;
249
250typedef struct lnet_counters {
251 __u32 msgs_alloc;
252 __u32 msgs_max;
253 __u32 errors;
254 __u32 send_count;
255 __u32 recv_count;
256 __u32 route_count;
257 __u32 drop_count;
258 __u64 send_length;
259 __u64 recv_length;
260 __u64 route_length;
261 __u64 drop_length;
262} WIRE_ATTR lnet_counters_t;
263
264#define LNET_NI_STATUS_UP 0x15aac0de
265#define LNET_NI_STATUS_DOWN 0xdeadface
266#define LNET_NI_STATUS_INVALID 0x00000000
267
268#define LNET_MAX_INTERFACES 16
269
James Simmons4420cfd2016-02-12 12:06:00 -0500270/**
Peng Taod7e09d02013-05-02 16:46:55 +0800271 * Objects maintained by the LNet are accessed through handles. Handle types
272 * have names of the form lnet_handle_xx_t, where xx is one of the two letter
273 * object type codes ('eq' for event queue, 'md' for memory descriptor, and
274 * 'me' for match entry).
275 * Each type of object is given a unique handle type to enhance type checking.
276 * The type lnet_handle_any_t can be used when a generic handle is needed.
277 * Every handle value can be converted into a value of type lnet_handle_any_t
278 * without loss of information.
279 */
280typedef struct {
281 __u64 cookie;
282} lnet_handle_any_t;
283
284typedef lnet_handle_any_t lnet_handle_eq_t;
285typedef lnet_handle_any_t lnet_handle_md_t;
286typedef lnet_handle_any_t lnet_handle_me_t;
287
288#define LNET_WIRE_HANDLE_COOKIE_NONE (-1)
289
290/**
291 * Invalidate handle \a h.
292 */
293static inline void LNetInvalidateHandle(lnet_handle_any_t *h)
294{
295 h->cookie = LNET_WIRE_HANDLE_COOKIE_NONE;
296}
297
298/**
299 * Compare handles \a h1 and \a h2.
300 *
301 * \return 1 if handles are equal, 0 if otherwise.
302 */
Greg Kroah-Hartman568414f2014-07-11 18:40:36 -0700303static inline int LNetHandleIsEqual(lnet_handle_any_t h1, lnet_handle_any_t h2)
Peng Taod7e09d02013-05-02 16:46:55 +0800304{
Joshua Baldocke4422942014-04-02 19:12:59 +1100305 return h1.cookie == h2.cookie;
Peng Taod7e09d02013-05-02 16:46:55 +0800306}
307
308/**
309 * Check whether handle \a h is invalid.
310 *
311 * \return 1 if handle is invalid, 0 if valid.
312 */
313static inline int LNetHandleIsInvalid(lnet_handle_any_t h)
314{
Julia Lawall625a3122015-08-29 19:30:05 +0200315 return h.cookie == LNET_WIRE_HANDLE_COOKIE_NONE;
Peng Taod7e09d02013-05-02 16:46:55 +0800316}
317
318/**
319 * Global process ID.
320 */
321typedef struct {
322 /** node id */
323 lnet_nid_t nid;
324 /** process id */
325 lnet_pid_t pid;
326} lnet_process_id_t;
327/** @} lnet_addr */
328
329/** \addtogroup lnet_me
James Simmons4420cfd2016-02-12 12:06:00 -0500330 * @{
331 */
Peng Taod7e09d02013-05-02 16:46:55 +0800332
333/**
334 * Specifies whether the match entry or memory descriptor should be unlinked
335 * automatically (LNET_UNLINK) or not (LNET_RETAIN).
336 */
337typedef enum {
338 LNET_RETAIN = 0,
339 LNET_UNLINK
340} lnet_unlink_t;
341
342/**
343 * Values of the type lnet_ins_pos_t are used to control where a new match
344 * entry is inserted. The value LNET_INS_BEFORE is used to insert the new
345 * entry before the current entry or before the head of the list. The value
346 * LNET_INS_AFTER is used to insert the new entry after the current entry
347 * or after the last item in the list.
348 */
349typedef enum {
350 /** insert ME before current position or head of the list */
351 LNET_INS_BEFORE,
352 /** insert ME after current position or tail of the list */
353 LNET_INS_AFTER,
354 /** attach ME at tail of local CPU partition ME list */
355 LNET_INS_LOCAL
356} lnet_ins_pos_t;
357
358/** @} lnet_me */
359
360/** \addtogroup lnet_md
James Simmons4420cfd2016-02-12 12:06:00 -0500361 * @{
362 */
Peng Taod7e09d02013-05-02 16:46:55 +0800363
364/**
365 * Defines the visible parts of a memory descriptor. Values of this type
366 * are used to initialize memory descriptors.
367 */
368typedef struct {
369 /**
370 * Specify the memory region associated with the memory descriptor.
371 * If the options field has:
372 * - LNET_MD_KIOV bit set: The start field points to the starting
373 * address of an array of lnet_kiov_t and the length field specifies
374 * the number of entries in the array. The length can't be bigger
375 * than LNET_MAX_IOV. The lnet_kiov_t is used to describe page-based
Masanari Iidad766b4b2014-03-21 23:42:52 +0900376 * fragments that are not necessarily mapped in virtual memory.
Peng Taod7e09d02013-05-02 16:46:55 +0800377 * - LNET_MD_IOVEC bit set: The start field points to the starting
378 * address of an array of struct iovec and the length field specifies
379 * the number of entries in the array. The length can't be bigger
380 * than LNET_MAX_IOV. The struct iovec is used to describe fragments
381 * that have virtual addresses.
382 * - Otherwise: The memory region is contiguous. The start field
383 * specifies the starting address for the memory region and the
384 * length field specifies its length.
385 *
386 * When the memory region is fragmented, all fragments but the first
387 * one must start on page boundary, and all but the last must end on
388 * page boundary.
389 */
James Simmons188acc62015-06-11 15:18:14 -0400390 void *start;
391 unsigned int length;
Peng Taod7e09d02013-05-02 16:46:55 +0800392 /**
393 * Specifies the maximum number of operations that can be performed
394 * on the memory descriptor. An operation is any action that could
395 * possibly generate an event. In the usual case, the threshold value
396 * is decremented for each operation on the MD. When the threshold
397 * drops to zero, the MD becomes inactive and does not respond to
398 * operations. A threshold value of LNET_MD_THRESH_INF indicates that
399 * there is no bound on the number of operations that may be applied
400 * to a MD.
401 */
James Simmons188acc62015-06-11 15:18:14 -0400402 int threshold;
Peng Taod7e09d02013-05-02 16:46:55 +0800403 /**
404 * Specifies the largest incoming request that the memory descriptor
405 * should respond to. When the unused portion of a MD (length -
406 * local offset) falls below this value, the MD becomes inactive and
407 * does not respond to further operations. This value is only used
408 * if the LNET_MD_MAX_SIZE option is set.
409 */
James Simmons188acc62015-06-11 15:18:14 -0400410 int max_size;
Peng Taod7e09d02013-05-02 16:46:55 +0800411 /**
412 * Specifies the behavior of the memory descriptor. A bitwise OR
413 * of the following values can be used:
414 * - LNET_MD_OP_PUT: The LNet PUT operation is allowed on this MD.
415 * - LNET_MD_OP_GET: The LNet GET operation is allowed on this MD.
416 * - LNET_MD_MANAGE_REMOTE: The offset used in accessing the memory
417 * region is provided by the incoming request. By default, the
418 * offset is maintained locally. When maintained locally, the
419 * offset is incremented by the length of the request so that
420 * the next operation (PUT or GET) will access the next part of
421 * the memory region. Note that only one offset variable exists
422 * per memory descriptor. If both PUT and GET operations are
423 * performed on a memory descriptor, the offset is updated each time.
424 * - LNET_MD_TRUNCATE: The length provided in the incoming request can
425 * be reduced to match the memory available in the region (determined
426 * by subtracting the offset from the length of the memory region).
427 * By default, if the length in the incoming operation is greater
428 * than the amount of memory available, the operation is rejected.
429 * - LNET_MD_ACK_DISABLE: An acknowledgment should not be sent for
430 * incoming PUT operations, even if requested. By default,
431 * acknowledgments are sent for PUT operations that request an
432 * acknowledgment. Acknowledgments are never sent for GET operations.
433 * The data sent in the REPLY serves as an implicit acknowledgment.
434 * - LNET_MD_KIOV: The start and length fields specify an array of
435 * lnet_kiov_t.
436 * - LNET_MD_IOVEC: The start and length fields specify an array of
437 * struct iovec.
438 * - LNET_MD_MAX_SIZE: The max_size field is valid.
439 *
440 * Note:
441 * - LNET_MD_KIOV or LNET_MD_IOVEC allows for a scatter/gather
442 * capability for memory descriptors. They can't be both set.
443 * - When LNET_MD_MAX_SIZE is set, the total length of the memory
444 * region (i.e. sum of all fragment lengths) must not be less than
445 * \a max_size.
446 */
James Simmons188acc62015-06-11 15:18:14 -0400447 unsigned int options;
Peng Taod7e09d02013-05-02 16:46:55 +0800448 /**
449 * A user-specified value that is associated with the memory
450 * descriptor. The value does not need to be a pointer, but must fit
451 * in the space used by a pointer. This value is recorded in events
452 * associated with operations on this MD.
453 */
James Simmons188acc62015-06-11 15:18:14 -0400454 void *user_ptr;
Peng Taod7e09d02013-05-02 16:46:55 +0800455 /**
456 * A handle for the event queue used to log the operations performed on
457 * the memory region. If this argument is a NULL handle (i.e. nullified
458 * by LNetInvalidateHandle()), operations performed on this memory
459 * descriptor are not logged.
460 */
461 lnet_handle_eq_t eq_handle;
462} lnet_md_t;
463
James Simmons4420cfd2016-02-12 12:06:00 -0500464/*
465 * Max Transfer Unit (minimum supported everywhere).
Peng Taod7e09d02013-05-02 16:46:55 +0800466 * CAVEAT EMPTOR, with multinet (i.e. routers forwarding between networks)
James Simmons4420cfd2016-02-12 12:06:00 -0500467 * these limits are system wide and not interface-local.
468 */
Peng Taod7e09d02013-05-02 16:46:55 +0800469#define LNET_MTU_BITS 20
470#define LNET_MTU (1 << LNET_MTU_BITS)
471
472/** limit on the number of fragments in discontiguous MDs */
James Simmons188acc62015-06-11 15:18:14 -0400473#define LNET_MAX_IOV 256
Peng Taod7e09d02013-05-02 16:46:55 +0800474
Peng Taod7e09d02013-05-02 16:46:55 +0800475/**
476 * Options for the MD structure. See lnet_md_t::options.
477 */
James Simmons188acc62015-06-11 15:18:14 -0400478#define LNET_MD_OP_PUT (1 << 0)
Peng Taod7e09d02013-05-02 16:46:55 +0800479/** See lnet_md_t::options. */
James Simmons188acc62015-06-11 15:18:14 -0400480#define LNET_MD_OP_GET (1 << 1)
Peng Taod7e09d02013-05-02 16:46:55 +0800481/** See lnet_md_t::options. */
482#define LNET_MD_MANAGE_REMOTE (1 << 2)
James Simmons188acc62015-06-11 15:18:14 -0400483/* unused (1 << 3) */
Peng Taod7e09d02013-05-02 16:46:55 +0800484/** See lnet_md_t::options. */
James Simmons188acc62015-06-11 15:18:14 -0400485#define LNET_MD_TRUNCATE (1 << 4)
Peng Taod7e09d02013-05-02 16:46:55 +0800486/** See lnet_md_t::options. */
James Simmons188acc62015-06-11 15:18:14 -0400487#define LNET_MD_ACK_DISABLE (1 << 5)
Peng Taod7e09d02013-05-02 16:46:55 +0800488/** See lnet_md_t::options. */
489#define LNET_MD_IOVEC (1 << 6)
490/** See lnet_md_t::options. */
James Simmons188acc62015-06-11 15:18:14 -0400491#define LNET_MD_MAX_SIZE (1 << 7)
Peng Taod7e09d02013-05-02 16:46:55 +0800492/** See lnet_md_t::options. */
James Simmons188acc62015-06-11 15:18:14 -0400493#define LNET_MD_KIOV (1 << 8)
Peng Taod7e09d02013-05-02 16:46:55 +0800494
495/* For compatibility with Cray Portals */
James Simmons188acc62015-06-11 15:18:14 -0400496#define LNET_MD_PHYS 0
Peng Taod7e09d02013-05-02 16:46:55 +0800497
498/** Infinite threshold on MD operations. See lnet_md_t::threshold */
James Simmons188acc62015-06-11 15:18:14 -0400499#define LNET_MD_THRESH_INF (-1)
Peng Taod7e09d02013-05-02 16:46:55 +0800500
501/* NB lustre portals uses struct iovec internally! */
502typedef struct iovec lnet_md_iovec_t;
503
504/**
505 * A page-based fragment of a MD.
506 */
507typedef struct {
508 /** Pointer to the page where the fragment resides */
James Simmons188acc62015-06-11 15:18:14 -0400509 struct page *kiov_page;
Peng Taod7e09d02013-05-02 16:46:55 +0800510 /** Length in bytes of the fragment */
James Simmons188acc62015-06-11 15:18:14 -0400511 unsigned int kiov_len;
Peng Taod7e09d02013-05-02 16:46:55 +0800512 /**
513 * Starting offset of the fragment within the page. Note that the
514 * end of the fragment must not pass the end of the page; i.e.,
515 * kiov_len + kiov_offset <= PAGE_CACHE_SIZE.
516 */
James Simmons188acc62015-06-11 15:18:14 -0400517 unsigned int kiov_offset;
Peng Taod7e09d02013-05-02 16:46:55 +0800518} lnet_kiov_t;
519/** @} lnet_md */
520
521/** \addtogroup lnet_eq
James Simmons4420cfd2016-02-12 12:06:00 -0500522 * @{
523 */
Peng Taod7e09d02013-05-02 16:46:55 +0800524
525/**
526 * Six types of events can be logged in an event queue.
527 */
528typedef enum {
529 /** An incoming GET operation has completed on the MD. */
530 LNET_EVENT_GET = 1,
531 /**
532 * An incoming PUT operation has completed on the MD. The
533 * underlying layers will not alter the memory (on behalf of this
534 * operation) once this event has been logged.
535 */
536 LNET_EVENT_PUT,
537 /**
538 * A REPLY operation has completed. This event is logged after the
539 * data (if any) from the REPLY has been written into the MD.
540 */
541 LNET_EVENT_REPLY,
542 /** An acknowledgment has been received. */
543 LNET_EVENT_ACK,
544 /**
545 * An outgoing send (PUT or GET) operation has completed. This event
546 * is logged after the entire buffer has been sent and it is safe for
547 * the caller to reuse the buffer.
548 *
549 * Note:
550 * - The LNET_EVENT_SEND doesn't guarantee message delivery. It can
551 * happen even when the message has not yet been put out on wire.
552 * - It's unsafe to assume that in an outgoing GET operation
553 * the LNET_EVENT_SEND event would happen before the
554 * LNET_EVENT_REPLY event. The same holds for LNET_EVENT_SEND and
555 * LNET_EVENT_ACK events in an outgoing PUT operation.
556 */
557 LNET_EVENT_SEND,
558 /**
559 * A MD has been unlinked. Note that LNetMDUnlink() does not
560 * necessarily trigger an LNET_EVENT_UNLINK event.
561 * \see LNetMDUnlink
562 */
563 LNET_EVENT_UNLINK,
564} lnet_event_kind_t;
565
James Simmons188acc62015-06-11 15:18:14 -0400566#define LNET_SEQ_BASETYPE long
Peng Taod7e09d02013-05-02 16:46:55 +0800567typedef unsigned LNET_SEQ_BASETYPE lnet_seq_t;
Joshua Baldocke4422942014-04-02 19:12:59 +1100568#define LNET_SEQ_GT(a, b) (((signed LNET_SEQ_BASETYPE)((a) - (b))) > 0)
Peng Taod7e09d02013-05-02 16:46:55 +0800569
Peng Taod7e09d02013-05-02 16:46:55 +0800570/**
571 * Information about an event on a MD.
572 */
573typedef struct {
574 /** The identifier (nid, pid) of the target. */
James Simmons188acc62015-06-11 15:18:14 -0400575 lnet_process_id_t target;
Peng Taod7e09d02013-05-02 16:46:55 +0800576 /** The identifier (nid, pid) of the initiator. */
James Simmons188acc62015-06-11 15:18:14 -0400577 lnet_process_id_t initiator;
Peng Taod7e09d02013-05-02 16:46:55 +0800578 /**
579 * The NID of the immediate sender. If the request has been forwarded
580 * by routers, this is the NID of the last hop; otherwise it's the
581 * same as the initiator.
582 */
James Simmons188acc62015-06-11 15:18:14 -0400583 lnet_nid_t sender;
Peng Taod7e09d02013-05-02 16:46:55 +0800584 /** Indicates the type of the event. */
James Simmons188acc62015-06-11 15:18:14 -0400585 lnet_event_kind_t type;
Peng Taod7e09d02013-05-02 16:46:55 +0800586 /** The portal table index specified in the request */
James Simmons188acc62015-06-11 15:18:14 -0400587 unsigned int pt_index;
Peng Taod7e09d02013-05-02 16:46:55 +0800588 /** A copy of the match bits specified in the request. */
James Simmons188acc62015-06-11 15:18:14 -0400589 __u64 match_bits;
Peng Taod7e09d02013-05-02 16:46:55 +0800590 /** The length (in bytes) specified in the request. */
James Simmons188acc62015-06-11 15:18:14 -0400591 unsigned int rlength;
Peng Taod7e09d02013-05-02 16:46:55 +0800592 /**
593 * The length (in bytes) of the data that was manipulated by the
594 * operation. For truncated operations, the manipulated length will be
595 * the number of bytes specified by the MD (possibly with an offset,
596 * see lnet_md_t). For all other operations, the manipulated length
597 * will be the length of the requested operation, i.e. rlength.
598 */
James Simmons188acc62015-06-11 15:18:14 -0400599 unsigned int mlength;
Peng Taod7e09d02013-05-02 16:46:55 +0800600 /**
601 * The handle to the MD associated with the event. The handle may be
602 * invalid if the MD has been unlinked.
603 */
James Simmons188acc62015-06-11 15:18:14 -0400604 lnet_handle_md_t md_handle;
Peng Taod7e09d02013-05-02 16:46:55 +0800605 /**
606 * A snapshot of the state of the MD immediately after the event has
607 * been processed. In particular, the threshold field in md will
608 * reflect the value of the threshold after the operation occurred.
609 */
James Simmons188acc62015-06-11 15:18:14 -0400610 lnet_md_t md;
Peng Taod7e09d02013-05-02 16:46:55 +0800611 /**
612 * 64 bits of out-of-band user data. Only valid for LNET_EVENT_PUT.
613 * \see LNetPut
614 */
James Simmons188acc62015-06-11 15:18:14 -0400615 __u64 hdr_data;
Peng Taod7e09d02013-05-02 16:46:55 +0800616 /**
617 * Indicates the completion status of the operation. It's 0 for
618 * successful operations, otherwise it's an error code.
619 */
James Simmons188acc62015-06-11 15:18:14 -0400620 int status;
Peng Taod7e09d02013-05-02 16:46:55 +0800621 /**
622 * Indicates whether the MD has been unlinked. Note that:
623 * - An event with unlinked set is the last event on the MD.
624 * - This field is also set for an explicit LNET_EVENT_UNLINK event.
625 * \see LNetMDUnlink
626 */
James Simmons188acc62015-06-11 15:18:14 -0400627 int unlinked;
Peng Taod7e09d02013-05-02 16:46:55 +0800628 /**
629 * The displacement (in bytes) into the memory region that the
630 * operation used. The offset can be determined by the operation for
631 * a remote managed MD or by the local MD.
632 * \see lnet_md_t::options
633 */
James Simmons188acc62015-06-11 15:18:14 -0400634 unsigned int offset;
Peng Taod7e09d02013-05-02 16:46:55 +0800635 /**
636 * The sequence number for this event. Sequence numbers are unique
637 * to each event.
638 */
James Simmons188acc62015-06-11 15:18:14 -0400639 volatile lnet_seq_t sequence;
Peng Taod7e09d02013-05-02 16:46:55 +0800640} lnet_event_t;
Peng Taod7e09d02013-05-02 16:46:55 +0800641
642/**
643 * Event queue handler function type.
644 *
645 * The EQ handler runs for each event that is deposited into the EQ. The
646 * handler is supplied with a pointer to the event that triggered the
647 * handler invocation.
648 *
649 * The handler must not block, must be reentrant, and must not call any LNet
650 * API functions. It should return as quickly as possible.
651 */
652typedef void (*lnet_eq_handler_t)(lnet_event_t *event);
653#define LNET_EQ_HANDLER_NONE NULL
654/** @} lnet_eq */
655
656/** \addtogroup lnet_data
James Simmons4420cfd2016-02-12 12:06:00 -0500657 * @{
658 */
Peng Taod7e09d02013-05-02 16:46:55 +0800659
660/**
661 * Specify whether an acknowledgment should be sent by target when the PUT
662 * operation completes (i.e., when the data has been written to a MD of the
663 * target process).
664 *
665 * \see lnet_md_t::options for the discussion on LNET_MD_ACK_DISABLE by which
666 * acknowledgments can be disabled for a MD.
667 */
668typedef enum {
669 /** Request an acknowledgment */
670 LNET_ACK_REQ,
671 /** Request that no acknowledgment should be generated. */
672 LNET_NOACK_REQ
673} lnet_ack_req_t;
674/** @} lnet_data */
675
676/** @} lnet */
677#endif