add support for CDX bus
cover add support for CDX bus
Support AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
Linux CDX bus patches has been submitted at:
https://lore.kernel.org/lkml/[email protected]/T/
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Nipun Gupta (6):
bus/cdx: introduce cdx bus
bus/cdx: add dma map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
bus: enable cdx bus
config/arm: add AMD CDX
MAINTAINERS | 5 + config/arm/arm64_cdx_linux_gcc | 17 + config/arm/meson.build | 15 + drivers/bus/cdx/cdx.c | 737 +++++++++++++++++++++++++ drivers/bus/cdx/cdx.h | 54 ++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 606 ++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/rte_bus_cdx.h | 245 ++++++++ drivers/bus/cdx/version.map | 21 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 15 files changed, 1807 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx.h create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/rte_bus_cdx.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.25.1
RFC PATCH 1/6 bus/cdx: introduce cdx bus
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + drivers/bus/cdx/cdx.c | 564 ++++++++++++++++++++++++++++++++++ drivers/bus/cdx/cdx.h | 54 ++++ drivers/bus/cdx/cdx_logs.h | 37 +++ drivers/bus/cdx/cdx_vfio.c | 428 ++++++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/rte_bus_cdx.h | 219 +++++++++++++ drivers/bus/cdx/version.map | 12 + 8 files changed, 1332 insertions(+) create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx.h create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/rte_bus_cdx.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -563,6 +563,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
drivers/bus/cdx/cdx.c new file +564 -0
564 lines not on this page · raw message
drivers/bus/cdx/cdx.h new file +54 -0
54 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _CDX_LOGS_H_ +#define _CDX_LOGS_H_ + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "fslmc: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "fslmc: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* _CDX_LOGS_H_ */
drivers/bus/cdx/cdx_vfio.c new file +428 -0
428 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +headers = files('rte_bus_cdx.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/rte_bus_cdx.h new file +219 -0
219 lines not on this page · raw message
drivers/bus/cdx/version.map new file +12 -0
@@ -0,0 +1,12 @@ +EXPERIMENTAL { + global: + + rte_cdx_dump; + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
Signature · 1 line
2.25.1
RFC PATCH 2/6 bus/cdx: add dma map and unmap support
In reply to Nipun GuptaCDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/bus/cdx/cdx.c +40 -0
@@ -549,12 +549,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +rte_cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = rte_cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = rte_cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.25.1
RFC PATCH 3/6 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
--- drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++- drivers/bus/cdx/rte_bus_cdx.h | 25 ++++ drivers/bus/cdx/version.map | 9 ++ lib/eal/common/eal_common_interrupts.c | 21 +++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 +++++ lib/eal/version.map | 2 + 8 files changed, 281 insertions(+), 2 deletions(-)
drivers/bus/cdx/cdx.c +11 -0
@@ -224,6 +224,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -415,6 +424,8 @@ rte_cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +180 -2
235 lines not on this page · raw message
drivers/bus/cdx/rte_bus_cdx.h +25 -0
@@ -81,6 +81,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -181,6 +182,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_experimental void rte_cdx_dump(FILE *f); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Register a CDX driver. *
drivers/bus/cdx/version.map +9 -0
@@ -10,3 +10,12 @@ EXPERIMENTAL { local: *; }; + +INTERNAL { + global: + + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; + + local: *; +};
lib/eal/common/eal_common_interrupts.c +21 -0
@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {
lib/eal/common/eal_interrupts.h +1 -0
@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */
lib/eal/include/rte_interrupts.h +32 -0
@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the irq count field of interrupt handle with user +* provided irq count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); + +/** +* @internal +* Returns the irq count field of the given interrupt handle instance. +* +* @param intr_handle +* pointer to the interrupt handle. +* +* @return +* - On success, ir count. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int rte_intr_irq_count_get(const struct rte_intr_handle *intr_handle); +/** * @internal * Set the number of event fd field of interrupt handle
lib/eal/version.map +2 -0
@@ -468,6 +468,8 @@ INTERNAL { rte_intr_instance_dup; rte_intr_instance_windows_handle_get; rte_intr_instance_windows_handle_set; + rte_intr_irq_count_get; + rte_intr_irq_count_set; rte_intr_max_intr_get; rte_intr_max_intr_set; rte_intr_nb_efd_get;
Signature · 1 line
2.25.1
RFC PATCH 4/6 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaAdd support for plugging and unplugging CDX devices on the CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/cdx.c | 142 +++++++++++++++++++++++++++++++--- drivers/bus/cdx/rte_bus_cdx.h | 1 + 2 files changed, 133 insertions(+), 10 deletions(-)
drivers/bus/cdx/cdx.c +132 -10
@@ -69,6 +69,7 @@#include <rte_eal_paging.h> #include <rte_errno.h> #include <rte_devargs.h> +#include <rte_kvargs.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <rte_vfio.h>
@@ -81,6 +82,15 @@#define SYSFS_CDX_DEVICES "/sys/bus/cdx/devices"#define CDX_BUS_NAME cdx +enum cdx_params { +RTE_CDX_PARAM_NAME , +}; + +static const char *const cdx_params_keys[] = { + [RTE_CDX_PARAM_NAME ] ="name" , +NULL , +}; +/** * @file * CDX probing using Linux sysfs.
@@ -88,7 +98,7 @@/* Add a device to CDX bus */ static void -rte_cdx_add_device (struct rte_cdx_device *cdx_dev) +cdx_add_device (struct rte_cdx_device *cdx_dev) {TAILQ_INSERT_TAIL (&rte_cdx_bus.device_list, cdx_dev, next); }
@@ -258,7 +268,7 @@ cdx_scan_one(const char *dirname, const char *dev_name) } dev->id.device_id = (uint16_t )tmp; -rte_cdx_add_device (dev); +cdx_add_device (dev);return 0 ;
@@ -275,7 +285,7 @@ cdx_scan_one(const char *dirname, const char *dev_name)* list. */ static int -rte_cdx_scan (void ) +cdx_scan (void ) {struct dirent *e;DIR *dir;
@@ -355,7 +365,7 @@ cdx_unmap_resource(void *requested_addr, size_t size)* Match the CDX Driver and Device using device id and vendor id. */ static int -rte_cdx_match (const struct rte_cdx_driver *cdx_drv, +cdx_match (const struct rte_cdx_driver *cdx_drv,const struct rte_cdx_device *cdx_dev) {const struct rte_cdx_id *id_table;
@@ -381,7 +391,7 @@ rte_cdx_match(const struct rte_cdx_driver *cdx_drv,* driver. */ static int -rte_cdx_probe_one_driver (struct rte_cdx_driver *dr, +cdx_probe_one_driver (struct rte_cdx_driver *dr,struct rte_cdx_device *dev) {const char *dev_name = dev->device.name;
@@ -392,7 +402,7 @@ rte_cdx_probe_one_driver(struct rte_cdx_driver *dr,return -EINVAL ;/* The device is not blocked; Check if driver supports it */ -if (!rte_cdx_match (dr, dev)) +if (!cdx_match (dr, dev))/* Match of device and driver failed */ return 1 ;
@@ -420,6 +430,7 @@ rte_cdx_probe_one_driver(struct rte_cdx_driver *dr, }else { dev->device.driver = &dr->driver; } + dev->driver = dr;return ret;
@@ -446,7 +457,7 @@ cdx_probe_all_drivers(struct rte_cdx_device *dev)return -EINVAL ;FOREACH_DRIVER_ON_CDXBUS (dr) { - rc =rte_cdx_probe_one_driver (dr, dev); + rc =cdx_probe_one_driver (dr, dev);if (rc <0 )/* negative value is an error */ return rc;
@@ -560,6 +571,71 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +/* Remove a device from CDX bus */ +static void +cdx_remove_device (struct rte_cdx_device *cdx_dev) +{ +TAILQ_REMOVE (&rte_cdx_bus.device_list, cdx_dev, next); +} + +/* +* If vendor/device ID match, call the remove() function of the +* driver. +*/ +static int +cdx_detach_dev (struct rte_cdx_device *dev) +{ +struct rte_cdx_driver *dr; +int ret =0 ; + +if (dev ==NULL ) +return -EINVAL ; + + dr = dev->driver; + +CDX_BUS_DEBUG ("detach device %s using driver: %s" , + dev->device.name, dr->driver.name); + +if (dr->remove) { + ret = dr->remove (dev); +if (ret <0 ) +return ret; + } + +/* clear driver structure */ + dev->driver =NULL ; + dev->device.driver =NULL ; + +rte_cdx_unmap_device (dev); + +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ; + +return 0 ; +} + +static int +cdx_plug (struct rte_device *dev) +{ +return cdx_probe_all_drivers (RTE_DEV_TO_CDX_DEV (dev)); +} + +static int +cdx_unplug (struct rte_device *dev) +{ +struct rte_cdx_device *cdx_dev; +int ret; + + cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + ret =cdx_detach_dev (cdx_dev); +if (ret ==0 ) { +cdx_remove_device (cdx_dev); +rte_devargs_remove (dev->devargs); +free (cdx_dev); + } +return ret; +} +static int cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) {
@@ -589,7 +665,7 @@ cdx_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) }static enum rte_iova_mode -rte_cdx_get_iommu_class (void ) +cdx_get_iommu_class (void ) {if (TAILQ_EMPTY (&rte_cdx_bus.device_list))return RTE_IOVA_DC ;
@@ -597,15 +673,61 @@ rte_cdx_get_iommu_class(void)return RTE_IOVA_VA ; } +static int +cdx_dev_match (const struct rte_device *dev, +const void *_kvlist) +{ +const struct rte_kvargs *kvlist = _kvlist; +const char *key = cdx_params_keys[RTE_CDX_PARAM_NAME ]; +const char *name; + +/* no kvlist arg, all devices match */ +if (kvlist ==NULL ) +return 0 ; + +/* if key is present in kvlist and does not match, filter device */ + name =rte_kvargs_get (kvlist, key); +if (name !=NULL &&strcmp (name, dev->name)) +return -1 ; + +return 0 ; +} + +static void * +cdx_dev_iterate (const void *start, +const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ +rte_bus_find_device_t find_device; +struct rte_kvargs *kvargs =NULL ; +struct rte_device *dev; + +if (str !=NULL ) { + kvargs =rte_kvargs_parse (str, cdx_params_keys); +if (kvargs ==NULL ) { +CDX_BUS_ERR ("cannot parse argument list %s" , str); + rte_errno =EINVAL ; +return NULL ; + } + } + find_device = rte_cdx_bus.bus.find_device; + dev =find_device (start, cdx_dev_match, kvargs); +rte_kvargs_free (kvargs); +return dev; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { - .scan = rte_cdx_scan, + .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, + .plug = cdx_plug, + .unplug = cdx_unplug, .parse = cdx_parse, .dma_map = cdx_dma_map, .dma_unmap = cdx_dma_unmap, - .get_iommu_class = rte_cdx_get_iommu_class, + .get_iommu_class = cdx_get_iommu_class, + .dev_iterate = cdx_dev_iterate, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
drivers/bus/cdx/rte_bus_cdx.h +1 -0
@@ -78,6 +78,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */
Signature · 1 line
2.25.1
RFC PATCH 5/6 bus: enable cdx bus
In reply to Nipun Guptaenable compilation of cdx bus
--- drivers/bus/meson.build | 1 + 1 file changed, 1 insertion(+)
drivers/bus/meson.build +1 -0
@@ -7,6 +7,7 @@ drivers = [ 'fslmc', 'ifpga', 'pci', + 'cdx', 'vdev', 'vmbus', ]
Signature · 1 line
2.25.1
RFC PATCH 6/6 config/arm: add AMD CDX
In reply to Nipun GuptaAdding support for AMD CDX devices
--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc
config/arm/arm64_cdx_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'
config/arm/meson.build +15 -0
@@ -63,6 +63,7 @@ part_number_config_arm = { '0xd09': {'compiler_options': ['-mcpu=cortex-a73']}, '0xd0a': {'compiler_options': ['-mcpu=cortex-a75']}, '0xd0b': {'compiler_options': ['-mcpu=cortex-a76']}, + '0xd42': {'compiler_options': ['-mcpu=cortex-a78']}, '0xd0c': { 'march': 'armv8.2-a', 'march_features': ['crypto'],
@@ -302,6 +303,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = { + 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +} + soc_centriq2400 = { 'description': 'Qualcomm Centriq 2400', 'implementer': '0x51',
@@ -448,6 +461,7 @@ generic: Generic un-optimized build for armv8 aarch64 execution mode. generic_aarch32: Generic un-optimized build for armv8 aarch32 execution mode. armada: Marvell ARMADA bluefield: NVIDIA BlueField +cdx: AMD CDX centriq2400: Qualcomm Centriq 2400 cn9k: Marvell OCTEON 9 cn10k: Marvell OCTEON 10
@@ -474,6 +488,7 @@ socs = { 'generic_aarch32': soc_generic_aarch32, 'armada': soc_armada, 'bluefield': soc_bluefield, + 'cdx': soc_cdx, 'centriq2400': soc_centriq2400, 'cn9k': soc_cn9k, 'cn10k' : soc_cn10k,
Signature · 1 line
2.25.1
cover add support for CDX bus
In reply to Nipun GuptaSupport AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
RFC patches in DPDK were submitted at:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (6):
bus/cdx: introduce cdx bus
bus/cdx: add dma map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
bus: enable cdx bus
config/arm: add AMD CDX
MAINTAINERS | 5 + config/arm/arm64_cdx_linux_gcc | 17 + config/arm/meson.build | 14 + drivers/bus/cdx/cdx.c | 743 +++++++++++++++++++++++++ drivers/bus/cdx/cdx.h | 54 ++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 598 ++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/rte_bus_cdx.h | 245 ++++++++ drivers/bus/cdx/version.map | 21 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 15 files changed, 1804 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx.h create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/rte_bus_cdx.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH 1/6 bus/cdx: introduce cdx bus
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + drivers/bus/cdx/cdx.c | 570 ++++++++++++++++++++++++++++++++++ drivers/bus/cdx/cdx.h | 54 ++++ drivers/bus/cdx/cdx_logs.h | 37 +++ drivers/bus/cdx/cdx_vfio.c | 420 +++++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/rte_bus_cdx.h | 219 +++++++++++++ drivers/bus/cdx/version.map | 19 ++ 8 files changed, 1337 insertions(+) create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx.h create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/rte_bus_cdx.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
drivers/bus/cdx/cdx.c new file +570 -0
570 lines not on this page · raw message
drivers/bus/cdx/cdx.h new file +54 -0
54 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _CDX_LOGS_H_ +#define _CDX_LOGS_H_ + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "fslmc: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "fslmc: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* _CDX_LOGS_H_ */
drivers/bus/cdx/cdx_vfio.c new file +420 -0
420 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +headers = files('rte_bus_cdx.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/rte_bus_cdx.h new file +219 -0
219 lines not on this page · raw message
drivers/bus/cdx/version.map new file +19 -0
@@ -0,0 +1,19 @@ +EXPERIMENTAL { + global: + + rte_cdx_dump; + + local: *; +}; + +INTERNAL { + global: + + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
Signature · 1 line
2.17.1
PATCH 2/6 bus/cdx: add dma map and unmap support
In reply to Nipun GuptaCDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/bus/cdx/cdx.c +40 -0
@@ -555,12 +555,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +rte_cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = rte_cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = rte_cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH 3/6 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
--- drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++- drivers/bus/cdx/rte_bus_cdx.h | 25 ++++ drivers/bus/cdx/version.map | 2 + lib/eal/common/eal_common_interrupts.c | 21 +++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 +++++ lib/eal/version.map | 2 + 8 files changed, 274 insertions(+), 2 deletions(-)
drivers/bus/cdx/cdx.c +11 -0
@@ -225,6 +225,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -416,6 +425,8 @@ rte_cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +180 -2
235 lines not on this page · raw message
drivers/bus/cdx/rte_bus_cdx.h +25 -0
@@ -81,6 +81,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -181,6 +182,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_experimental void rte_cdx_dump(FILE *f); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Register a CDX driver. *
drivers/bus/cdx/version.map +2 -0
@@ -14,6 +14,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
lib/eal/common/eal_common_interrupts.c +21 -0
@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {
lib/eal/common/eal_interrupts.h +1 -0
@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */
lib/eal/include/rte_interrupts.h +32 -0
@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the irq count field of interrupt handle with user +* provided irq count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); + +/** +* @internal +* Returns the irq count field of the given interrupt handle instance. +* +* @param intr_handle +* pointer to the interrupt handle. +* +* @return +* - On success, ir count. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int rte_intr_irq_count_get(const struct rte_intr_handle *intr_handle); +/** * @internal * Set the number of event fd field of interrupt handle
lib/eal/version.map +2 -0
@@ -458,6 +458,8 @@ INTERNAL { rte_intr_instance_dup; rte_intr_instance_windows_handle_get; rte_intr_instance_windows_handle_set; + rte_intr_irq_count_get; + rte_intr_irq_count_set; rte_intr_max_intr_get; rte_intr_max_intr_set; rte_intr_nb_efd_get;
Signature · 1 line
2.17.1
PATCH 4/6 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on the CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/cdx.c | 142 +++++++++++++++++++++++++++++++--- drivers/bus/cdx/rte_bus_cdx.h | 1 + 2 files changed, 133 insertions(+), 10 deletions(-)
drivers/bus/cdx/cdx.c +132 -10
@@ -69,6 +69,7 @@#include <rte_eal_paging.h> #include <rte_errno.h> #include <rte_devargs.h> +#include <rte_kvargs.h> #include <rte_malloc.h> #include <rte_memcpy.h> #include <rte_vfio.h>
@@ -82,6 +83,15 @@#define CDX_BUS_NAME cdx#define CDX_DEV_PREFIX "cdx-" +enum cdx_params { +RTE_CDX_PARAM_NAME , +}; + +static const char *const cdx_params_keys[] = { + [RTE_CDX_PARAM_NAME ] ="name" , +NULL , +}; +/** * @file * CDX probing using Linux sysfs.
@@ -89,7 +99,7 @@/* Add a device to CDX bus */ static void -rte_cdx_add_device (struct rte_cdx_device *cdx_dev) +cdx_add_device (struct rte_cdx_device *cdx_dev) {TAILQ_INSERT_TAIL (&rte_cdx_bus.device_list, cdx_dev, next); }
@@ -259,7 +269,7 @@ cdx_scan_one(const char *dirname, const char *dev_name) } dev->id.device_id = (uint16_t )tmp; -rte_cdx_add_device (dev); +cdx_add_device (dev);return 0 ;
@@ -276,7 +286,7 @@ cdx_scan_one(const char *dirname, const char *dev_name)* list. */ static int -rte_cdx_scan (void ) +cdx_scan (void ) {struct dirent *e;DIR *dir;
@@ -356,7 +366,7 @@ cdx_unmap_resource(void *requested_addr, size_t size)* Match the CDX Driver and Device using device id and vendor id. */ static int -rte_cdx_match (const struct rte_cdx_driver *cdx_drv, +cdx_match (const struct rte_cdx_driver *cdx_drv,const struct rte_cdx_device *cdx_dev) {const struct rte_cdx_id *id_table;
@@ -382,7 +392,7 @@ rte_cdx_match(const struct rte_cdx_driver *cdx_drv,* driver. */ static int -rte_cdx_probe_one_driver (struct rte_cdx_driver *dr, +cdx_probe_one_driver (struct rte_cdx_driver *dr,struct rte_cdx_device *dev) {const char *dev_name = dev->device.name;
@@ -393,7 +403,7 @@ rte_cdx_probe_one_driver(struct rte_cdx_driver *dr,return -EINVAL ;/* The device is not blocked; Check if driver supports it */ -if (!rte_cdx_match (dr, dev)) +if (!cdx_match (dr, dev))/* Match of device and driver failed */ return 1 ;
@@ -421,6 +431,7 @@ rte_cdx_probe_one_driver(struct rte_cdx_driver *dr, }else { dev->device.driver = &dr->driver; } + dev->driver = dr;return ret;
@@ -447,7 +458,7 @@ cdx_probe_all_drivers(struct rte_cdx_device *dev)return -EINVAL ;FOREACH_DRIVER_ON_CDXBUS (dr) { - rc =rte_cdx_probe_one_driver (dr, dev); + rc =cdx_probe_one_driver (dr, dev);if (rc <0 )/* negative value is an error */ return rc;
@@ -566,6 +577,71 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +/* Remove a device from CDX bus */ +static void +cdx_remove_device (struct rte_cdx_device *cdx_dev) +{ +TAILQ_REMOVE (&rte_cdx_bus.device_list, cdx_dev, next); +} + +/* +* If vendor/device ID match, call the remove() function of the +* driver. +*/ +static int +cdx_detach_dev (struct rte_cdx_device *dev) +{ +struct rte_cdx_driver *dr; +int ret =0 ; + +if (dev ==NULL ) +return -EINVAL ; + + dr = dev->driver; + +CDX_BUS_DEBUG ("detach device %s using driver: %s" , + dev->device.name, dr->driver.name); + +if (dr->remove) { + ret = dr->remove (dev); +if (ret <0 ) +return ret; + } + +/* clear driver structure */ + dev->driver =NULL ; + dev->device.driver =NULL ; + +rte_cdx_unmap_device (dev); + +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ; + +return 0 ; +} + +static int +cdx_plug (struct rte_device *dev) +{ +return cdx_probe_all_drivers (RTE_DEV_TO_CDX_DEV (dev)); +} + +static int +cdx_unplug (struct rte_device *dev) +{ +struct rte_cdx_device *cdx_dev; +int ret; + + cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + ret =cdx_detach_dev (cdx_dev); +if (ret ==0 ) { +cdx_remove_device (cdx_dev); +rte_devargs_remove (dev->devargs); +free (cdx_dev); + } +return ret; +} +static int cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) {
@@ -595,7 +671,7 @@ cdx_dma_unmap(struct rte_device *dev, void *addr, uint64_t iova, size_t len) }static enum rte_iova_mode -rte_cdx_get_iommu_class (void ) +cdx_get_iommu_class (void ) {if (TAILQ_EMPTY (&rte_cdx_bus.device_list))return RTE_IOVA_DC ;
@@ -603,15 +679,61 @@ rte_cdx_get_iommu_class(void)return RTE_IOVA_VA ; } +static int +cdx_dev_match (const struct rte_device *dev, +const void *_kvlist) +{ +const struct rte_kvargs *kvlist = _kvlist; +const char *key = cdx_params_keys[RTE_CDX_PARAM_NAME ]; +const char *name; + +/* no kvlist arg, all devices match */ +if (kvlist ==NULL ) +return 0 ; + +/* if key is present in kvlist and does not match, filter device */ + name =rte_kvargs_get (kvlist, key); +if (name !=NULL &&strcmp (name, dev->name)) +return -1 ; + +return 0 ; +} + +static void * +cdx_dev_iterate (const void *start, +const char *str, + const struct rte_dev_iterator *it __rte_unused) +{ +rte_bus_find_device_t find_device; +struct rte_kvargs *kvargs =NULL ; +struct rte_device *dev; + +if (str !=NULL ) { + kvargs =rte_kvargs_parse (str, cdx_params_keys); +if (kvargs ==NULL ) { +CDX_BUS_ERR ("cannot parse argument list %s" , str); + rte_errno =EINVAL ; +return NULL ; + } + } + find_device = rte_cdx_bus.bus.find_device; + dev =find_device (start, cdx_dev_match, kvargs); +rte_kvargs_free (kvargs); +return dev; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { - .scan = rte_cdx_scan, + .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, + .plug = cdx_plug, + .unplug = cdx_unplug, .parse = cdx_parse, .dma_map = cdx_dma_map, .dma_unmap = cdx_dma_unmap, - .get_iommu_class = rte_cdx_get_iommu_class, + .get_iommu_class = cdx_get_iommu_class, + .dev_iterate = cdx_dev_iterate, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
drivers/bus/cdx/rte_bus_cdx.h +1 -0
@@ -78,6 +78,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */
Signature · 1 line
2.17.1
PATCH 5/6 bus: enable cdx bus
In reply to Nipun Guptaenable the compilation of cdx bus
--- drivers/bus/meson.build | 1 + 1 file changed, 1 insertion(+)
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
PATCH 6/6 config/arm: add AMD CDX
In reply to Nipun GuptaAdding support for AMD CDX devices
--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc
config/arm/arm64_cdx_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'
config/arm/meson.build +14 -0
@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = { + 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +} + soc_centriq2400 = { 'description': 'Qualcomm Centriq 2400', 'implementer': '0x51',
@@ -463,6 +475,7 @@ generic_aarch32: Generic un-optimized build for armv8 aarch32 execution mode. armada: Marvell ARMADA bluefield: NVIDIA BlueField bluefield3: NVIDIA BlueField-3 +cdx: AMD CDX centriq2400: Qualcomm Centriq 2400 cn9k: Marvell OCTEON 9 cn10k: Marvell OCTEON 10
@@ -490,6 +503,7 @@ socs = { 'armada': soc_armada, 'bluefield': soc_bluefield, 'bluefield3': soc_bluefield3, + 'cdx': soc_cdx, 'centriq2400': soc_centriq2400, 'cn9k': soc_cn9k, 'cn10k' : soc_cn10k,
Signature · 1 line
2.17.1
Hello,
Quoted 7 lines · Nipun Gupta
Support AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
Quoted 8 lines
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdxVFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
Hard to tell just from this link what the status is. Has it been reviewed?
When are you expecting this to get merged?
Quoted 13 lines
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Quoted 6 lines
RFC patches in DPDK were submitted at:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/Changes
RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Just a quick pass on this series.
- There is an issue with the exported header rte_bus_cdx.h. All the bus specific / driver only parts must be moved to a dedicated bus_cdx_driver.h header (which must be listed in driver_sdk_headers).
- To whom is the rte_cdx_dump symbol intended to? Is this for use by user applications?
If so, the rte_bus_cdx.h can be kept, to export this symbol.
But otherwise, everything in rte_bus_cdx.h can be moved to bus_cdx_driver.h.
- Please remove the rte_ prefix for static symbols in *.c.
Signature · 1 line
David Marchand
Quoted 19 lines · David Marchand
Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hello,
Quoted 13 lines · Nipun Gupta
Support AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
Quoted 6 lines
Quoted 2 lines
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.htmlHard to tell just from this link what the status is. Has it been reviewed?
When are you expecting this to get merged?
The CDX bus code has been merged and VFIO code is under review. Apart from this, we will soon have Open source Linux from AMD which has all the required patches for CDX in a week or so (I will provide the link once that is available).
Quoted 28 lines
Quoted 15 lines
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Quoted 6 lines
RFC patches in DPDK were submitted at:
http://patches.dpdk.org/project/dpdk/patch/[email protected]/Changes
RFC->v1:
- Marked few API's as internal which were not required to be provided to user.Just a quick pass on this series.
- There is an issue with the exported header
rte_bus_cdx.h. All the bus specific / driver only parts must be moved to a dedicatedbus_cdx_driver.hheader (which must be listed indriver_sdk_headers).
Quoted 6 lines
- To whom is the
rte_cdx_dumpsymbol intended to? Is this for use by user applications?
If so, therte_bus_cdx.hcan be kept, to export this symbol.
But otherwise, everything inrte_bus_cdx.hcan be moved tobus_cdx_driver.h.- Please remove the
rte_prefix for static symbols in *.c.
Agree to this.
Regards,
Nipun
Quoted 5 lines
--
David Marchand
Quoted 38 lines
-----Original Message-----
From: Gupta, Nipun
Sent: Friday, April 7, 2023 1:00 PM
To: David Marchand <[email protected]>
Cc: [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH 0/6] add support for CDX busQuoted 1 line · David Marchand
Caution: This message originated from an External Source. Use proper caution
when opening attachments, clicking links, or responding.
Quoted 17 lines
Hello,
Quoted 12 lines · Nipun Gupta
Support AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
Quoted 4 lines
Quoted 3 lines
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
Quoted 8 lines
Quoted 3 lines
Hard to tell just from this link what the status is. Has it been reviewed?
When are you expecting this to get merged?The CDX bus code has been merged and VFIO code is under review. Apart from this, we will soon have Open source Linux from AMD which has all the required patches for CDX in a week or so (I will provide the link once that is available).
The CDX bus and VFIO support is now available at Xilinx open-source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Regards,
Nipun
v2 cover add support for CDX bus
In reply to Nipun GuptaSupport AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
The CDX bus and VFIO support is available at Xilinx open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (6):
bus/cdx: introduce cdx bus
bus/cdx: add dma map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
bus: enable cdx bus
config/arm: add AMD CDX
MAINTAINERS | 5 + config/arm/arm64_cdx_linux_gcc | 17 + config/arm/meson.build | 14 + drivers/bus/cdx/bus_cdx_driver.h | 227 ++++++++ drivers/bus/cdx/cdx.c | 694 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 619 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 12 + drivers/bus/cdx/private.h | 49 ++ drivers/bus/cdx/version.map | 13 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 15 files changed, 1744 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v2 1/6 bus/cdx: introduce cdx bus
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++++ drivers/bus/cdx/cdx.c | 521 +++++++++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 +++ drivers/bus/cdx/cdx_vfio.c | 437 ++++++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + 8 files changed, 1274 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
drivers/bus/cdx/bus_cdx_driver.h new file +201 -0
201 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +521 -0
521 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _CDX_LOGS_H_ +#define _CDX_LOGS_H_ + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* _CDX_LOGS_H_ */
drivers/bus/cdx/cdx_vfio.c new file +437 -0
437 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +49 -0
49 lines not on this page · raw message
drivers/bus/cdx/version.map new file +11 -0
@@ -0,0 +1,11 @@ +INTERNAL { + global: + + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
Signature · 1 line
2.17.1
Re: [PATCH v2 1/6] bus/cdx: introduce cdx bus
Quoted 10 lines · Nipun Gupta
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>
<...>
Quoted 5 lines
drivers/bus/cdx/cdx.c new file +5
-0+/* map a particular resource from a file */ +void * +cdx_map_resource (void *requested_addr,int fd,off_t offset,size_t size, +int additional_flags) +{
drivers/bus/cdx/cdx.c line 303
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+void *mapaddr; + +/* Map the cdx MMIO memory resource of device */ + mapaddr =rte_mem_map (requested_addr, size, +RTE_PROT_READ |RTE_PROT_WRITE , +RTE_MAP_SHARED | additional_flags, fd, offset); +if (mapaddr ==NULL ) { + CDX_BUS_ERR("%s(): cannot map resource(%d, %p, 0x%zx, 0x%llx): %s (%p)", + __func__, fd, requested_addr, size, + (unsigned long long)offset,
checkpatches.sh complains about '%l' usage, and 'offset' seems defined as 'off_t' type.
As far as I can see 'off_t' is not part of C standard (but posix standard), and it is signed, also not clear if 32 bits or 64 bits.
Since caller of this function already passes parameter with 'uint64_t' type, why not change the 'offset' type of this function to 'uint64_t' for simplification, and use 'PRIu64' format specifier?
RE: [PATCH v2 1/6] bus/cdx: introduce cdx bus
Quoted 45 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, April 14, 2023 10:15 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v2 1/6] bus/cdx: introduce cdx busQuoted 10 lines · Nipun Gupta
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]><...>
drivers/bus/cdx/cdx.c
Quoted 13 lines
drivers/bus/cdx/cdx.c new file +13
-0+/* map a particular resource from a file */ +void * +cdx_map_resource (void *requested_addr,int fd,off_t offset,size_t size, +int additional_flags) +{ +void *mapaddr; + +/* Map the cdx MMIO memory resource of device */ + mapaddr =rte_mem_map (requested_addr, size, +RTE_PROT_READ |RTE_PROT_WRITE , +RTE_MAP_SHARED | additional_flags, fd, offset); +if (mapaddr ==NULL ) { + CDX_BUS_ERR("%s(): cannot map resource(%d, %p, 0x%zx,0x%llx): %s (%p)",
drivers/bus/cdx/cdx.c line 303
Quoted 2 lines
drivers/bus/cdx/cdx.c new file +2
-0+ __func__, fd, requested_addr, size, + (unsigned long long)offset,
checkpatches.shcomplains about '%l' usage, and 'offset' seems defined as 'off_t' type.
Quoted 6 lines
As far as I can see '
off_t' is not part of C standard (but posix standard), and it is signed, also not clear if 32 bits or 64 bits.Since caller of this function already passes parameter with '
uint64_t' type, why not change the 'offset' type of this function to 'uint64_t' for simplification, and use 'PRIu64' format specifier?
Makes sense. Will update this in next respin.
PATCH v2 2/6 bus/cdx: add dma map and unmap support
In reply to Nipun GuptaCDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/bus/cdx/cdx.c +40 -0
@@ -506,12 +506,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH v2 3/6 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 ++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + lib/eal/common/eal_common_interrupts.c | 21 +++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 +++++ lib/eal/version.map | 2 + 8 files changed, 274 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -72,6 +72,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -173,6 +174,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_internal void rte_cdx_register(struct rte_cdx_driver *driver); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Helper for CDX device registration from driver (eth, crypto, raw) instance */
drivers/bus/cdx/cdx.c +11 -0
@@ -204,6 +204,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -395,6 +404,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +180 -2
235 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -6,6 +6,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
lib/eal/common/eal_common_interrupts.c +21 -0
@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {
lib/eal/common/eal_interrupts.h +1 -0
@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */
lib/eal/include/rte_interrupts.h +32 -0
@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the irq count field of interrupt handle with user +* provided irq count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); + +/** +* @internal +* Returns the irq count field of the given interrupt handle instance. +* +* @param intr_handle +* pointer to the interrupt handle. +* +* @return +* - On success, ir count. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int rte_intr_irq_count_get(const struct rte_intr_handle *intr_handle); +/** * @internal * Set the number of event fd field of interrupt handle
lib/eal/version.map +2 -0
@@ -458,6 +458,8 @@ INTERNAL { rte_intr_instance_dup; rte_intr_instance_windows_handle_get; rte_intr_instance_windows_handle_set; + rte_intr_irq_count_get; + rte_intr_irq_count_set; rte_intr_max_intr_get; rte_intr_max_intr_set; rte_intr_nb_efd_get;
Signature · 1 line
2.17.1
Re: [PATCH v2 3/6] bus/cdx: add support for MSI
Quoted 5 lines · Nipun Gupta
MSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
Signed-off-by Nipun Gupta <[email protected]>
This commit also adds two new internal eal APIs and extends "struct rte_intr_handle", can you please document this in the commit log?
RE: [PATCH v2 3/6] bus/cdx: add support for MSI
Quoted 12 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, April 14, 2023 10:15 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v2 3/6] bus/cdx: add support for MSIOn 4/13/2023 2:27 PM, Nipun Gupta wrote:
Quoted 8 lines
Quoted 5 lines
MSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
Signed-off-by Nipun Gupta <[email protected]>This commit also adds two new internal eal APIs and extends "struct
rte_intr_handle", can you please document this in the commit log?
Sure. Will update.
PATCH v2 4/6 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on the CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -69,6 +69,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v2 5/6 bus: enable cdx bus
In reply to Nipun Guptaenable the compilation of cdx bus
--- drivers/bus/meson.build | 1 + 1 file changed, 1 insertion(+)
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
Re: [PATCH v2 5/6] bus: enable cdx bus
Quoted 12 lines · Nipun Gupta
enable the compilation of cdx bus
Signed-off-by Nipun Gupta <[email protected]>--- drivers/bus/meson.build | 1 + 1 file changed, 1 insertion(+)drivers/bus/meson.build +0
-0
drivers/bus/meson.build line 9
Quoted 7 lines
drivers/bus/meson.build +1
-0@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Why not squash this to the first patch?
I think better to enable bus with the first patch and gradually expand the feature, this way each patch is checked that it builds fine.
There are cases some interim patches can't be built successfully, which may required enabling after a few patches, but I think this is not the case.
RE: [PATCH v2 5/6] bus: enable cdx bus
Quoted 34 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Friday, April 14, 2023 10:16 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v2 5/6] bus: enable cdx busQuoted 12 lines · Nipun Gupta
enable the compilation of cdx bus
Signed-off-by Nipun Gupta <[email protected]>--- drivers/bus/meson.build | 1 + 1 file changed, 1 insertion(+)drivers/bus/meson.build +0
-0drivers/bus/meson.build line 9
Quoted 7 lines
drivers/bus/meson.build +1
-0@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',Why not squash this to the first patch?
Quoted 5 lines
I think better to enable bus with the first patch and gradually expand the feature, this way each patch is checked that it builds fine.
There are cases some interim patches can't be built successfully, which may required enabling after a few patches, but I think this is not the case.
Sure, I will merge into the first patch. Compilation should be working there too.
Thanks,
Nipun
PATCH v2 6/6 config/arm: add AMD CDX
In reply to Nipun GuptaAdding support for AMD CDX devices
--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc
config/arm/arm64_cdx_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'
config/arm/meson.build +14 -0
@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = { + 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +} + soc_centriq2400 = { 'description': 'Qualcomm Centriq 2400', 'implementer': '0x51',
@@ -463,6 +475,7 @@ generic_aarch32: Generic un-optimized build for armv8 aarch32 execution mode. armada: Marvell ARMADA bluefield: NVIDIA BlueField bluefield3: NVIDIA BlueField-3 +cdx: AMD CDX centriq2400: Qualcomm Centriq 2400 cn9k: Marvell OCTEON 9 cn10k: Marvell OCTEON 10
@@ -490,6 +503,7 @@ socs = { 'armada': soc_armada, 'bluefield': soc_bluefield, 'bluefield3': soc_bluefield3, + 'cdx': soc_cdx, 'centriq2400': soc_centriq2400, 'cn9k': soc_cn9k, 'cn10k' : soc_cn10k,
Signature · 1 line
2.17.1
Quoted 9 lines · Nipun Gupta
Support AMD CDX bus, for FPGA based CDX devices. The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The patches are intended for DPDK 23.07 release, and have been sent as an RFC as patches are yet to be merged in Linux.
not RFC anymore
Quoted 16 lines
The CDX bus and VFIO support is available at Xilinx open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/anddrivers/vfio/cdx)Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdxVFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.htmlCDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
Quoted 5 lines
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Overall looks good to me,
there are a few warnings by check-git-log.sh, can you please check?
Also what do you think to add a release notes update for new bus?
Quoted 43 lines
Changes
v1->v2:
- Moved filerte_cdx_bus.hto internalbus_cdx_driver.hand added this file todeivce_cdx_headers
- Movedcdx.htoprivate.h
- Removedrte_prefix from the static symbols in .c files.Changes
RFC->v1:
- Marked few API's as internal which were not required to be provided to user.Nipun Gupta (6):
bus/cdx: introduce cdx bus
bus/cdx: add dma map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
bus: enable cdx bus
config/arm: add AMD CDXMAINTAINERS | 5 + config/arm/arm64_cdx_linux_gcc | 17 + config/arm/meson.build | 14 + drivers/bus/cdx/bus_cdx_driver.h | 227 ++++++++ drivers/bus/cdx/cdx.c | 694 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 619 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 12 + drivers/bus/cdx/private.h | 49 ++ drivers/bus/cdx/version.map | 13 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 15 files changed, 1744 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
v3 cover Support AMD CDX bus, for FPGA based CDX devices. The CDX
In reply to Nipun GuptaIt uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported by check-git-log.sh
- updated release notes
- updated offset to uint64_t instead of off_t in cdx_map_resource
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (5):
bus/cdx: introduce cdx bus
bus/cdx: add DMA map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
config/arm: add AMD CDX
MAINTAINERS | 5 + config/arm/arm64_cdx_linux_gcc | 17 + config/arm/meson.build | 14 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 227 ++++++++ drivers/bus/cdx/cdx.c | 693 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 615 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 ++ drivers/bus/cdx/version.map | 13 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 16 files changed, 1746 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v3 1/5 bus/cdx: introduce cdx bus
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++ drivers/bus/cdx/cdx.c | 520 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 437 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1280 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
doc/guides/rel_notes/release_23_07.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------
drivers/bus/cdx/bus_cdx_driver.h new file +201 -0
201 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +520 -0
520 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _CDX_LOGS_H_ +#define _CDX_LOGS_H_ + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* _CDX_LOGS_H_ */
drivers/bus/cdx/cdx_vfio.c new file +437 -0
437 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +49 -0
49 lines not on this page · raw message
drivers/bus/cdx/version.map new file +11 -0
@@ -0,0 +1,11 @@ +INTERNAL { + global: + + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
PATCH v3 2/5 bus/cdx: add DMA map and unmap support
In reply to Nipun GuptaCDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/bus/cdx/cdx.c +40 -0
@@ -505,12 +505,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH v3 3/5 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
A couple of API's have been introduced in the EAL interrupt framework:
- rte_intr_irq_count_set: This API is used to set the total interrupts on the interrupt handle. This would be provided by VFIO (irq.count) for VFIO enabled devices.
- rte_intr_irq_count_get: This API returns the total number interrupts which were set.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 ++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + lib/eal/common/eal_common_interrupts.c | 21 +++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 +++++ lib/eal/version.map | 2 + 8 files changed, 274 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -72,6 +72,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -173,6 +174,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_internal void rte_cdx_register(struct rte_cdx_driver *driver); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Helper for CDX device registration from driver (eth, crypto, raw) instance */
drivers/bus/cdx/cdx.c +11 -0
@@ -204,6 +204,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -394,6 +403,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +180 -2
235 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -6,6 +6,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
lib/eal/common/eal_common_interrupts.c +21 -0
@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {
lib/eal/common/eal_interrupts.h +1 -0
@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */
lib/eal/include/rte_interrupts.h +32 -0
@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the irq count field of interrupt handle with user +* provided irq count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); + +/** +* @internal +* Returns the irq count field of the given interrupt handle instance. +* +* @param intr_handle +* pointer to the interrupt handle. +* +* @return +* - On success, ir count. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int rte_intr_irq_count_get(const struct rte_intr_handle *intr_handle); +/** * @internal * Set the number of event fd field of interrupt handle
lib/eal/version.map +2 -0
@@ -458,6 +458,8 @@ INTERNAL { rte_intr_instance_dup; rte_intr_instance_windows_handle_get; rte_intr_instance_windows_handle_set; + rte_intr_irq_count_get; + rte_intr_irq_count_set; rte_intr_max_intr_get; rte_intr_max_intr_set; rte_intr_nb_efd_get;
Signature · 1 line
2.17.1
PATCH v3 4/5 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on the CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -69,6 +69,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v3 5/5 config/arm: add AMD CDX
In reply to Nipun GuptaAdding support for AMD CDX devices
--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc
config/arm/arm64_cdx_linux_gcc new file +17 -0
@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'
config/arm/meson.build +14 -0
@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = { + 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +} + soc_centriq2400 = { 'description': 'Qualcomm Centriq 2400', 'implementer': '0x51',
@@ -463,6 +475,7 @@ generic_aarch32: Generic un-optimized build for armv8 aarch32 execution mode. armada: Marvell ARMADA bluefield: NVIDIA BlueField bluefield3: NVIDIA BlueField-3 +cdx: AMD CDX centriq2400: Qualcomm Centriq 2400 cn9k: Marvell OCTEON 9 cn10k: Marvell OCTEON 10
@@ -490,6 +503,7 @@ socs = { 'armada': soc_armada, 'bluefield': soc_bluefield, 'bluefield3': soc_bluefield3, + 'cdx': soc_cdx, 'centriq2400': soc_centriq2400, 'cn9k': soc_cn9k, 'cn10k' : soc_cn10k,
Signature · 1 line
2.17.1
Re: [PATCH v3 5/5] config/arm: add AMD CDX
Quoted 41 lines · Nipun Gupta
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gccconfig/arm/arm64_cdx_linux_gcc new file +17
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {
config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}
Hi Nipun,
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
RE: [PATCH v3 5/5] config/arm: add AMD CDX
Quoted 67 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, May 4, 2023 8:59 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXReview
Quoted 10 lines · Nipun Gupta
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 31 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +17
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too (arm64_armv8_linux_gcc).
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".
Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Thanks,
Nipun
Re: [PATCH v3 5/5] config/arm: add AMD CDX
08/05/2023 12:24, Gupta, Nipun:
Quoted 64 lines
From: Yigit, Ferruh <[email protected]>
Quoted 56 lines · Nipun Gupta
Review
Quoted 10 lines
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 31 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +17
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too (
arm64_armv8_linux_gcc).
Quoted 7 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Please let's skip this patch for now.
You should send it separately later, with perf testing and HW description in the commit log.
RE: [PATCH v3 5/5] config/arm: add AMD CDX
Quoted 84 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Monday, May 8, 2023 4:14 PM
To: Yigit, Ferruh <[email protected]>; Gupta, Nipun <[email protected]>
Cc: [email protected]; [email protected]; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDX08/05/2023 12:24, Gupta, Nipun:
Quoted 57 lines
From: Yigit, Ferruh <[email protected]>
Quoted 56 lines · Nipun Gupta
Review
Quoted 10 lines
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 31 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +17
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 6 lines
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too
(
arm64_armv8_linux_gcc).Quoted 2 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx
config
Quoted 4 lines
Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".
Quoted 7 lines
Quoted 1 line
Maybe ARM guys can provide more information regarding if there is any
impact
Quoted 1 line
on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Please let's skip this patch for now.
You should send it separately later, with perf testing and HW description in the commit log.
Sure, I will skip this and send another spin for CDX bus without this change.
Thanks,
Nipun
Quoted 2 lines
Re: [PATCH v3 5/5] config/arm: add AMD CDX
In reply to Gupta, NipunQuoted 74 lines · Nipun
Quoted 67 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, May 4, 2023 8:59 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXReview
Quoted 10 lines · Nipun Gupta
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 31 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +17
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] +cpp = ['ccache', 'aarch64-linux-gnu-g++'] +ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too (
arm64_armv8_linux_gcc).
Quoted 8 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Hi Honnappa, Ruifeng,
Can you please support on this question, what is the difference of 'march= armv8-a' flag (comparing march= armv8a)?
Should we consider adding an arm config file to support this flag?
Thanks,
ferruh
RE: [PATCH v3 5/5] config/arm: add AMD CDX
<snip>
Quoted 69 lines
Quoted 56 lines
Quoted 56 lines · Nipun Gupta
Review
Quoted 10 lines
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 30 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +16
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] cpp = ['ccache', +'aarch64-linux-gnu-g++'] ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build index renamed from config/arm/meson.build +0
-0
5213434ca4..39b8929534100644config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 6 lines
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too
(
arm64_armv8_linux_gcc).Quoted 6 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".
Quoted 8 lines
Quoted 3 lines
Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Hi Honnappa, Ruifeng,
Can you please support on this question, what is the difference of 'march= armv8-a' flag (comparing march= armv8a)?
I am assuming you meant, 'march=armv8.4-a' vs 'march=armv8-a'.
'march=armv8-a' will compile for the ARM V8.0-a ISA which is the base V8-a version of the ISA. This compilation ensures that the binaries can run on any ARM V8-a platforms.
'march=armv8.4-a' will compile the binary for ARM V8.4 ISA. The binary will use additional (possibly instructions that improve performance) instructions which are not supported in ARM V8.0-a. This binary can run only on machines that support V8.4-a and higher. But, it will provide optimized binary for the target platform.
Quoted 1 line
Should we consider adding an arm config file to support this flag?
We support the optimized binary through the config files. We should keep these config changes.
Quoted 4 lines
Thanks,
ferruh
Re: [PATCH v3 5/5] config/arm: add AMD CDX
Quoted 75 lines · Honnappa Nagarahalli
<snip>
Quoted 73 lines
Quoted 56 lines
Quoted 56 lines · Nipun Gupta
Review
Quoted 10 lines
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 30 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +16
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] cpp = ['ccache', +'aarch64-linux-gnu-g++'] ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build index renamed from config/arm/meson.build +0
-0
5213434ca4..39b8929534100644config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 6 lines
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too
(
arm64_armv8_linux_gcc).Quoted 9 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Quoted 6 lines
Quoted 4 lines
Hi Honnappa, Ruifeng,
Can you please support on this question, what is the difference of 'march= armv8-a' flag (comparing march= armv8a)?
I am assuming you meant, 'march=armv8.4-a' vs 'march=armv8-a'.
Yes
Quoted 6 lines
'march=armv8-a' will compile for the ARM V8.0-a ISA which is the base V8-a version of the ISA. This compilation ensures that the binaries can run on any ARM V8-a platforms.
'march=armv8.4-a' will compile the binary for ARM V8.4 ISA. The binary will use additional (possibly instructions that improve performance) instructions which are not supported in ARM V8.0-a. This binary can run only on machines that support V8.4-a and higher. But, it will provide optimized binary for the target platform.Quoted 1 line
Should we consider adding an arm config file to support this flag?
We support the optimized binary through the config files. We should keep these config changes.
Got it, thanks for the guidance.
RE: [PATCH v3 5/5] config/arm: add AMD CDX
[AMD Official Use Only - General]
Quoted 107 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Monday, May 8, 2023 11:17 PM
To: Honnappa Nagarahalli <[email protected]>; Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]; Ruifeng Wang <[email protected]>
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXQuoted 61 lines · Honnappa Nagarahalli
<snip>
Quoted 59 lines
Quoted 59 lines
Quoted 58 lines · Nipun Gupta
Review
Quoted 10 lines
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 30 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +16
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] cpp = ['ccache', +'aarch64-linux-gnu-g++'] ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build index renamed from config/arm/meson.build +0
-0
5213434ca4..39b8929534100644config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Hi Ferruh,
CDX driver works with generic ARM compilation too
(
arm64_armv8_linux_gcc).Quoted 4 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for genericARM
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
compilation "march= armv8-a".
Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78
cores.
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Hi Honnappa, Ruifeng,
Can you please support on this question, what is the difference of
'march=
Quoted 3 lines
Quoted 1 line
armv8-a' flag (comparing march= armv8a)?
I am assuming you meant, 'march=armv8.4-a' vs 'march=armv8-a'.
Yes
Quoted 1 line
'march=armv8-a' will compile for the ARM V8.0-a ISA which is the base V8-a
version of the ISA. This compilation ensures that the binaries can run on any ARM V8-a platforms.
Quoted 1 line
'march=armv8.4-a' will compile the binary for ARM V8.4 ISA. The binary will
use additional (possibly instructions that improve performance) instructions which are not supported in ARM V8.0-a. This binary can run only on machines that support V8.4-a and higher. But, it will provide optimized binary for the target platform.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
Quoted 1 line
Should we consider adding an arm config file to support this flag?
We support the optimized binary through the config files. We should keep
these config changes.
Quoted 1 line
Got it, thanks for the guidance.
Thanks Honnappa, Ferruh,
As discussed with Thomas too, we will add this as a separate platform patch, with more platform details separated from CDX bus (patch sent out v4).
RE: [PATCH v3 5/5] config/arm: add AMD CDX
In reply to Ferruh YigitQuoted 92 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, May 8, 2023 7:27 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXQuoted 73 lines · Nipun
Quoted 66 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, May 4, 2023 8:59 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXReview
Quoted 10 lines · Nipun Gupta
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 30 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +16
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] cpp = ['ccache', +'aarch64-linux-gnu-g++'] ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build index renamed from config/arm/meson.build +0
-0
5213434ca4..39b8929534100644config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too (
arm64_armv8_linux_gcc).Quoted 8 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Quoted 5 lines
Hi Honnappa, Ruifeng,
Can you please support on this question, what is the difference of 'march= armv8-a' flag (comparing march= armv8a)?
Should we consider adding an arm config file to support this flag?
I see there is a new version without change to config file.
FWIW, native build is fine without this change. Because the specific (implementer, part number) flags are already in place. What enabled by this change are options for soc build (-Dplatform=cdx) and cross-build (--cross-file arm64_cdx_linux_gcc).
Regards,
Ruifeng
Quoted 4 lines
Thanks,
ferruh
Re: [PATCH v3 5/5] config/arm: add AMD CDX
Quoted 94 lines · Ruifeng Wang
Quoted 94 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, May 8, 2023 7:27 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXQuoted 73 lines · Nipun
Quoted 66 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, May 4, 2023 8:59 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXReview
Quoted 10 lines · Nipun Gupta
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 config/arm/arm64_cdx_linux_gcc(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 30 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +16
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] cpp = ['ccache', +'aarch64-linux-gnu-g++'] ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build index renamed from config/arm/meson.build +0
-0
5213434ca4..39b8929534100644config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too (
arm64_armv8_linux_gcc).Quoted 8 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Hi Honnappa, Ruifeng,
Quoted 9 lines
Quoted 3 lines
Can you please support on this question, what is the difference of 'march= armv8-a' flag (comparing march= armv8a)?
Should we consider adding an arm config file to support this flag?I see there is a new version without change to config file.
FWIW, native build is fine without this change. Because the specific (implementer, part number) flags are already in place. What enabled by this change are options for soc build (-Dplatform=cdx) and cross-build (--cross-filearm64_cdx_linux_gcc).
Hi Ruifeng, Honnappa,
Config file will come as standalone patch, it only separated from this set.
And config file is required mainly for '--march=armv8.4-a' parameter.
There are multiple configs using the same parameter, is it a good option to create a common config for 'armv8.4-a', similar to 'generic' one? Or is it preferred that each SoC adding its own config, as done in this patch?
Thanks,
ferruh
RE: [PATCH v3 5/5] config/arm: add AMD CDX
Quoted 119 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Wednesday, June 14, 2023 6:31 PM
To: Ruifeng Wang <[email protected]>; Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>; nd <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXQuoted 95 lines · Ruifeng Wang
Quoted 95 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Monday, May 8, 2023 7:27 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]; Honnappa Nagarahalli <[email protected]>; Ruifeng Wang <[email protected]>
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXQuoted 73 lines · Nipun
Quoted 66 lines
-----Original Message-----
From: Yigit, Ferruh <[email protected]>
Sent: Thursday, May 4, 2023 8:59 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v3 5/5] config/arm: add AMD CDXReview
Quoted 10 lines · Nipun Gupta
Adding support for AMD CDX devices
Signed-off-by Nipun Gupta <[email protected]>--- config/arm/arm64_cdx_linux_gcc | 17 +++++++++++++++++ config/arm/meson.build | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644config/arm/arm64_cdx_linux_gcc
(quoted diff) +0
-0b/config/arm/arm64_cdx_linux_gcc
Quoted 30 lines
new file mode 100644
index 0000000000..8e6d619daeconfig/arm/arm64_cdx_linux_gcc new file +16
-0@@ -0,0 +1,17 @@ +[binaries] +c = ['ccache', 'aarch64-linux-gnu-gcc'] cpp = ['ccache', +'aarch64-linux-gnu-g++'] ar = 'aarch64-linux-gnu-ar' +as = 'aarch64-linux-gnu-as' +strip = 'aarch64-linux-gnu-strip' +pkgconfig = 'aarch64-linux-gnu-pkg-config' +pcap-config = '' + +[host_machine] +system = 'linux' +cpu_family = 'aarch64' +cpu = 'armv8-a' +endian = 'little' + +[properties] +platform = 'cdx'config/arm/meson.build index renamed from config/arm/meson.build +0
-0
5213434ca4..39b8929534100644config/arm/meson.build +1
-0@@ -305,6 +305,18 @@ soc_bluefield = { 'numa': false } +soc_cdx = {config/arm/meson.build soc_bluefield = { · line 318
Quoted 10 lines
config/arm/meson.build +10
-0+ 'description': 'AMD CDX', + 'implementer': '0x41', + 'part_number': '0xd42', + 'flags': [ + ['RTE_MACHINE', '"cdx"'], + ['RTE_MAX_LCORE', 16], + ['RTE_MAX_NUMA_NODES', 1] + ], + 'numa': false +}Hi Nipun,
Quoted 2 lines
Why we need a new arm platform/config? Is it because of above flags? If it can work with default values, I think we can drop this patch.
Hi Ferruh,
CDX driver works with generic ARM compilation too (
arm64_armv8_linux_gcc).Quoted 8 lines
The versal platforms supporting CDX have A78 cores, and adding this cdx config Helps to provide gcc option "march= armv8.4-a" which is for implementer "
0xd42" (ARM cortex A78 cores)., whereas for generic ARM compilation "march= armv8-a".Maybe ARM guys can provide more information regarding if there is any impact on using generic architecture flag (i.e. march= armv8a) on A78 cores.
Hi Honnappa, Ruifeng,
Quoted 8 lines
Quoted 3 lines
Can you please support on this question, what is the difference of 'march= armv8-a' flag (comparing march= armv8a)?
Should we consider adding an arm config file to support this flag?I see there is a new version without change to config file.
FWIW, native build is fine without this change. Because the specific (implementer, part number) flags are already in place. What enabled by this change are options for soc build (-Dplatform=cdx) and cross-build (--cross-file
arm64_cdx_linux_gcc).Quoted 1 line
Hi Ruifeng, Honnappa,
Quoted 7 lines
Config file will come as standalone patch, it only separated from this set.
And config file is required mainly for '--march=armv8.4-a' parameter.
There are multiple configs using the same parameter, is it a good option to create a common config for 'armv8.4-a', similar to 'generic' one?
Or is it preferred that each SoC adding its own config, as done in this patch?
Hi Ferruh,
It is preferred that each SoC adding its own config.
SoCs at the same ISA level (e.g. armv8.4-a) can have different optional features/extensions supported. Therefore, SoC config is provided alongside with part number config.
Thanks.
Quoted 7 lines
Thanks,
ferruh
v4 cover Support AMD CDX bus, for FPGA based CDX devices. The CDX
In reply to Nipun GuptaIt uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v3->v4:
- removed platform specific patch (adding config for ARM CDX) from this series
Changes v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported by check-git-log.sh
- updated release notes
- updated offset to uint64_t instead of off_t in cdx_map_resource
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (4):
bus/cdx: introduce cdx bus
bus/cdx: add DMA map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 227 ++++++++ drivers/bus/cdx/cdx.c | 693 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 615 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 ++ drivers/bus/cdx/version.map | 13 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 14 files changed, 1715 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v4 1/4 bus/cdx: introduce cdx bus
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++ drivers/bus/cdx/cdx.c | 520 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 437 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1280 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
doc/guides/rel_notes/release_23_07.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------
drivers/bus/cdx/bus_cdx_driver.h new file +201 -0
201 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +520 -0
520 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef _CDX_LOGS_H_ +#define _CDX_LOGS_H_ + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* _CDX_LOGS_H_ */
drivers/bus/cdx/cdx_vfio.c new file +437 -0
437 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +49 -0
49 lines not on this page · raw message
drivers/bus/cdx/version.map new file +11 -0
@@ -0,0 +1,11 @@ +INTERNAL { + global: + + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
RE: [PATCH v4 1/4] bus/cdx: introduce cdx bus
Quoted 38 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Monday, May 8, 2023 7:18 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Nipun Gupta <[email protected]>
Subject: [PATCH v4 1/4] bus/cdx: introduce cdx busCDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++ drivers/bus/cdx/cdx.c | 520 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 437 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1280 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
...
Quoted 48 lines
drivers/bus/cdx/cdx.c new file +45
-0@@ -0,0 +1,520 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +/* +* Architecture Overview +* ===================== +* CDX is a Hardware Architecture designed for AMD FPGA devices. It +* consists of sophisticated mechanism for interaction between FPGA, +* Firmware and the APUs (Application CPUs). +* +* Firmware resides on RPU (Realtime CPUs) which interacts with +* the FPGA program manager and the APUs. The RPU provides memory-mapped +* interface (RPU if) which is used to communicate with APUs. +* +* The diagram below shows an overview of the CDX architecture: +* +* +--------------------------------------+ +* | DPDK | +* | DPDK CDX drivers | +* | | | +* | DPDK CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* +-----------------------------|--------+ +* | Application CPUs (APU) | | +* | | | +* | VFIO CDX driver | +* | Linux OS | | +* | Linux CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* | +* +------------------------| RPU if |----+ +* | | | +* | V | +* | Realtime CPUs (RPU) | +* | | +* +--------------------------------------+ +* | +* +---------------------|----------------+ +* | FPGA | | +* | +-----------------------+ |
drivers/bus/cdx/cdx.c line 55
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+* | | | | | +* | +-------+ +-------+ +-------+ | +* | | dev 1 | | dev 2 | | dev 3 | | +* | +-------+ +-------+ +-------+ | +* +--------------------------------------+ +* +* The RPU firmware extracts the device information from the loaded FPGA +* image and implements a mechanism that allows the APU drivers to +* enumerate such devices (device personality and resource details) via +* a dedicated communication channel.
What is APU? CPU resources that application uses? Then why cpu resources that DPDK Uses are not part of it?
I also notice that there are more and more vfio-XXX devices in DPDK now: pci/platform/cdx. Some vfio related code are very similar. In the future we may need to think about make them a common lib or something.
Thanks,
Chenbo
Quoted 9 lines
drivers/bus/cdx/cdx.c new file +2
-0+* +* VFIO CDX driver provides the CDX device resources like MMIO and interrupts
+ * to map to user-space. DPDK CDX bus uses sysfs interface and the vfio- cdx
+ * driver to discover and initialize the CDX devices for user-space
+ * applications.
+ */
+
RE: [PATCH v4 1/4] bus/cdx: introduce cdx bus
[AMD Official Use Only - General]
Quoted 111 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Tuesday, May 9, 2023 12:25 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: RE: [PATCH v4 1/4] bus/cdx: introduce cdx busCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 5 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Monday, May 8, 2023 7:18 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected];Quoted 33 lines
Nipun Gupta <[email protected]>
Subject: [PATCH v4 1/4] bus/cdx: introduce cdx busCDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++ drivers/bus/cdx/cdx.c | 520 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 437 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1280 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map...
Quoted 6 lines
drivers/bus/cdx/cdx.c new file +3
-0@@ -0,0 +1,520 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ drivers/bus/cdx/cdx.c line 13
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+ +/* +* Architecture Overview +* ===================== +* CDX is a Hardware Architecture designed for AMD FPGA devices. It +* consists of sophisticated mechanism for interaction between FPGA, +* Firmware and the APUs (Application CPUs). +* +* Firmware resides on RPU (Realtime CPUs) which interacts with +* the FPGA program manager and the APUs. The RPU provides memory- mapped
Quoted 29 lines
drivers/bus/cdx/cdx.c new file +29
-0+* interface (RPU if) which is used to communicate with APUs. +* +* The diagram below shows an overview of the CDX architecture: +* +* +--------------------------------------+ +* | DPDK | +* | DPDK CDX drivers | +* | | | +* | DPDK CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* +-----------------------------|--------+ +* | Application CPUs (APU) | | +* | | | +* | VFIO CDX driver | +* | Linux OS | | +* | Linux CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* | +* +------------------------| RPU if |----+ +* | | | +* | V | +* | Realtime CPUs (RPU) | +* | | +* +--------------------------------------+ +* | drivers/bus/cdx/cdx.c
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+* +---------------------|----------------+ +* | FPGA | | +* | +-----------------------+ | +* | | | | | +* | +-------+ +-------+ +-------+ | +* | | dev 1 | | dev 2 | | dev 3 | | +* | +-------+ +-------+ +-------+ | +* +--------------------------------------+ +* +* The RPU firmware extracts the device information from the loaded
Quoted 8 lines
FPGA
drivers/bus/cdx/cdx.c line 55
Quoted 3 lines
drivers/bus/cdx/cdx.c new file +3
-0+* image and implements a mechanism that allows the APU drivers to +* enumerate such devices (device personality and resource details) via +* a dedicated communication channel. What is APU? CPU resources that application uses? Then why cpu resources that DPDK
Uses are not part of it?
Hi Chenbo,
APU's are application processor unit and are on-chip CPU's. So in short APUs are CPUs only on which applications like DPDK are running.
Thanks,
Nipun
Re: [PATCH v4 1/4] bus/cdx: introduce cdx bus
Quoted 120 lines · Nipun
[AMD Official Use Only - General]
Quoted 116 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Tuesday, May 9, 2023 12:25 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: RE: [PATCH v4 1/4] bus/cdx: introduce cdx busCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 5 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Monday, May 8, 2023 7:18 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected];Quoted 33 lines
Nipun Gupta <[email protected]>
Subject: [PATCH v4 1/4] bus/cdx: introduce cdx busCDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++ drivers/bus/cdx/cdx.c | 520 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 437 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1280 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map...
Quoted 6 lines
drivers/bus/cdx/cdx.c new file +3
-0@@ -0,0 +1,520 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ drivers/bus/cdx/cdx.c line 13
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+ +/* +* Architecture Overview +* ===================== +* CDX is a Hardware Architecture designed for AMD FPGA devices. It +* consists of sophisticated mechanism for interaction between FPGA, +* Firmware and the APUs (Application CPUs). +* +* Firmware resides on RPU (Realtime CPUs) which interacts with +* the FPGA program manager and the APUs. The RPU provides memory- mapped
Quoted 29 lines
drivers/bus/cdx/cdx.c new file +29
-0+* interface (RPU if) which is used to communicate with APUs. +* +* The diagram below shows an overview of the CDX architecture: +* +* +--------------------------------------+ +* | DPDK | +* | DPDK CDX drivers | +* | | | +* | DPDK CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* +-----------------------------|--------+ +* | Application CPUs (APU) | | +* | | | +* | VFIO CDX driver | +* | Linux OS | | +* | Linux CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* | +* +------------------------| RPU if |----+ +* | | | +* | V | +* | Realtime CPUs (RPU) | +* | | +* +--------------------------------------+ +* | drivers/bus/cdx/cdx.c
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+* +---------------------|----------------+ +* | FPGA | | +* | +-----------------------+ | +* | | | | | +* | +-------+ +-------+ +-------+ | +* | | dev 1 | | dev 2 | | dev 3 | | +* | +-------+ +-------+ +-------+ | +* +--------------------------------------+ +* +* The RPU firmware extracts the device information from the loaded FPGA
Quoted 3 lines
drivers/bus/cdx/cdx.c new file +3
-0+* image and implements a mechanism that allows the APU drivers to +* enumerate such devices (device personality and resource details) via +* a dedicated communication channel.
Quoted 9 lines
Quoted 3 lines
What is APU? CPU resources that application uses? Then why cpu resources that DPDK
Uses are not part of it?Hi Chenbo,
APU's are application processor unit and are on-chip CPU's. So in short APUs are CPUs only on which applications like DPDK are running.
There are two sets of processing unit in the SoC. FW runs on RPU, everything else runs on APU (Arm cores), including OS, DPDK etc..
RE: [PATCH v4 1/4] bus/cdx: introduce cdx bus
Quoted 139 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, May 9, 2023 7:26 PM
To: Gupta, Nipun <[email protected]>; Xia, Chenbo <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v4 1/4] bus/cdx: introduce cdx busQuoted 41 lines · Nipun
[AMD Official Use Only - General]
Quoted 37 lines
-----Original Message-----
From: Xia, Chenbo <[email protected]>
Sent: Tuesday, May 9, 2023 12:25 PM
To: Gupta, Nipun <[email protected]>; [email protected]; [email protected]; [email protected]
Cc: Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: RE: [PATCH v4 1/4] bus/cdx: introduce cdx busCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Quoted 5 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Monday, May 8, 2023 7:18 PM
To: [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected];Quoted 18 lines
Nipun Gupta <[email protected]>
Subject: [PATCH v4 1/4] bus/cdx: introduce cdx busCDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++++ drivers/bus/cdx/cdx.c | 520+++++++++++++++++++++++++
Quoted 74 lines
Quoted 74 lines
Quoted 15 lines
drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 437 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 49 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1280 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map...
Quoted 6 lines
drivers/bus/cdx/cdx.c new file +3
-0@@ -0,0 +1,520 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ drivers/bus/cdx/cdx.c line 13
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+ +/* +* Architecture Overview +* ===================== +* CDX is a Hardware Architecture designed for AMD FPGA devices. It +* consists of sophisticated mechanism for interaction between FPGA, +* Firmware and the APUs (Application CPUs). +* +* Firmware resides on RPU (Realtime CPUs) which interacts with +* the FPGA program manager and the APUs. The RPU provides memory- mapped
Quoted 39 lines
drivers/bus/cdx/cdx.c new file +39
-0+* interface (RPU if) which is used to communicate with APUs. +* +* The diagram below shows an overview of the CDX architecture: +* +* +--------------------------------------+ +* | DPDK | +* | DPDK CDX drivers | +* | | | +* | DPDK CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* +-----------------------------|--------+ +* | Application CPUs (APU) | | +* | | | +* | VFIO CDX driver | +* | Linux OS | | +* | Linux CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* | +* +------------------------| RPU if |----+ +* | | | +* | V | +* | Realtime CPUs (RPU) | +* | | +* +--------------------------------------+ +* | +* +---------------------|----------------+ +* | FPGA | | +* | +-----------------------+ | +* | | | | | +* | +-------+ +-------+ +-------+ | +* | | dev 1 | | dev 2 | | dev 3 | | +* | +-------+ +-------+ +-------+ | +* +--------------------------------------+ +* +* The RPU firmware extracts the device information from the loaded Quoted 3 lines
Quoted 3 lines
FPGA
Quoted 2 lines
drivers/bus/cdx/cdx.c new file +2
-0+* image and implements a mechanism that allows the APU drivers to +* enumerate such devices (device personality and resource details) via
Quoted 3 lines
Quoted 3 lines
drivers/bus/cdx/cdx.c line 55
Quoted 1 line
drivers/bus/cdx/cdx.c new file +1
-0+* a dedicated communication channel. What is APU? CPU resources that application uses? Then why cpu
resources
Quoted 5 lines
Quoted 2 lines
that DPDK
Uses are not part of it?Hi Chenbo,
Quoted 7 lines
Quoted 1 line
APU's are application processor unit and are on-chip CPU's. So in short
APUs
Quoted 2 lines
are CPUs only on which applications like DPDK are running.
There are two sets of processing unit in the SoC. FW runs on RPU, everything else runs on APU (Arm cores), including OS, DPDK etc..
Cool, thanks Nipun and Ferruh for the explanation!
Re: [PATCH v4 1/4] bus/cdx: introduce cdx bus
In reply to Nipun GuptaHello,
If I understand well, it is very specific to AMD devices. So I suggest adding "AMD" in title and descriptions.
08/05/2023 13:18, Nipun Gupta:
Quoted 10 lines
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>
[...]
Quoted 1 line
+CDX bus driver
Can we name it "AMD CDX bus"?
Quoted 3 lines
MAINTAINERS +3
-0+M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/
[...]
Quoted 1 line
+* **Added CDX bus support.**
Here as well and in other places, would be more precise to say "AMD CDX".
Quoted 4 lines
doc/guides/rel_notes/release_23_07.rst +4
-0+ + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs.
[...]
drivers/bus/cdx/bus_cdx_driver.h line 6
Quoted 2 lines
drivers/bus/cdx/bus_cdx_driver.h new file +2
-0+#ifndef _BUS_CDX_DRIVER_H_ +#define _BUS_CDX_DRIVER_H_
In general I prefer not adding underscores,
as it is not required, and not really private.
[...]
drivers/bus/cdx/bus_cdx_driver.h line 23
Quoted 6 lines
drivers/bus/cdx/bus_cdx_driver.h new file +6
-0+#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <errno.h> +#include <stdint.h> +#include <inttypes.h>
I would bet some includes are not needed for this header file.
Quoted 7 lines
drivers/bus/cdx/bus_cdx_driver.h new file +7
-0+ +#include <bus_driver.h> +#include <dev_driver.h> +#include <rte_debug.h> +#include <rte_interrupts.h> +#include <rte_dev.h> +#include <rte_bus.h>
[...]
RE: [PATCH v4 1/4] bus/cdx: introduce cdx bus
[AMD Official Use Only - General]
Quoted 25 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, May 24, 2023 4:45 PM
To: Gupta, Nipun <[email protected]>
Cc: [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v4 1/4] bus/cdx: introduce cdx busCaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
Hello,
If I understand well, it is very specific to AMD devices. So I suggest adding "AMD" in title and descriptions.
08/05/2023 13:18, Nipun Gupta:
Quoted 6 lines
CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).
Quoted 8 lines
Quoted 4 lines
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>[...]
Quoted 1 line
+CDX bus driver
Can we name it "AMD CDX bus"?
Sure will update.
Quoted 13 lines
Quoted 4 lines
MAINTAINERS +3
-0+M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/[...]
Quoted 1 line
+* **Added CDX bus support.**
Here as well and in other places, would be more precise to say "AMD CDX".
doc/guides/rel_notes/release_23_07.rst New Features
Quoted 3 lines
doc/guides/rel_notes/release_23_07.rst +3
-0+ + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on
Quoted 8 lines
system
Quoted 1 line
+ bus for embedded CPUs.
[...]
drivers/bus/cdx/bus_cdx_driver.h line 6
Quoted 2 lines
drivers/bus/cdx/bus_cdx_driver.h new file +2
-0+#ifndef _BUS_CDX_DRIVER_H_ +#define _BUS_CDX_DRIVER_H_In general I prefer not adding underscores,
as it is not required, and not really private.
Okay.. I will update for all the header files.
Quoted 10 lines
[...]
drivers/bus/cdx/bus_cdx_driver.h line 23
Quoted 6 lines
drivers/bus/cdx/bus_cdx_driver.h new file +6
-0+#include <stdio.h> +#include <stdlib.h> +#include <limits.h> +#include <errno.h> +#include <stdint.h> +#include <inttypes.h> I would bet some includes are not needed for this header file.
Will cut them short.
Thanks,
Nipun
Quoted 11 lines
Quoted 8 lines
drivers/bus/cdx/bus_cdx_driver.h new file +7
-0+ +#include <bus_driver.h> +#include <dev_driver.h> +#include <rte_debug.h> +#include <rte_interrupts.h> +#include <rte_dev.h> +#include <rte_bus.h> [...]
PATCH v4 2/4 bus/cdx: add DMA map and unmap support
In reply to Nipun GuptaCDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/bus/cdx/cdx.c +40 -0
@@ -505,12 +505,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH v4 3/4 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
A couple of API's have been introduced in the EAL interrupt framework:
- rte_intr_irq_count_set: This API is used to set the total interrupts on the interrupt handle. This would be provided by VFIO (irq.count) for VFIO enabled devices.
- rte_intr_irq_count_get: This API returns the total number interrupts which were set.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 ++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + lib/eal/common/eal_common_interrupts.c | 21 +++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 +++++ lib/eal/version.map | 2 + 8 files changed, 274 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -72,6 +72,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -173,6 +174,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_internal void rte_cdx_register(struct rte_cdx_driver *driver); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Helper for CDX device registration from driver (eth, crypto, raw) instance */
drivers/bus/cdx/cdx.c +11 -0
@@ -204,6 +204,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -394,6 +403,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +180 -2
235 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -6,6 +6,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
lib/eal/common/eal_common_interrupts.c +21 -0
@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {
lib/eal/common/eal_interrupts.h +1 -0
@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */
lib/eal/include/rte_interrupts.h +32 -0
@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the irq count field of interrupt handle with user +* provided irq count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); + +/** +* @internal +* Returns the irq count field of the given interrupt handle instance. +* +* @param intr_handle +* pointer to the interrupt handle. +* +* @return +* - On success, ir count. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int rte_intr_irq_count_get(const struct rte_intr_handle *intr_handle); +/** * @internal * Set the number of event fd field of interrupt handle
lib/eal/version.map +2 -0
@@ -458,6 +458,8 @@ INTERNAL { rte_intr_instance_dup; rte_intr_instance_windows_handle_get; rte_intr_instance_windows_handle_set; + rte_intr_irq_count_get; + rte_intr_irq_count_set; rte_intr_max_intr_get; rte_intr_max_intr_set; rte_intr_nb_efd_get;
Signature · 1 line
2.17.1
Re: [PATCH v4 3/4] bus/cdx: add support for MSI
08/05/2023 13:18, Nipun Gupta:
Quoted 11 lines
MSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
A couple of API's have been introduced in the EAL interrupt framework:
-rte_intr_irq_count_set: This API is used to set the total interrupts on the interrupt handle. This would be provided by VFIO (irq.count) for VFIO enabled devices.
-rte_intr_irq_count_get: This API returns the total number interrupts which were set.
[...]
lib/eal/common/eal_interrupts.h struct rte_intr_handle { · line 19
Quoted 7 lines
lib/eal/common/eal_interrupts.h +1
-0@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */
Why only via VFIO?
[...]
lib/eal/common/eal_interrupts.h struct rte_intr_handle {
Quoted 9 lines
lib/eal/common/eal_interrupts.h +9
-0+/** +* @internal +* Set the irq count field of interrupt handle with user +* provided irq count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count
Please write IRQ all uppercase consistently.
Same for CDX.
lib/eal/common/eal_interrupts.h
Quoted 2 lines
lib/eal/common/eal_interrupts.h +2
-0+ rte_intr_irq_count_get; + rte_intr_irq_count_set;
Adding a new API in EAL deserves a separate commit with a different audience. It looks like it has been hidden from EAL reviewers eyes so far.
RE: [PATCH v4 3/4] bus/cdx: add support for MSI
[AMD Official Use Only - General]
Quoted 26 lines
-----Original Message-----
From: Thomas Monjalon <[email protected]>
Sent: Wednesday, May 24, 2023 4:37 PM
To: Gupta, Nipun <[email protected]>
Cc: [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v4 3/4] bus/cdx: add support for MSICaution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
08/05/2023 13:18, Nipun Gupta:
Quoted 11 lines
MSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
A couple of API's have been introduced in the EAL interrupt framework:
-rte_intr_irq_count_set: This API is used to set the total interrupts on the interrupt handle. This would be provided by VFIO (irq.count) for VFIO enabled devices.
-rte_intr_irq_count_get: This API returns the total number interrupts which were set.[...]
Quoted 9 lines
lib/eal/common/eal_interrupts.h struct rte_intr_handle { · line 19
Quoted 7 lines
lib/eal/common/eal_interrupts.h +1
-0@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< IRQ count provided via VFIO */ Why only via VFIO?
Though this represents total number of irq count, for VFIO it is returned by VFIO_DEVICE_GET_IRQ_INFO ioctl call. I am not sure about UIO, so added Comment w.r.t. VFIO only. I will make it generic in next spin.
Quoted 12 lines
[...]
Quoted 9 lines
+/**
+ * @internal
+ * Set the irq count field of interrupt handle with user
+ * provided irq count value.
+ *
+ * @paramintr_handle
+ * pointer to the interrupt handle.
+ * @paramirq_count
+ * IRQ count
Quoted 2 lines
Please write IRQ all uppercase consistently.
Same for CDX.
Sure.
Quoted 6 lines
lib/eal/common/eal_interrupts.h
Quoted 3 lines
lib/eal/common/eal_interrupts.h +2
-0+ rte_intr_irq_count_get; + rte_intr_irq_count_set;Adding a new API in EAL deserves a separate commit with a different audience. It looks like it has been hidden from EAL reviewers eyes so far.
Will make a separate commit for this.
Thanks,
Nipun
PATCH v4 4/4 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on the CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -69,6 +69,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH v4 0/4] Support AMD CDX bus, for FPGA based CDX devices. The CDX
In reply to Nipun GuptaQuoted 44 lines · Nipun Gupta
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/anddrivers/vfio/cdx)Linux CDX bus patches has been added into linux next:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdxVFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.htmlCDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes
v3->v4:
- removed platform specific patch (adding config for ARM CDX) from this seriesChanges
v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported bycheck-git-log.sh
- updated release notes
- updated offset touint64_tinstead ofoff_tincdx_map_resourceChanges
v1->v2:
- Moved filerte_cdx_bus.hto internalbus_cdx_driver.hand added this file todeivce_cdx_headers
- Movedcdx.htoprivate.h
- Removedrte_prefix from the static symbols in .c files.Changes
RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Quoted 5 lines
Nipun Gupta (4):
bus/cdx: introduce cdx bus
bus/cdx: add DMA map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
For series,
v5 cover Support AMD CDX bus
In reply to Nipun GuptaThe CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx/AMD open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux AMD CDX bus patches has been added into linux tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v4->v5
- Split patch and have a separate commit for eal interrupt field (irq_count) and corresponding set/get APIs (rte_intr_irq_count_set, rte_intr_irq_count_get)
- Renamed "CDX bus" to "AMD CDX bus" in documentation/commit headings
- Removed unnecessary headers
Changes v3->v4:
- removed platform specific patch (adding config for ARM CDX) from this series
Changes v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported by check-git-log.sh
- updated release notes
- updated offset to uint64_t instead of off_t in cdx_map_resource
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (5):
bus/cdx: introduce AMD CDX bus
bus/cdx: add DMA map and unmap support eal/interrupts: add IRQ count in interrupt handle bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 222 ++++++++ drivers/bus/cdx/cdx.c | 690 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 605 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 46 ++ drivers/bus/cdx/version.map | 13 + drivers/bus/meson.build | 1 + lib/eal/common/eal_common_interrupts.c | 21 + lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++ lib/eal/version.map | 2 + 14 files changed, 1694 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v5 1/5 bus/cdx: introduce AMD CDX bus
AMD CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 196 ++++++++++ drivers/bus/cdx/cdx.c | 517 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 427 ++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 46 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1259 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +AMD CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
doc/guides/rel_notes/release_23_07.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added AMD CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------
drivers/bus/cdx/bus_cdx_driver.h new file +196 -0
196 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +517 -0
517 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef CDX_LOGS_H +#define CDX_LOGS_H + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* CDX_LOGS_H */
drivers/bus/cdx/cdx_vfio.c new file +427 -0
427 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +46 -0
46 lines not on this page · raw message
drivers/bus/cdx/version.map new file +11 -0
@@ -0,0 +1,11 @@ +INTERNAL { + global: + + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
Re: [PATCH v5 1/5] bus/cdx: introduce AMD CDX bus
Hello,
Quoted 71 lines · Nipun Gupta
AMD CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO
IO_MEMORYregions as well as the DMA interface for the device (IOMMU).This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
Signed-off-by Nipun Gupta <[email protected]>Acked-by Ferruh Yigit <[email protected]>--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 196 ++++++++++ drivers/bus/cdx/cdx.c | 517 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 427 ++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 46 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1259 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.mapMAINTAINERS +5
-0@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +AMD CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/doc/guides/rel_notes/release_23_07.rst +6
-0@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added AMD CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------drivers/bus/cdx/bus_cdx_driver.h new file +0
-0
drivers/bus/cdx/bus_cdx_driver.h line 10
Quoted 10 lines
drivers/bus/cdx/bus_cdx_driver.h new file +10
-0@@ -0,0 +1,196 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef BUS_CDX_DRIVER_H +#define BUS_CDX_DRIVER_H + +/** +* @file +*
No need for empty line here.
drivers/bus/cdx/bus_cdx_driver.h line 16
Quoted 6 lines
drivers/bus/cdx/bus_cdx_driver.h new file +6
-0+* AMD CDX bus interface +*/ + +#ifdef __cplusplus +extern "C" { +#endif
Do you expect some out of tree drivers written in C++? Otherwise, this is unneeded.
drivers/bus/cdx/bus_cdx_driver.h line 24
Quoted 8 lines
drivers/bus/cdx/bus_cdx_driver.h new file +8
-0+ +#include <stdlib.h> +#include <inttypes.h> + +#include <bus_driver.h> +#include <dev_driver.h> +#include <rte_interrupts.h> +#include <rte_dev.h>
dev_driver.h is the "driver" header embedding rte_dev.h, no need to include rte_dev.h again.
drivers/bus/cdx/bus_cdx_driver.h line 25
Quoted 1 line
drivers/bus/cdx/bus_cdx_driver.h new file +1
-0+#include <rte_bus.h>
Idem, including bus_driver.h is enough.
drivers/bus/cdx/bus_cdx_driver.h line 36
Quoted 11 lines
drivers/bus/cdx/bus_cdx_driver.h new file +11
-0+ +/* Forward declarations */ +struct rte_cdx_device ; +struct rte_cdx_driver ; + +#define CDX_MAX_RESOURCE 4 + +/** List of CDX devices */ +RTE_TAILQ_HEAD (rte_cdx_device_list, rte_cdx_device); +/** List of CDX drivers */ +RTE_TAILQ_HEAD (rte_cdx_driver_list, rte_cdx_driver);
You don't need to name/expose those types, this is only used in the singleton object for the bus (see below with comment on rte_cdx_bus struct).
drivers/bus/cdx/bus_cdx_driver.h line 43
Quoted 7 lines
drivers/bus/cdx/bus_cdx_driver.h new file +7
-0+ +/* CDX Bus iterators */ +#define FOREACH_DEVICE_ON_CDXBUS (p) \ + RTE_TAILQ_FOREACH(p, &rte_cdx_bus.device_list, next) + +#define FOREACH_DRIVER_ON_CDXBUS (p) \ + RTE_TAILQ_FOREACH(p, &rte_cdx_bus.driver_list, next)
These iterators can probably be hidden in the bus code. I see no need to expose them to drivers.
So either move this to cdx.c, or if multiple code units need them, move to private.h.
Quoted 72 lines
drivers/bus/cdx/bus_cdx_driver.h new file +72
-0+ +/** Any CDX device identifier (vendor, device) */ +#define RTE_CDX_ANY_ID (0xffff) + +#define RTE_PMD_REGISTER_CDX_TABLE (name, table) \ +static const char DRV_EXP_TAG(name, cdx_tbl_export)[] __rte_used = \ +RTE_STR(table) + +/** +* A structure describing an ID for a CDX driver. Each driver provides a +* table of these IDs for each device that it supports. +*/ +struct rte_cdx_id { +uint16_t vendor_id;/**< Vendor ID. */ +uint16_t device_id;/**< Device ID. */ +}; + +/** +* A structure describing a CDX device. +*/ +struct rte_cdx_device { +RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ +struct rte_device device;/**< Inherit core device */ +struct rte_cdx_id id;/**< CDX ID. */ +struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ]; +/**< CDX Memory Resource */ +}; + +/** +* @internal +* Helper macro for drivers that need to convert to struct rte_cdx_device. +*/ +#define RTE_DEV_TO_CDX_DEV (ptr) \ + container_of(ptr, struct rte_cdx_device, device) + +#define RTE_DEV_TO_CDX_DEV_CONST (ptr) \ + container_of(ptr, const struct rte_cdx_device, device) + +#define RTE_ETH_DEV_TO_CDX_DEV (eth_dev) RTE_DEV_TO_CDX_DEV((eth_dev)->device) + +#ifdef __cplusplus +/** C++ macro used to help building up tables of device IDs */ +#define RTE_CDX_DEVICE (vend, dev) \ + (vend), \ + (dev) +#else +/** Macro used to help building up tables of device IDs */ +#define RTE_CDX_DEVICE (vend, dev) \ + .vendor_id = (vend), \ + .device_id = (dev) +#endif + +/** +* Initialisation function for the driver called during CDX probing. +*/ +typedef int (rte_cdx_probe_t )(struct rte_cdx_driver *,struct rte_cdx_device *); + +/** +* Uninitialisation function for the driver called during hotplugging. +*/ +typedef int (rte_cdx_remove_t )(struct rte_cdx_device *); + +/** +* A structure describing a CDX driver. +*/ +struct rte_cdx_driver { +RTE_TAILQ_ENTRY (rte_cdx_driver) next;/**< Next in list. */ +struct rte_driver driver;/**< Inherit core driver. */ +struct rte_cdx_bus *bus;/**< CDX bus reference. */ +rte_cdx_probe_t *probe;/**< Device probe function. */ +rte_cdx_remove_t *remove;/**< Device remove function. */ +const struct rte_cdx_id *id_table;/**< ID table, NULL terminated. */
drivers/bus/cdx/bus_cdx_driver.h line 125
Quoted 10 lines
drivers/bus/cdx/bus_cdx_driver.h new file +10
-0+uint32_t drv_flags;/**< Flags RTE_CDX_DRV_*. */ +}; + +/** +* Structure describing the CDX bus +*/ +struct rte_cdx_bus { +struct rte_bus bus;/**< Inherit the generic class */ +struct rte_cdx_device_list device_list;/**< List of CDX devices */ +struct rte_cdx_driver_list driver_list;/**< List of CDX drivers */
As I mentionned above, we can go with a simple:RTE_TAILQ_HEAD(, rte_cdx_device) device_list;RTE_TAILQ_HEAD(, rte_cdx_driver) driver_list;
drivers/bus/cdx/bus_cdx_driver.h line 126
Quoted 1 line
drivers/bus/cdx/bus_cdx_driver.h new file +1
-0+};
And I don't see a need to expose the object rte_cdx_bus object in the drivers API, so the rte_cdx_bus structure can probably move to private.h.
drivers/bus/cdx/bus_cdx_driver.h line 135
Quoted 9 lines
drivers/bus/cdx/bus_cdx_driver.h new file +9
-0+ +/** +* Get Pathname of CDX devices directory. +* +* @return +* sysfs path for CDX devices. +*/ +__rte_internal +const char *rte_cdx_get_sysfs_path(void);
Hard to tell without a first CDX driver.. will there be a user for this symbol?
drivers/bus/cdx/bus_cdx_driver.h line 146
Quoted 11 lines
drivers/bus/cdx/bus_cdx_driver.h new file +11
-0+ +/** +* Map the CDX device resources in user space virtual memory address +* +* @param dev +* A pointer to a rte_cdx_device structure describing the device +* to use +* +* @return +* 0 on success, negative on error and positive if no driver +* is found for the device.
positive if no driver is found?
This sounds like a copy/paste.
Quoted 239 lines
drivers/bus/cdx/bus_cdx_driver.h new file +50
-0+*/ +__rte_internal +int rte_cdx_map_device(struct rte_cdx_device *dev); + +/** +* Unmap this device +* +* @param dev +* A pointer to a rte_cdx_device structure describing the device +* to use +*/ +__rte_internal +void rte_cdx_unmap_device(struct rte_cdx_device *dev); + +/** +* Register a CDX driver. +* +* @param driver +* A pointer to a rte_cdx_driver structure describing the driver +* to be registered. +*/ +__rte_internal +void rte_cdx_register(struct rte_cdx_driver *driver); + +/** +* Helper for CDX device registration from driver (eth, crypto, raw) instance +*/ +#define RTE_PMD_REGISTER_CDX (nm, cdx_drv) \ + RTE_INIT(cdxinitfn_ ##nm) \ + {\ + (cdx_drv).driver.name = RTE_STR(nm);\ + rte_cdx_register(&cdx_drv); \ + } \ + RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +/** +* Unregister a CDX driver. +* +* @param driver +* A pointer to a rte_cdx_driver structure describing the driver +* to be unregistered. +*/ +__rte_internal +void rte_cdx_unregister(struct rte_cdx_driver *driver); + +#ifdef __cplusplus +} +#endif + +#endif /* BUS_CDX_DRIVER_H */ drivers/bus/cdx/cdx.c new file +183
-0@@ -0,0 +1,517 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +/* +* Architecture Overview +* ===================== +* CDX is a Hardware Architecture designed for AMD FPGA devices. It +* consists of sophisticated mechanism for interaction between FPGA, +* Firmware and the APUs (Application CPUs). +* +* Firmware resides on RPU (Realtime CPUs) which interacts with +* the FPGA program manager and the APUs. The RPU provides memory-mapped +* interface (RPU if) which is used to communicate with APUs. +* +* The diagram below shows an overview of the AMD CDX architecture: +* +* +--------------------------------------+ +* | DPDK | +* | DPDK CDX drivers | +* | | | +* | DPDK AMD CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* +-----------------------------|--------+ +* | Application CPUs (APU) | | +* | | | +* | VFIO CDX driver | +* | Linux OS | | +* | Linux AMD CDX bus | +* | | | +* +-----------------------------|--------+ +* | +* | +* +------------------------| RPU if |----+ +* | | | +* | V | +* | Realtime CPUs (RPU) | +* | | +* +--------------------------------------+ +* | +* +---------------------|----------------+ +* | FPGA | | +* | +-----------------------+ | +* | | | | | +* | +-------+ +-------+ +-------+ | +* | | dev 1 | | dev 2 | | dev 3 | | +* | +-------+ +-------+ +-------+ | +* +--------------------------------------+ +* +* The RPU firmware extracts the device information from the loaded FPGA +* image and implements a mechanism that allows the APU drivers to +* enumerate such devices (device personality and resource details) via +* a dedicated communication channel. +* +* VFIO CDX driver provides the CDX device resources like MMIO and interrupts +* to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx +* driver to discover and initialize the CDX devices for user-space +* applications. +*/ + +#include <string.h> +#include <dirent.h> + +#include <rte_eal_paging.h> +#include <rte_errno.h> +#include <rte_devargs.h> +#include <rte_malloc.h> +#include <rte_vfio.h> + +#include <eal_filesystem.h> + +#include "bus_cdx_driver.h" +#include "cdx_logs.h" +#include "private.h" + +#define SYSFS_CDX_DEVICES "/sys/bus/cdx/devices" +#define CDX_BUS_NAME cdx +#define CDX_DEV_PREFIX "cdx-" + +/** +* @file +* CDX probing using Linux sysfs. +*/ + +/* Add a device to CDX bus */ +static void +cdx_add_device (struct rte_cdx_device *cdx_dev) +{ +TAILQ_INSERT_TAIL (&rte_cdx_bus.device_list, cdx_dev, next); +} + +static int +cdx_get_kernel_driver_by_path (const char *filename,char *driver_name, +size_t len) +{ +int count; +char path[PATH_MAX ]; +char *name; + +if (!filename || !driver_name) +return -1 ; + + count =readlink (filename, path,PATH_MAX ); +if (count >=PATH_MAX ) +return -1 ; + +/* For device does not have a driver */ +if (count <0 ) +return 1 ; + + path[count] ='\0' ; + + name =strrchr (path,'/' ); +if (name) { +strlcpy (driver_name, name +1 , len); +return 0 ; + } + +return -1 ; +} + +int rte_cdx_map_device (struct rte_cdx_device *dev) +{ +return cdx_vfio_map_resource (dev); +} + +void rte_cdx_unmap_device (struct rte_cdx_device *dev) +{ +cdx_vfio_unmap_resource (dev); +} + +static struct rte_devargs * +cdx_devargs_lookup (const char *dev_name) +{ +struct rte_devargs *devargs; + + RTE_EAL_DEVARGS_FOREACH("cdx", devargs) { +if (strcmp (devargs->name, dev_name) ==0 ) +return devargs; + } +return NULL ; +} + +static bool +cdx_ignore_device (const char *dev_name) +{ +struct rte_devargs *devargs =cdx_devargs_lookup (dev_name); + +switch (rte_cdx_bus.bus.conf.scan_mode) { +case RTE_BUS_SCAN_ALLOWLIST : +if (devargs && devargs->policy ==RTE_DEV_ALLOWED ) +return false; +break ; +case RTE_BUS_SCAN_UNDEFINED : +case RTE_BUS_SCAN_BLOCKLIST : +if (devargs ==NULL || devargs->policy !=RTE_DEV_BLOCKED ) +return false; +break ; + } +return true; +} + +/* +* Scan one cdx sysfs entry, and fill the devices list from it. +* It checks if the CDX device is bound to vfio-cdx driver. In case +* the device is vfio bound, it reads the vendor and device id and +* stores it for device-driver matching. +*/ +static int +cdx_scan_one (const char *dirname,const char *dev_name) +{ +char filename[PATH_MAX ]; +struct rte_cdx_device *dev =NULL ; +char driver[PATH_MAX ]; +unsigned long tmp; +char *name =NULL ; +int ret; + + dev =calloc (1 ,sizeof (*dev)); +if (!dev) +return -ENOMEM ;
drivers/bus/cdx/cdx.c line 193
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+ + name =calloc (1 ,RTE_DEV_NAME_MAX_LEN ); +if (!name) { + ret = -ENOMEM ; + goto err; + } + + dev->device.bus = &rte_cdx_bus.bus; +memcpy (name, dev_name,RTE_DEV_NAME_MAX_LEN ); + dev->device.name = name;
If you dynamically allocate the name, you need to keep a reference to it in the rte_cdx_device object for freeing in a cleanup() later. The reason is that the rte_device object "name" field is const.
So rather than dynamically allocate to a fixed size, why not have a name[RTE_DEV_NAME_MAX_LEN] in rte_cdx_device?
Quoted 34 lines
drivers/bus/cdx/cdx.c new file +34
-0+ +/* parse driver */ +snprintf (filename,sizeof (filename),"%s/driver" , dirname); + ret =cdx_get_kernel_driver_by_path (filename, driver,sizeof (driver)); +if (ret <0 ) { +CDX_BUS_ERR ("Fail to get kernel driver" ); + ret =-1 ; + goto err; + } + +/* +* Check if device is bound to 'vfio-cdx' driver, so that user-space +* can gracefully access the device. +*/ +if (ret ||strcmp (driver,"vfio-cdx" )) { + ret =0 ; + goto err; + } + +/* get vendor id */ +snprintf (filename,sizeof (filename),"%s/vendor" , dirname); +if (eal_parse_sysfs_value (filename, &tmp) <0 ) { + ret =-1 ; + goto err; + } + dev->id.vendor_id = (uint16_t )tmp; + +/* get device id */ +snprintf (filename,sizeof (filename),"%s/device" , dirname); +if (eal_parse_sysfs_value (filename, &tmp) <0 ) { +free (dev); +return -1 ; + } + dev->id.device_id = (uint16_t )tmp;
drivers/bus/cdx/cdx.c line 237
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+ +cdx_add_device (dev); + +return 0 ; + +err: +if (name) +free (name); +if (dev) +free (dev);
free() handles NULL fine, no need to check.
Quoted 77 lines
drivers/bus/cdx/cdx.c new file +77
-0+return ret; +} + +/* +* Scan the content of the CDX bus, and the devices in the devices +* list. +*/ +static int +cdx_scan (void ) +{ +struct dirent *e; +DIR *dir; +char dirname[PATH_MAX ]; + + dir =opendir (rte_cdx_get_sysfs_path ()); +if (dir ==NULL ) { +CDX_BUS_ERR ("%s(): opendir failed: %s" , __func__, +strerror (errno)); +return -1 ; + } + +while ((e =readdir (dir)) !=NULL ) { +if (e->d_name[0 ] =='.' ) +continue ; + +if (cdx_ignore_device (e->d_name)) +continue ; + +snprintf (dirname,sizeof (dirname),"%s/%s" , +rte_cdx_get_sysfs_path (), e->d_name); + +if (cdx_scan_one (dirname, e->d_name) <0 ) + goto error; + } +closedir (dir); +return 0 ; + +error: +closedir (dir); +return -1 ; +} + +const char * +rte_cdx_get_sysfs_path (void ) +{ +return SYSFS_CDX_DEVICES ; +} + +/* map a particular resource from a file */ +void * +cdx_map_resource (void *requested_addr,int fd,uint64_t offset,size_t size, +int additional_flags) +{ +void *mapaddr; + +/* Map the cdx MMIO memory resource of device */ + mapaddr =rte_mem_map (requested_addr, size, +RTE_PROT_READ |RTE_PROT_WRITE , +RTE_MAP_SHARED | additional_flags, fd, offset); +if (mapaddr ==NULL ) { +CDX_BUS_ERR ("%s(): cannot map resource(%d, %p, 0x%zx, 0x%" PRIx64"): %s (%p)" , + __func__, fd, requested_addr, size, offset, +rte_strerror (rte_errno), mapaddr); + } +CDX_BUS_DEBUG ("CDX MMIO memory mapped at %p" , mapaddr); + +return mapaddr; +} + +/* unmap a particular resource */ +void +cdx_unmap_resource (void *requested_addr,size_t size) +{ +if (requested_addr ==NULL ) +return ; + +/* Unmap the CDX memory resource of device */
drivers/bus/cdx/cdx.c line 324
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+if (rte_mem_unmap (requested_addr, size)) { +CDX_BUS_ERR ("%s(): cannot mem unmap(%p, %#zx): %s" , __func__, + requested_addr, size,rte_strerror (rte_errno)); + } +CDX_BUS_DEBUG ("CDX memory unmapped at %p" , requested_addr); +} +/* +* Match the CDX Driver and Device using device id and vendor id. +*/ +static int
bool
Quoted 25 lines
drivers/bus/cdx/cdx.c new file +25
-0+cdx_match(const struct rte_cdx_driver *cdx_drv, + const struct rte_cdx_device *cdx_dev) +{ + const struct rte_cdx_id *id_table; + +for (id_table = cdx_drv->id_table; id_table->vendor_id !=0 ; + id_table++) { +/* check if device's identifiers match the driver's ones */ +if (id_table->vendor_id != cdx_dev->id.vendor_id && + id_table->vendor_id !=RTE_CDX_ANY_ID ) +continue ; +if (id_table->device_id != cdx_dev->id.device_id && + id_table->device_id !=RTE_CDX_ANY_ID ) +continue ; + +return 1 ; + } + +return 0 ; +} + +/* +* If vendor id and device id match, call the probe() function of the +* driver. +*/
drivers/bus/cdx/cdx.c line 359
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+static int +cdx_probe_one_driver (struct rte_cdx_driver *dr, +struct rte_cdx_device *dev) +{ +const char *dev_name = dev->device.name; +bool already_probed; +int ret; + +if ((dr ==NULL ) || (dev ==NULL )) +return -EINVAL ;
This symbol can't be called with dr or dev == NULL.
Quoted 42 lines
drivers/bus/cdx/cdx.c new file +42
-0+ +/* The device is not blocked; Check if driver supports it */ +if (!cdx_match (dr, dev)) +/* Match of device and driver failed */ +return 1 ; + + already_probed =rte_dev_is_probed (&dev->device); +if (already_probed) { +CDX_BUS_INFO ("Device %s is already probed" , dev->device.name); +return -EEXIST ; + } + +CDX_BUS_DEBUG (" probe device %s using driver: %s" , dev_name, + dr->driver.name); + + ret =cdx_vfio_map_resource (dev); +if (ret !=0 ) { +CDX_BUS_ERR ("CDX map device failed: %d" , ret); + goto error_map_device; + } + +/* call the driver probe() function */ + ret = dr->probe (dr, dev); +if (ret) { +CDX_BUS_ERR ("Probe CDX driver: %s device: %s failed: %d" , + dr->driver.name, dev_name, ret); + goto error_probe; + }else { + dev->device.driver = &dr->driver; + } + +return ret; + +error_probe: +cdx_vfio_unmap_resource (dev); +error_map_device: +return ret; +} + +/* +* If vendor/device ID match, call the probe() function of all +* registered driver for the given device. Return < 0 if initialization
drivers/bus/cdx/cdx.c line 411
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+* failed, return 1 if no driver is found for this device. +*/ +static int +cdx_probe_all_drivers (struct rte_cdx_device *dev) +{ +struct rte_cdx_driver *dr =NULL ; +int rc =0 ; + +if (dev ==NULL ) +return -EINVAL ;
This symbol can't be called with dev == NULL.
Quoted 89 lines
drivers/bus/cdx/cdx.c new file +89
-0+ +FOREACH_DRIVER_ON_CDXBUS (dr) { + rc =cdx_probe_one_driver (dr, dev); +if (rc <0 ) +/* negative value is an error */ +return rc; +if (rc >0 ) +/* positive value means driver doesn't support it */ +continue ; +return 0 ; + } +return 1 ; +} + +/* +* Scan the content of the CDX bus, and call the probe() function for +* all registered drivers that have a matching entry in its id_table +* for discovered devices. +*/ +static int +cdx_probe (void ) +{ +struct rte_cdx_device *dev =NULL ; +size_t probed =0 , failed =0 ; +int ret =0 ; + +FOREACH_DEVICE_ON_CDXBUS (dev) { + probed++; + + ret =cdx_probe_all_drivers (dev); +if (ret <0 ) { +CDX_BUS_ERR ("Requested device %s cannot be used" , + dev->device.name); + rte_errno = errno; + failed++; + ret =0 ; + } + } + +return (probed && probed == failed) ?-1 :0 ; +} + +static int +cdx_parse (const char *name,void *addr) +{ +const char **out = addr; +int ret; + + ret =strncmp (name,CDX_DEV_PREFIX ,strlen (CDX_DEV_PREFIX )); + +if (ret ==0 && addr) + *out = name; + +return ret; +} + +/* register a driver */ +void +rte_cdx_register (struct rte_cdx_driver *driver) +{ +TAILQ_INSERT_TAIL (&rte_cdx_bus.driver_list, driver, next); + driver->bus = &rte_cdx_bus; +} + +/* unregister a driver */ +void +rte_cdx_unregister (struct rte_cdx_driver *driver) +{ +TAILQ_REMOVE (&rte_cdx_bus.driver_list, driver, next); + driver->bus =NULL ; +} + +static struct rte_device * +cdx_find_device (const struct rte_device *start,rte_dev_cmp_t cmp, +const void *data) +{ +const struct rte_cdx_device *cdx_start; +struct rte_cdx_device *cdx_dev; + +if (start !=NULL ) { + cdx_start =RTE_DEV_TO_CDX_DEV_CONST (start); + cdx_dev =TAILQ_NEXT (cdx_start, next); + }else { + cdx_dev =TAILQ_FIRST (&rte_cdx_bus.device_list); + } +while (cdx_dev !=NULL ) { +if (cmp (&cdx_dev->device, data) ==0 ) +return &cdx_dev->device; + cdx_dev =TAILQ_NEXT (cdx_dev, next);
drivers/bus/cdx/cdx.c line 510
Quoted 10 lines
drivers/bus/cdx/cdx.c new file +10
-0+ } +return NULL ; +} + +struct rte_cdx_bus rte_cdx_bus = { + .bus = { + .scan = cdx_scan, + .probe = cdx_probe, + .find_device = cdx_find_device, + .parse = cdx_parse,
I see neither unplug, nor cleanup op which is strange because this API provides a way to unregister drivers.
Quoted 7 lines
drivers/bus/cdx/cdx.c new file +7
-0+ }, + .device_list = TAILQ_HEAD_INITIALIZER(rte_cdx_bus.device_list), + .driver_list = TAILQ_HEAD_INITIALIZER(rte_cdx_bus.driver_list), +}; + +RTE_REGISTER_BUS (cdx, rte_cdx_bus.bus); +RTE_LOG_REGISTER_DEFAULT (cdx_logtype_bus,NOTICE );
[snip]
Quoted 25 lines
drivers/bus/cdx/meson.build new file +13
-0@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)drivers/bus/cdx/private.h new file +0
-0
drivers/bus/cdx/private.h line 10
Quoted 10 lines
drivers/bus/cdx/private.h new file +10
-0@@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef CDX_PRIVATE_H +#define CDX_PRIVATE_H + +#include "bus_cdx_driver.h" + +extern struct rte_cdx_bus rte_cdx_bus;
This could move to cdx.c.
Quoted 36 lines
drivers/bus/cdx/private.h new file +36
-0+ +/** +* Map a particular resource from a file. +* +* @param requested_addr +* The starting address for the new mapping range. +* @param fd +* The file descriptor. +* @param offset +* The offset for the mapping range. +* @param size +* The size for the mapping range. +* @param additional_flags +* The additional rte_mem_map() flags for the mapping range. +* @return +* - On success, the function returns a pointer to the mapped area. +* - On error, NULL is returned. +*/ +void *cdx_map_resource (void *requested_addr,int fd,uint64_t offset, +size_t size,int additional_flags); + +/** +* Unmap a particular resource. +* +* @param requested_addr +* The address for the unmapping range. +* @param size +* The size for the unmapping range. +*/ +void cdx_unmap_resource (void *requested_addr,size_t size); + +/* map/unmap VFIO resource */ +int cdx_vfio_map_resource (struct rte_cdx_device *dev); +int cdx_vfio_unmap_resource (struct rte_cdx_device *dev); + +#endif /* CDX_PRIVATE_H */
Signature · 1 line
David Marchand
Re: [PATCH v5 1/5] bus/cdx: introduce AMD CDX bus
On 6/1/2023 8:30 PM, David Marchand wrote:
<snip>
Quoted 10 lines
drivers/bus/cdx/cdx.c line 510
Quoted 7 lines
drivers/bus/cdx/cdx.c new file +7
-0+ +struct rte_cdx_bus rte_cdx_bus = { + .bus = { + .scan = cdx_scan, + .probe = cdx_probe, + .find_device = cdx_find_device, + .parse = cdx_parse,I see neither unplug, nor cleanup op which is strange because this API provides a way to unregister drivers.
plug/unplug are part of patch 5/5.
Nipun
Re: [PATCH v5 1/5] bus/cdx: introduce AMD CDX bus
In reply to David MarchandQuoted 5 lines · David Marchand
Hello,
Quoted 1 line · Nipun Gupta
<snip>
Quoted 9 lines
drivers/bus/cdx/bus_cdx_driver.h line 16
Quoted 6 lines
+ * AMD CDX bus interface
+ */drivers/bus/cdx/bus_cdx_driver.h new file +4
-0+ +#ifdef __cplusplus +extern "C" { +#endif Do you expect some out of tree drivers written in C++? Otherwise, this is unneeded.
As the CDX devices are FPGA based, customers would be using CDX bus framework and adding CDX drivers on top of it, so we do expect some out of tree drivers here and would like to keep it.
Thanks,
Nipun
PATCH v5 2/5 bus/cdx: add DMA map and unmap support
In reply to Nipun GuptaAMD CDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
drivers/bus/cdx/cdx.c +40 -0
@@ -502,12 +502,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + } + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
Re: [PATCH v5 2/5] bus/cdx: add DMA map and unmap support
Quoted 19 lines · Nipun Gupta
AMD CDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
Signed-off-by Nipun Gupta <[email protected]>Acked-by Ferruh Yigit <[email protected]>--- drivers/bus/cdx/cdx.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)drivers/bus/cdx/cdx.c +0
-0@@ -502,12 +502,52 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; }
drivers/bus/cdx/cdx.c cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, · line 513
Quoted 10 lines
drivers/bus/cdx/cdx.c +9
-0+static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + }
RTE_DEV_TO_CDX_DEV() applies an offset to dev.
Checking dev != NULL is probably a better check.
But on the other hand, calling this dma_map op will be done through dev->bus->dma_map.
So checking dev is useless too.
Quoted 4 lines
drivers/bus/cdx/cdx.c +4
-0+ +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +}
drivers/bus/cdx/cdx.c cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp, · line 527
Quoted 10 lines
drivers/bus/cdx/cdx.c +10
-0+ +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +struct rte_cdx_device *cdx_dev =RTE_DEV_TO_CDX_DEV (dev); + +if (!cdx_dev) { + rte_errno =EINVAL ; +return -1 ; + }
Idem.
Quoted 29 lines
drivers/bus/cdx/cdx.c +17
-1+ +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list), --2.17.1
Signature · 1 line
David Marchand
PATCH v5 3/5 eal/interrupts: add IRQ count in interrupt handle
In reply to Nipun GuptaHave total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned when VFIO_DEVICE_GET_IRQ_INFO ioctl is invoked. This IRQ_count can used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.
--- lib/eal/common/eal_common_interrupts.c | 21 +++++++++++++++++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++++++++++++++++++++++++++ lib/eal/version.map | 2 ++ 4 files changed, 56 insertions(+)
lib/eal/common/eal_common_interrupts.c +21 -0
@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {
lib/eal/common/eal_interrupts.h +1 -0
@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< Total IRQ count */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */
lib/eal/include/rte_interrupts.h +32 -0
@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the IRQ count field of interrupt handle with user +* provided IRQ count value. +* +* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); + +/** +* @internal +* Returns the IRQ count field of the given interrupt handle instance. +* +* @param intr_handle +* pointer to the interrupt handle. +* +* @return +* - On success, ir count. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int rte_intr_irq_count_get(const struct rte_intr_handle *intr_handle); +/** * @internal * Set the number of event fd field of interrupt handle
lib/eal/version.map +2 -0
@@ -458,6 +458,8 @@ INTERNAL { rte_intr_instance_dup; rte_intr_instance_windows_handle_get; rte_intr_instance_windows_handle_set; + rte_intr_irq_count_get; + rte_intr_irq_count_set; rte_intr_max_intr_get; rte_intr_max_intr_set; rte_intr_nb_efd_get;
Signature · 1 line
2.17.1
Re: [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
Quoted 65 lines · Nipun Gupta
Have total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned when
VFIO_DEVICE_GET_IRQ_INFOioctl is invoked. ThisIRQ_countcan used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.Signed-off-by Nipun Gupta <[email protected]>Acked-by Ferruh Yigit <[email protected]>--- lib/eal/common/eal_common_interrupts.c | 21 +++++++++++++++++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++++++++++++++++++++++++++ lib/eal/version.map | 2 ++ 4 files changed, 56 insertions(+)lib/eal/common/eal_common_interrupts.c +21
-0@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {lib/eal/common/eal_interrupts.h +1
-0@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< Total IRQ count */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ lib/eal/include/rte_interrupts.h +0
-0
lib/eal/include/rte_interrupts.h __rte_internal · line 512
Quoted 7 lines
lib/eal/include/rte_interrupts.h +4
-0@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the IRQ count field of interrupt handle with user +* provided IRQ count value.
I am intrigued by this new notion.
We already have different sizes in the intr_handle, why do we need a new one?
Plus, in the cdx patch using this new API, I see that an fd array is filled based on nb_efd.
So it seems to me that this new irq_count is just a duplicate of nb_efd.
Quoted 13 lines
lib/eal/include/rte_interrupts.h +13
-0+* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count +* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); +
Signature · 1 line
David Marchand
Re: [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
Hi David,
Quoted 78 lines · David Marchand
Quoted 65 lines · Nipun Gupta
Have total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned when
VFIO_DEVICE_GET_IRQ_INFOioctl is invoked. ThisIRQ_countcan used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.Signed-off-by Nipun Gupta <[email protected]>Acked-by Ferruh Yigit <[email protected]>--- lib/eal/common/eal_common_interrupts.c | 21 +++++++++++++++++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++++++++++++++++++++++++++ lib/eal/version.map | 2 ++ 4 files changed, 56 insertions(+)lib/eal/common/eal_common_interrupts.c +21
-0@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle *intr_handle,return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count; +fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {lib/eal/common/eal_interrupts.h +1
-0@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< Total IRQ count */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ lib/eal/include/rte_interrupts.h +0
-0lib/eal/include/rte_interrupts.h __rte_internal · line 512
Quoted 7 lines
lib/eal/include/rte_interrupts.h +4
-0@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the IRQ count field of interrupt handle with user +* provided IRQ count value. I am intrigued by this new notion.
We already have different sizes in theintr_handle, why do we need a new one?
Quoted 3 lines
Plus, in the cdx patch using this new API, I see that an fd array is filled based on
nb_efd.
So it seems to me that this newirq_countis just a duplicate ofnb_efd.
The API rte_intr_efd_enable() sets the nb_efd and max_intr to values provided by the caller (+ NB_OTHER_INTR for max_intr). These values are dependent on the number of interrupts which are enabled by any DPDK driver rather than the actual number of interrupts supported or provided by the Linux driver.
With CDX bus the devices can have interrupts which are not really bound by the number of queues, and as these devices are programmable (FPGA based), users are free to implement the interrupts as per the need. I need to provide the total number of interrupts supported by the device to the drivers.
nb_intr is also there, which is default initialized by RTE_MAX_RXTX_INTR_VEC_ID, due to which this does not seem to be best fit. Though as per the meaning it shall represent the total number of interrupts supported by the device. Maybe we can remove the default value and use this as a total interrupt count supported for the device?
w.r.t. comments on the other patches, I will fix them in the next respin.
Regards,
Nipun
Quoted 20 lines
Quoted 5 lines
lib/eal/include/rte_interrupts.h +3
-0+* @param intr_handle +* pointer to the interrupt handle. +* @param irq_count lib/eal/include/rte_interrupts.h __rte_internal · line 526
Quoted 10 lines
lib/eal/include/rte_interrupts.h +10
-0+* IRQ count +* +* @return +* - On success, zero. +* - On failure, a negative value and rte_errno is set. +*/ +__rte_internal +int +rte_intr_irq_count_set (struct rte_intr_handle *intr_handle,int irq_count); +--
David Marchand
RE: [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
Quoted 113 lines
-----Original Message-----
From: Gupta, Nipun
Sent: Thursday, June 1, 2023 11:35 PM
To: David Marchand <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yigit, Ferruh <[email protected]>; Anand, Harpreet <[email protected]>; Agarwal, Nikhil <[email protected]>
Subject: Re: [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handleHi David,
Quoted 2 lines · David Marchand
On Thu, May 25, 2023 at 12:08 PM Nipun Gupta <[email protected]>
Quoted 16 lines · wrote:
Quoted 16 lines
Have total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned when
VFIO_DEVICE_GET_IRQ_INFOioctl is invoked. ThisIRQ_countcan used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.Signed-off-by Nipun Gupta <[email protected]>Acked-by Ferruh Yigit <[email protected]>--- lib/eal/common/eal_common_interrupts.c | 21 +++++++++++++++++ lib/eal/common/eal_interrupts.h | 1 + lib/eal/include/rte_interrupts.h | 32 ++++++++++++++++++++++++++ lib/eal/version.map | 2 ++ 4 files changed, 56 insertions(+)Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-0
b/lib/eal/common/eal_common_interrupts.cQuoted 4 lines
lib/eal/common/eal_common_interrupts.c int rte_intr_elist_index_set(struct rte_intr_handle
Quoted 4 lines
index
97b64fed58..a0167d9ad4100644lib/eal/common/eal_common_interrupts.c +0
-0@@ -398,6 +398,27 @@ int rte_intr_elist_index_set(struct rte_intr_handle
*intr_handle,Quoted 20 lines
Quoted 20 lines
lib/eal/common/eal_common_interrupts.c +17
-0return -rte_errno; } +int rte_intr_irq_count_set (struct rte_intr_handle *intr_handle, +int irq_count) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + + intr_handle->irq_count = irq_count; + +return 0 ; +fail: +return -rte_errno; +} + +int rte_intr_irq_count_get (const struct rte_intr_handle *intr_handle) +{ +CHECK_VALID_INTR_HANDLE (intr_handle); + +return intr_handle->irq_count;Quoted 8 lines
Review
Quoted 8 lines
lib/eal/common/eal_common_interrupts.c +4
-0+fail: +return -rte_errno; +} +int rte_intr_vec_list_alloc (struct rte_intr_handle *intr_handle,const char *name,int size) {(quoted diff) +0
-0
b/lib/eal/common/eal_interrupts.hQuoted 27 lines
Quoted 16 lines
index
482781b862..eaf8e20187100644lib/eal/common/eal_interrupts.h +1
-0@@ -16,6 +16,7 @@ struct rte_intr_handle { };uint32_t alloc_flags;/**< flags passed at allocation */ enum rte_intr_handle_type type;/**< handle type */ +uint32_t irq_count;/**< Total IRQ count */ uint32_t max_intr;/**< max interrupt requested */ uint32_t nb_efd;/**< number of available efd(event fd) */ uint8_t efd_counter_size;/**< size of efd counter, used for vdev */ lib/eal/include/rte_interrupts.h +0
-0lib/eal/include/rte_interrupts.h __rte_internal · line 512
Quoted 7 lines
lib/eal/include/rte_interrupts.h +4
-0@@ -506,6 +506,38 @@ __rte_internalint rte_intr_max_intr_get (const struct rte_intr_handle *intr_handle); +/** +* @internal +* Set the IRQ count field of interrupt handle with user +* provided IRQ count value. I am intrigued by this new notion.
We already have different sizes in theintr_handle, why do we need a new one?Quoted 3 lines
Plus, in the cdx patch using this new API, I see that an fd array is filled based on
nb_efd.
So it seems to me that this newirq_countis just a duplicate ofnb_efd.The API
rte_intr_efd_enable()sets thenb_efdandmax_intrto values provided by the caller (+NB_OTHER_INTRformax_intr). These values are dependent on the number of interrupts which are enabled by any DPDK driver rather than the actual number of interrupts supported or provided by the Linux driver.With CDX bus the devices can have interrupts which are not really bound by the number of queues, and as these devices are programmable (FPGA based), users are free to implement the interrupts as per the need. I need to provide the total number of interrupts supported by the device to the drivers.
Quoted 5 lines
nb_intris also there, which is default initialized byRTE_MAX_RXTX_INTR_VEC_ID, due to which this does not seem to be best fit. Though as per the meaning it shall represent the total number of interrupts supported by the device. Maybe we can remove the default value and use this as a total interrupt count supported for the device?
On more look nb_intr seems to be more aligned towards the number of efd's allocated, rather than the total number of interrupts supported on the device. So, it should have a default value, but yes then I am not sure it this can be used to represent total number of interrupt count. Please let me know if your views on this.
Regards,
Nipun
RE: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
In reply to Nipun GuptaQuoted 13 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Thursday, May 25, 2023 3:38 PM
To: [email protected]; [email protected]; [email protected]; Harman Kalra <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Nipun Gupta <[email protected]>
Subject: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
Quoted 9 lines
External Email
----------------------------------------------------------------------
Have total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned whenVFIO_DEVICE_GET_IRQ_INFOioctl is invoked. ThisIRQ_countcan used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.
Hi Nipun,
We already have "max_intr" field for the same purpose and its respective APIs plt_intr_max_intr_set()/plt_intr_max_intr_get()
Thanks
Harman
Re: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
Quoted 22 lines · Harman Kalra
Quoted 12 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Thursday, May 25, 2023 3:38 PM
To: [email protected]; [email protected]; [email protected]; Harman Kalra <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Nipun Gupta <[email protected]>
Subject: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handleQuoted 9 lines
External Email
----------------------------------------------------------------------
Have total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned whenVFIO_DEVICE_GET_IRQ_INFOioctl is invoked. ThisIRQ_countcan used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.
Quoted 4 lines
Hi Nipun,
We already have "
max_intr" field for the same purpose and its respective APIs plt_intr_max_intr_set()/plt_intr_max_intr_get()
Hi Harman,
If we have a look into rte_intr_efd_enable() API, 'max_intr' being set in this API. So once a driver is using the interrupts the 'max_intr' would be overwritten. 'nb_intr' which is described as "Max vector count" seems more relevant to me here and I have used 'nb_intr' to have the total interrupt count available and sent out the updated series for CDX bus. Please let me know in case you have separate thoughts on this.
Thanks,
Nipun
Quoted 3 lines
Thanks
Harman
RE: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handle
Quoted 45 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Tuesday, June 6, 2023 12:57 PM
To: Harman Kalra <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handleQuoted 5 lines · Harman Kalra
Quoted 5 lines
-----Original Message-----
From: Nipun Gupta <[email protected]>
Sent: Thursday, May 25, 2023 3:38 PM
To: [email protected]; [email protected];Quoted 17 lines
Quoted 7 lines
Harman Kalra <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; Nipun Gupta <[email protected]>
Subject: [EXT] [PATCH v5 3/5] eal/interrupts: add IRQ count in interrupt handleQuoted 9 lines
External Email
---------------------------------------------------------------------
- Have total number of IRQ count support in interrupt handle. In case of VFIO this IRQ count is returned whenVFIO_DEVICE_GET_IRQ_INFOioctl is invoked. ThisIRQ_countcan used by the devices to store/provide total number of interrupts available and to enable or disable these interrupts.Quoted 5 lines
Hi Nipun,
We already have "
max_intr" field for the same purpose and its respective APIs plt_intr_max_intr_set()/plt_intr_max_intr_get()
Quoted 9 lines
Hi Harman,
If we have a look into
rte_intr_efd_enable()API, 'max_intr' being set in this API. So once a driver is using the interrupts the 'max_intr' would be overwritten. 'nb_intr' which is described as "Max vector count" seems more relevant to me here and I have used 'nb_intr' to have the total interrupt count available and sent out the updated series for CDX bus. Please let me know in case you have separate thoughts on this.
Hi Nipun,
Got your point, we are aligned on this.
Just to bring to your notice, In pci_vfio_setup_interrupts(), if irq.count > nb_intr we are updating nb_intr as part of rte_intr_event_list_update()
Thanks
Harman
Quoted 6 lines
Thanks,
NipunQuoted 3 lines
Thanks
Harman
PATCH v5 4/5 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
A couple of API's have been introduced in the EAL interrupt framework:
- rte_intr_irq_count_set: This API is used to set the total interrupts on the interrupt handle. This would be provided by VFIO (irq.count) for VFIO enabled devices.
- rte_intr_irq_count_get: This API returns the total number interrupts which were set.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 +++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + 4 files changed, 218 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -67,6 +67,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -168,6 +169,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_internal void rte_cdx_register(struct rte_cdx_driver *driver); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Helper for CDX device registration from driver (eth, crypto, raw) instance */
drivers/bus/cdx/cdx.c +11 -0
@@ -201,6 +201,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s\n" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -391,6 +400,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +180 -2
235 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -6,6 +6,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
Signature · 1 line
2.17.1
Re: [PATCH v5 4/5] bus/cdx: add support for MSI
Quoted 70 lines · Nipun Gupta
MSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
A couple of API's have been introduced in the EAL interrupt framework:
-rte_intr_irq_count_set: This API is used to set the total interrupts on the interrupt handle. This would be provided by VFIO (irq.count) for VFIO enabled devices.
-rte_intr_irq_count_get: This API returns the total number interrupts which were set.Signed-off-by Nipun Gupta <[email protected]>Acked-by Ferruh Yigit <[email protected]>--- drivers/bus/cdx/bus_cdx_driver.h | 25 +++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 182 ++++++++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + 4 files changed, 218 insertions(+), 2 deletions(-)drivers/bus/cdx/bus_cdx_driver.h +25
-0@@ -67,6 +67,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/** @@ -168,6 +169,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_internal void rte_cdx_register(struct rte_cdx_driver *driver); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Helper for CDX device registration from driver (eth, crypto, raw) instance */ drivers/bus/cdx/cdx.c +0
-0
drivers/bus/cdx/cdx.c cdx_scan_one(const char *dirname, const char *dev_name) · line 208
Quoted 8 lines
drivers/bus/cdx/cdx.c +5
-0@@ -201,6 +201,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { + CDX_BUS_ERR("Failed to create interrupt instance for %s\n",
CDX_BUS_ERR already appends a \n.
Quoted 79 lines
drivers/bus/cdx/cdx.c +6
-0+ dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device. @@ -391,6 +400,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;drivers/bus/cdx/cdx_vfio.c +37
-0@@ -50,6 +50,10 @@ struct mapped_cdx_resource {/** mapped cdx device list */ TAILQ_HEAD (mapped_cdx_res_list, mapped_cdx_resource); +/* IRQ set buffer length for MSI interrupts */ +#define MSI_IRQ_SET_BUF_LEN (sizeof(struct vfio_irq_set) + \ + sizeof(int) * (RTE_MAX_RXTX_INTR_VEC_ID + 1)) +static struct rte_tailq_elem cdx_vfio_tailq = { .name ="VFIO_CDX_RESOURCE_LIST" , };@@ -94,6 +98,27 @@ cdx_vfio_unmap_resource_primary(struct rte_cdx_device *dev)char cdx_addr[PATH_MAX ] = {0 };struct mapped_cdx_resource *vfio_res =NULL ;struct mapped_cdx_res_list *vfio_res_list; +int ret, vfio_dev_fd; + +if (rte_intr_fd_get (dev->intr_handle) <0 ) +return -1 ; + +if (close (rte_intr_fd_get (dev->intr_handle)) <0 ) { +CDX_BUS_ERR ("Error when closing eventfd file descriptor for %s" , + dev->device.name); +return -1 ; + } + + vfio_dev_fd =rte_intr_dev_fd_get (dev->intr_handle); +if (vfio_dev_fd <0 ) +return -1 ; + + ret =rte_vfio_release_device (rte_cdx_get_sysfs_path (), dev->device.name, + vfio_dev_fd); +if (ret <0 ) { +CDX_BUS_ERR ("Cannot release VFIO device" ); +return ret; + } vfio_res_list =RTE_TAILQ_CAST (cdx_vfio_tailq.head, mapped_cdx_res_list);@@ -116,6 +141,18 @@ cdx_vfio_unmap_resource_secondary(struct rte_cdx_device *dev) {struct mapped_cdx_resource *vfio_res =NULL ;struct mapped_cdx_res_list *vfio_res_list; +int ret, vfio_dev_fd; + + vfio_dev_fd =rte_intr_dev_fd_get (dev->intr_handle); +if (vfio_dev_fd <0 ) +return -1 ; + + ret =rte_vfio_release_device (rte_cdx_get_sysfs_path (), dev->device.name, + vfio_dev_fd); +if (ret <0 ) { +CDX_BUS_ERR ("Cannot release VFIO device" ); +return ret; + } vfio_res_list =RTE_TAILQ_CAST (cdx_vfio_tailq.head, mapped_cdx_res_list);
drivers/bus/cdx/cdx_vfio.c cdx_vfio_unmap_resource(struct rte_cdx_device *dev) · line 182
Quoted 7 lines
drivers/bus/cdx/cdx_vfio.c +2
-1@@ -140,9 +177,80 @@ cdx_vfio_unmap_resource(struct rte_cdx_device *dev)return cdx_vfio_unmap_resource_secondary (dev); } +/* set up interrupt support (but not enable interrupts) */ static int -cdx_rte_vfio_setup_device (int vfio_dev_fd) +cdx_vfio_setup_interrupts(struct rte_cdx_device *dev, int vfio_dev_fd,
Why rename this function?
Quoted 9 lines
drivers/bus/cdx/cdx_vfio.c +8
-0+ int num_irqs) { +int i, ret; + +if (num_irqs ==0 ) +return 0 ; + +/* start from MSI interrupt type */ +for (i =0 ; i < num_irqs; i++) {
[snip]
Signature · 1 line
David Marchand
Re: [PATCH v5 4/5] bus/cdx: add support for MSI
Quoted 3 lines · David Marchand
Quoted 1 line · Nipun Gupta
<snip>
Quoted 23 lines
Quoted 23 lines
drivers/bus/cdx/cdx_vfio.c +12
-0@@ -116,6 +141,18 @@ cdx_vfio_unmap_resource_secondary(struct rte_cdx_device *dev) {struct mapped_cdx_resource *vfio_res =NULL ;struct mapped_cdx_res_list *vfio_res_list; +int ret, vfio_dev_fd; + + vfio_dev_fd =rte_intr_dev_fd_get (dev->intr_handle); +if (vfio_dev_fd <0 ) +return -1 ; + + ret =rte_vfio_release_device (rte_cdx_get_sysfs_path (), dev->device.name, + vfio_dev_fd); +if (ret <0 ) { +CDX_BUS_ERR ("Cannot release VFIO device" ); +return ret; + } vfio_res_list =RTE_TAILQ_CAST (cdx_vfio_tailq.head, mapped_cdx_res_list);@@ -140,9 +177,80 @@ cdx_vfio_unmap_resource(struct rte_cdx_device *dev)return cdx_vfio_unmap_resource_secondary (dev); }
Quoted 6 lines
drivers/bus/cdx/cdx_vfio.c cdx_vfio_unmap_resource(struct rte_cdx_device *dev) · line 182
Quoted 4 lines
drivers/bus/cdx/cdx_vfio.c +2
-1+/* set up interrupt support (but not enable interrupts) */ static int -cdx_rte_vfio_setup_device (int vfio_dev_fd) +cdx_vfio_setup_interrupts(struct rte_cdx_device *dev, int vfio_dev_fd,Why rename this function?
This is actually not renamed. git commit is showing this, because parameters of cdx_rte_vfio_setup_device() has been updated and a new API has also been added cdx_vfio_setup_interrupts(). It shows parameter update as "+cdx_rte_vfio_setup_device()" just after this API code.
Thanks,
Nipun
PATCH v5 5/5 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on AMD CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -64,6 +64,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
v6 cover Support AMD CDX bus
In reply to Nipun GuptaThe CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx/AMD open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux AMD CDX bus patches has been added into linux tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v5->v6
- Removed newly introduce irq_count parameter, and use num_intr instead.
- Removed rte_cdx_sysfs_path(), and directly used the macro for the sysfs path.
- Removed few unrequired param checks in multiple APIs
- add name variable in rte_cdx_device
- moved rte_cdx_bus from bus_cdx_driver.h to private.h
- Other code cleanup
Changes v4->v5
- Split patch and have a separate commit for eal interrupt field (irq_count) and corresponding set/get APIs (rte_intr_irq_count_set, rte_intr_irq_count_get)
- Renamed "CDX bus" to "AMD CDX bus" in documentation/commit headings
- Removed unnecessary headers
Changes v3->v4:
- removed platform specific patch (adding config for ARM CDX) from this series
Changes v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported by check-git-log.sh
- updated release notes
- updated offset to uint64_t instead of off_t in cdx_map_resource
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (4):
bus/cdx: introduce AMD CDX bus
bus/cdx: add DMA map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 201 ++++++++ drivers/bus/cdx/cdx.c | 666 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 598 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 53 ++ drivers/bus/cdx/version.map | 13 + drivers/bus/meson.build | 1 + 10 files changed, 1593 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v6 1/4 bus/cdx: introduce AMD CDX bus
AMD CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 175 +++++++++ drivers/bus/cdx/cdx.c | 503 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 426 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 53 +++ drivers/bus/cdx/version.map | 11 + drivers/bus/meson.build | 1 + 10 files changed, 1230 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +AMD CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
doc/guides/rel_notes/release_23_07.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added AMD CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------
drivers/bus/cdx/bus_cdx_driver.h new file +175 -0
175 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +503 -0
503 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef CDX_LOGS_H +#define CDX_LOGS_H + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs are with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* CDX_LOGS_H */
drivers/bus/cdx/cdx_vfio.c new file +426 -0
426 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +53 -0
53 lines not on this page · raw message
drivers/bus/cdx/version.map new file +11 -0
@@ -0,0 +1,11 @@ +INTERNAL { + global: + + rte_cdx_get_sysfs_path; + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
Re: [PATCH v6 1/4] bus/cdx: introduce AMD CDX bus
05/06/2023 15:26, Nipun Gupta:
drivers/bus/cdx/version.map line 4
Quoted 4 lines
drivers/bus/cdx/version.map new file +4
-0+INTERNAL { + global: + + rte_cdx_get_sysfs_path;
Why exporting this function to the drivers?
Another minor comment: please make sure all doxygen comments are ended with a dot.
PATCH v6 2/4 bus/cdx: add DMA map and unmap support
In reply to Nipun GuptaAMD CDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/bus/cdx/cdx.c +30 -0
@@ -488,12 +488,42 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +RTE_SET_USED (dev); + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +RTE_SET_USED (dev); + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH v6 3/4 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 +++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 176 ++++++++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + 4 files changed, 212 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -56,6 +56,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -147,6 +148,30 @@ void rte_cdx_unmap_device(struct rte_cdx_device *dev);__rte_internal void rte_cdx_register(struct rte_cdx_driver *driver); +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Helper for CDX device registration from driver (eth, crypto, raw) instance */
drivers/bus/cdx/cdx.c +11 -0
@@ -202,6 +202,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -380,6 +389,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +174 -2
229 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -6,6 +6,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
Signature · 1 line
2.17.1
Re: [PATCH v6 3/4] bus/cdx: add support for MSI
drivers/bus/cdx/cdx_vfio.c cdx_vfio_unmap_resource(struct rte_cdx_device *dev) · line 183
Quoted 4 lines · Nipun Gupta
drivers/bus/cdx/cdx_vfio.c +2
-1+/* set up interrupt support (but not enable interrupts) */ static int -cdx_rte_vfio_setup_device (int vfio_dev_fd) +cdx_vfio_setup_interrupts(struct rte_cdx_device *dev, int vfio_dev_fd,
I had dropped a bit too much of the hunk in my previous comment, but see below:
[snip]
drivers/bus/cdx/cdx_vfio.c cdx_vfio_unmap_resource(struct rte_cdx_device *dev) · line 242
Quoted 3 lines
drivers/bus/cdx/cdx_vfio.c +3
-0+static int +cdx_vfio_setup_device (struct rte_cdx_device *dev,int vfio_dev_fd, +int num_irqs)
cdx_rte_vfio_setup_device() is renamed to cdx_vfio_setup_device(). Such a rename is unneeded noise, cdx_vfio_setup_device() should be used from the start, in patch1.
If there is no further comment on the series, I can fix this when applying.
Signature · 1 line
David Marchand
Re: [PATCH v6 3/4] bus/cdx: add support for MSI
Quoted 19 lines · David Marchand
drivers/bus/cdx/cdx_vfio.c cdx_vfio_unmap_resource(struct rte_cdx_device *dev) · line 183
Quoted 4 lines · Nipun Gupta
drivers/bus/cdx/cdx_vfio.c +2
-1+/* set up interrupt support (but not enable interrupts) */ static int -cdx_rte_vfio_setup_device (int vfio_dev_fd) +cdx_vfio_setup_interrupts(struct rte_cdx_device *dev, int vfio_dev_fd,I had dropped a bit too much of the hunk in my previous comment, but see below:
[snip]
drivers/bus/cdx/cdx_vfio.c cdx_vfio_unmap_resource(struct rte_cdx_device *dev) · line 242
Quoted 3 lines
drivers/bus/cdx/cdx_vfio.c +3
-0+static int +cdx_vfio_setup_device (struct rte_cdx_device *dev,int vfio_dev_fd, +int num_irqs)
cdx_rte_vfio_setup_device()is renamed tocdx_vfio_setup_device(). Such a rename is unneeded noise,cdx_vfio_setup_device()should be used from the start, in patch1.
Quoted 1 line
If there is no further comment on the series, I can fix this when applying.
Thanks for pointing. I missed this part. There are some minor changes requested by Thomas and I would send out a version today with this change you mentioned as well.
Regards,
Nipun
Quoted 5 lines
--
David Marchand
PATCH v6 4/4 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on AMD CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -52,6 +52,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
v7 cover Support AMD CDX bus
In reply to Nipun GuptaThe CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx/AMD open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux AMD CDX bus patches has been added into linux tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v6->v7
- removed redundant references to rte_cdx_sysfs_path().
- Fixed naming of cdx_vfio_setup_device() API from the first patch itself.
- Added dot after few sentences in comments.
Changes v5->v6
- Removed newly introduce irq_count parameter, and use num_intr instead.
- Removed rte_cdx_sysfs_path(), and directly used the macro for the sysfs path.
- Removed few unrequired param checks in multiple APIs
- add name variable in rte_cdx_device
- moved rte_cdx_bus from bus_cdx_driver.h to private.h
- Other code cleanup
Changes v4->v5
- Split patch and have a separate commit for eal interrupt field (irq_count) and corresponding set/get APIs (rte_intr_irq_count_set, rte_intr_irq_count_get)
- Renamed "CDX bus" to "AMD CDX bus" in documentation/commit headings
- Removed unnecessary headers
Changes v3->v4:
- removed platform specific patch (adding config for ARM CDX) from this series
Changes v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported by check-git-log.sh
- updated release notes
- updated offset to uint64_t instead of off_t in cdx_map_resource
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (4):
bus/cdx: introduce AMD CDX bus
bus/cdx: add DMA map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 192 +++++++ drivers/bus/cdx/cdx.c | 666 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 598 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 53 ++ drivers/bus/cdx/version.map | 12 + drivers/bus/meson.build | 1 + 10 files changed, 1583 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v7 1/4 bus/cdx: introduce AMD CDX bus
AMD CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 166 ++++++++ drivers/bus/cdx/cdx.c | 503 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 426 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 53 +++ drivers/bus/cdx/version.map | 10 + drivers/bus/meson.build | 1 + 10 files changed, 1220 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +AMD CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
doc/guides/rel_notes/release_23_07.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added AMD CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------
drivers/bus/cdx/bus_cdx_driver.h new file +166 -0
166 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +503 -0
503 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef CDX_LOGS_H +#define CDX_LOGS_H + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* CDX_LOGS_H */
drivers/bus/cdx/cdx_vfio.c new file +426 -0
426 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +53 -0
53 lines not on this page · raw message
drivers/bus/cdx/version.map new file +10 -0
@@ -0,0 +1,10 @@ +INTERNAL { + global: + + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
Re: [PATCH v7 1/4] bus/cdx: introduce AMD CDX bus
06/06/2023 12:02, Nipun Gupta:
drivers/bus/cdx/bus_cdx_driver.h line 27
Quoted 4 lines
drivers/bus/cdx/bus_cdx_driver.h new file +4
-0+/* Forward declarations */ +struct rte_cdx_device ; +struct rte_cdx_driver ; +struct rte_cdx_bus ;
You should be very careful about what you export.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define CDX_BUS_DEVICES_PATH "/sys/bus/cdx/devices"
This define is not needed in the .h file.
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define CDX_MAX_RESOURCE 4
This size looks required for rte_cdx_device,
but as an exported constant, it should be prefixed with RTE_
Quoted 3 lines
drivers/bus/cdx/bus_cdx_driver.h new file +3
-0+ +/** Any CDX device identifier (vendor, device). */ +#define RTE_CDX_ANY_ID (0xffff)
Re: [PATCH v7 1/4] bus/cdx: introduce AMD CDX bus
Quoted 9 lines · Thomas Monjalon
06/06/2023 12:02, Nipun Gupta:
drivers/bus/cdx/bus_cdx_driver.h line 27
Quoted 4 lines
drivers/bus/cdx/bus_cdx_driver.h new file +4
-0+/* Forward declarations */ +struct rte_cdx_device ; +struct rte_cdx_driver ; +struct rte_cdx_bus ;You should be very careful about what you export.
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define CDX_BUS_DEVICES_PATH "/sys/bus/cdx/devices"This define is not needed in the .h file.
This is required and used by some of the out of tree CDX drivers which are developed by the customers, so it is needed here.
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ +#define CDX_MAX_RESOURCE 4This size looks required for
rte_cdx_device,
but as an exported constant, it should be prefixed withRTE_
Sure, will update.
Thanks,
Nipun
Quoted 7 lines
Quoted 4 lines
drivers/bus/cdx/bus_cdx_driver.h new file +3
-0+ +/** Any CDX device identifier (vendor, device). */ +#define RTE_CDX_ANY_ID (0xffff)
Re: [PATCH v7 1/4] bus/cdx: introduce AMD CDX bus
06/06/2023 15:38, Nipun Gupta:
Quoted 11 lines · Thomas Monjalon
Quoted 9 lines
06/06/2023 12:02, Nipun Gupta:
drivers/bus/cdx/bus_cdx_driver.h line 27
Quoted 4 lines
drivers/bus/cdx/bus_cdx_driver.h new file +4
-0+/* Forward declarations */ +struct rte_cdx_device ; +struct rte_cdx_driver ; +struct rte_cdx_bus ;You should be very careful about what you export.
Quoted 7 lines
Quoted 4 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +#define CDX_BUS_DEVICES_PATH "/sys/bus/cdx/devices"This define is not needed in the .h file.
This is required and used by some of the out of tree CDX drivers which are developed by the customers, so it is needed here.
In this case, it should be prefixed with RTE_
Quoted 20 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ +#define CDX_MAX_RESOURCE 4This size looks required for
rte_cdx_device,
but as an exported constant, it should be prefixed withRTE_Sure, will update.
Thanks,
NipunQuoted 7 lines
Quoted 4 lines
drivers/bus/cdx/bus_cdx_driver.h new file +3
-0+ +/** Any CDX device identifier (vendor, device). */ +#define RTE_CDX_ANY_ID (0xffff)
PATCH v7 2/4 bus/cdx: add DMA map and unmap support
In reply to Nipun GuptaAMD CDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/bus/cdx/cdx.c +30 -0
@@ -488,12 +488,42 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +RTE_SET_USED (dev); + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +RTE_SET_USED (dev); + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH v7 3/4 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 +++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 176 ++++++++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + 4 files changed, 212 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -56,6 +56,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -149,6 +150,30 @@ void rte_cdx_register(struct rte_cdx_driver *driver); } \RTE_PMD_EXPORT_NAME (nm, __COUNTER__) +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. + */ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Unregister a CDX driver. *
drivers/bus/cdx/cdx.c +11 -0
@@ -202,6 +202,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -380,6 +389,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +174 -2
229 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -5,6 +5,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
Signature · 1 line
2.17.1
PATCH v7 4/4 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on AMD CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -52,6 +52,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[CDX_MAX_RESOURCE ];
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
v8 cover Support AMD CDX bus
In reply to Nipun GuptaThe CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx/AMD open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/ and drivers/vfio/cdx)
Linux AMD CDX bus patches has been added into linux tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdx
VFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.html
CDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Changes v7->v8
- Renamed CDX_BUS_DEVICES_PATH to RTE_CDX_BUS_DEVICES_PATH
- Renamed CDX_MAX_RESOURCE to RTE_CDX_MAX_RESOURCE
Changes v6->v7
- removed redundant references to rte_cdx_sysfs_path().
- Fixed naming of cdx_vfio_setup_device() API from the first patch itself.
- Added dot after few sentences in comments.
Changes v5->v6
- Removed newly introduce irq_count parameter, and use num_intr instead.
- Removed rte_cdx_sysfs_path(), and directly used the macro for the sysfs path.
- Removed few unrequired param checks in multiple APIs
- add name variable in rte_cdx_device
- moved rte_cdx_bus from bus_cdx_driver.h to private.h
- Other code cleanup
Changes v4->v5
- Split patch and have a separate commit for eal interrupt field (irq_count) and corresponding set/get APIs (rte_intr_irq_count_set, rte_intr_irq_count_get)
- Renamed "CDX bus" to "AMD CDX bus" in documentation/commit headings
- Removed unnecessary headers
Changes v3->v4:
- removed platform specific patch (adding config for ARM CDX) from this series
Changes v2->v3:
- merged cdx bus compilation enablement in the first patch
- fixed issue reported by check-git-log.sh
- updated release notes
- updated offset to uint64_t instead of off_t in cdx_map_resource
Changes v1->v2:
- Moved file rte_cdx_bus.h to internal bus_cdx_driver.h and added this file to deivce_cdx_headers
- Moved cdx.h to private.h
- Removed rte_ prefix from the static symbols in .c files.
Changes RFC->v1:
- Marked few API's as internal which were not required to be provided to user.
Nipun Gupta (4):
bus/cdx: introduce AMD CDX bus
bus/cdx: add DMA map and unmap support
bus/cdx: add support for MSI
bus/cdx: support plug unplug and dev iterator
MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 192 +++++++ drivers/bus/cdx/cdx.c | 666 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 598 ++++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 53 ++ drivers/bus/cdx/version.map | 12 + drivers/bus/meson.build | 1 + 10 files changed, 1583 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
Signature · 1 line
2.17.1
PATCH v8 1/4 bus/cdx: introduce AMD CDX bus
AMD CDX bus supports multiple type of devices, which can be exposed to user-space via vfio-cdx.
vfio-cdx provides the MMIO IO_MEMORY regions as well as the DMA interface for the device (IOMMU).
This support aims to enable the DPDK to support the cdx devices in user-space using VFIO interface.
--- MAINTAINERS | 5 + doc/guides/rel_notes/release_23_07.rst | 6 + drivers/bus/cdx/bus_cdx_driver.h | 166 ++++++++ drivers/bus/cdx/cdx.c | 503 +++++++++++++++++++++++++ drivers/bus/cdx/cdx_logs.h | 37 ++ drivers/bus/cdx/cdx_vfio.c | 426 +++++++++++++++++++++ drivers/bus/cdx/meson.build | 13 + drivers/bus/cdx/private.h | 53 +++ drivers/bus/cdx/version.map | 10 + drivers/bus/meson.build | 1 + 10 files changed, 1220 insertions(+) create mode 100644 drivers/bus/cdx/bus_cdx_driver.h create mode 100644 drivers/bus/cdx/cdx.c create mode 100644 drivers/bus/cdx/cdx_logs.h create mode 100644 drivers/bus/cdx/cdx_vfio.c create mode 100644 drivers/bus/cdx/meson.build create mode 100644 drivers/bus/cdx/private.h create mode 100644 drivers/bus/cdx/version.map
MAINTAINERS +5 -0
@@ -569,6 +569,11 @@ M: Parav Pandit <[email protected]> M: Xueming Li <[email protected]> F: drivers/bus/auxiliary/ +AMD CDX bus driver +M: Nipun Gupta <[email protected]> +M: Nikhil Agarwal <[email protected]> +F: drivers/bus/cdx/ + Intel FPGA bus M: Rosen Xu <[email protected]> F: drivers/bus/ifpga/
doc/guides/rel_notes/release_23_07.rst +6 -0
@@ -55,6 +55,12 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Added AMD CDX bus support.** + + CDX bus driver has been added to support AMD CDX bus, which operates + on FPGA based CDX devices. The CDX devices are memory mapped on system + bus for embedded CPUs. + Removed Items -------------
drivers/bus/cdx/bus_cdx_driver.h new file +166 -0
166 lines not on this page · raw message
drivers/bus/cdx/cdx.c new file +503 -0
503 lines not on this page · raw message
drivers/bus/cdx/cdx_logs.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright (C) 2022-2023, Advanced Micro Devices, Inc. +*/ + +#ifndef CDX_LOGS_H +#define CDX_LOGS_H + +extern int cdx_logtype_bus; + +#define CDX_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, cdx_logtype_bus, "cdx: " fmt "\n", \ + ##args) + +/* Debug logs with Function names */ +#define CDX_BUS_DEBUG(fmt, args...) \ + rte_log(RTE_LOG_DEBUG, cdx_logtype_bus, "cdx: %s(): " fmt "\n", \ + __func__, ##args) + +#define CDX_BUS_INFO(fmt, args...) \ + CDX_BUS_LOG(INFO, fmt, ## args) +#define CDX_BUS_ERR(fmt, args...) \ + CDX_BUS_LOG(ERR, fmt, ## args) +#define CDX_BUS_WARN(fmt, args...) \ + CDX_BUS_LOG(WARNING, fmt, ## args) + +/* DP Logs, toggled out at compile time if level lower than current level */ +#define CDX_BUS_DP_LOG(level, fmt, args...) \ + RTE_LOG_DP(level, PMD, fmt, ## args) + +#define CDX_BUS_DP_DEBUG(fmt, args...) \ + CDX_BUS_DP_LOG(DEBUG, fmt, ## args) +#define CDX_BUS_DP_INFO(fmt, args...) \ + CDX_BUS_DP_LOG(INFO, fmt, ## args) +#define CDX_BUS_DP_WARN(fmt, args...) \ + CDX_BUS_DP_LOG(WARNING, fmt, ## args) + +#endif /* CDX_LOGS_H */
drivers/bus/cdx/cdx_vfio.c new file +426 -0
426 lines not on this page · raw message
drivers/bus/cdx/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright (C) 2022-2023, Advanced Micro Devices, Inc. + +if not is_linux + build = false + reason = 'only supported on Linux' +endif + +driver_sdk_headers = files('bus_cdx_driver.h') +sources = files( + 'cdx.c', + 'cdx_vfio.c', +)
drivers/bus/cdx/private.h new file +53 -0
53 lines not on this page · raw message
drivers/bus/cdx/version.map new file +10 -0
@@ -0,0 +1,10 @@ +INTERNAL { + global: + + rte_cdx_map_device; + rte_cdx_register; + rte_cdx_unmap_device; + rte_cdx_unregister; + + local: *; +};
drivers/bus/meson.build +1 -0
@@ -3,6 +3,7 @@ drivers = [ 'auxiliary', + 'cdx', 'dpaa', 'fslmc', 'ifpga',
Signature · 1 line
2.17.1
PATCH v8 2/4 bus/cdx: add DMA map and unmap support
In reply to Nipun GuptaAMD CDX bus can use VFIO interface for mapping and unmapping of DMA addresses in the IOMMU. This change adds the callback support for map and unmap APIs as well as fetching the IOMMU class.
--- drivers/bus/cdx/cdx.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
drivers/bus/cdx/cdx.c +30 -0
@@ -488,12 +488,42 @@ cdx_find_device(const struct rte_device *start, rte_dev_cmp_t cmp,return NULL ; } +static int +cdx_dma_map (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +RTE_SET_USED (dev); + +return rte_vfio_container_dma_map (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static int +cdx_dma_unmap (struct rte_device *dev,void *addr,uint64_t iova,size_t len) +{ +RTE_SET_USED (dev); + +return rte_vfio_container_dma_unmap (RTE_VFIO_DEFAULT_CONTAINER_FD , + (uintptr_t )addr, iova, len); +} + +static enum rte_iova_mode +cdx_get_iommu_class (void ) +{ +if (TAILQ_EMPTY (&rte_cdx_bus.device_list)) +return RTE_IOVA_DC ; + +return RTE_IOVA_VA ; +} +struct rte_cdx_bus rte_cdx_bus = { .bus = { .scan = cdx_scan, .probe = cdx_probe, .find_device = cdx_find_device, .parse = cdx_parse, + .dma_map = cdx_dma_map, + .dma_unmap = cdx_dma_unmap, + .get_iommu_class = cdx_get_iommu_class, }, .device_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.device_list), .driver_list =TAILQ_HEAD_INITIALIZER (rte_cdx_bus.driver_list),
Signature · 1 line
2.17.1
PATCH v8 3/4 bus/cdx: add support for MSI
In reply to Nipun GuptaMSI's are exposed to the devices using VFIO (vfio-cdx). This patch uses the same to add support for MSI for the devices on the cdx bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 25 +++++ drivers/bus/cdx/cdx.c | 11 ++ drivers/bus/cdx/cdx_vfio.c | 176 ++++++++++++++++++++++++++++++- drivers/bus/cdx/version.map | 2 + 4 files changed, 212 insertions(+), 2 deletions(-)
drivers/bus/cdx/bus_cdx_driver.h +25 -0
@@ -56,6 +56,7 @@ struct rte_cdx_device {struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[RTE_CDX_MAX_RESOURCE ];/**< CDX Memory Resource */ +struct rte_intr_handle *intr_handle;/**< Interrupt handle */ };/**
@@ -149,6 +150,30 @@ void rte_cdx_register(struct rte_cdx_driver *driver); } \RTE_PMD_EXPORT_NAME (nm, __COUNTER__) +/** +* Enables VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. + */ +__rte_internal +int rte_cdx_vfio_intr_enable(const struct rte_intr_handle *intr_handle); + +/** +* Disable VFIO Interrupts for CDX bus devices. +* +* @param intr_handle +* Pointer to the interrupt handle. +* +* @return +* 0 on success, -1 on error. +*/ +__rte_internal +int rte_cdx_vfio_intr_disable(const struct rte_intr_handle *intr_handle); +/** * Unregister a CDX driver. *
drivers/bus/cdx/cdx.c +11 -0
@@ -202,6 +202,15 @@ cdx_scan_one(const char *dirname, const char *dev_name) goto err; } +/* Allocate interrupt instance for cdx device */ + dev->intr_handle = +rte_intr_instance_alloc (RTE_INTR_INSTANCE_F_PRIVATE ); +if (dev->intr_handle ==NULL ) { +CDX_BUS_ERR ("Failed to create interrupt instance for %s" , + dev->device.name); +return -ENOMEM ; + } +/* * Check if device is bound to 'vfio-cdx' driver, so that user-space * can gracefully access the device.
@@ -380,6 +389,8 @@ cdx_probe_one_driver(struct rte_cdx_driver *dr,return ret; error_probe: +rte_intr_instance_free (dev->intr_handle); + dev->intr_handle =NULL ;cdx_vfio_unmap_resource (dev); error_map_device:return ret;
drivers/bus/cdx/cdx_vfio.c +174 -2
229 lines not on this page · raw message
drivers/bus/cdx/version.map +2 -0
@@ -5,6 +5,8 @@ INTERNAL { rte_cdx_register; rte_cdx_unmap_device; rte_cdx_unregister; + rte_cdx_vfio_intr_disable; + rte_cdx_vfio_intr_enable; local: *; };
Signature · 1 line
2.17.1
PATCH v8 4/4 bus/cdx: support plug unplug and dev iterator
In reply to Nipun GuptaThis change adds support for plugging and unplugging CDX devices on AMD CDX bus. Also, CDX dev iterator support has been added for the CDX bus.
--- drivers/bus/cdx/bus_cdx_driver.h | 1 + drivers/bus/cdx/cdx.c | 122 +++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+)
drivers/bus/cdx/bus_cdx_driver.h +1 -0
@@ -52,6 +52,7 @@ struct rte_cdx_id {struct rte_cdx_device {RTE_TAILQ_ENTRY (rte_cdx_device) next;/**< Next probed CDX device. */ struct rte_device device;/**< Inherit core device */ +struct rte_cdx_driver *driver;/**< CDX driver used in probing */ char name[RTE_DEV_NAME_MAX_LEN ];/**< Device name */ struct rte_cdx_id id;/**< CDX ID. */ struct rte_mem_resource mem_resource[RTE_CDX_MAX_RESOURCE ];
drivers/bus/cdx/cdx.c +122 -0
161 lines not on this page · raw message
Signature · 1 line
2.17.1
Thomas Monjalon
AppliedRe: [PATCH v8 0/4] Support AMD CDX bus
In reply to Nipun Gupta07/06/2023 06:24, Nipun Gupta:
Quoted 21 lines
The CDX devices are memory mapped on system bus for embedded CPUs.
It uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices.
The CDX bus and VFIO support is available at Xilinx/AMD open source tree:
https://github.com/Xilinx/linux-xlnx (drivers/cdx/anddrivers/vfio/cdx)Linux AMD CDX bus patches has been added into linux tree:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/cdxVFIO patches are also submitted in upstream:
https://www.spinics.net/lists/kvm/msg310623.htmlCDX is a Hardware Architecture designed for AMD FPGA devices. It consists of mechanism for interaction between FPGA, Firmware and the APUs (Application CPUs).
Firmware resides on RPU (Realtime CPUs) which interacts with the FPGA program manager and the APUs. The RPU provides memory-mapped interface (RPU if) which is used to communicate with APUs.
Quoted 4 lines
VFIO CDX driver provides the CDX device resources like MMIO and interrupts to map to user-space. DPDK CDX bus uses sysfs interface and the vfio-cdx driver to discover and initialize the CDX devices for user-space applications.
Applied, thanks.