Whamcloud - gitweb
Revert "b20288 fix a deadlock in kiblnd_check_conns i=isaac i=maxim"
[fs/lustre-release.git] / lnet / klnds / viblnd / viblnd_wire.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lnet/klnds/viblnd/viblnd_wire.h
37  *
38  * IB Wire message format.
39  * These are sent in sender's byte order (i.e. receiver flips).
40  */
41
42 typedef struct kib_connparams
43 {
44         __u32             ibcp_queue_depth;
45         __u32             ibcp_max_msg_size;
46         __u32             ibcp_max_frags;
47 } WIRE_ATTR kib_connparams_t;
48
49 typedef struct
50 {
51         lnet_hdr_t        ibim_hdr;             /* portals header */
52         char              ibim_payload[0];      /* piggy-backed payload */
53 } WIRE_ATTR kib_immediate_msg_t;
54
55 #ifndef IBNAL_USE_FMR
56 # error "IBNAL_USE_FMR must be defined 1 or 0 before including this file"
57 #endif
58
59 #if IBNAL_USE_FMR
60 typedef struct
61 {
62         __u64             rd_addr;              /* IO VMA address */
63         __u32             rd_nob;               /* # of bytes */
64         __u32             rd_key;               /* remote key */
65 } WIRE_ATTR kib_rdma_desc_t;
66 #else
67 /* YEUCH! the __u64 address is split into 2 __u32 fields to ensure proper
68  * packing.  Otherwise we can't fit enough frags into an IBNAL message (<=
69  * smallest page size on any arch). */
70 typedef struct
71 {
72         __u32             rf_nob;               /* # of bytes */
73         __u32             rf_addr_lo;           /* lo 4 bytes of vaddr */
74         __u32             rf_addr_hi;           /* hi 4 bytes of vaddr */
75 } WIRE_ATTR kib_rdma_frag_t;
76
77 typedef struct
78 {
79         __u32             rd_key;               /* local/remote key */
80         __u32             rd_nfrag;             /* # fragments */
81         kib_rdma_frag_t   rd_frags[0];          /* buffer frags */
82 } WIRE_ATTR kib_rdma_desc_t;
83 #endif
84
85 typedef struct
86 {
87         lnet_hdr_t        ibprm_hdr;            /* portals header */
88         __u64             ibprm_cookie;         /* opaque completion cookie */
89 } WIRE_ATTR kib_putreq_msg_t;
90
91 typedef struct
92 {
93         __u64             ibpam_src_cookie;     /* reflected completion cookie */
94         __u64             ibpam_dst_cookie;     /* opaque completion cookie */
95         kib_rdma_desc_t   ibpam_rd;             /* sender's sink buffer */
96 } WIRE_ATTR kib_putack_msg_t;
97
98 typedef struct
99 {
100         lnet_hdr_t        ibgm_hdr;             /* portals header */
101         __u64             ibgm_cookie;          /* opaque completion cookie */
102         kib_rdma_desc_t   ibgm_rd;              /* rdma descriptor */
103 } WIRE_ATTR kib_get_msg_t;
104
105 typedef struct
106 {
107         __u64             ibcm_cookie;          /* opaque completion cookie */
108         __s32             ibcm_status;          /* < 0 failure: >= 0 length */
109 } WIRE_ATTR kib_completion_msg_t;
110
111 typedef struct
112 {
113         /* First 2 fields fixed FOR ALL TIME */
114         __u32             ibm_magic;            /* I'm an openibnal message */
115         __u16             ibm_version;          /* this is my version number */
116
117         __u8              ibm_type;             /* msg type */
118         __u8              ibm_credits;          /* returned credits */
119         __u32             ibm_nob;              /* # bytes in whole message */
120         __u32             ibm_cksum;            /* checksum (0 == no checksum) */
121         __u64             ibm_srcnid;           /* sender's NID */
122         __u64             ibm_srcstamp;         /* sender's incarnation */
123         __u64             ibm_dstnid;           /* destination's NID */
124         __u64             ibm_dststamp;         /* destination's incarnation */
125         __u64             ibm_seq;              /* sequence number */
126
127         union {
128                 kib_connparams_t      connparams;
129                 kib_immediate_msg_t   immediate;
130                 kib_putreq_msg_t      putreq;
131                 kib_putack_msg_t      putack;
132                 kib_get_msg_t         get;
133                 kib_completion_msg_t  completion;
134         } WIRE_ATTR ibm_u;
135 } WIRE_ATTR kib_msg_t;
136
137 #define IBNAL_MSG_MAGIC LNET_PROTO_VIB_MAGIC    /* unique magic */
138
139 #define IBNAL_MSG_VERSION_RDMAREPLYNOTRSRVD 0x10 /* previous version */
140
141 #define IBNAL_MSG_VERSION           0x11        /* current version */
142
143 #define IBNAL_MSG_CONNREQ           0xc0        /* connection request */
144 #define IBNAL_MSG_CONNACK           0xc1        /* connection acknowledge */
145 #define IBNAL_MSG_NOOP              0xd0        /* nothing (just credits) */
146 #define IBNAL_MSG_IMMEDIATE         0xd1        /* immediate */
147 #define IBNAL_MSG_PUT_REQ           0xd2        /* putreq (src->sink) */
148 #define IBNAL_MSG_PUT_NAK           0xd3        /* completion (sink->src) */
149 #define IBNAL_MSG_PUT_ACK           0xd4        /* putack (sink->src) */
150 #define IBNAL_MSG_PUT_DONE          0xd5        /* completion (src->sink) */
151 #define IBNAL_MSG_GET_REQ           0xd6        /* getreq (sink->src) */
152 #define IBNAL_MSG_GET_DONE          0xd7        /* completion (src->sink: all OK) */
153
154 /* connection rejection reasons */
155 #define IBNAL_REJECT_CONN_RACE       0          /* You lost connection race */
156 #define IBNAL_REJECT_NO_RESOURCES    1          /* Out of memory/conns etc */
157 #define IBNAL_REJECT_FATAL           2          /* Anything else */