xref: /openbmc/qemu/block/export/virtio-blk-handler.h (revision 40d522490714b65e0856444277db6c14c5cc3796)
15c368029SXie Yongji /*
25c368029SXie Yongji  * Handler for virtio-blk I/O
35c368029SXie Yongji  *
45c368029SXie Yongji  * Copyright (C) 2022 Bytedance Inc. and/or its affiliates. All rights reserved.
55c368029SXie Yongji  *
65c368029SXie Yongji  * Author:
75c368029SXie Yongji  *   Xie Yongji <xieyongji@bytedance.com>
85c368029SXie Yongji  *
95c368029SXie Yongji  * This work is licensed under the terms of the GNU GPL, version 2 or
105c368029SXie Yongji  * later.  See the COPYING file in the top-level directory.
115c368029SXie Yongji  */
125c368029SXie Yongji 
135c368029SXie Yongji #ifndef VIRTIO_BLK_HANDLER_H
145c368029SXie Yongji #define VIRTIO_BLK_HANDLER_H
155c368029SXie Yongji 
165c368029SXie Yongji #include "sysemu/block-backend.h"
175c368029SXie Yongji 
185c368029SXie Yongji #define VIRTIO_BLK_SECTOR_BITS 9
195c368029SXie Yongji #define VIRTIO_BLK_SECTOR_SIZE (1ULL << VIRTIO_BLK_SECTOR_BITS)
205c368029SXie Yongji 
215c368029SXie Yongji #define VIRTIO_BLK_MAX_DISCARD_SECTORS 32768
225c368029SXie Yongji #define VIRTIO_BLK_MAX_WRITE_ZEROES_SECTORS 32768
235c368029SXie Yongji 
245c368029SXie Yongji typedef struct {
255c368029SXie Yongji     BlockBackend *blk;
26*0862a087SXie Yongji     char *serial;
275c368029SXie Yongji     uint32_t logical_block_size;
285c368029SXie Yongji     bool writable;
295c368029SXie Yongji } VirtioBlkHandler;
305c368029SXie Yongji 
315c368029SXie Yongji int coroutine_fn virtio_blk_process_req(VirtioBlkHandler *handler,
325c368029SXie Yongji                                         struct iovec *in_iov,
335c368029SXie Yongji                                         struct iovec *out_iov,
345c368029SXie Yongji                                         unsigned int in_num,
355c368029SXie Yongji                                         unsigned int out_num);
365c368029SXie Yongji 
375c368029SXie Yongji #endif /* VIRTIO_BLK_HANDLER_H */
38