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