bus: hide bus object
Make rte_bus opaque for non internal users. This will make extending this object possible without breaking the ABI. Introduce a new driver header and move rte_bus definition and helpers. Update drivers and library to use the internal header. Some applications may have been dereferencing rte_bus objects, mark this object's accessors as stable. Signed-off-by: David Marchand <david.marchand@redhat.com> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
This commit is contained in:
parent
148c51a3de
commit
a04322f616
@ -9,7 +9,7 @@
|
||||
#include <rte_common.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_kvargs.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_class.h>
|
||||
|
||||
#include "test.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <rte_common.h>
|
||||
#include <rte_kvargs.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_bus_vdev.h>
|
||||
|
||||
#include "test.h"
|
||||
|
@ -47,12 +47,6 @@ Deprecation Notices
|
||||
* mempool: The mempool API macros ``MEMPOOL_PG_*`` are deprecated and
|
||||
will be removed in DPDK 22.11.
|
||||
|
||||
* bus: The ``rte_bus`` object will be made opaque in DPDK 22.11.
|
||||
The goal is to remove it from the public ABI and make this object extendable.
|
||||
As a side effect, registering a bus will be marked as an internal API:
|
||||
external users may still register their bus using a new driver header
|
||||
(see ``enable_driver_sdk`` meson option).
|
||||
|
||||
* drivers: As a follow-up of the work on the ``rte_bus`` object,
|
||||
the ``rte_driver`` and ``rte_device`` objects (and as a domino effect,
|
||||
their bus-specific counterparts) will be made opaque in DPDK 22.11.
|
||||
|
@ -88,6 +88,12 @@ API Changes
|
||||
in the future. Applications can use ``devtools/cocci/func_or_ret.cocci``
|
||||
to update their code.
|
||||
|
||||
* bus: Registering a bus has been marked as an internal API.
|
||||
External users may still register their bus using the ``bus_driver.h``
|
||||
driver header (see ``enable_driver_sdk`` meson option).
|
||||
The ``rte_bus`` object is now opaque and must be manipulated through added
|
||||
accessors.
|
||||
|
||||
* drivers: Registering a driver on the ``auxiliary``, ``ifpga``, ``pci``,
|
||||
``vdev``, ``vmbus`` buses has been marked as an internal API.
|
||||
External users may still register their driver using the associated driver
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include <rte_errno.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_per_lcore.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_eal.h>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_errno.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
|
||||
#include "bus_auxiliary_driver.h"
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <ethdev_driver.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_ring.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_mbuf_pool_ops.h>
|
||||
#include <rte_mbuf_dyn.h>
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <rte_log.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_memcpy.h>
|
||||
|
@ -5,7 +5,7 @@
|
||||
#ifndef BUS_FSLMC_PRIVATE_H
|
||||
#define BUS_FSLMC_PRIVATE_H
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
|
||||
#include <bus_fslmc_driver.h>
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <rte_errno.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_per_lcore.h>
|
||||
#include <rte_memory.h>
|
||||
#include <rte_memzone.h>
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <rte_malloc.h>
|
||||
#include <rte_vfio.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_spinlock.h>
|
||||
#include <rte_tailq.h>
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <rte_errno.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_lcore.h>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_bus_pci.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_errno.h>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_pci_driver.h>
|
||||
#include <rte_os_shim.h>
|
||||
#include <rte_pci.h>
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <rte_eal.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_memory.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <sys/uio.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_vmbus_driver.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_eal_paging.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <rte_errno.h>
|
||||
#include <rte_class.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_pci_driver.h>
|
||||
|
||||
#include "mlx5_common_log.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <sys/mman.h>
|
||||
#include <libgen.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_log.h>
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_pci_driver.h>
|
||||
#include <rte_kvargs.h>
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <ethdev_vdev.h>
|
||||
#include <rte_devargs.h>
|
||||
#include <rte_kvargs.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_vdev_driver.h>
|
||||
|
||||
#include "failsafe_private.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Copyright 2017 Mellanox Technologies, Ltd
|
||||
*/
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_malloc.h>
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <ethdev_driver.h>
|
||||
#include <ethdev_pci.h>
|
||||
#include <rte_pci.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_pci_driver.h>
|
||||
#include <bus_auxiliary_driver.h>
|
||||
#include <rte_common.h>
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include <rte_memory.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_vmbus_driver.h>
|
||||
#include <rte_alarm.h>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rte_alarm.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <bus_vdev_driver.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_dev.h>
|
||||
|
@ -9,7 +9,7 @@
|
||||
#endif
|
||||
|
||||
#include <rte_io.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
|
||||
#include "virtio_pci.h"
|
||||
#include "virtio_logs.h"
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include "ioat_private.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_debug.h>
|
||||
#include <rte_string_fns.h>
|
||||
#include <rte_errno.h>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_class.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_devargs.h>
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_class.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_devargs.h>
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_errno.h>
|
||||
#include <rte_alarm.h>
|
||||
|
296
lib/eal/include/bus_driver.h
Normal file
296
lib/eal/include/bus_driver.h
Normal file
@ -0,0 +1,296 @@
|
||||
/* SPDX-License-Identifier: BSD-3-Clause
|
||||
* Copyright (c) 2022 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef BUS_DRIVER_H
|
||||
#define BUS_DRIVER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <rte_compat.h>
|
||||
#include <rte_dev.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_tailq.h>
|
||||
|
||||
struct rte_devargs;
|
||||
struct rte_device;
|
||||
|
||||
/** Double linked list of buses */
|
||||
RTE_TAILQ_HEAD(rte_bus_list, rte_bus);
|
||||
|
||||
/**
|
||||
* Bus specific scan for devices attached on the bus.
|
||||
* For each bus object, the scan would be responsible for finding devices and
|
||||
* adding them to its private device list.
|
||||
*
|
||||
* A bus should mandatorily implement this method.
|
||||
*
|
||||
* @return
|
||||
* 0 for successful scan
|
||||
* <0 for unsuccessful scan with error value
|
||||
*/
|
||||
typedef int (*rte_bus_scan_t)(void);
|
||||
|
||||
/**
|
||||
* Implementation specific probe function which is responsible for linking
|
||||
* devices on that bus with applicable drivers.
|
||||
*
|
||||
* This is called while iterating over each registered bus.
|
||||
*
|
||||
* @return
|
||||
* 0 for successful probe
|
||||
* !0 for any error while probing
|
||||
*/
|
||||
typedef int (*rte_bus_probe_t)(void);
|
||||
|
||||
/**
|
||||
* Device iterator to find a device on a bus.
|
||||
*
|
||||
* This function returns an rte_device if one of those held by the bus
|
||||
* matches the data passed as parameter.
|
||||
*
|
||||
* If the comparison function returns zero this function should stop iterating
|
||||
* over any more devices. To continue a search the device of a previous search
|
||||
* can be passed via the start parameter.
|
||||
*
|
||||
* @param cmp
|
||||
* Comparison function.
|
||||
*
|
||||
* @param data
|
||||
* Data to compare each device against.
|
||||
*
|
||||
* @param start
|
||||
* starting point for the iteration
|
||||
*
|
||||
* @return
|
||||
* The first device matching the data, NULL if none exists.
|
||||
*/
|
||||
typedef struct rte_device *
|
||||
(*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* Implementation specific probe function which is responsible for linking
|
||||
* devices on that bus with applicable drivers.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer that was returned by a previous call to find_device.
|
||||
*
|
||||
* @return
|
||||
* 0 on success.
|
||||
* !0 on error.
|
||||
*/
|
||||
typedef int (*rte_bus_plug_t)(struct rte_device *dev);
|
||||
|
||||
/**
|
||||
* Implementation specific remove function which is responsible for unlinking
|
||||
* devices on that bus from assigned driver.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer that was returned by a previous call to find_device.
|
||||
*
|
||||
* @return
|
||||
* 0 on success.
|
||||
* !0 on error.
|
||||
*/
|
||||
typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
|
||||
|
||||
/**
|
||||
* Bus specific parsing function.
|
||||
* Validates the syntax used in the textual representation of a device,
|
||||
* If the syntax is valid and ``addr`` is not NULL, writes the bus-specific
|
||||
* device representation to ``addr``.
|
||||
*
|
||||
* @param[in] name
|
||||
* device textual description
|
||||
*
|
||||
* @param[out] addr
|
||||
* device information location address, into which parsed info
|
||||
* should be written. If NULL, nothing should be written, which
|
||||
* is not an error.
|
||||
*
|
||||
* @return
|
||||
* 0 if parsing was successful.
|
||||
* !0 for any error.
|
||||
*/
|
||||
typedef int (*rte_bus_parse_t)(const char *name, void *addr);
|
||||
|
||||
/**
|
||||
* Parse bus part of the device arguments.
|
||||
*
|
||||
* The field name of the struct rte_devargs will be set.
|
||||
*
|
||||
* @param da
|
||||
* Pointer to the devargs to parse.
|
||||
*
|
||||
* @return
|
||||
* 0 on successful parsing, otherwise rte_errno is set.
|
||||
* -EINVAL: on parsing error.
|
||||
* -ENODEV: if no key matching a device argument is specified.
|
||||
* -E2BIG: device name is too long.
|
||||
*/
|
||||
typedef int (*rte_bus_devargs_parse_t)(struct rte_devargs *da);
|
||||
|
||||
/**
|
||||
* Device level DMA map function.
|
||||
* After a successful call, the memory segment will be mapped to the
|
||||
* given device.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer.
|
||||
* @param addr
|
||||
* Virtual address to map.
|
||||
* @param iova
|
||||
* IOVA address to map.
|
||||
* @param len
|
||||
* Length of the memory segment being mapped.
|
||||
*
|
||||
* @return
|
||||
* 0 if mapping was successful.
|
||||
* Negative value and rte_errno is set otherwise.
|
||||
*/
|
||||
typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
|
||||
uint64_t iova, size_t len);
|
||||
|
||||
/**
|
||||
* Device level DMA unmap function.
|
||||
* After a successful call, the memory segment will no longer be
|
||||
* accessible by the given device.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer.
|
||||
* @param addr
|
||||
* Virtual address to unmap.
|
||||
* @param iova
|
||||
* IOVA address to unmap.
|
||||
* @param len
|
||||
* Length of the memory segment being mapped.
|
||||
*
|
||||
* @return
|
||||
* 0 if un-mapping was successful.
|
||||
* Negative value and rte_errno is set otherwise.
|
||||
*/
|
||||
typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
|
||||
uint64_t iova, size_t len);
|
||||
|
||||
/**
|
||||
* Implement a specific hot-unplug handler, which is responsible for
|
||||
* handle the failure when device be hot-unplugged. When the event of
|
||||
* hot-unplug be detected, it could call this function to handle
|
||||
* the hot-unplug failure and avoid app crash.
|
||||
* @param dev
|
||||
* Pointer of the device structure.
|
||||
*
|
||||
* @return
|
||||
* 0 on success.
|
||||
* !0 on error.
|
||||
*/
|
||||
typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
|
||||
|
||||
/**
|
||||
* Implement a specific sigbus handler, which is responsible for handling
|
||||
* the sigbus error which is either original memory error, or specific memory
|
||||
* error that caused of device be hot-unplugged. When sigbus error be captured,
|
||||
* it could call this function to handle sigbus error.
|
||||
* @param failure_addr
|
||||
* Pointer of the fault address of the sigbus error.
|
||||
*
|
||||
* @return
|
||||
* 0 for success handle the sigbus for hot-unplug.
|
||||
* 1 for not process it, because it is a generic sigbus error.
|
||||
* -1 for failed to handle the sigbus for hot-unplug.
|
||||
*/
|
||||
typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
|
||||
|
||||
/**
|
||||
* Bus scan policies
|
||||
*/
|
||||
enum rte_bus_scan_mode {
|
||||
RTE_BUS_SCAN_UNDEFINED,
|
||||
RTE_BUS_SCAN_ALLOWLIST,
|
||||
RTE_BUS_SCAN_BLOCKLIST,
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure used to configure bus operations.
|
||||
*/
|
||||
struct rte_bus_conf {
|
||||
enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get common iommu class of the all the devices on the bus. The bus may
|
||||
* check that those devices are attached to iommu driver.
|
||||
* If no devices are attached to the bus. The bus may return with don't care
|
||||
* (_DC) value.
|
||||
* Otherwise, The bus will return appropriate _pa or _va iova mode.
|
||||
*
|
||||
* @return
|
||||
* enum rte_iova_mode value.
|
||||
*/
|
||||
typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void);
|
||||
|
||||
/**
|
||||
* A structure describing a generic bus.
|
||||
*/
|
||||
struct rte_bus {
|
||||
RTE_TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */
|
||||
const char *name; /**< Name of the bus */
|
||||
rte_bus_scan_t scan; /**< Scan for devices attached to bus */
|
||||
rte_bus_probe_t probe; /**< Probe devices on bus */
|
||||
rte_bus_find_device_t find_device; /**< Find a device on the bus */
|
||||
rte_bus_plug_t plug; /**< Probe single device for drivers */
|
||||
rte_bus_unplug_t unplug; /**< Remove single device from driver */
|
||||
rte_bus_parse_t parse; /**< Parse a device name */
|
||||
rte_bus_devargs_parse_t devargs_parse; /**< Parse bus devargs */
|
||||
rte_dev_dma_map_t dma_map; /**< DMA map for device in the bus */
|
||||
rte_dev_dma_unmap_t dma_unmap; /**< DMA unmap for device in the bus */
|
||||
struct rte_bus_conf conf; /**< Bus configuration */
|
||||
rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */
|
||||
rte_dev_iterate_t dev_iterate; /**< Device iterator. */
|
||||
rte_bus_hot_unplug_handler_t hot_unplug_handler;
|
||||
/**< handle hot-unplug failure on the bus */
|
||||
rte_bus_sigbus_handler_t sigbus_handler;
|
||||
/**< handle sigbus error on the bus */
|
||||
};
|
||||
|
||||
/**
|
||||
* Register a Bus handler.
|
||||
*
|
||||
* @param bus
|
||||
* A pointer to a rte_bus structure describing the bus
|
||||
* to be registered.
|
||||
*/
|
||||
__rte_internal
|
||||
void rte_bus_register(struct rte_bus *bus);
|
||||
|
||||
/**
|
||||
* Helper for Bus registration.
|
||||
* The constructor has higher priority than PMD constructors.
|
||||
*/
|
||||
#define RTE_REGISTER_BUS(nm, bus) \
|
||||
RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
|
||||
{\
|
||||
(bus).name = RTE_STR(nm);\
|
||||
rte_bus_register(&bus); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister a Bus handler.
|
||||
*
|
||||
* @param bus
|
||||
* A pointer to a rte_bus structure describing the bus
|
||||
* to be unregistered.
|
||||
*/
|
||||
__rte_internal
|
||||
void rte_bus_unregister(struct rte_bus *bus);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BUS_DRIVER_H */
|
@ -55,6 +55,10 @@ headers += files(
|
||||
'rte_vfio.h',
|
||||
)
|
||||
|
||||
driver_sdk_headers = files(
|
||||
'bus_driver.h',
|
||||
)
|
||||
|
||||
# special case install the generic headers, since they go in a subdir
|
||||
generic_headers = files(
|
||||
'generic/rte_atomic.h',
|
||||
|
@ -20,284 +20,21 @@ extern "C" {
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <rte_dev.h>
|
||||
#include <rte_eal.h>
|
||||
#include <rte_log.h>
|
||||
|
||||
/** Double linked list of buses */
|
||||
RTE_TAILQ_HEAD(rte_bus_list, rte_bus);
|
||||
|
||||
/**
|
||||
* Bus specific scan for devices attached on the bus.
|
||||
* For each bus object, the scan would be responsible for finding devices and
|
||||
* adding them to its private device list.
|
||||
*
|
||||
* A bus should mandatorily implement this method.
|
||||
*
|
||||
* @return
|
||||
* 0 for successful scan
|
||||
* <0 for unsuccessful scan with error value
|
||||
*/
|
||||
typedef int (*rte_bus_scan_t)(void);
|
||||
|
||||
/**
|
||||
* Implementation specific probe function which is responsible for linking
|
||||
* devices on that bus with applicable drivers.
|
||||
*
|
||||
* This is called while iterating over each registered bus.
|
||||
*
|
||||
* @return
|
||||
* 0 for successful probe
|
||||
* !0 for any error while probing
|
||||
*/
|
||||
typedef int (*rte_bus_probe_t)(void);
|
||||
|
||||
/**
|
||||
* Device iterator to find a device on a bus.
|
||||
*
|
||||
* This function returns an rte_device if one of those held by the bus
|
||||
* matches the data passed as parameter.
|
||||
*
|
||||
* If the comparison function returns zero this function should stop iterating
|
||||
* over any more devices. To continue a search the device of a previous search
|
||||
* can be passed via the start parameter.
|
||||
*
|
||||
* @param cmp
|
||||
* Comparison function.
|
||||
*
|
||||
* @param data
|
||||
* Data to compare each device against.
|
||||
*
|
||||
* @param start
|
||||
* starting point for the iteration
|
||||
*
|
||||
* @return
|
||||
* The first device matching the data, NULL if none exists.
|
||||
*/
|
||||
typedef struct rte_device *
|
||||
(*rte_bus_find_device_t)(const struct rte_device *start, rte_dev_cmp_t cmp,
|
||||
const void *data);
|
||||
|
||||
/**
|
||||
* Implementation specific probe function which is responsible for linking
|
||||
* devices on that bus with applicable drivers.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer that was returned by a previous call to find_device.
|
||||
*
|
||||
* @return
|
||||
* 0 on success.
|
||||
* !0 on error.
|
||||
*/
|
||||
typedef int (*rte_bus_plug_t)(struct rte_device *dev);
|
||||
|
||||
/**
|
||||
* Implementation specific remove function which is responsible for unlinking
|
||||
* devices on that bus from assigned driver.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer that was returned by a previous call to find_device.
|
||||
*
|
||||
* @return
|
||||
* 0 on success.
|
||||
* !0 on error.
|
||||
*/
|
||||
typedef int (*rte_bus_unplug_t)(struct rte_device *dev);
|
||||
|
||||
/**
|
||||
* Bus specific parsing function.
|
||||
* Validates the syntax used in the textual representation of a device,
|
||||
* If the syntax is valid and ``addr`` is not NULL, writes the bus-specific
|
||||
* device representation to ``addr``.
|
||||
*
|
||||
* @param[in] name
|
||||
* device textual description
|
||||
*
|
||||
* @param[out] addr
|
||||
* device information location address, into which parsed info
|
||||
* should be written. If NULL, nothing should be written, which
|
||||
* is not an error.
|
||||
*
|
||||
* @return
|
||||
* 0 if parsing was successful.
|
||||
* !0 for any error.
|
||||
*/
|
||||
typedef int (*rte_bus_parse_t)(const char *name, void *addr);
|
||||
|
||||
/**
|
||||
* Parse bus part of the device arguments.
|
||||
*
|
||||
* The field name of the struct rte_devargs will be set.
|
||||
*
|
||||
* @param da
|
||||
* Pointer to the devargs to parse.
|
||||
*
|
||||
* @return
|
||||
* 0 on successful parsing, otherwise rte_errno is set.
|
||||
* -EINVAL: on parsing error.
|
||||
* -ENODEV: if no key matching a device argument is specified.
|
||||
* -E2BIG: device name is too long.
|
||||
*/
|
||||
typedef int (*rte_bus_devargs_parse_t)(struct rte_devargs *da);
|
||||
|
||||
/**
|
||||
* Device level DMA map function.
|
||||
* After a successful call, the memory segment will be mapped to the
|
||||
* given device.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer.
|
||||
* @param addr
|
||||
* Virtual address to map.
|
||||
* @param iova
|
||||
* IOVA address to map.
|
||||
* @param len
|
||||
* Length of the memory segment being mapped.
|
||||
*
|
||||
* @return
|
||||
* 0 if mapping was successful.
|
||||
* Negative value and rte_errno is set otherwise.
|
||||
*/
|
||||
typedef int (*rte_dev_dma_map_t)(struct rte_device *dev, void *addr,
|
||||
uint64_t iova, size_t len);
|
||||
|
||||
/**
|
||||
* Device level DMA unmap function.
|
||||
* After a successful call, the memory segment will no longer be
|
||||
* accessible by the given device.
|
||||
*
|
||||
* @param dev
|
||||
* Device pointer.
|
||||
* @param addr
|
||||
* Virtual address to unmap.
|
||||
* @param iova
|
||||
* IOVA address to unmap.
|
||||
* @param len
|
||||
* Length of the memory segment being mapped.
|
||||
*
|
||||
* @return
|
||||
* 0 if un-mapping was successful.
|
||||
* Negative value and rte_errno is set otherwise.
|
||||
*/
|
||||
typedef int (*rte_dev_dma_unmap_t)(struct rte_device *dev, void *addr,
|
||||
uint64_t iova, size_t len);
|
||||
|
||||
/**
|
||||
* Implement a specific hot-unplug handler, which is responsible for
|
||||
* handle the failure when device be hot-unplugged. When the event of
|
||||
* hot-unplug be detected, it could call this function to handle
|
||||
* the hot-unplug failure and avoid app crash.
|
||||
* @param dev
|
||||
* Pointer of the device structure.
|
||||
*
|
||||
* @return
|
||||
* 0 on success.
|
||||
* !0 on error.
|
||||
*/
|
||||
typedef int (*rte_bus_hot_unplug_handler_t)(struct rte_device *dev);
|
||||
|
||||
/**
|
||||
* Implement a specific sigbus handler, which is responsible for handling
|
||||
* the sigbus error which is either original memory error, or specific memory
|
||||
* error that caused of device be hot-unplugged. When sigbus error be captured,
|
||||
* it could call this function to handle sigbus error.
|
||||
* @param failure_addr
|
||||
* Pointer of the fault address of the sigbus error.
|
||||
*
|
||||
* @return
|
||||
* 0 for success handle the sigbus for hot-unplug.
|
||||
* 1 for not process it, because it is a generic sigbus error.
|
||||
* -1 for failed to handle the sigbus for hot-unplug.
|
||||
*/
|
||||
typedef int (*rte_bus_sigbus_handler_t)(const void *failure_addr);
|
||||
|
||||
/**
|
||||
* Bus scan policies
|
||||
*/
|
||||
enum rte_bus_scan_mode {
|
||||
RTE_BUS_SCAN_UNDEFINED,
|
||||
RTE_BUS_SCAN_ALLOWLIST,
|
||||
RTE_BUS_SCAN_BLOCKLIST,
|
||||
};
|
||||
|
||||
/**
|
||||
* A structure used to configure bus operations.
|
||||
*/
|
||||
struct rte_bus_conf {
|
||||
enum rte_bus_scan_mode scan_mode; /**< Scan policy. */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get common iommu class of the all the devices on the bus. The bus may
|
||||
* check that those devices are attached to iommu driver.
|
||||
* If no devices are attached to the bus. The bus may return with don't care
|
||||
* (_DC) value.
|
||||
* Otherwise, The bus will return appropriate _pa or _va iova mode.
|
||||
*
|
||||
* @return
|
||||
* enum rte_iova_mode value.
|
||||
*/
|
||||
typedef enum rte_iova_mode (*rte_bus_get_iommu_class_t)(void);
|
||||
|
||||
|
||||
/**
|
||||
* A structure describing a generic bus.
|
||||
*/
|
||||
struct rte_bus {
|
||||
RTE_TAILQ_ENTRY(rte_bus) next; /**< Next bus object in linked list */
|
||||
const char *name; /**< Name of the bus */
|
||||
rte_bus_scan_t scan; /**< Scan for devices attached to bus */
|
||||
rte_bus_probe_t probe; /**< Probe devices on bus */
|
||||
rte_bus_find_device_t find_device; /**< Find a device on the bus */
|
||||
rte_bus_plug_t plug; /**< Probe single device for drivers */
|
||||
rte_bus_unplug_t unplug; /**< Remove single device from driver */
|
||||
rte_bus_parse_t parse; /**< Parse a device name */
|
||||
rte_bus_devargs_parse_t devargs_parse; /**< Parse bus devargs */
|
||||
rte_dev_dma_map_t dma_map; /**< DMA map for device in the bus */
|
||||
rte_dev_dma_unmap_t dma_unmap; /**< DMA unmap for device in the bus */
|
||||
struct rte_bus_conf conf; /**< Bus configuration */
|
||||
rte_bus_get_iommu_class_t get_iommu_class; /**< Get iommu class */
|
||||
rte_dev_iterate_t dev_iterate; /**< Device iterator. */
|
||||
rte_bus_hot_unplug_handler_t hot_unplug_handler;
|
||||
/**< handle hot-unplug failure on the bus */
|
||||
rte_bus_sigbus_handler_t sigbus_handler;
|
||||
/**< handle sigbus error on the bus */
|
||||
|
||||
};
|
||||
struct rte_bus;
|
||||
struct rte_device;
|
||||
|
||||
/**
|
||||
* Retrieve a bus name.
|
||||
*
|
||||
* @warning
|
||||
* @b EXPERIMENTAL: this API may change without prior notice
|
||||
*
|
||||
* @param bus
|
||||
* A pointer to a rte_bus structure.
|
||||
* @return
|
||||
* A pointer to the bus name string.
|
||||
*/
|
||||
__rte_experimental
|
||||
const char *rte_bus_name(const struct rte_bus *bus);
|
||||
|
||||
/**
|
||||
* Register a Bus handler.
|
||||
*
|
||||
* @param bus
|
||||
* A pointer to a rte_bus structure describing the bus
|
||||
* to be registered.
|
||||
*/
|
||||
void rte_bus_register(struct rte_bus *bus);
|
||||
|
||||
/**
|
||||
* Unregister a Bus handler.
|
||||
*
|
||||
* @param bus
|
||||
* A pointer to a rte_bus structure describing the bus
|
||||
* to be unregistered.
|
||||
*/
|
||||
void rte_bus_unregister(struct rte_bus *bus);
|
||||
|
||||
/**
|
||||
* Scan all the buses.
|
||||
*
|
||||
@ -387,17 +124,6 @@ struct rte_bus *rte_bus_find_by_name(const char *busname);
|
||||
*/
|
||||
enum rte_iova_mode rte_bus_get_iommu_class(void);
|
||||
|
||||
/**
|
||||
* Helper for Bus registration.
|
||||
* The constructor has higher priority than PMD constructors.
|
||||
*/
|
||||
#define RTE_REGISTER_BUS(nm, bus) \
|
||||
RTE_INIT_PRIO(businitfn_ ##nm, BUS) \
|
||||
{\
|
||||
(bus).name = RTE_STR(nm);\
|
||||
rte_bus_register(&bus); \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include <rte_dev.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_alarm.h>
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_spinlock.h>
|
||||
#include <rte_errno.h>
|
||||
|
||||
|
@ -12,10 +12,9 @@ DPDK_23 {
|
||||
rte_bus_find_by_device;
|
||||
rte_bus_find_by_name;
|
||||
rte_bus_get_iommu_class;
|
||||
rte_bus_name;
|
||||
rte_bus_probe;
|
||||
rte_bus_register;
|
||||
rte_bus_scan;
|
||||
rte_bus_unregister;
|
||||
rte_calloc;
|
||||
rte_calloc_socket;
|
||||
rte_cpu_get_flag_enabled;
|
||||
@ -425,14 +424,13 @@ EXPERIMENTAL {
|
||||
rte_thread_self;
|
||||
rte_thread_set_affinity_by_id;
|
||||
rte_thread_set_priority;
|
||||
|
||||
# added in 22.11
|
||||
rte_bus_name;
|
||||
};
|
||||
|
||||
INTERNAL {
|
||||
global:
|
||||
|
||||
rte_bus_register;
|
||||
rte_bus_unregister;
|
||||
rte_eal_get_baseaddr;
|
||||
rte_eal_parse_coremask;
|
||||
rte_firmware_read;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <string.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_log.h>
|
||||
#include <rte_interrupts.h>
|
||||
#include <rte_memcpy.h>
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <rte_bus.h>
|
||||
#include <bus_driver.h>
|
||||
#include <rte_common.h>
|
||||
#include <rte_cycles.h>
|
||||
#include <rte_dev.h>
|
||||
|
Loading…
Reference in New Issue
Block a user