linux/drivers/xen/grant-dma-ops.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Xen grant DMA-mapping layer - contains special DMA-mapping routines
 * for providing grant references as DMA addresses to be used by frontends
 * (e.g. virtio) in Xen guests
 *
 * Copyright (c) 2021, Juergen Gross <[email protected]>
 */

#include <linux/module.h>
#include <linux/dma-map-ops.h>
#include <linux/of.h>
#include <linux/pci.h>
#include <linux/pfn.h>
#include <linux/xarray.h>
#include <linux/virtio_anchor.h>
#include <linux/virtio.h>
#include <xen/xen.h>
#include <xen/xen-ops.h>
#include <xen/grant_table.h>

struct xen_grant_dma_data {};

static DEFINE_XARRAY_FLAGS(xen_grant_dma_devices, XA_FLAGS_LOCK_IRQ);

#define XEN_GRANT_DMA_ADDR_OFF

static inline dma_addr_t grant_to_dma(grant_ref_t grant)
{}

static inline grant_ref_t dma_to_grant(dma_addr_t dma)
{}

static struct xen_grant_dma_data *find_xen_grant_dma_data(struct device *dev)
{}

static int store_xen_grant_dma_data(struct device *dev,
				    struct xen_grant_dma_data *data)
{}

/*
 * DMA ops for Xen frontends (e.g. virtio).
 *
 * Used to act as a kind of software IOMMU for Xen guests by using grants as
 * DMA addresses.
 * Such a DMA address is formed by using the grant reference as a frame
 * number and setting the highest address bit (this bit is for the backend
 * to be able to distinguish it from e.g. a mmio address).
 */
static void *xen_grant_dma_alloc(struct device *dev, size_t size,
				 dma_addr_t *dma_handle, gfp_t gfp,
				 unsigned long attrs)
{}

static void xen_grant_dma_free(struct device *dev, size_t size, void *vaddr,
			       dma_addr_t dma_handle, unsigned long attrs)
{}

static struct page *xen_grant_dma_alloc_pages(struct device *dev, size_t size,
					      dma_addr_t *dma_handle,
					      enum dma_data_direction dir,
					      gfp_t gfp)
{}

static void xen_grant_dma_free_pages(struct device *dev, size_t size,
				     struct page *vaddr, dma_addr_t dma_handle,
				     enum dma_data_direction dir)
{}

static dma_addr_t xen_grant_dma_map_page(struct device *dev, struct page *page,
					 unsigned long offset, size_t size,
					 enum dma_data_direction dir,
					 unsigned long attrs)
{}

static void xen_grant_dma_unmap_page(struct device *dev, dma_addr_t dma_handle,
				     size_t size, enum dma_data_direction dir,
				     unsigned long attrs)
{}

static void xen_grant_dma_unmap_sg(struct device *dev, struct scatterlist *sg,
				   int nents, enum dma_data_direction dir,
				   unsigned long attrs)
{}

static int xen_grant_dma_map_sg(struct device *dev, struct scatterlist *sg,
				int nents, enum dma_data_direction dir,
				unsigned long attrs)
{}

static int xen_grant_dma_supported(struct device *dev, u64 mask)
{}

static const struct dma_map_ops xen_grant_dma_ops =;

static struct device_node *xen_dt_get_node(struct device *dev)
{}

static int xen_dt_grant_init_backend_domid(struct device *dev,
					   struct device_node *np,
					   domid_t *backend_domid)
{}

static int xen_grant_init_backend_domid(struct device *dev,
					domid_t *backend_domid)
{}

static void xen_grant_setup_dma_ops(struct device *dev, domid_t backend_domid)
{}

bool xen_virtio_restricted_mem_acc(struct virtio_device *dev)
{}

MODULE_DESCRIPTION();
MODULE_AUTHOR();
MODULE_LICENSE();