1 #ifndef __DRBD_PROTOCOL_H
2 #define __DRBD_PROTOCOL_H
5 /* receiver (data socket) */
7 P_DATA_REPLY = 0x01, /* Response to P_DATA_REQUEST */
8 P_RS_DATA_REPLY = 0x02, /* Response to P_RS_DATA_REQUEST */
11 P_BECOME_SYNC_TARGET = 0x05,
12 P_BECOME_SYNC_SOURCE = 0x06,
13 P_UNPLUG_REMOTE = 0x07, /* Used at various times to hint the peer */
14 P_DATA_REQUEST = 0x08, /* Used to ask for a data block */
15 P_RS_DATA_REQUEST = 0x09, /* Used to ask for a data block for resync */
22 P_AUTH_CHALLENGE = 0x10,
23 P_AUTH_RESPONSE = 0x11,
24 P_STATE_CHG_REQ = 0x12,
26 /* asender (meta socket */
29 P_RECV_ACK = 0x15, /* Used in protocol B */
30 P_WRITE_ACK = 0x16, /* Used in protocol C */
31 P_RS_WRITE_ACK = 0x17, /* Is a P_WRITE_ACK, additionally call set_in_sync(). */
32 P_SUPERSEDED = 0x18, /* Used in proto C, two-primaries conflict detection */
33 P_NEG_ACK = 0x19, /* Sent if local disk is unusable */
34 P_NEG_DREPLY = 0x1a, /* Local disk is broken... */
35 P_NEG_RS_DREPLY = 0x1b, /* Local disk is broken... */
37 P_STATE_CHG_REPLY = 0x1d,
39 /* "new" commands, no longer fitting into the ordering scheme above */
41 P_OV_REQUEST = 0x1e, /* data socket */
43 P_OV_RESULT = 0x20, /* meta socket */
44 P_CSUM_RS_REQUEST = 0x21, /* data socket */
45 P_RS_IS_IN_SYNC = 0x22, /* meta socket */
46 P_SYNC_PARAM89 = 0x23, /* data socket, protocol version 89 replacement for P_SYNC_PARAM */
47 P_COMPRESSED_BITMAP = 0x24, /* compressed or otherwise encoded bitmap transfer */
48 /* P_CKPT_FENCE_REQ = 0x25, * currently reserved for protocol D */
49 /* P_CKPT_DISABLE_REQ = 0x26, * currently reserved for protocol D */
50 P_DELAY_PROBE = 0x27, /* is used on BOTH sockets */
51 P_OUT_OF_SYNC = 0x28, /* Mark as out of sync (Outrunning), data socket */
52 P_RS_CANCEL = 0x29, /* meta: Used to cancel RS_DATA_REQUEST packet by SyncSource */
53 P_CONN_ST_CHG_REQ = 0x2a, /* data sock: Connection wide state request */
54 P_CONN_ST_CHG_REPLY = 0x2b, /* meta sock: Connection side state req reply */
55 P_RETRY_WRITE = 0x2c, /* Protocol C: retry conflicting write request */
56 P_PROTOCOL_UPDATE = 0x2d, /* data sock: is used in established connections */
58 P_MAY_IGNORE = 0x100, /* Flag to test if (cmd > P_MAY_IGNORE) ... */
59 P_MAX_OPT_CMD = 0x101,
61 /* special command ids for handshake */
63 P_INITIAL_META = 0xfff1, /* First Packet on the MetaSock */
64 P_INITIAL_DATA = 0xfff2, /* First Packet on the Socket */
66 P_CONNECTION_FEATURES = 0xfffe /* FIXED for the next century! */
70 #define __packed __attribute__((packed))
73 /* This is the layout for a packet on the wire.
74 * The byteorder is the network byte order.
75 * (except block_id and barrier fields.
76 * these are pointers to local structs
77 * and have no relevance for the partner,
78 * which just echoes them as received.)
80 * NOTE that the payload starts at a long aligned offset,
81 * regardless of 32 or 64 bit arch!
86 u16 length; /* bytes of data after this header */
89 /* Header for big packets, Used for data packets exceeding 64kB */
91 u16 magic; /* use DRBD_MAGIC_BIG here */
104 /* these defines must not be changed without changing the protocol version */
105 #define DP_HARDBARRIER 1 /* depricated */
106 #define DP_RW_SYNC 2 /* equals REQ_SYNC */
107 #define DP_MAY_SET_IN_SYNC 4
108 #define DP_UNPLUG 8 /* not used anymore */
109 #define DP_FUA 16 /* equals REQ_FUA */
110 #define DP_FLUSH 32 /* equals REQ_FLUSH */
111 #define DP_DISCARD 64 /* equals REQ_DISCARD */
112 #define DP_SEND_RECEIVE_ACK 128 /* This is a proto B write request */
113 #define DP_SEND_WRITE_ACK 256 /* This is a proto C write request */
116 u64 sector; /* 64 bits sector number */
117 u64 block_id; /* to identify the request in protocol B&C */
123 * commands which share a struct:
125 * P_RECV_ACK (proto B), P_WRITE_ACK (proto C),
126 * P_SUPERSEDED (proto C, two-primaries conflict detection)
128 * P_DATA_REQUEST, P_RS_DATA_REQUEST
141 u32 pad; /* to multiple of 8 Byte */
145 * commands with their own struct for additional fields:
146 * P_CONNECTION_FEATURES
153 struct p_connection_features {
158 /* should be more than enough for future enhancements
159 * for now, feature_flags and the reserved array shall be zero.
167 u32 barrier; /* barrier number _handle_ only */
168 u32 pad; /* to multiple of 8 Byte */
171 struct p_barrier_ack {
179 /* Since protocol version 88 and higher. */
183 struct p_rs_param_89 {
185 /* protocol version 89: */
186 char verify_alg[SHARED_SECRET_MAX];
187 char csums_alg[SHARED_SECRET_MAX];
190 struct p_rs_param_95 {
192 char verify_alg[SHARED_SECRET_MAX];
193 char csums_alg[SHARED_SECRET_MAX];
200 enum drbd_conn_flags {
201 CF_DISCARD_MY_DATA = 1,
213 /* Since protocol version 87 and higher. */
214 char integrity_alg[0];
219 u64 uuid[UI_EXTENDED_SIZE];
227 u64 d_size; /* size of disk */
228 u64 u_size; /* user requested size */
229 u64 c_size; /* current exported size */
230 u32 max_bio_size; /* Maximal size of a BIO */
231 u16 queue_order_type; /* not yet implemented in DRBD*/
232 u16 dds_flags; /* use enum dds_flags here. */
244 struct p_req_state_reply {
248 struct p_drbd06_param {
258 struct p_block_desc {
261 u32 pad; /* to multiple of 8 Byte */
264 /* Valid values for the encoding field.
265 * Bump proto version when changing this. */
266 enum drbd_bitmap_code {
267 /* RLE_VLI_Bytes = 0,
268 * and other bit variants had been defined during
269 * algorithm evaluation. */
273 struct p_compressed_bm {
274 /* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
275 * (encoding & 0x80): polarity (set/unset) of first runlength
276 * ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
277 * used to pad up to head.length bytes
284 struct p_delay_probe93 {
285 u32 seq_num; /* sequence number to match the two probe packets */
286 u32 offset; /* usecs the probe got sent after the reference time point */
290 * Bitmap packets need to fit within a single page on the sender and receiver,
291 * so we are limited to 4 KiB (and not to PAGE_SIZE, which can be bigger).
293 #define DRBD_SOCKET_BUFFER_SIZE 4096
295 #endif /* __DRBD_PROTOCOL_H */