/* SPDX-License-Identifier: GPL-2.0-or-later */ /* * RDMA Network Block Driver * * Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved. * Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved. * Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved. */ #ifndef RNBD_PROTO_H #define RNBD_PROTO_H #include <linux/types.h> #include <linux/blk-mq.h> #include <linux/limits.h> #include <linux/inet.h> #include <linux/in.h> #include <linux/in6.h> #include <rdma/ib.h> #define RNBD_PROTO_VER_MAJOR … #define RNBD_PROTO_VER_MINOR … /* The default port number the RTRS server is listening on. */ #define RTRS_PORT … /** * enum rnbd_msg_types - RNBD message types * @RNBD_MSG_SESS_INFO: initial session info from client to server * @RNBD_MSG_SESS_INFO_RSP: initial session info from server to client * @RNBD_MSG_OPEN: open (map) device request * @RNBD_MSG_OPEN_RSP: response to an @RNBD_MSG_OPEN * @RNBD_MSG_IO: block IO request operation * @RNBD_MSG_CLOSE: close (unmap) device request */ enum rnbd_msg_type { … }; /** * struct rnbd_msg_hdr - header of RNBD messages * @type: Message type, valid values see: enum rnbd_msg_types */ struct rnbd_msg_hdr { … }; /** * We allow to map RO many times and RW only once. We allow to map yet another * time RW, if MIGRATION is provided (second RW export can be required for * example for VM migration) */ enum rnbd_access_mode { … }; static const __maybe_unused struct { … } rnbd_access_modes[] = …; /** * struct rnbd_msg_sess_info - initial session info from client to server * @hdr: message header * @ver: RNBD protocol version */ struct rnbd_msg_sess_info { … }; /** * struct rnbd_msg_sess_info_rsp - initial session info from server to client * @hdr: message header * @ver: RNBD protocol version */ struct rnbd_msg_sess_info_rsp { … }; /** * struct rnbd_msg_open - request to open a remote device. * @hdr: message header * @access_mode: the mode to open remote device, valid values see: * enum rnbd_access_mode * @device_name: device path on remote side */ struct rnbd_msg_open { … }; /** * struct rnbd_msg_close - request to close a remote device. * @hdr: message header * @device_id: device_id on server side to identify the device */ struct rnbd_msg_close { … }; enum rnbd_cache_policy { … }; /** * struct rnbd_msg_open_rsp - response message to RNBD_MSG_OPEN * @hdr: message header * @device_id: device_id on server side to identify the device * @nsectors: number of sectors in the usual 512b unit * @max_hw_sectors: max hardware sectors in the usual 512b unit * @max_write_zeroes_sectors: max sectors for WRITE ZEROES in the 512b unit * @max_discard_sectors: max. sectors that can be discarded at once in 512b * unit. * @discard_granularity: size of the internal discard allocation unit in bytes * @discard_alignment: offset from internal allocation assignment in bytes * @physical_block_size: physical block size device supports in bytes * @logical_block_size: logical block size device supports in bytes * @max_segments: max segments hardware support in one transfer * @secure_discard: supports secure discard * @obsolete_rotational: obsolete, not in used. * @cache_policy: support write-back caching or FUA? */ struct rnbd_msg_open_rsp { … }; /** * struct rnbd_msg_io - message for I/O read/write * @hdr: message header * @device_id: device_id on server side to find the right device * @sector: bi_sector attribute from struct bio * @rw: valid values are defined in enum rnbd_io_flags * @bi_size: number of bytes for I/O read/write * @prio: priority */ struct rnbd_msg_io { … }; #define RNBD_OP_BITS … #define RNBD_OP_MASK … /** * enum rnbd_io_flags - RNBD request types from rq_flag_bits * @RNBD_OP_READ: read sectors from the device * @RNBD_OP_WRITE: write sectors to the device * @RNBD_OP_FLUSH: flush the volatile write cache * @RNBD_OP_DISCARD: discard sectors * @RNBD_OP_SECURE_ERASE: securely erase sectors * @RNBD_OP_WRITE_ZEROES: write zeroes sectors * @RNBD_F_SYNC: request is sync (sync write or read) * @RNBD_F_FUA: forced unit access */ enum rnbd_io_flags { … }; static inline u32 rnbd_op(u32 flags) { … } static inline u32 rnbd_flags(u32 flags) { … } static inline blk_opf_t rnbd_to_bio_flags(u32 rnbd_opf) { … } static inline u32 rq_to_rnbd_flags(struct request *rq) { … } const char *rnbd_access_mode_str(enum rnbd_access_mode mode); #endif /* RNBD_PROTO_H */