Whamcloud - gitweb
cd1ba5f32c80a7ccfd9fae0b912ecfed5982bad7
[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 } kib_connparams_t __attribute__((packed));
12
13 typedef struct
14 {
15         ptl_hdr_t         ibim_hdr;             /* portals header */
16         char              ibim_payload[0];      /* piggy-backed payload */
17 } kib_immediate_msg_t __attribute__((packed));
18
19 /* YEUCH! the __u64 address is split into 2 __u32 fields to ensure proper
20  * packing.  Otherwise we can't fit enough frags into an IBNAL message (<=
21  * smallest page size on any arch). */
22 typedef struct
23 {
24         __u32             rf_nob;               /* # of bytes */
25         __u32             rf_addr_lo;           /* lo 4 bytes of vaddr */
26         __u32             rf_addr_hi;           /* hi 4 bytes of vaddr */
27 } kib_rdma_frag_t __attribute__((packed));
28
29 typedef struct
30 {
31         __u32             rd_key;               /* local/remote key */
32         __u32             rd_nfrag;             /* # fragments */
33         kib_rdma_frag_t   rd_frags[0];          /* buffer frags */
34 } kib_rdma_desc_t __attribute__((packed));
35
36 /* CAVEAT EMPTOR!  We don't actually put ibprm_rd on the wire; it's just there
37  * to remember the source buffers while we wait for the PUT_ACK */
38
39 typedef struct
40 {
41         ptl_hdr_t         ibprm_hdr;            /* portals header */
42         __u64             ibprm_cookie;         /* opaque completion cookie */
43 } kib_putreq_msg_t __attribute__((packed));
44
45 typedef struct
46 {
47         __u64             ibpam_src_cookie;     /* reflected completion cookie */
48         __u64             ibpam_dst_cookie;     /* opaque completion cookie */
49         kib_rdma_desc_t   ibpam_rd;             /* sender's sink buffer */
50 } kib_putack_msg_t __attribute__((packed));
51
52 typedef struct
53 {
54         ptl_hdr_t         ibgm_hdr;             /* portals header */
55         __u64             ibgm_cookie;          /* opaque completion cookie */
56         kib_rdma_desc_t   ibgm_rd;              /* rdma descriptor */
57 } kib_get_msg_t __attribute__((packed));
58
59 typedef struct
60 {
61         __u64             ibcm_cookie;          /* opaque completion cookie */
62         __s32             ibcm_status;          /* < 0 failure: >= 0 length */
63         __u32             ibcm_pad;             /* pad to 8 byte boundary */
64 } kib_completion_msg_t __attribute__((packed));
65
66 typedef struct
67 {
68         /* First 2 fields fixed FOR ALL TIME */
69         __u32             ibm_magic;            /* I'm an openibnal message */
70         __u16             ibm_version;          /* this is my version number */
71
72         __u8              ibm_type;             /* msg type */
73         __u8              ibm_credits;          /* returned credits */
74         __u32             ibm_nob;              /* # bytes in whole message */
75         __u32             ibm_cksum;            /* checksum (0 == no checksum) */
76         __u64             ibm_srcnid;           /* sender's NID */
77         __u64             ibm_srcstamp;         /* sender's incarnation */
78         __u64             ibm_dstnid;           /* destination's NID */
79         __u64             ibm_dststamp;         /* destination's incarnation */
80         __u64             ibm_seq;              /* sequence number */
81
82         union {
83                 kib_connparams_t      connparams;
84                 kib_immediate_msg_t   immediate;
85                 kib_putreq_msg_t      putreq;
86                 kib_putack_msg_t      putack;
87                 kib_get_msg_t         get;
88                 kib_completion_msg_t  completion;
89         } ibm_u __attribute__((packed));
90 } kib_msg_t __attribute__((packed));
91
92 #define IBNAL_MSG_MAGIC       0x0be91b91        /* unique magic */
93 #define IBNAL_MSG_VERSION              5        /* current protocol version */
94
95 #define IBNAL_MSG_CONNREQ           0xc0        /* connection request */
96 #define IBNAL_MSG_CONNACK           0xc1        /* connection acknowledge */
97 #define IBNAL_MSG_NOOP              0xd0        /* nothing (just credits) */
98 #define IBNAL_MSG_IMMEDIATE         0xd1        /* immediate */
99 #define IBNAL_MSG_PUT_REQ           0xd2        /* putreq (src->sink) */
100 #define IBNAL_MSG_PUT_NAK           0xd3        /* completion (sink->src) */
101 #define IBNAL_MSG_PUT_ACK           0xd4        /* putack (sink->src) */
102 #define IBNAL_MSG_PUT_DONE          0xd5        /* completion (src->sink) */
103 #define IBNAL_MSG_GET_REQ           0xd6        /* getreq (sink->src) */
104 #define IBNAL_MSG_GET_DONE          0xd7        /* completion (src->sink: all OK) */