Whamcloud - gitweb
8589a905c0e9fa74eaf0feb87f56781b574020ef
[fs/lustre-release.git] / lnet / include / uapi / linux / lnet / lnet-idl.h
1 /*
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
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
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  *
26  * Copyright (c) 2012, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  */
32
33 #ifndef __UAPI_LNET_IDL_H__
34 #define __UAPI_LNET_IDL_H__
35
36 #include <linux/types.h>
37
38 /************************************************************************
39  * Core LNet wire message format.
40  * These are sent in sender's byte order (i.e. receiver flips).
41  */
42
43 /**
44  * Address of an end-point in an LNet network.
45  *
46  * A node can have multiple end-points and hence multiple addresses.
47  * An LNet network can be a simple network (e.g. tcp0) or a network of
48  * LNet networks connected by LNet routers. Therefore an end-point address
49  * has two parts: network ID, and address within a network.
50  *
51  * \see LNET_NIDNET, LNET_NIDADDR, and LNET_MKNID.
52  */
53 typedef __u64 lnet_nid_t;
54
55 /**
56  * ID of a process in a node. Shortened as PID to distinguish from
57  * lnet_process_id, the global process ID.
58  */
59 typedef __u32 lnet_pid_t;
60
61 /* Packed version of struct lnet_process_id to transfer via network */
62 struct lnet_process_id_packed {
63         lnet_nid_t nid;
64         lnet_pid_t pid; /* node id / process id */
65 } __attribute__((packed));
66
67 /* The wire handle's interface cookie only matches one network interface in
68  * one epoch (i.e. new cookie when the interface restarts or the node
69  * reboots).  The object cookie only matches one object on that interface
70  * during that object's lifetime (i.e. no cookie re-use).
71  */
72 struct lnet_handle_wire {
73         __u64 wh_interface_cookie;
74         __u64 wh_object_cookie;
75 } __attribute__((packed));
76
77 enum lnet_msg_type {
78         LNET_MSG_ACK = 0,
79         LNET_MSG_PUT,
80         LNET_MSG_GET,
81         LNET_MSG_REPLY,
82         LNET_MSG_HELLO,
83 };
84
85 /* The variant fields of the portals message header are aligned on an 8
86  * byte boundary in the message header.  Note that all types used in these
87  * wire structs MUST be fixed size and the smaller types are placed at the
88  * end.
89  */
90 struct lnet_ack {
91         struct lnet_handle_wire dst_wmd;
92         __u64                   match_bits;
93         __u32                   mlength;
94 } __attribute__((packed));
95
96 struct lnet_put {
97         struct lnet_handle_wire ack_wmd;
98         __u64                   match_bits;
99         __u64                   hdr_data;
100         __u32                   ptl_index;
101         __u32                   offset;
102 } __attribute__((packed));
103
104 struct lnet_get {
105         struct lnet_handle_wire return_wmd;
106         __u64                   match_bits;
107         __u32                   ptl_index;
108         __u32                   src_offset;
109         __u32                   sink_length;
110 } __attribute__((packed));
111
112 struct lnet_reply {
113         struct lnet_handle_wire dst_wmd;
114 } __attribute__((packed));
115
116 struct lnet_hello {
117         __u64                   incarnation;
118         __u32                   type;
119 } __attribute__((packed));
120
121 struct lnet_hdr {
122         lnet_nid_t      dest_nid;
123         lnet_nid_t      src_nid;
124         lnet_pid_t      dest_pid;
125         lnet_pid_t      src_pid;
126         __u32           type;           /* enum lnet_msg_type */
127         __u32           payload_length; /* payload data to follow */
128         /*<------__u64 aligned------->*/
129         union {
130                 struct lnet_ack         ack;
131                 struct lnet_put         put;
132                 struct lnet_get         get;
133                 struct lnet_reply       reply;
134                 struct lnet_hello       hello;
135         } msg;
136 } __attribute__((packed));
137
138 /* A HELLO message contains a magic number and protocol version
139  * code in the header's dest_nid, the peer's NID in the src_nid, and
140  * LNET_MSG_HELLO in the type field.  All other common fields are zero
141  * (including payload_size; i.e. no payload).
142  * This is for use by byte-stream LNDs (e.g. TCP/IP) to check the peer is
143  * running the same protocol and to find out its NID. These LNDs should
144  * exchange HELLO messages when a connection is first established.  Individual
145  * LNDs can put whatever else they fancy in lnet_hdr::msg.
146  */
147 struct lnet_magicversion {
148         __u32   magic;          /* LNET_PROTO_TCP_MAGIC */
149         __u16   version_major;  /* increment on incompatible change */
150         __u16   version_minor;  /* increment on compatible change */
151 } __attribute__((packed));
152
153 /* PROTO MAGIC for LNDs */
154 #define LNET_PROTO_IB_MAGIC             0x0be91b91
155 #define LNET_PROTO_GNI_MAGIC            0xb00fbabe /* ask Kim */
156 #define LNET_PROTO_TCP_MAGIC            0xeebc0ded
157 #define LNET_PROTO_ACCEPTOR_MAGIC       0xacce7100
158 #define LNET_PROTO_PING_MAGIC           0x70696E67 /* 'ping' */
159
160 /* Placeholder for a future "unified" protocol across all LNDs */
161 /* Current LNDs that receive a request with this magic will respond
162  * with a "stub" reply using their current protocol */
163 #define LNET_PROTO_MAGIC                0x45726963 /* ! */
164
165 #define LNET_PROTO_TCP_VERSION_MAJOR    1
166 #define LNET_PROTO_TCP_VERSION_MINOR    0
167
168 /* Acceptor connection request */
169 struct lnet_acceptor_connreq {
170         __u32   acr_magic;      /* PTL_ACCEPTOR_PROTO_MAGIC */
171         __u32   acr_version;    /* protocol version */
172         __u64   acr_nid;        /* target NID */
173 } __attribute__((packed));
174
175 #define LNET_PROTO_ACCEPTOR_VERSION     1
176
177 struct lnet_counters_common {
178         __u32   lcc_msgs_alloc;
179         __u32   lcc_msgs_max;
180         __u32   lcc_errors;
181         __u32   lcc_send_count;
182         __u32   lcc_recv_count;
183         __u32   lcc_route_count;
184         __u32   lcc_drop_count;
185         __u64   lcc_send_length;
186         __u64   lcc_recv_length;
187         __u64   lcc_route_length;
188         __u64   lcc_drop_length;
189 } __attribute__((packed));
190
191
192 #define LNET_NI_STATUS_UP       0x15aac0de
193 #define LNET_NI_STATUS_DOWN     0xdeadface
194 #define LNET_NI_STATUS_INVALID  0x00000000
195
196 struct lnet_ni_status {
197         lnet_nid_t ns_nid;
198         __u32      ns_status;
199         __u32      ns_unused;
200 } __attribute__((packed));
201
202 /*
203  * NB: value of these features equal to LNET_PROTO_PING_VERSION_x
204  * of old LNet, so there shouldn't be any compatibility issue
205  */
206 #define LNET_PING_FEAT_INVAL            (0)             /* no feature */
207 #define LNET_PING_FEAT_BASE             (1 << 0)        /* just a ping */
208 #define LNET_PING_FEAT_NI_STATUS        (1 << 1)        /* return NI status */
209 #define LNET_PING_FEAT_RTE_DISABLED     (1 << 2)        /* Routing enabled */
210 #define LNET_PING_FEAT_MULTI_RAIL       (1 << 3)        /* Multi-Rail aware */
211 #define LNET_PING_FEAT_DISCOVERY        (1 << 4)        /* Supports Discovery */
212
213 /*
214  * All ping feature bits fit to hit the wire.
215  * In lnet_assert_wire_constants() this is compared against its open-coded
216  * value, and in lnet_ping_target_update() it is used to verify that no
217  * unknown bits have been set.
218  * New feature bits can be added, just be aware that this does change the
219  * over-the-wire protocol.
220  */
221 #define LNET_PING_FEAT_BITS             (LNET_PING_FEAT_BASE | \
222                                          LNET_PING_FEAT_NI_STATUS | \
223                                          LNET_PING_FEAT_RTE_DISABLED | \
224                                          LNET_PING_FEAT_MULTI_RAIL | \
225                                          LNET_PING_FEAT_DISCOVERY)
226
227 struct lnet_ping_info {
228         __u32                   pi_magic;
229         __u32                   pi_features;
230         lnet_pid_t              pi_pid;
231         __u32                   pi_nnis;
232         struct lnet_ni_status   pi_ni[0];
233 } __attribute__((packed));
234
235 #define LNET_PING_INFO_SIZE(NNIDS) \
236         offsetof(struct lnet_ping_info, pi_ni[NNIDS])
237 #define LNET_PING_INFO_LONI(PINFO)      ((PINFO)->pi_ni[0].ns_nid)
238 #define LNET_PING_INFO_SEQNO(PINFO)     ((PINFO)->pi_ni[0].ns_status)
239
240 #endif