xref: /dpdk/drivers/bus/cdx/private.h (revision 45ef232af515b94ccd3c49bc100110aaef4641f1)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (C) 2022-2023, Advanced Micro Devices, Inc.
3  */
4 
5 #ifndef CDX_PRIVATE_H
6 #define CDX_PRIVATE_H
7 
8 #include "bus_cdx_driver.h"
9 
10 /**
11  * Structure describing the CDX bus.
12  */
13 struct rte_cdx_bus {
14 	struct rte_bus bus;				/**< Inherit the generic class */
15 	RTE_TAILQ_HEAD(, rte_cdx_device) device_list;	/**< List of CDX devices */
16 	RTE_TAILQ_HEAD(, rte_cdx_driver) driver_list;	/**< List of CDX drivers */
17 };
18 
19 /**
20  * Map a particular resource from a file.
21  *
22  * @param requested_addr
23  *      The starting address for the new mapping range.
24  * @param fd
25  *      The file descriptor.
26  * @param offset
27  *      The offset for the mapping range.
28  * @param size
29  *      The size for the mapping range.
30  * @param additional_flags
31  *      The additional rte_mem_map() flags for the mapping range.
32  * @return
33  *   - On success, the function returns a pointer to the mapped area.
34  *   - On error, NULL is returned.
35  */
36 void *cdx_map_resource(void *requested_addr, int fd, uint64_t offset,
37 		size_t size, int additional_flags);
38 
39 /**
40  * Unmap a particular resource.
41  *
42  * @param requested_addr
43  *      The address for the unmapping range.
44  * @param size
45  *      The size for the unmapping range.
46  */
47 void cdx_unmap_resource(void *requested_addr, size_t size);
48 
49 /* map/unmap VFIO resource */
50 int cdx_vfio_map_resource(struct rte_cdx_device *dev);
51 int cdx_vfio_unmap_resource(struct rte_cdx_device *dev);
52 
53 #endif /* CDX_PRIVATE_H */
54