From ff3bc497e48cfecdd7dae709a37fe0253fb742ed Mon Sep 17 00:00:00 2001 From: Timothy McDaniel Date: Thu, 15 Oct 2020 09:16:46 -0500 Subject: [PATCH] eventdev: add PCI probe named convenience function Add new internal wrapper function for use by pci drivers as a .probe function to attach to an event interface. Same as rte_event_pmd_pci_probe, except the caller can specify the name. Updated rte_event_pmd_pci_probe so as to not duplicate code. Signed-off-by: Timothy McDaniel Reviewed-by: Gage Eads --- lib/librte_eventdev/rte_eventdev_pmd_pci.h | 46 ++++++++++++++------ lib/librte_eventdev/rte_eventdev_version.map | 2 + 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/lib/librte_eventdev/rte_eventdev_pmd_pci.h b/lib/librte_eventdev/rte_eventdev_pmd_pci.h index a3f9244d3a..5f238bf496 100644 --- a/lib/librte_eventdev/rte_eventdev_pmd_pci.h +++ b/lib/librte_eventdev/rte_eventdev_pmd_pci.h @@ -32,28 +32,25 @@ typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev); /** * @internal - * Wrapper for use by pci drivers as a .probe function to attach to a event - * interface. + * Wrapper for use by pci drivers as a .probe function to attach to an event + * interface. Same as rte_event_pmd_pci_probe, except caller can specify + * the name. */ +__rte_experimental static inline int -rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv, - struct rte_pci_device *pci_dev, - size_t private_data_size, - eventdev_pmd_pci_callback_t devinit) +rte_event_pmd_pci_probe_named(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev, + size_t private_data_size, + eventdev_pmd_pci_callback_t devinit, + const char *name) { struct rte_eventdev *eventdev; - - char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN]; - int retval; if (devinit == NULL) return -EINVAL; - rte_pci_device_name(&pci_dev->addr, eventdev_name, - sizeof(eventdev_name)); - - eventdev = rte_event_pmd_allocate(eventdev_name, + eventdev = rte_event_pmd_allocate(name, pci_dev->device.numa_node); if (eventdev == NULL) return -ENOMEM; @@ -88,6 +85,29 @@ rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv, return -ENXIO; } +/** + * @internal + * Wrapper for use by pci drivers as a .probe function to attach to a event + * interface. + */ +static inline int +rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv, + struct rte_pci_device *pci_dev, + size_t private_data_size, + eventdev_pmd_pci_callback_t devinit) +{ + char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN]; + + rte_pci_device_name(&pci_dev->addr, eventdev_name, + sizeof(eventdev_name)); + + return rte_event_pmd_pci_probe_named(pci_drv, + pci_dev, + private_data_size, + devinit, + eventdev_name); +} + /** * @internal * Wrapper for use by pci drivers as a .remove function to detach a event diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map index 2846d04483..8ae8420f9b 100644 --- a/lib/librte_eventdev/rte_eventdev_version.map +++ b/lib/librte_eventdev/rte_eventdev_version.map @@ -136,4 +136,6 @@ EXPERIMENTAL { # changed in 20.11 __rte_eventdev_trace_port_setup; + # added in 20.11 + rte_event_pmd_pci_probe_named; }; -- 2.20.1