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