1a0308938SDavid Stevens /* SPDX-License-Identifier: GPL-2.0 */
2a0308938SDavid Stevens /*
3a0308938SDavid Stevens  * dma-bufs for virtio exported objects
4a0308938SDavid Stevens  *
5a0308938SDavid Stevens  * Copyright (C) 2020 Google, Inc.
6a0308938SDavid Stevens  */
7a0308938SDavid Stevens 
8a0308938SDavid Stevens #ifndef _LINUX_VIRTIO_DMA_BUF_H
9a0308938SDavid Stevens #define _LINUX_VIRTIO_DMA_BUF_H
10a0308938SDavid Stevens 
11a0308938SDavid Stevens #include <linux/dma-buf.h>
12a0308938SDavid Stevens #include <linux/uuid.h>
13a0308938SDavid Stevens #include <linux/virtio.h>
14a0308938SDavid Stevens 
15a0308938SDavid Stevens /**
16a0308938SDavid Stevens  * struct virtio_dma_buf_ops - operations possible on exported object dma-buf
17a0308938SDavid Stevens  * @ops: the base dma_buf_ops. ops.attach MUST be virtio_dma_buf_attach.
18a0308938SDavid Stevens  * @device_attach: [optional] callback invoked by virtio_dma_buf_attach during
19a0308938SDavid Stevens  *		   all attach operations.
20a0308938SDavid Stevens  * @get_uid: [required] callback to get the uuid of the exported object.
21a0308938SDavid Stevens  */
22a0308938SDavid Stevens struct virtio_dma_buf_ops {
23a0308938SDavid Stevens 	struct dma_buf_ops ops;
24a0308938SDavid Stevens 	int (*device_attach)(struct dma_buf *dma_buf,
25a0308938SDavid Stevens 			     struct dma_buf_attachment *attach);
26a0308938SDavid Stevens 	int (*get_uuid)(struct dma_buf *dma_buf, uuid_t *uuid);
27a0308938SDavid Stevens };
28a0308938SDavid Stevens 
29a0308938SDavid Stevens int virtio_dma_buf_attach(struct dma_buf *dma_buf,
30a0308938SDavid Stevens 			  struct dma_buf_attachment *attach);
31a0308938SDavid Stevens 
32a0308938SDavid Stevens struct dma_buf *virtio_dma_buf_export
33a0308938SDavid Stevens 	(const struct dma_buf_export_info *exp_info);
34a0308938SDavid Stevens bool is_virtio_dma_buf(struct dma_buf *dma_buf);
35a0308938SDavid Stevens int virtio_dma_buf_get_uuid(struct dma_buf *dma_buf, uuid_t *uuid);
36a0308938SDavid Stevens 
37a0308938SDavid Stevens #endif /* _LINUX_VIRTIO_DMA_BUF_H */
38