Whamcloud - gitweb
LU-14627 lnet: Ensure ref taken when queueing for discovery
[fs/lustre-release.git] / lnet / klnds / o2iblnd / o2iblnd-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) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2011, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * lnet/klnds/o2iblnd/o2iblnd-idl.h
32  *
33  * Author: Eric Barton <eric@bartonsoftware.com>
34  */
35 #ifndef __LNET_O2IBLND_IDL_H__
36 #define __LNET_O2IBLND_IDL_H__
37
38 #include <uapi/linux/lnet/lnet-idl.h>
39
40 /************************************************************************
41  * IB Wire message format.
42  * These are sent in sender's byte order (i.e. receiver flips).
43  */
44
45 struct kib_connparams {
46         u16                     ibcp_queue_depth;
47         u16                     ibcp_max_frags;
48         u32                     ibcp_max_msg_size;
49 } __packed;
50
51 struct kib_immediate_msg {
52         struct lnet_hdr         ibim_hdr;       /* portals header */
53         char                    ibim_payload[0];/* piggy-backed payload */
54 } __packed;
55
56 struct kib_rdma_frag {
57         u32                     rf_nob;         /* # bytes this frag */
58         u64                     rf_addr;        /* CAVEAT EMPTOR: misaligned!! */
59 } __packed;
60
61 struct kib_rdma_desc {
62         u32                     rd_key;         /* local/remote key */
63         u32                     rd_nfrags;      /* # fragments */
64         struct kib_rdma_frag    rd_frags[0];    /* buffer frags */
65 } __packed;
66
67 struct kib_putreq_msg {
68         struct lnet_hdr         ibprm_hdr;      /* portals header */
69         u64                     ibprm_cookie;   /* opaque completion cookie */
70 } __packed;
71
72 struct kib_putack_msg {
73         u64                     ibpam_src_cookie;/* reflected completion cookie */
74         u64                     ibpam_dst_cookie;/* opaque completion cookie */
75         struct kib_rdma_desc    ibpam_rd;       /* sender's sink buffer */
76 } __packed;
77
78 struct kib_get_msg {
79         struct lnet_hdr         ibgm_hdr;       /* portals header */
80         u64                     ibgm_cookie;    /* opaque completion cookie */
81         struct kib_rdma_desc    ibgm_rd;        /* rdma descriptor */
82 } __packed;
83
84 struct kib_completion_msg {
85         u64                     ibcm_cookie;    /* opaque completion cookie */
86         s32                     ibcm_status;    /* < 0 failure: >= 0 length */
87 } __packed;
88
89 struct kib_msg {
90         /* First 2 fields fixed FOR ALL TIME */
91         u32                     ibm_magic;      /* I'm an ibnal message */
92         u16                     ibm_version;    /* this is my version number */
93
94         u8                      ibm_type;       /* msg type */
95         u8                      ibm_credits;    /* returned credits */
96         u32                     ibm_nob;        /* # bytes in whole message */
97         u32                     ibm_cksum;      /* checksum (0 == no checksum) */
98         u64                     ibm_srcnid;     /* sender's NID */
99         u64                     ibm_srcstamp;   /* sender's incarnation */
100         u64                     ibm_dstnid;     /* destination's NID */
101         u64                     ibm_dststamp;   /* destination's incarnation */
102
103         union {
104                 struct kib_connparams           connparams;
105                 struct kib_immediate_msg        immediate;
106                 struct kib_putreq_msg           putreq;
107                 struct kib_putack_msg           putack;
108                 struct kib_get_msg              get;
109                 struct kib_completion_msg       completion;
110         } __packed ibm_u;
111 } __packed;
112
113 #define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC     /* unique magic */
114
115 #define IBLND_MSG_VERSION_1     0x11
116 #define IBLND_MSG_VERSION_2     0x12
117 #define IBLND_MSG_VERSION       IBLND_MSG_VERSION_2
118
119 #define IBLND_MSG_CONNREQ       0xc0    /* connection request */
120 #define IBLND_MSG_CONNACK       0xc1    /* connection acknowledge */
121 #define IBLND_MSG_NOOP          0xd0    /* nothing (just credits) */
122 #define IBLND_MSG_IMMEDIATE     0xd1    /* immediate */
123 #define IBLND_MSG_PUT_REQ       0xd2    /* putreq (src->sink) */
124 #define IBLND_MSG_PUT_NAK       0xd3    /* completion (sink->src) */
125 #define IBLND_MSG_PUT_ACK       0xd4    /* putack (sink->src) */
126 #define IBLND_MSG_PUT_DONE      0xd5    /* completion (src->sink) */
127 #define IBLND_MSG_GET_REQ       0xd6    /* getreq (sink->src) */
128 #define IBLND_MSG_GET_DONE      0xd7    /* completion (src->sink: all OK) */
129
130 struct kib_rej {
131         u32                     ibr_magic;      /* sender's magic */
132         u16                     ibr_version;    /* sender's version */
133         u8                      ibr_why;        /* reject reason */
134         u8                      ibr_padding;    /* padding */
135         u64                     ibr_incarnation;/* incarnation of peer_ni */
136         struct kib_connparams   ibr_cp;         /* connection parameters */
137 } __packed;
138
139 /* connection rejection reasons */
140 #define IBLND_REJECT_CONN_RACE       1          /* You lost connection race */
141 #define IBLND_REJECT_NO_RESOURCES    2          /* Out of memory/conns etc */
142 #define IBLND_REJECT_FATAL           3          /* Anything else */
143
144 #define IBLND_REJECT_CONN_UNCOMPAT   4          /* incompatible version peer_ni */
145 #define IBLND_REJECT_CONN_STALE      5          /* stale peer_ni */
146
147 /* peer_ni's rdma frags doesn't match mine */
148 #define IBLND_REJECT_RDMA_FRAGS      6
149 /* peer_ni's msg queue size doesn't match mine */
150 #define IBLND_REJECT_MSG_QUEUE_SIZE  7
151 #define IBLND_REJECT_INVALID_SRV_ID  8
152
153 /***********************************************************************/
154
155 #endif /* __LNET_O2IBLND_IDL_H__ */