18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef __DRBD_PROTOCOL_H
38c2ecf20Sopenharmony_ci#define __DRBD_PROTOCOL_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_cienum drbd_packet {
68c2ecf20Sopenharmony_ci	/* receiver (data socket) */
78c2ecf20Sopenharmony_ci	P_DATA		      = 0x00,
88c2ecf20Sopenharmony_ci	P_DATA_REPLY	      = 0x01, /* Response to P_DATA_REQUEST */
98c2ecf20Sopenharmony_ci	P_RS_DATA_REPLY	      = 0x02, /* Response to P_RS_DATA_REQUEST */
108c2ecf20Sopenharmony_ci	P_BARRIER	      = 0x03,
118c2ecf20Sopenharmony_ci	P_BITMAP	      = 0x04,
128c2ecf20Sopenharmony_ci	P_BECOME_SYNC_TARGET  = 0x05,
138c2ecf20Sopenharmony_ci	P_BECOME_SYNC_SOURCE  = 0x06,
148c2ecf20Sopenharmony_ci	P_UNPLUG_REMOTE	      = 0x07, /* Used at various times to hint the peer */
158c2ecf20Sopenharmony_ci	P_DATA_REQUEST	      = 0x08, /* Used to ask for a data block */
168c2ecf20Sopenharmony_ci	P_RS_DATA_REQUEST     = 0x09, /* Used to ask for a data block for resync */
178c2ecf20Sopenharmony_ci	P_SYNC_PARAM	      = 0x0a,
188c2ecf20Sopenharmony_ci	P_PROTOCOL	      = 0x0b,
198c2ecf20Sopenharmony_ci	P_UUIDS		      = 0x0c,
208c2ecf20Sopenharmony_ci	P_SIZES		      = 0x0d,
218c2ecf20Sopenharmony_ci	P_STATE		      = 0x0e,
228c2ecf20Sopenharmony_ci	P_SYNC_UUID	      = 0x0f,
238c2ecf20Sopenharmony_ci	P_AUTH_CHALLENGE      = 0x10,
248c2ecf20Sopenharmony_ci	P_AUTH_RESPONSE	      = 0x11,
258c2ecf20Sopenharmony_ci	P_STATE_CHG_REQ	      = 0x12,
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci	/* (meta socket) */
288c2ecf20Sopenharmony_ci	P_PING		      = 0x13,
298c2ecf20Sopenharmony_ci	P_PING_ACK	      = 0x14,
308c2ecf20Sopenharmony_ci	P_RECV_ACK	      = 0x15, /* Used in protocol B */
318c2ecf20Sopenharmony_ci	P_WRITE_ACK	      = 0x16, /* Used in protocol C */
328c2ecf20Sopenharmony_ci	P_RS_WRITE_ACK	      = 0x17, /* Is a P_WRITE_ACK, additionally call set_in_sync(). */
338c2ecf20Sopenharmony_ci	P_SUPERSEDED	      = 0x18, /* Used in proto C, two-primaries conflict detection */
348c2ecf20Sopenharmony_ci	P_NEG_ACK	      = 0x19, /* Sent if local disk is unusable */
358c2ecf20Sopenharmony_ci	P_NEG_DREPLY	      = 0x1a, /* Local disk is broken... */
368c2ecf20Sopenharmony_ci	P_NEG_RS_DREPLY	      = 0x1b, /* Local disk is broken... */
378c2ecf20Sopenharmony_ci	P_BARRIER_ACK	      = 0x1c,
388c2ecf20Sopenharmony_ci	P_STATE_CHG_REPLY     = 0x1d,
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	/* "new" commands, no longer fitting into the ordering scheme above */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci	P_OV_REQUEST	      = 0x1e, /* data socket */
438c2ecf20Sopenharmony_ci	P_OV_REPLY	      = 0x1f,
448c2ecf20Sopenharmony_ci	P_OV_RESULT	      = 0x20, /* meta socket */
458c2ecf20Sopenharmony_ci	P_CSUM_RS_REQUEST     = 0x21, /* data socket */
468c2ecf20Sopenharmony_ci	P_RS_IS_IN_SYNC	      = 0x22, /* meta socket */
478c2ecf20Sopenharmony_ci	P_SYNC_PARAM89	      = 0x23, /* data socket, protocol version 89 replacement for P_SYNC_PARAM */
488c2ecf20Sopenharmony_ci	P_COMPRESSED_BITMAP   = 0x24, /* compressed or otherwise encoded bitmap transfer */
498c2ecf20Sopenharmony_ci	/* P_CKPT_FENCE_REQ      = 0x25, * currently reserved for protocol D */
508c2ecf20Sopenharmony_ci	/* P_CKPT_DISABLE_REQ    = 0x26, * currently reserved for protocol D */
518c2ecf20Sopenharmony_ci	P_DELAY_PROBE         = 0x27, /* is used on BOTH sockets */
528c2ecf20Sopenharmony_ci	P_OUT_OF_SYNC         = 0x28, /* Mark as out of sync (Outrunning), data socket */
538c2ecf20Sopenharmony_ci	P_RS_CANCEL           = 0x29, /* meta: Used to cancel RS_DATA_REQUEST packet by SyncSource */
548c2ecf20Sopenharmony_ci	P_CONN_ST_CHG_REQ     = 0x2a, /* data sock: Connection wide state request */
558c2ecf20Sopenharmony_ci	P_CONN_ST_CHG_REPLY   = 0x2b, /* meta sock: Connection side state req reply */
568c2ecf20Sopenharmony_ci	P_RETRY_WRITE	      = 0x2c, /* Protocol C: retry conflicting write request */
578c2ecf20Sopenharmony_ci	P_PROTOCOL_UPDATE     = 0x2d, /* data sock: is used in established connections */
588c2ecf20Sopenharmony_ci        /* 0x2e to 0x30 reserved, used in drbd 9 */
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci	/* REQ_OP_DISCARD. We used "discard" in different contexts before,
618c2ecf20Sopenharmony_ci	 * which is why I chose TRIM here, to disambiguate. */
628c2ecf20Sopenharmony_ci	P_TRIM                = 0x31,
638c2ecf20Sopenharmony_ci
648c2ecf20Sopenharmony_ci	/* Only use these two if both support FF_THIN_RESYNC */
658c2ecf20Sopenharmony_ci	P_RS_THIN_REQ         = 0x32, /* Request a block for resync or reply P_RS_DEALLOCATED */
668c2ecf20Sopenharmony_ci	P_RS_DEALLOCATED      = 0x33, /* Contains only zeros on sync source node */
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	/* REQ_WRITE_SAME.
698c2ecf20Sopenharmony_ci	 * On a receiving side without REQ_WRITE_SAME,
708c2ecf20Sopenharmony_ci	 * we may fall back to an opencoded loop instead. */
718c2ecf20Sopenharmony_ci	P_WSAME               = 0x34,
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	/* 0x35 already claimed in DRBD 9 */
748c2ecf20Sopenharmony_ci	P_ZEROES              = 0x36, /* data sock: zero-out, WRITE_ZEROES */
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	/* 0x40 .. 0x48 already claimed in DRBD 9 */
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	P_MAY_IGNORE	      = 0x100, /* Flag to test if (cmd > P_MAY_IGNORE) ... */
798c2ecf20Sopenharmony_ci	P_MAX_OPT_CMD	      = 0x101,
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	/* special command ids for handshake */
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	P_INITIAL_META	      = 0xfff1, /* First Packet on the MetaSock */
848c2ecf20Sopenharmony_ci	P_INITIAL_DATA	      = 0xfff2, /* First Packet on the Socket */
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_ci	P_CONNECTION_FEATURES = 0xfffe	/* FIXED for the next century! */
878c2ecf20Sopenharmony_ci};
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#ifndef __packed
908c2ecf20Sopenharmony_ci#define __packed __attribute__((packed))
918c2ecf20Sopenharmony_ci#endif
928c2ecf20Sopenharmony_ci
938c2ecf20Sopenharmony_ci/* This is the layout for a packet on the wire.
948c2ecf20Sopenharmony_ci * The byteorder is the network byte order.
958c2ecf20Sopenharmony_ci *     (except block_id and barrier fields.
968c2ecf20Sopenharmony_ci *	these are pointers to local structs
978c2ecf20Sopenharmony_ci *	and have no relevance for the partner,
988c2ecf20Sopenharmony_ci *	which just echoes them as received.)
998c2ecf20Sopenharmony_ci *
1008c2ecf20Sopenharmony_ci * NOTE that the payload starts at a long aligned offset,
1018c2ecf20Sopenharmony_ci * regardless of 32 or 64 bit arch!
1028c2ecf20Sopenharmony_ci */
1038c2ecf20Sopenharmony_cistruct p_header80 {
1048c2ecf20Sopenharmony_ci	u32	  magic;
1058c2ecf20Sopenharmony_ci	u16	  command;
1068c2ecf20Sopenharmony_ci	u16	  length;	/* bytes of data after this header */
1078c2ecf20Sopenharmony_ci} __packed;
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/* Header for big packets, Used for data packets exceeding 64kB */
1108c2ecf20Sopenharmony_cistruct p_header95 {
1118c2ecf20Sopenharmony_ci	u16	  magic;	/* use DRBD_MAGIC_BIG here */
1128c2ecf20Sopenharmony_ci	u16	  command;
1138c2ecf20Sopenharmony_ci	u32	  length;
1148c2ecf20Sopenharmony_ci} __packed;
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistruct p_header100 {
1178c2ecf20Sopenharmony_ci	u32	  magic;
1188c2ecf20Sopenharmony_ci	u16	  volume;
1198c2ecf20Sopenharmony_ci	u16	  command;
1208c2ecf20Sopenharmony_ci	u32	  length;
1218c2ecf20Sopenharmony_ci	u32	  pad;
1228c2ecf20Sopenharmony_ci} __packed;
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ci/* These defines must not be changed without changing the protocol version.
1258c2ecf20Sopenharmony_ci * New defines may only be introduced together with protocol version bump or
1268c2ecf20Sopenharmony_ci * new protocol feature flags.
1278c2ecf20Sopenharmony_ci */
1288c2ecf20Sopenharmony_ci#define DP_HARDBARRIER	      1 /* no longer used */
1298c2ecf20Sopenharmony_ci#define DP_RW_SYNC	      2 /* equals REQ_SYNC    */
1308c2ecf20Sopenharmony_ci#define DP_MAY_SET_IN_SYNC    4
1318c2ecf20Sopenharmony_ci#define DP_UNPLUG             8 /* not used anymore   */
1328c2ecf20Sopenharmony_ci#define DP_FUA               16 /* equals REQ_FUA     */
1338c2ecf20Sopenharmony_ci#define DP_FLUSH             32 /* equals REQ_PREFLUSH   */
1348c2ecf20Sopenharmony_ci#define DP_DISCARD           64 /* equals REQ_OP_DISCARD */
1358c2ecf20Sopenharmony_ci#define DP_SEND_RECEIVE_ACK 128 /* This is a proto B write request */
1368c2ecf20Sopenharmony_ci#define DP_SEND_WRITE_ACK   256 /* This is a proto C write request */
1378c2ecf20Sopenharmony_ci#define DP_WSAME            512 /* equiv. REQ_WRITE_SAME */
1388c2ecf20Sopenharmony_ci#define DP_ZEROES          1024 /* equiv. REQ_OP_WRITE_ZEROES */
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/* possible combinations:
1418c2ecf20Sopenharmony_ci * REQ_OP_WRITE_ZEROES:  DP_DISCARD | DP_ZEROES
1428c2ecf20Sopenharmony_ci * REQ_OP_WRITE_ZEROES + REQ_NOUNMAP: DP_ZEROES
1438c2ecf20Sopenharmony_ci */
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_cistruct p_data {
1468c2ecf20Sopenharmony_ci	u64	    sector;    /* 64 bits sector number */
1478c2ecf20Sopenharmony_ci	u64	    block_id;  /* to identify the request in protocol B&C */
1488c2ecf20Sopenharmony_ci	u32	    seq_num;
1498c2ecf20Sopenharmony_ci	u32	    dp_flags;
1508c2ecf20Sopenharmony_ci} __packed;
1518c2ecf20Sopenharmony_ci
1528c2ecf20Sopenharmony_cistruct p_trim {
1538c2ecf20Sopenharmony_ci	struct p_data p_data;
1548c2ecf20Sopenharmony_ci	u32	    size;	/* == bio->bi_size */
1558c2ecf20Sopenharmony_ci} __packed;
1568c2ecf20Sopenharmony_ci
1578c2ecf20Sopenharmony_cistruct p_wsame {
1588c2ecf20Sopenharmony_ci	struct p_data p_data;
1598c2ecf20Sopenharmony_ci	u32           size;     /* == bio->bi_size */
1608c2ecf20Sopenharmony_ci} __packed;
1618c2ecf20Sopenharmony_ci
1628c2ecf20Sopenharmony_ci/*
1638c2ecf20Sopenharmony_ci * commands which share a struct:
1648c2ecf20Sopenharmony_ci *  p_block_ack:
1658c2ecf20Sopenharmony_ci *   P_RECV_ACK (proto B), P_WRITE_ACK (proto C),
1668c2ecf20Sopenharmony_ci *   P_SUPERSEDED (proto C, two-primaries conflict detection)
1678c2ecf20Sopenharmony_ci *  p_block_req:
1688c2ecf20Sopenharmony_ci *   P_DATA_REQUEST, P_RS_DATA_REQUEST
1698c2ecf20Sopenharmony_ci */
1708c2ecf20Sopenharmony_cistruct p_block_ack {
1718c2ecf20Sopenharmony_ci	u64	    sector;
1728c2ecf20Sopenharmony_ci	u64	    block_id;
1738c2ecf20Sopenharmony_ci	u32	    blksize;
1748c2ecf20Sopenharmony_ci	u32	    seq_num;
1758c2ecf20Sopenharmony_ci} __packed;
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_cistruct p_block_req {
1788c2ecf20Sopenharmony_ci	u64 sector;
1798c2ecf20Sopenharmony_ci	u64 block_id;
1808c2ecf20Sopenharmony_ci	u32 blksize;
1818c2ecf20Sopenharmony_ci	u32 pad;	/* to multiple of 8 Byte */
1828c2ecf20Sopenharmony_ci} __packed;
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ci/*
1858c2ecf20Sopenharmony_ci * commands with their own struct for additional fields:
1868c2ecf20Sopenharmony_ci *   P_CONNECTION_FEATURES
1878c2ecf20Sopenharmony_ci *   P_BARRIER
1888c2ecf20Sopenharmony_ci *   P_BARRIER_ACK
1898c2ecf20Sopenharmony_ci *   P_SYNC_PARAM
1908c2ecf20Sopenharmony_ci *   ReportParams
1918c2ecf20Sopenharmony_ci */
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ci/* supports TRIM/DISCARD on the "wire" protocol */
1948c2ecf20Sopenharmony_ci#define DRBD_FF_TRIM 1
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ci/* Detect all-zeros during resync, and rather TRIM/UNMAP/DISCARD those blocks
1978c2ecf20Sopenharmony_ci * instead of fully allocate a supposedly thin volume on initial resync */
1988c2ecf20Sopenharmony_ci#define DRBD_FF_THIN_RESYNC 2
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci/* supports REQ_WRITE_SAME on the "wire" protocol.
2018c2ecf20Sopenharmony_ci * Note: this flag is overloaded,
2028c2ecf20Sopenharmony_ci * its presence also
2038c2ecf20Sopenharmony_ci *   - indicates support for 128 MiB "batch bios",
2048c2ecf20Sopenharmony_ci *     max discard size of 128 MiB
2058c2ecf20Sopenharmony_ci *     instead of 4M before that.
2068c2ecf20Sopenharmony_ci *   - indicates that we exchange additional settings in p_sizes
2078c2ecf20Sopenharmony_ci *     drbd_send_sizes()/receive_sizes()
2088c2ecf20Sopenharmony_ci */
2098c2ecf20Sopenharmony_ci#define DRBD_FF_WSAME 4
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ci/* supports REQ_OP_WRITE_ZEROES on the "wire" protocol.
2128c2ecf20Sopenharmony_ci *
2138c2ecf20Sopenharmony_ci * We used to map that to "discard" on the sending side, and if we cannot
2148c2ecf20Sopenharmony_ci * guarantee that discard zeroes data, the receiving side would map discard
2158c2ecf20Sopenharmony_ci * back to zero-out.
2168c2ecf20Sopenharmony_ci *
2178c2ecf20Sopenharmony_ci * With the introduction of REQ_OP_WRITE_ZEROES,
2188c2ecf20Sopenharmony_ci * we started to use that for both WRITE_ZEROES and DISCARDS,
2198c2ecf20Sopenharmony_ci * hoping that WRITE_ZEROES would "do what we want",
2208c2ecf20Sopenharmony_ci * UNMAP if possible, zero-out the rest.
2218c2ecf20Sopenharmony_ci *
2228c2ecf20Sopenharmony_ci * The example scenario is some LVM "thin" backend.
2238c2ecf20Sopenharmony_ci *
2248c2ecf20Sopenharmony_ci * While an un-allocated block on dm-thin reads as zeroes, on a dm-thin
2258c2ecf20Sopenharmony_ci * with "skip_block_zeroing=true", after a partial block write allocated
2268c2ecf20Sopenharmony_ci * that block, that same block may well map "undefined old garbage" from
2278c2ecf20Sopenharmony_ci * the backends on LBAs that have not yet been written to.
2288c2ecf20Sopenharmony_ci *
2298c2ecf20Sopenharmony_ci * If we cannot distinguish between zero-out and discard on the receiving
2308c2ecf20Sopenharmony_ci * side, to avoid "undefined old garbage" to pop up randomly at later times
2318c2ecf20Sopenharmony_ci * on supposedly zero-initialized blocks, we'd need to map all discards to
2328c2ecf20Sopenharmony_ci * zero-out on the receiving side.  But that would potentially do a full
2338c2ecf20Sopenharmony_ci * alloc on thinly provisioned backends, even when the expectation was to
2348c2ecf20Sopenharmony_ci * unmap/trim/discard/de-allocate.
2358c2ecf20Sopenharmony_ci *
2368c2ecf20Sopenharmony_ci * We need to distinguish on the protocol level, whether we need to guarantee
2378c2ecf20Sopenharmony_ci * zeroes (and thus use zero-out, potentially doing the mentioned full-alloc),
2388c2ecf20Sopenharmony_ci * or if we want to put the emphasis on discard, and only do a "best effort
2398c2ecf20Sopenharmony_ci * zeroing" (by "discarding" blocks aligned to discard-granularity, and zeroing
2408c2ecf20Sopenharmony_ci * only potential unaligned head and tail clippings), to at least *try* to
2418c2ecf20Sopenharmony_ci * avoid "false positives" in an online-verify later, hoping that someone
2428c2ecf20Sopenharmony_ci * set skip_block_zeroing=false.
2438c2ecf20Sopenharmony_ci */
2448c2ecf20Sopenharmony_ci#define DRBD_FF_WZEROES 8
2458c2ecf20Sopenharmony_ci
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_cistruct p_connection_features {
2488c2ecf20Sopenharmony_ci	u32 protocol_min;
2498c2ecf20Sopenharmony_ci	u32 feature_flags;
2508c2ecf20Sopenharmony_ci	u32 protocol_max;
2518c2ecf20Sopenharmony_ci
2528c2ecf20Sopenharmony_ci	/* should be more than enough for future enhancements
2538c2ecf20Sopenharmony_ci	 * for now, feature_flags and the reserved array shall be zero.
2548c2ecf20Sopenharmony_ci	 */
2558c2ecf20Sopenharmony_ci
2568c2ecf20Sopenharmony_ci	u32 _pad;
2578c2ecf20Sopenharmony_ci	u64 reserved[7];
2588c2ecf20Sopenharmony_ci} __packed;
2598c2ecf20Sopenharmony_ci
2608c2ecf20Sopenharmony_cistruct p_barrier {
2618c2ecf20Sopenharmony_ci	u32 barrier;	/* barrier number _handle_ only */
2628c2ecf20Sopenharmony_ci	u32 pad;	/* to multiple of 8 Byte */
2638c2ecf20Sopenharmony_ci} __packed;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_cistruct p_barrier_ack {
2668c2ecf20Sopenharmony_ci	u32 barrier;
2678c2ecf20Sopenharmony_ci	u32 set_size;
2688c2ecf20Sopenharmony_ci} __packed;
2698c2ecf20Sopenharmony_ci
2708c2ecf20Sopenharmony_cistruct p_rs_param {
2718c2ecf20Sopenharmony_ci	u32 resync_rate;
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci	      /* Since protocol version 88 and higher. */
2748c2ecf20Sopenharmony_ci	char verify_alg[];
2758c2ecf20Sopenharmony_ci} __packed;
2768c2ecf20Sopenharmony_ci
2778c2ecf20Sopenharmony_cistruct p_rs_param_89 {
2788c2ecf20Sopenharmony_ci	u32 resync_rate;
2798c2ecf20Sopenharmony_ci	/* protocol version 89: */
2808c2ecf20Sopenharmony_ci	char verify_alg[SHARED_SECRET_MAX];
2818c2ecf20Sopenharmony_ci	char csums_alg[SHARED_SECRET_MAX];
2828c2ecf20Sopenharmony_ci} __packed;
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_cistruct p_rs_param_95 {
2858c2ecf20Sopenharmony_ci	u32 resync_rate;
2868c2ecf20Sopenharmony_ci	char verify_alg[SHARED_SECRET_MAX];
2878c2ecf20Sopenharmony_ci	char csums_alg[SHARED_SECRET_MAX];
2888c2ecf20Sopenharmony_ci	u32 c_plan_ahead;
2898c2ecf20Sopenharmony_ci	u32 c_delay_target;
2908c2ecf20Sopenharmony_ci	u32 c_fill_target;
2918c2ecf20Sopenharmony_ci	u32 c_max_rate;
2928c2ecf20Sopenharmony_ci} __packed;
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_cienum drbd_conn_flags {
2958c2ecf20Sopenharmony_ci	CF_DISCARD_MY_DATA = 1,
2968c2ecf20Sopenharmony_ci	CF_DRY_RUN = 2,
2978c2ecf20Sopenharmony_ci};
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_cistruct p_protocol {
3008c2ecf20Sopenharmony_ci	u32 protocol;
3018c2ecf20Sopenharmony_ci	u32 after_sb_0p;
3028c2ecf20Sopenharmony_ci	u32 after_sb_1p;
3038c2ecf20Sopenharmony_ci	u32 after_sb_2p;
3048c2ecf20Sopenharmony_ci	u32 conn_flags;
3058c2ecf20Sopenharmony_ci	u32 two_primaries;
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci	/* Since protocol version 87 and higher. */
3088c2ecf20Sopenharmony_ci	char integrity_alg[];
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci} __packed;
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_cistruct p_uuids {
3138c2ecf20Sopenharmony_ci	u64 uuid[UI_EXTENDED_SIZE];
3148c2ecf20Sopenharmony_ci} __packed;
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_cistruct p_rs_uuid {
3178c2ecf20Sopenharmony_ci	u64	    uuid;
3188c2ecf20Sopenharmony_ci} __packed;
3198c2ecf20Sopenharmony_ci
3208c2ecf20Sopenharmony_ci/* optional queue_limits if (agreed_features & DRBD_FF_WSAME)
3218c2ecf20Sopenharmony_ci * see also struct queue_limits, as of late 2015 */
3228c2ecf20Sopenharmony_cistruct o_qlim {
3238c2ecf20Sopenharmony_ci	/* we don't need it yet, but we may as well communicate it now */
3248c2ecf20Sopenharmony_ci	u32 physical_block_size;
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci	/* so the original in struct queue_limits is unsigned short,
3278c2ecf20Sopenharmony_ci	 * but I'd have to put in padding anyways. */
3288c2ecf20Sopenharmony_ci	u32 logical_block_size;
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ci	/* One incoming bio becomes one DRBD request,
3318c2ecf20Sopenharmony_ci	 * which may be translated to several bio on the receiving side.
3328c2ecf20Sopenharmony_ci	 * We don't need to communicate chunk/boundary/segment ... limits.
3338c2ecf20Sopenharmony_ci	 */
3348c2ecf20Sopenharmony_ci
3358c2ecf20Sopenharmony_ci	/* various IO hints may be useful with "diskless client" setups */
3368c2ecf20Sopenharmony_ci	u32 alignment_offset;
3378c2ecf20Sopenharmony_ci	u32 io_min;
3388c2ecf20Sopenharmony_ci	u32 io_opt;
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci	/* We may need to communicate integrity stuff at some point,
3418c2ecf20Sopenharmony_ci	 * but let's not get ahead of ourselves. */
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	/* Backend discard capabilities.
3448c2ecf20Sopenharmony_ci	 * Receiving side uses "blkdev_issue_discard()", no need to communicate
3458c2ecf20Sopenharmony_ci	 * more specifics.  If the backend cannot do discards, the DRBD peer
3468c2ecf20Sopenharmony_ci	 * may fall back to blkdev_issue_zeroout().
3478c2ecf20Sopenharmony_ci	 */
3488c2ecf20Sopenharmony_ci	u8 discard_enabled;
3498c2ecf20Sopenharmony_ci	u8 discard_zeroes_data;
3508c2ecf20Sopenharmony_ci	u8 write_same_capable;
3518c2ecf20Sopenharmony_ci	u8 _pad;
3528c2ecf20Sopenharmony_ci} __packed;
3538c2ecf20Sopenharmony_ci
3548c2ecf20Sopenharmony_cistruct p_sizes {
3558c2ecf20Sopenharmony_ci	u64	    d_size;  /* size of disk */
3568c2ecf20Sopenharmony_ci	u64	    u_size;  /* user requested size */
3578c2ecf20Sopenharmony_ci	u64	    c_size;  /* current exported size */
3588c2ecf20Sopenharmony_ci	u32	    max_bio_size;  /* Maximal size of a BIO */
3598c2ecf20Sopenharmony_ci	u16	    queue_order_type;  /* not yet implemented in DRBD*/
3608c2ecf20Sopenharmony_ci	u16	    dds_flags; /* use enum dds_flags here. */
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci	/* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */
3638c2ecf20Sopenharmony_ci	struct o_qlim qlim[];
3648c2ecf20Sopenharmony_ci} __packed;
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_cistruct p_state {
3678c2ecf20Sopenharmony_ci	u32	    state;
3688c2ecf20Sopenharmony_ci} __packed;
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_cistruct p_req_state {
3718c2ecf20Sopenharmony_ci	u32	    mask;
3728c2ecf20Sopenharmony_ci	u32	    val;
3738c2ecf20Sopenharmony_ci} __packed;
3748c2ecf20Sopenharmony_ci
3758c2ecf20Sopenharmony_cistruct p_req_state_reply {
3768c2ecf20Sopenharmony_ci	u32	    retcode;
3778c2ecf20Sopenharmony_ci} __packed;
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_cistruct p_drbd06_param {
3808c2ecf20Sopenharmony_ci	u64	  size;
3818c2ecf20Sopenharmony_ci	u32	  state;
3828c2ecf20Sopenharmony_ci	u32	  blksize;
3838c2ecf20Sopenharmony_ci	u32	  protocol;
3848c2ecf20Sopenharmony_ci	u32	  version;
3858c2ecf20Sopenharmony_ci	u32	  gen_cnt[5];
3868c2ecf20Sopenharmony_ci	u32	  bit_map_gen[5];
3878c2ecf20Sopenharmony_ci} __packed;
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_cistruct p_block_desc {
3908c2ecf20Sopenharmony_ci	u64 sector;
3918c2ecf20Sopenharmony_ci	u32 blksize;
3928c2ecf20Sopenharmony_ci	u32 pad;	/* to multiple of 8 Byte */
3938c2ecf20Sopenharmony_ci} __packed;
3948c2ecf20Sopenharmony_ci
3958c2ecf20Sopenharmony_ci/* Valid values for the encoding field.
3968c2ecf20Sopenharmony_ci * Bump proto version when changing this. */
3978c2ecf20Sopenharmony_cienum drbd_bitmap_code {
3988c2ecf20Sopenharmony_ci	/* RLE_VLI_Bytes = 0,
3998c2ecf20Sopenharmony_ci	 * and other bit variants had been defined during
4008c2ecf20Sopenharmony_ci	 * algorithm evaluation. */
4018c2ecf20Sopenharmony_ci	RLE_VLI_Bits = 2,
4028c2ecf20Sopenharmony_ci};
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_cistruct p_compressed_bm {
4058c2ecf20Sopenharmony_ci	/* (encoding & 0x0f): actual encoding, see enum drbd_bitmap_code
4068c2ecf20Sopenharmony_ci	 * (encoding & 0x80): polarity (set/unset) of first runlength
4078c2ecf20Sopenharmony_ci	 * ((encoding >> 4) & 0x07): pad_bits, number of trailing zero bits
4088c2ecf20Sopenharmony_ci	 * used to pad up to head.length bytes
4098c2ecf20Sopenharmony_ci	 */
4108c2ecf20Sopenharmony_ci	u8 encoding;
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_ci	u8 code[];
4138c2ecf20Sopenharmony_ci} __packed;
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_cistruct p_delay_probe93 {
4168c2ecf20Sopenharmony_ci	u32     seq_num; /* sequence number to match the two probe packets */
4178c2ecf20Sopenharmony_ci	u32     offset;  /* usecs the probe got sent after the reference time point */
4188c2ecf20Sopenharmony_ci} __packed;
4198c2ecf20Sopenharmony_ci
4208c2ecf20Sopenharmony_ci/*
4218c2ecf20Sopenharmony_ci * Bitmap packets need to fit within a single page on the sender and receiver,
4228c2ecf20Sopenharmony_ci * so we are limited to 4 KiB (and not to PAGE_SIZE, which can be bigger).
4238c2ecf20Sopenharmony_ci */
4248c2ecf20Sopenharmony_ci#define DRBD_SOCKET_BUFFER_SIZE 4096
4258c2ecf20Sopenharmony_ci
4268c2ecf20Sopenharmony_ci#endif  /* __DRBD_PROTOCOL_H */
427