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));
148 struct lnet_reply reply;
149 struct lnet_hello hello;
150 } __attribute__((packed));
152 /* This is used for message headers that lnet code is manipulating.
153 * All fields before the union are in host-byte-order.
156 struct lnet_nid dest_nid;
157 struct lnet_nid src_nid;
160 __u32 type; /* enum lnet_msg_type */
161 __u32 payload_length; /* payload data to follow */
162 /*<------__u64 aligned------->*/
163 union lnet_cmd_hdr msg;
164 } __attribute__((packed));
166 /* This is used to support conversion between an lnet_hdr and
167 * the content of a network message.
169 struct _lnet_hdr_nid4 {
174 __u32 type; /* enum lnet_msg_type */
175 __u32 payload_length; /* payload data to follow */
176 /*<------__u64 aligned------->*/
177 union lnet_cmd_hdr msg;
178 } __attribute__((packed));
180 /* This is stored in a network message buffer. Content cannot be accessed
181 * without converting to an lnet_hdr.
183 struct lnet_hdr_nid4 {
184 char _bytes[sizeof(struct _lnet_hdr_nid4)];
185 } __attribute__((packed));
187 /* A HELLO message contains a magic number and protocol version
188 * code in the header's dest_nid, the peer's NID in the src_nid, and
189 * LNET_MSG_HELLO in the type field. All other common fields are zero
190 * (including payload_size; i.e. no payload).
191 * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
192 * running the same protocol and to find out its NID. These LNDs should
193 * exchange HELLO messages when a connection is first established. Individual
194 * LNDs can put whatever else they fancy in lnet_hdr::msg.
196 struct lnet_magicversion {
197 __u32 magic; /* LNET_PROTO_TCP_MAGIC */
198 __u16 version_major; /* increment on incompatible change */
199 __u16 version_minor; /* increment on compatible change */
200 } __attribute__((packed));
202 /* PROTO MAGIC for LNDs */
203 #define LNET_PROTO_IB_MAGIC 0x0be91b91
204 #define LNET_PROTO_GNI_MAGIC 0xb00fbabe /* ask Kim */
205 #define LNET_PROTO_TCP_MAGIC 0xeebc0ded
206 #define LNET_PROTO_KFI_MAGIC 0xdeadbeef
207 #define LNET_PROTO_ACCEPTOR_MAGIC 0xacce7100
208 #define LNET_PROTO_PING_MAGIC 0x70696E67 /* 'ping' */
210 /* Placeholder for a future "unified" protocol across all LNDs */
211 /* Current LNDs that receive a request with this magic will respond
212 * with a "stub" reply using their current protocol */
213 #define LNET_PROTO_MAGIC 0x45726963 /* ! */
215 #define LNET_PROTO_TCP_VERSION_MAJOR 1
216 #define LNET_PROTO_TCP_VERSION_MINOR 0
218 /* Acceptor connection request */
219 struct lnet_acceptor_connreq {
220 __u32 acr_magic; /* LNET_PROTO_ACCEPTOR_MAGIC */
221 __u32 acr_version; /* protocol version */
222 __u64 acr_nid; /* target NID */
223 } __attribute__((packed));
225 #define LNET_PROTO_ACCEPTOR_VERSION 1
227 struct lnet_acceptor_connreq_v2 {
228 __u32 acr_magic; /* LNET_PROTO_ACCEPTOR_MAGIC */
229 __u32 acr_version; /* protocol version - 2 */
230 struct lnet_nid acr_nid; /* target NID */
231 } __attribute__((packed));
233 /* For use with 16-byte addresses */
234 #define LNET_PROTO_ACCEPTOR_VERSION_16 2
236 struct lnet_counters_common {
237 __u32 lcc_msgs_alloc;
240 __u32 lcc_send_count;
241 __u32 lcc_recv_count;
242 __u32 lcc_route_count;
243 __u32 lcc_drop_count;
244 __u64 lcc_send_length;
245 __u64 lcc_recv_length;
246 __u64 lcc_route_length;
247 __u64 lcc_drop_length;
248 } __attribute__((packed));
251 #define LNET_NI_STATUS_UP 0x15aac0de
252 #define LNET_NI_STATUS_DOWN 0xdeadface
253 #define LNET_NI_STATUS_INVALID 0x00000000
255 struct lnet_ni_status {
259 } __attribute__((packed));
262 * NB: value of these features equal to LNET_PROTO_PING_VERSION_x
263 * of old LNet, so there shouldn't be any compatibility issue
265 #define LNET_PING_FEAT_INVAL (0) /* no feature */
266 #define LNET_PING_FEAT_BASE (1 << 0) /* just a ping */
267 #define LNET_PING_FEAT_NI_STATUS (1 << 1) /* return NI status */
268 #define LNET_PING_FEAT_RTE_DISABLED (1 << 2) /* Routing enabled */
269 #define LNET_PING_FEAT_MULTI_RAIL (1 << 3) /* Multi-Rail aware */
270 #define LNET_PING_FEAT_DISCOVERY (1 << 4) /* Supports Discovery */
273 * All ping feature bits fit to hit the wire.
274 * In lnet_assert_wire_constants() this is compared against its open-coded
275 * value, and in lnet_ping_target_update() it is used to verify that no
276 * unknown bits have been set.
277 * New feature bits can be added, just be aware that this does change the
278 * over-the-wire protocol.
280 #define LNET_PING_FEAT_BITS (LNET_PING_FEAT_BASE | \
281 LNET_PING_FEAT_NI_STATUS | \
282 LNET_PING_FEAT_RTE_DISABLED | \
283 LNET_PING_FEAT_MULTI_RAIL | \
284 LNET_PING_FEAT_DISCOVERY)
286 struct lnet_ping_info {
291 struct lnet_ni_status pi_ni[0];
292 } __attribute__((packed));
294 #define LNET_PING_INFO_HDR_SIZE \
295 offsetof(struct lnet_ping_info, pi_ni[0])
296 #define LNET_PING_INFO_MIN_SIZE \
297 offsetof(struct lnet_ping_info, pi_ni[LNET_INTERFACES_MIN])
298 #define LNET_PING_INFO_LONI(PINFO) ((PINFO)->pi_ni[0].ns_nid)
299 #define LNET_PING_INFO_SEQNO(PINFO) ((PINFO)->pi_ni[0].ns_status)
300 #define lnet_ping_info_size(pinfo) \
301 offsetof(struct lnet_ping_info, pi_ni[(pinfo)->pi_nnis])