1 /* SPDX-License-Identifier: GPL-2.0 */ 1 2 /* 3 * PCI Peer 2 Peer DMA support. 4 * 5 * Copyright (c) 2016-2018, Logan Gunthorpe 6 * Copyright (c) 2016-2017, Microsemi Corporat 7 * Copyright (c) 2017, Christoph Hellwig 8 * Copyright (c) 2018, Eideticom Inc. 9 */ 10 11 #ifndef _LINUX_PCI_P2PDMA_H 12 #define _LINUX_PCI_P2PDMA_H 13 14 #include <linux/pci.h> 15 16 struct block_device; 17 struct scatterlist; 18 19 #ifdef CONFIG_PCI_P2PDMA 20 int pci_p2pdma_add_resource(struct pci_dev *pd 21 u64 offset); 22 int pci_p2pdma_distance_many(struct pci_dev *p 23 int num_clients, 24 bool pci_has_p2pmem(struct pci_dev *pdev); 25 struct pci_dev *pci_p2pmem_find_many(struct de 26 void *pci_alloc_p2pmem(struct pci_dev *pdev, s 27 void pci_free_p2pmem(struct pci_dev *pdev, voi 28 pci_bus_addr_t pci_p2pmem_virt_to_bus(struct p 29 struct scatterlist *pci_p2pmem_alloc_sgl(struc 30 unsig 31 void pci_p2pmem_free_sgl(struct pci_dev *pdev, 32 void pci_p2pmem_publish(struct pci_dev *pdev, 33 int pci_p2pdma_enable_store(const char *page, 34 bool *use_p2pdma); 35 ssize_t pci_p2pdma_enable_show(char *page, str 36 bool use_p2pdma 37 #else /* CONFIG_PCI_P2PDMA */ 38 static inline int pci_p2pdma_add_resource(stru 39 size_t size, u64 offset) 40 { 41 return -EOPNOTSUPP; 42 } 43 static inline int pci_p2pdma_distance_many(str 44 struct device **clients, int num_clien 45 { 46 return -1; 47 } 48 static inline bool pci_has_p2pmem(struct pci_d 49 { 50 return false; 51 } 52 static inline struct pci_dev *pci_p2pmem_find_ 53 54 { 55 return NULL; 56 } 57 static inline void *pci_alloc_p2pmem(struct pc 58 { 59 return NULL; 60 } 61 static inline void pci_free_p2pmem(struct pci_ 62 size_t size) 63 { 64 } 65 static inline pci_bus_addr_t pci_p2pmem_virt_t 66 67 { 68 return 0; 69 } 70 static inline struct scatterlist *pci_p2pmem_a 71 unsigned int *nents, u32 lengt 72 { 73 return NULL; 74 } 75 static inline void pci_p2pmem_free_sgl(struct 76 struct scatterlist *sgl) 77 { 78 } 79 static inline void pci_p2pmem_publish(struct p 80 { 81 } 82 static inline int pci_p2pdma_enable_store(cons 83 struct pci_dev **p2p_dev, bool 84 { 85 *use_p2pdma = false; 86 return 0; 87 } 88 static inline ssize_t pci_p2pdma_enable_show(c 89 struct pci_dev *p2p_dev, bool 90 { 91 return sprintf(page, "none\n"); 92 } 93 #endif /* CONFIG_PCI_P2PDMA */ 94 95 96 static inline int pci_p2pdma_distance(struct p 97 struct device *client, bool verbose) 98 { 99 return pci_p2pdma_distance_many(provid 100 } 101 102 static inline struct pci_dev *pci_p2pmem_find( 103 { 104 return pci_p2pmem_find_many(&client, 1 105 } 106 107 #endif /* _LINUX_PCI_P2P_H */ 108
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.