@@ -26,6 +26,45 @@ struct p2pdma_provider {
2626 u64 bus_offset ;
2727};
2828
29+ enum pci_p2pdma_map_type {
30+ /*
31+ * PCI_P2PDMA_MAP_UNKNOWN: Used internally as an initial state before
32+ * the mapping type has been calculated. Exported routines for the API
33+ * will never return this value.
34+ */
35+ PCI_P2PDMA_MAP_UNKNOWN = 0 ,
36+
37+ /*
38+ * Not a PCI P2PDMA transfer.
39+ */
40+ PCI_P2PDMA_MAP_NONE ,
41+
42+ /*
43+ * PCI_P2PDMA_MAP_NOT_SUPPORTED: Indicates the transaction will
44+ * traverse the host bridge and the host bridge is not in the
45+ * allowlist. DMA Mapping routines should return an error when
46+ * this is returned.
47+ */
48+ PCI_P2PDMA_MAP_NOT_SUPPORTED ,
49+
50+ /*
51+ * PCI_P2PDMA_MAP_BUS_ADDR: Indicates that two devices can talk to
52+ * each other directly through a PCI switch and the transaction will
53+ * not traverse the host bridge. Such a mapping should program
54+ * the DMA engine with PCI bus addresses.
55+ */
56+ PCI_P2PDMA_MAP_BUS_ADDR ,
57+
58+ /*
59+ * PCI_P2PDMA_MAP_THRU_HOST_BRIDGE: Indicates two devices can talk
60+ * to each other, but the transaction traverses a host bridge on the
61+ * allowlist. In this case, a normal mapping either with CPU physical
62+ * addresses (in the case of dma-direct) or IOVA addresses (in the
63+ * case of IOMMUs) should be used to program the DMA engine.
64+ */
65+ PCI_P2PDMA_MAP_THRU_HOST_BRIDGE ,
66+ };
67+
2968#ifdef CONFIG_PCI_P2PDMA
3069struct p2pdma_provider * pci_p2pdma_enable (struct pci_dev * pdev );
3170int pci_p2pdma_add_resource (struct pci_dev * pdev , int bar , size_t size ,
@@ -45,6 +84,8 @@ int pci_p2pdma_enable_store(const char *page, struct pci_dev **p2p_dev,
4584 bool * use_p2pdma );
4685ssize_t pci_p2pdma_enable_show (char * page , struct pci_dev * p2p_dev ,
4786 bool use_p2pdma );
87+ enum pci_p2pdma_map_type pci_p2pdma_map_type (struct p2pdma_provider * provider ,
88+ struct device * dev );
4889#else /* CONFIG_PCI_P2PDMA */
4990static inline struct p2pdma_provider * pci_p2pdma_enable (struct pci_dev * pdev )
5091{
@@ -105,6 +146,11 @@ static inline ssize_t pci_p2pdma_enable_show(char *page,
105146{
106147 return sprintf (page , "none\n" );
107148}
149+ static inline enum pci_p2pdma_map_type
150+ pci_p2pdma_map_type (struct p2pdma_provider * provider , struct device * dev )
151+ {
152+ return PCI_P2PDMA_MAP_NOT_SUPPORTED ;
153+ }
108154#endif /* CONFIG_PCI_P2PDMA */
109155
110156
@@ -119,45 +165,6 @@ static inline struct pci_dev *pci_p2pmem_find(struct device *client)
119165 return pci_p2pmem_find_many (& client , 1 );
120166}
121167
122- enum pci_p2pdma_map_type {
123- /*
124- * PCI_P2PDMA_MAP_UNKNOWN: Used internally as an initial state before
125- * the mapping type has been calculated. Exported routines for the API
126- * will never return this value.
127- */
128- PCI_P2PDMA_MAP_UNKNOWN = 0 ,
129-
130- /*
131- * Not a PCI P2PDMA transfer.
132- */
133- PCI_P2PDMA_MAP_NONE ,
134-
135- /*
136- * PCI_P2PDMA_MAP_NOT_SUPPORTED: Indicates the transaction will
137- * traverse the host bridge and the host bridge is not in the
138- * allowlist. DMA Mapping routines should return an error when
139- * this is returned.
140- */
141- PCI_P2PDMA_MAP_NOT_SUPPORTED ,
142-
143- /*
144- * PCI_P2PDMA_MAP_BUS_ADDR: Indicates that two devices can talk to
145- * each other directly through a PCI switch and the transaction will
146- * not traverse the host bridge. Such a mapping should program
147- * the DMA engine with PCI bus addresses.
148- */
149- PCI_P2PDMA_MAP_BUS_ADDR ,
150-
151- /*
152- * PCI_P2PDMA_MAP_THRU_HOST_BRIDGE: Indicates two devices can talk
153- * to each other, but the transaction traverses a host bridge on the
154- * allowlist. In this case, a normal mapping either with CPU physical
155- * addresses (in the case of dma-direct) or IOVA addresses (in the
156- * case of IOMMUs) should be used to program the DMA engine.
157- */
158- PCI_P2PDMA_MAP_THRU_HOST_BRIDGE ,
159- };
160-
161168struct pci_p2pdma_map_state {
162169 struct p2pdma_provider * mem ;
163170 enum pci_p2pdma_map_type map ;
0 commit comments