4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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.
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).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2012, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
32 #ifndef __UAPI_LNET_IDL_H__
33 #define __UAPI_LNET_IDL_H__
35 #include <linux/types.h>
37 /************************************************************************
38 * Core LNet wire message format.
39 * These are sent in sender's byte order (i.e. receiver flips).
42 /** Address of an end-point in an LNet network.
44 * A node can have multiple end-points and hence multiple addresses.
45 * An LNet network can be a simple network (e.g. tcp0) or a network of
46 * LNet networks connected by LNet routers. Therefore an end-point address
47 * has two parts: network ID, and address within a network.
48 * The most-significant-byte in this format is always 0. A larger value
49 * would imply a larger nid with a larger address.
51 * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
53 typedef __u64 lnet_nid_t;
56 * Address of LNet end-point in extended form
58 * To support addresses larger than 32bits we have
59 * an extended nid which supports up to 128 bits
60 * of address and is extensible.
61 * If nid_size is 0, then the nid can be stored in an lnet_nid_t,
62 * and the first 8 bytes of the 'struct lnet_nid' are identical to
63 * the lnet_nid_t in big-endian format.
64 * If nid_type == 0xff, then all other fields should be ignored
65 * and this is an ANY wildcard address. In particular, the nid_size
66 * can be 0xff without making the address too big to fit.
69 __u8 nid_size; /* total bytes - 8 */
73 } __attribute__((packed));
75 #define NID_BYTES(nid) ((nid)->nid_size + 8)
76 #define NID_ADDR_BYTES(nid) ((nid)->nid_size + 4)
79 * ID of a process in a node. Shortened as PID to distinguish from
80 * lnet_process_id, the global process ID.
82 typedef __u32 lnet_pid_t;
84 /* Packed version of struct lnet_process_id to transfer via network */
85 struct lnet_process_id_packed {
87 lnet_pid_t pid; /* node id / process id */
88 } __attribute__((packed));
90 /* The wire handle's interface cookie only matches one network interface in
91 * one epoch (i.e. new cookie when the interface restarts or the node
92 * reboots). The object cookie only matches one object on that interface
93 * during that object's lifetime (i.e. no cookie re-use).
95 struct lnet_handle_wire {
96 __u64 wh_interface_cookie;
97 __u64 wh_object_cookie;
98 } __attribute__((packed));
108 /* The variant fields of the portals message header are aligned on an 8
109 * byte boundary in the message header. Note that all types used in these
110 * wire structs MUST be fixed size and the smaller types are placed at the
114 struct lnet_handle_wire dst_wmd;
117 } __attribute__((packed));
120 struct lnet_handle_wire ack_wmd;
125 } __attribute__((packed));
128 struct lnet_handle_wire return_wmd;
133 } __attribute__((packed));
136 struct lnet_handle_wire dst_wmd;
137 } __attribute__((packed));
142 } __attribute__((packed));
149 __u32 type; /* enum lnet_msg_type */
150 __u32 payload_length; /* payload data to follow */
151 /*<------__u64 aligned------->*/
156 struct lnet_reply reply;
157 struct lnet_hello hello;
159 } __attribute__((packed));
161 /* A HELLO message contains a magic number and protocol version
162 * code in the header's dest_nid, the peer's NID in the src_nid, and
163 * LNET_MSG_HELLO in the type field. All other common fields are zero
164 * (including payload_size; i.e. no payload).
165 * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
166 * running the same protocol and to find out its NID. These LNDs should
167 * exchange HELLO messages when a connection is first established. Individual
168 * LNDs can put whatever else they fancy in lnet_hdr::msg.
170 struct lnet_magicversion {
171 __u32 magic; /* LNET_PROTO_TCP_MAGIC */
172 __u16 version_major; /* increment on incompatible change */
173 __u16 version_minor; /* increment on compatible change */
174 } __attribute__((packed));
176 /* PROTO MAGIC for LNDs */
177 #define LNET_PROTO_IB_MAGIC 0x0be91b91
178 #define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */
179 #define LNET_PROTO_TCP_MAGIC 0xeebc0ded
180 #define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100
181 #define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */
183 /* Placeholder for a future "unified" protocol across all LNDs */
184 /* Current LNDs that receive a request with this magic will respond
185 * with a "stub" reply using their current protocol */
186 #define LNET_PROTO_MAGIC 0x45726963 /* ! */
188 #define LNET_PROTO_TCP_VERSION_MAJOR 1
189 #define LNET_PROTO_TCP_VERSION_MINOR 0
191 /* Acceptor connection request */
192 struct lnet_acceptor_connreq {
193 __u32 acr_magic; /* LNET_PROTO_ACCEPTOR_MAGIC */
194 __u32 acr_version; /* protocol version */
195 __u64 acr_nid; /* target NID */
196 } __attribute__((packed));
198 #define LNET_PROTO_ACCEPTOR_VERSION 1
200 struct lnet_acceptor_connreq_v2 {
201 __u32 acr_magic; /* LNET_PROTO_ACCEPTOR_MAGIC */
202 __u32 acr_version; /* protocol version - 2 */
203 struct lnet_nid acr_nid; /* target NID */
204 } __attribute__((packed));
206 /* For use with 16-byte addresses */
207 #define LNET_PROTO_ACCEPTOR_VERSION_16 2
209 struct lnet_counters_common {
210 __u32 lcc_msgs_alloc;
213 __u32 lcc_send_count;
214 __u32 lcc_recv_count;
215 __u32 lcc_route_count;
216 __u32 lcc_drop_count;
217 __u64 lcc_send_length;
218 __u64 lcc_recv_length;
219 __u64 lcc_route_length;
220 __u64 lcc_drop_length;
221 } __attribute__((packed));
224 #define LNET_NI_STATUS_UP 0x15aac0de
225 #define LNET_NI_STATUS_DOWN 0xdeadface
226 #define LNET_NI_STATUS_INVALID 0x00000000
228 struct lnet_ni_status {
232 } __attribute__((packed));
235 * NB: value of these features equal to LNET_PROTO_PING_VERSION_x
236 * of old LNet, so there shouldn't be any compatibility issue
238 #define LNET_PING_FEAT_INVAL (0) /* no feature */
239 #define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */
240 #define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */
241 #define LNET_PING_FEAT_RTE_DISABLED (1 << 2) /* Routing enabled */
242 #define LNET_PING_FEAT_MULTI_RAIL (1 << 3) /* Multi-Rail aware */
243 #define LNET_PING_FEAT_DISCOVERY (1 << 4) /* Supports Discovery */
246 * All ping feature bits fit to hit the wire.
247 * In lnet_assert_wire_constants() this is compared against its open-coded
248 * value, and in lnet_ping_target_update() it is used to verify that no
249 * unknown bits have been set.
250 * New feature bits can be added, just be aware that this does change the
251 * over-the-wire protocol.
253 #define LNET_PING_FEAT_BITS (LNET_PING_FEAT_BASE | \
254 LNET_PING_FEAT_NI_STATUS | \
255 LNET_PING_FEAT_RTE_DISABLED | \
256 LNET_PING_FEAT_MULTI_RAIL | \
257 LNET_PING_FEAT_DISCOVERY)
259 struct lnet_ping_info {
264 struct lnet_ni_status pi_ni[0];
265 } __attribute__((packed));
267 #define LNET_PING_INFO_SIZE(NNIDS) \
268 offsetof(struct lnet_ping_info, pi_ni[NNIDS])
269 #define LNET_PING_INFO_LONI(PINFO) ((PINFO)->pi_ni[0].ns_nid)
270 #define LNET_PING_INFO_SEQNO(PINFO) ((PINFO)->pi_ni[0].ns_status)