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