Defining the internal implementation of a PCI device and related methods. Signed-off-by: Christophe Milard <christophe.mil...@linaro.org> --- platform/linux-generic/Makefile.am | 3 + platform/linux-generic/include/odp/pci.h | 36 +++++++ .../linux-generic/include/odp/plat/pci_types.h | 40 ++++++++ platform/linux-generic/include/odp_pci_internal.h | 103 +++++++++++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 platform/linux-generic/include/odp/pci.h create mode 100644 platform/linux-generic/include/odp/plat/pci_types.h create mode 100644 platform/linux-generic/include/odp_pci_internal.h
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index d0938c9..1e1015d 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -33,6 +33,7 @@ odpinclude_HEADERS = \ $(srcdir)/include/odp/packet_flags.h \ $(srcdir)/include/odp/packet.h \ $(srcdir)/include/odp/packet_io.h \ + $(srcdir)/include/odp/pci.h \ $(srcdir)/include/odp/pool.h \ $(srcdir)/include/odp/queue.h \ $(srcdir)/include/odp/random.h \ @@ -68,6 +69,7 @@ odpplatinclude_HEADERS = \ $(srcdir)/include/odp/plat/event_types.h \ $(srcdir)/include/odp/plat/packet_types.h \ $(srcdir)/include/odp/plat/packet_io_types.h \ + $(srcdir)/include/odp/plat/pci_types.h \ $(srcdir)/include/odp/plat/pool_types.h \ $(srcdir)/include/odp/plat/queue_types.h \ $(srcdir)/include/odp/plat/rwlock_types.h \ @@ -105,6 +107,7 @@ noinst_HEADERS = \ ${srcdir}/include/odp_packet_netmap.h \ ${srcdir}/include/odp_packet_socket.h \ ${srcdir}/include/odp_packet_tap.h \ + ${srcdir}/include/odp_pci_internal.h \ ${srcdir}/include/odp_pkt_queue_internal.h \ ${srcdir}/include/odp_pool_internal.h \ ${srcdir}/include/odp_queue_internal.h \ diff --git a/platform/linux-generic/include/odp/pci.h b/platform/linux-generic/include/odp/pci.h new file mode 100644 index 0000000..e00841e --- /dev/null +++ b/platform/linux-generic/include/odp/pci.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP PCI interface + */ + +#include <odp/plat/pci_types.h> + +#ifndef ODP_PLAT_PCI_H_ +#define ODP_PLAT_PCI_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** @ingroup odp_pci + * @{ + */ + +/** + * @} + */ + +#include <odp/api/pci.h> + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/plat/pci_types.h b/platform/linux-generic/include/odp/plat/pci_types.h new file mode 100644 index 0000000..f9e3551 --- /dev/null +++ b/platform/linux-generic/include/odp/plat/pci_types.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP PCI interface + */ + +#ifndef ODP_PCI_TYPES_H_ +#define ODP_PCI_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/std_types.h> +#include <odp/plat/strong_types.h> +#include <odp/plat/pool_types.h> + +/** @addtogroup odp_pci + * @{ + */ + +/** PCI device */ +typedef ODP_HANDLE_T(odp_pci_dev_t); +#define ODP_PCI_DEV_INVALID _odp_cast_scalar(odp_pci_dev_t, 0) + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp_pci_internal.h b/platform/linux-generic/include/odp_pci_internal.h new file mode 100644 index 0000000..aa00f13 --- /dev/null +++ b/platform/linux-generic/include/odp_pci_internal.h @@ -0,0 +1,103 @@ +/* Copyright (c) 2015, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP pci interface - implementation internal + */ + +#ifndef ODP_PCI_INTERNAL_H_ +#define ODP_PCI_INTERNAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/std_types.h> +#include <odp/pool.h> +#include <odp/packet.h> +#include <odp/debug.h> +#include <odp/align.h> +#include <odp_align_internal.h> +#include <odp/config.h> +#include <odp/byteorder.h> +#include <odp/event.h> +#include <odp_forward_typedefs_internal.h> + +/** @addtogroup odp_pci + * @{ + */ + +/** Maximum number of PCI resources. */ +#define _ODP_PCI_MAX_RESOURCE 6 + +/** PCI address length (something like "0000:06:00.0" + NULL) */ +#define _ODP_PCI_ADDR_LEN 13 + +/** + * A structure describing an ID for a PCI device. + */ +typedef struct pci_id_t { + uint16_t vendor_id; /**< Vendor ID or PCI_ANY_ID. */ + uint16_t device_id; /**< Device ID or PCI_ANY_ID. */ + uint16_t subsystem_vendor_id; /**< Subsystem vendor ID or PCI_ANY_ID. */ + uint16_t subsystem_device_id; /**< Subsystem device ID or PCI_ANY_ID. */ +} pci_id_t; + +/** + * PCI resource (BAR map region) + */ +typedef struct pci_resource_t { + /** address (virtual, in user space) of the BAR region */ + void *addr; + /** size of the region, in bytes */ + uint64_t size; +} pci_resource_t; + +/** + * PCI device + */ +typedef struct pci_dev_t { + /** the address of the device:format: "0000:23:00.0" */ + char pci_address[_ODP_PCI_ADDR_LEN]; + /** PCI id for this device */ + pci_id_t pci_id; + /** the -up to 6- different PCI BAR regions that the device may have */ + pci_resource_t bar_maps[_ODP_PCI_MAX_RESOURCE]; + /** A pointer to whatever the PCI implementation (vfio, uio) needs */ + void *implementation_data; +} pci_dev_t; + +/** + * Initialise and map the PCI interface for the given pci address, + * + * @param pci_addr pci address to the baord that should be initialized and + * mapped, i.e. something like: "0000:23:00.0" + * @param pktio The packetio handle the interface belongs to. + * + * @returns a odp_pci_dev_t handle (PCI device) + * or ODP_PCI_DEV_INVALID on error, + */ +odp_pci_dev_t _odp_pci_init(const char *pci_addr); + +/** + * Release a PCI device + * + * @param pci_dev A handle to a pci device + * + */ +void _odp_pci_release(odp_pci_dev_t pci_dev); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif -- 2.1.4 _______________________________________________ lng-odp mailing list lng-odp@lists.linaro.org https://lists.linaro.org/mailman/listinfo/lng-odp