Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lnet / klnds / viblnd / viblnd_wire.h
1 /************************************************************************
2  * IB Wire message format.
3  * These are sent in sender's byte order (i.e. receiver flips).
4  */
5
6 typedef struct kib_connparams
7 {
8         __u32             ibcp_queue_depth;
9         __u32             ibcp_max_msg_size;
10         __u32             ibcp_max_frags;
11 } WIRE_ATTR kib_connparams_t;
12
13 typedef struct
14 {
15         lnet_hdr_t        ibim_hdr;             /* portals header */
16         char              ibim_payload[0];      /* piggy-backed payload */
17 } WIRE_ATTR kib_immediate_msg_t;
18
19 #ifndef IBNAL_USE_FMR
20 # error "IBNAL_USE_FMR must be defined 1 or 0 before including this file"
21 #endif
22
23 #if IBNAL_USE_FMR
24 typedef struct
25 {
26         __u64             rd_addr;              /* IO VMA address */
27         __u32             rd_nob;               /* # of bytes */
28         __u32             rd_key;               /* remote key */
29 } WIRE_ATTR kib_rdma_desc_t;
30 #else
31 /* YEUCH! the __u64 address is split into 2 __u32 fields to ensure proper
32  * packing.  Otherwise we can't fit enough frags into an IBNAL message (<=
33  * smallest page size on any arch). */
34 typedef struct
35 {
36         __u32             rf_nob;               /* # of bytes */
37         __u32             rf_addr_lo;           /* lo 4 bytes of vaddr */
38         __u32             rf_addr_hi;           /* hi 4 bytes of vaddr */
39 } WIRE_ATTR kib_rdma_frag_t;
40
41 typedef struct
42 {
43         __u32             rd_key;               /* local/remote key */
44         __u32             rd_nfrag;             /* # fragments */
45         kib_rdma_frag_t   rd_frags[0];          /* buffer frags */
46 } WIRE_ATTR kib_rdma_desc_t;
47 #endif
48
49 typedef struct
50 {
51         lnet_hdr_t        ibprm_hdr;            /* portals header */
52         __u64             ibprm_cookie;         /* opaque completion cookie */
53 } WIRE_ATTR kib_putreq_msg_t;
54
55 typedef struct
56 {
57         __u64             ibpam_src_cookie;     /* reflected completion cookie */
58         __u64             ibpam_dst_cookie;     /* opaque completion cookie */
59         kib_rdma_desc_t   ibpam_rd;             /* sender's sink buffer */
60 } WIRE_ATTR kib_putack_msg_t;
61
62 typedef struct
63 {
64         lnet_hdr_t        ibgm_hdr;             /* portals header */
65         __u64             ibgm_cookie;          /* opaque completion cookie */
66         kib_rdma_desc_t   ibgm_rd;              /* rdma descriptor */
67 } WIRE_ATTR kib_get_msg_t;
68
69 typedef struct
70 {
71         __u64             ibcm_cookie;          /* opaque completion cookie */
72         __s32             ibcm_status;          /* < 0 failure: >= 0 length */
73 } WIRE_ATTR kib_completion_msg_t;
74
75 typedef struct
76 {
77         /* First 2 fields fixed FOR ALL TIME */
78         __u32             ibm_magic;            /* I'm an openibnal message */
79         __u16             ibm_version;          /* this is my version number */
80
81         __u8              ibm_type;             /* msg type */
82         __u8              ibm_credits;          /* returned credits */
83         __u32             ibm_nob;              /* # bytes in whole message */
84         __u32             ibm_cksum;            /* checksum (0 == no checksum) */
85         __u64             ibm_srcnid;           /* sender's NID */
86         __u64             ibm_srcstamp;         /* sender's incarnation */
87         __u64             ibm_dstnid;           /* destination's NID */
88         __u64             ibm_dststamp;         /* destination's incarnation */
89         __u64             ibm_seq;              /* sequence number */
90
91         union {
92                 kib_connparams_t      connparams;
93                 kib_immediate_msg_t   immediate;
94                 kib_putreq_msg_t      putreq;
95                 kib_putack_msg_t      putack;
96                 kib_get_msg_t         get;
97                 kib_completion_msg_t  completion;
98         } WIRE_ATTR ibm_u;
99 } WIRE_ATTR kib_msg_t;
100
101 #define IBNAL_MSG_MAGIC LNET_PROTO_VIB_MAGIC    /* unique magic */
102
103 #define IBNAL_MSG_VERSION_RDMAREPLYNOTRSRVD 0x10 /* previous version */
104
105 #define IBNAL_MSG_VERSION           0x11        /* current version */
106
107 #define IBNAL_MSG_CONNREQ           0xc0        /* connection request */
108 #define IBNAL_MSG_CONNACK           0xc1        /* connection acknowledge */
109 #define IBNAL_MSG_NOOP              0xd0        /* nothing (just credits) */
110 #define IBNAL_MSG_IMMEDIATE         0xd1        /* immediate */
111 #define IBNAL_MSG_PUT_REQ           0xd2        /* putreq (src->sink) */
112 #define IBNAL_MSG_PUT_NAK           0xd3        /* completion (sink->src) */
113 #define IBNAL_MSG_PUT_ACK           0xd4        /* putack (sink->src) */
114 #define IBNAL_MSG_PUT_DONE          0xd5        /* completion (src->sink) */
115 #define IBNAL_MSG_GET_REQ           0xd6        /* getreq (sink->src) */
116 #define IBNAL_MSG_GET_DONE          0xd7        /* completion (src->sink: all OK) */
117
118 /* connection rejection reasons */
119 #define IBNAL_REJECT_CONN_RACE       0          /* You lost connection race */
120 #define IBNAL_REJECT_NO_RESOURCES    1          /* Out of memory/conns etc */
121 #define IBNAL_REJECT_FATAL           2          /* Anything else */