]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - include/linux/pci-p2pdma.h
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * PCI Peer 2 Peer DMA support.
5 * Copyright (c) 2016-2018, Logan Gunthorpe
6 * Copyright (c) 2016-2017, Microsemi Corporation
7 * Copyright (c) 2017, Christoph Hellwig
8 * Copyright (c) 2018, Eideticom Inc.
11 #ifndef _LINUX_PCI_P2PDMA_H
12 #define _LINUX_PCI_P2PDMA_H
14 #include <linux/pci.h>
19 #ifdef CONFIG_PCI_P2PDMA
20 int pci_p2pdma_add_resource(struct pci_dev
*pdev
, int bar
, size_t size
,
22 int pci_p2pdma_distance_many(struct pci_dev
*provider
, struct device
**clients
,
23 int num_clients
, bool verbose
);
24 bool pci_has_p2pmem(struct pci_dev
*pdev
);
25 struct pci_dev
*pci_p2pmem_find_many(struct device
**clients
, int num_clients
);
26 void *pci_alloc_p2pmem(struct pci_dev
*pdev
, size_t size
);
27 void pci_free_p2pmem(struct pci_dev
*pdev
, void *addr
, size_t size
);
28 pci_bus_addr_t
pci_p2pmem_virt_to_bus(struct pci_dev
*pdev
, void *addr
);
29 struct scatterlist
*pci_p2pmem_alloc_sgl(struct pci_dev
*pdev
,
30 unsigned int *nents
, u32 length
);
31 void pci_p2pmem_free_sgl(struct pci_dev
*pdev
, struct scatterlist
*sgl
);
32 void pci_p2pmem_publish(struct pci_dev
*pdev
, bool publish
);
33 int pci_p2pdma_map_sg(struct device
*dev
, struct scatterlist
*sg
, int nents
,
34 enum dma_data_direction dir
);
35 int pci_p2pdma_enable_store(const char *page
, struct pci_dev
**p2p_dev
,
37 ssize_t
pci_p2pdma_enable_show(char *page
, struct pci_dev
*p2p_dev
,
39 #else /* CONFIG_PCI_P2PDMA */
40 static inline int pci_p2pdma_add_resource(struct pci_dev
*pdev
, int bar
,
41 size_t size
, u64 offset
)
45 static inline int pci_p2pdma_distance_many(struct pci_dev
*provider
,
46 struct device
**clients
, int num_clients
, bool verbose
)
50 static inline bool pci_has_p2pmem(struct pci_dev
*pdev
)
54 static inline struct pci_dev
*pci_p2pmem_find_many(struct device
**clients
,
59 static inline void *pci_alloc_p2pmem(struct pci_dev
*pdev
, size_t size
)
63 static inline void pci_free_p2pmem(struct pci_dev
*pdev
, void *addr
,
67 static inline pci_bus_addr_t
pci_p2pmem_virt_to_bus(struct pci_dev
*pdev
,
72 static inline struct scatterlist
*pci_p2pmem_alloc_sgl(struct pci_dev
*pdev
,
73 unsigned int *nents
, u32 length
)
77 static inline void pci_p2pmem_free_sgl(struct pci_dev
*pdev
,
78 struct scatterlist
*sgl
)
81 static inline void pci_p2pmem_publish(struct pci_dev
*pdev
, bool publish
)
84 static inline int pci_p2pdma_map_sg(struct device
*dev
,
85 struct scatterlist
*sg
, int nents
, enum dma_data_direction dir
)
89 static inline int pci_p2pdma_enable_store(const char *page
,
90 struct pci_dev
**p2p_dev
, bool *use_p2pdma
)
95 static inline ssize_t
pci_p2pdma_enable_show(char *page
,
96 struct pci_dev
*p2p_dev
, bool use_p2pdma
)
98 return sprintf(page
, "none\n");
100 #endif /* CONFIG_PCI_P2PDMA */
103 static inline int pci_p2pdma_distance(struct pci_dev
*provider
,
104 struct device
*client
, bool verbose
)
106 return pci_p2pdma_distance_many(provider
, &client
, 1, verbose
);
109 static inline struct pci_dev
*pci_p2pmem_find(struct device
*client
)
111 return pci_p2pmem_find_many(&client
, 1);
114 #endif /* _LINUX_PCI_P2P_H */