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