[dpdk-dev] [PATCH v1] bus/auxiliary: introduce auxiliary bus

Xueming(Steven) Li xuemingl at nvidia.com
Thu Apr 15 09:46:26 CEST 2021


> -----Original Message-----
> From: Wang, Haiyue <haiyue.wang at intel.com>
> Sent: Thursday, April 15, 2021 3:36 PM
> To: Xueming(Steven) Li <xuemingl at nvidia.com>; NBU-Contact-Thomas Monjalon <thomas at monjalon.net>
> Cc: dev at dpdk.org; Asaf Penso <asafp at nvidia.com>; Parav Pandit <parav at nvidia.com>; Ray Kinsella <mdr at ashroe.eu>; Neil Horman
> <nhorman at tuxdriver.com>
> Subject: RE: [dpdk-dev] [PATCH v1] bus/auxiliary: introduce auxiliary bus
> 
> > -----Original Message-----
> > From: dev <dev-bounces at dpdk.org> On Behalf Of Xueming Li
> > Sent: Tuesday, April 13, 2021 11:23
> > To: Thomas Monjalon <thomas at monjalon.net>
> > Cc: dev at dpdk.org; xuemingl at nvidia.com; Asaf Penso <asafp at nvidia.com>;
> > Parav Pandit <parav at nvidia.com>; Ray Kinsella <mdr at ashroe.eu>; Neil
> > Horman <nhorman at tuxdriver.com>
> > Subject: [dpdk-dev] [PATCH v1] bus/auxiliary: introduce auxiliary bus
> >
> > Auxiliary [1] provides a way to split function into child-devices
> > representing sub-domains of functionality. Each auxiliary_device
> > represents a part of its parent functionality.
> >
> > Auxiliary device is identified by unique device name, sysfs path:
> >   /sys/bus/auxiliary/devices/<name>
> >
> > [1] kernel auxiliary bus document:
> > https://www.kernel.org/doc/html/latest/driver-api/auxiliary_bus.html
> >
> > Signed-off-by: Xueming Li <xuemingl at nvidia.com>
> > ---
> >  MAINTAINERS                               |   5 +
> >  drivers/bus/auxiliary/auxiliary_common.c  | 391
> > ++++++++++++++++++++++  drivers/bus/auxiliary/auxiliary_params.c  |  58 ++++
> >  drivers/bus/auxiliary/linux/auxiliary.c   | 147 ++++++++
> >  drivers/bus/auxiliary/meson.build         |  17 +
> >  drivers/bus/auxiliary/private.h           | 118 +++++++
> >  drivers/bus/auxiliary/rte_bus_auxiliary.h | 180 ++++++++++
> >  drivers/bus/auxiliary/version.map         |  10 +
> >  drivers/bus/meson.build                   |   2 +-
> >  9 files changed, 927 insertions(+), 1 deletion(-)  create mode 100644
> > drivers/bus/auxiliary/auxiliary_common.c
> >  create mode 100644 drivers/bus/auxiliary/auxiliary_params.c
> >  create mode 100644 drivers/bus/auxiliary/linux/auxiliary.c
> >  create mode 100644 drivers/bus/auxiliary/meson.build  create mode
> > 100644 drivers/bus/auxiliary/private.h  create mode 100644
> > drivers/bus/auxiliary/rte_bus_auxiliary.h
> >  create mode 100644 drivers/bus/auxiliary/version.map
> >
> 
> 
> > --- /dev/null
> > +++ b/drivers/bus/auxiliary/rte_bus_auxiliary.h
> > @@ -0,0 +1,180 @@
> > +/* SPDX-License-Identifier: BSD-3-Clause
> > + * Copyright 2021 Mellanox Technologies, Ltd  */
> > +
> > +#ifndef _RTE_BUS_AUXILIARY_H_
> > +#define _RTE_BUS_AUXILIARY_H_
> > +
> > +/**
> > + * @file
> > + *
> > + * RTE Auxiliary Bus Interface.
> > + */
> > +
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
> > +
> > +#include <stdio.h>
> > +#include <stdlib.h>
> > +#include <limits.h>
> > +#include <errno.h>
> > +#include <sys/queue.h>
> > +#include <stdint.h>
> > +#include <inttypes.h>
> > +
> > +#include <rte_debug.h>
> > +#include <rte_interrupts.h>
> > +#include <rte_dev.h>
> > +#include <rte_bus.h>
> > +#include <rte_kvargs.h>
> > +
> > +/* Forward declarations */
> > +struct rte_auxiliary_driver;
> > +struct rte_auxiliary_bus;
> > +struct rte_auxiliary_device;
> > +
> > +/**
> > + * Match function for the driver to decide if device can be handled.
> > + */
> > +typedef bool(auxiliary_match_t) (const char *);
> > +
> > +/**
> > + * Initialization function for the driver called during auxiliary probing.
> > + */
> > +typedef int(auxiliary_probe_t) (struct rte_auxiliary_driver*,
> > +				struct rte_auxiliary_device*);
> > +
> > +/**
> > + * Uninitialization function for the driver called during hotplugging.
> > + */
> > +typedef int (auxiliary_remove_t)(struct rte_auxiliary_device *);
> > +
> > +/**
> > + * Driver-specific DMA mapping. After a successful call the device
> > + * will be able to read/write from/to this segment.
> > + *
> > + * @param dev
> > + *   Pointer to the auxiliary device.
> > + * @param addr
> > + *   Starting virtual address of memory to be mapped.
> > + * @param iova
> > + *   Starting IOVA address of memory to be mapped.
> > + * @param len
> > + *   Length of memory segment being mapped.
> > + * @return
> > + *   - 0 On success.
> > + *   - Negative value and rte_errno is set otherwise.
> > + */
> > +typedef int (auxiliary_dma_map_t)(struct rte_auxiliary_device *dev, void *addr,
> > +				  uint64_t iova, size_t len);
> > +
> > +/**
> > + * Driver-specific DMA un-mapping. After a successful call the device
> > + * will not be able to read/write from/to this segment.
> > + *
> > + * @param dev
> > + *   Pointer to the auxiliary device.
> > + * @param addr
> > + *   Starting virtual address of memory to be unmapped.
> > + * @param iova
> > + *   Starting IOVA address of memory to be unmapped.
> > + * @param len
> > + *   Length of memory segment being unmapped.
> > + * @return
> > + *   - 0 On success.
> > + *   - Negative value and rte_errno is set otherwise.
> > + */
> > +typedef int (auxiliary_dma_unmap_t)(struct rte_auxiliary_device *dev,
> > +				    void *addr, uint64_t iova, size_t len);
> > +
> > +/**
> > + * A structure describing an auxiliary device.
> > + */
> > +struct rte_auxiliary_device {
> > +	TAILQ_ENTRY(rte_auxiliary_device) next;   /**< Next probed device. */
> > +	char name[RTE_DEV_NAME_MAX_LEN + 1];      /**< ASCII device name */
> > +	struct rte_device device;                 /**< Inherit core device */
> > +	struct rte_intr_handle intr_handle;       /**< Interrupt handle */
> > +	struct rte_auxiliary_driver *driver;      /**< driver used in probing */
> > +};
> > +
> > +/** List of auxiliary devices */
> > +TAILQ_HEAD(rte_auxiliary_device_list, rte_auxiliary_device);
> > +/** List of auxiliary drivers */
> > +TAILQ_HEAD(rte_auxiliary_driver_list, rte_auxiliary_driver);
> > +
> > +/**
> > + * Structure describing the auxiliary bus  */ struct
> > +rte_auxiliary_bus {
> > +	struct rte_bus bus;                  /**< Inherit the generic class */
> > +	struct rte_auxiliary_device_list device_list;  /**< List of devices */
> > +	struct rte_auxiliary_driver_list driver_list;  /**< List of drivers
> > +*/ };
> > +
> > +/**
> > + * A structure describing an auxiliary driver.
> > + */
> > +struct rte_auxiliary_driver {
> > +	TAILQ_ENTRY(rte_auxiliary_driver) next; /**< Next in list. */
> > +	struct rte_driver driver;            /**< Inherit core driver. */
> > +	struct rte_auxiliary_bus *bus;       /**< Auxiliary bus reference. */
> > +	auxiliary_match_t *match;            /**< Device match function. */
> > +	auxiliary_probe_t *probe;            /**< Device Probe function. */
> > +	auxiliary_remove_t *remove;          /**< Device Remove function. */
> > +	auxiliary_dma_map_t *dma_map;        /**< Device dma map function. */
> > +	auxiliary_dma_unmap_t *dma_unmap;    /**< Device dma unmap function. */
> 
> These API type can be pointer type defined, then no need "*":
> 
> typedef int (*auxiliary_dma_unmap_t)(struct rte_auxiliary_device *dev,
> 				    void *addr, uint64_t iova, size_t len);
> 
> auxiliary_dma_unmap_t dma_unmap;
> 
> Like:
> https://patchwork.dpdk.org/project/dpdk/patch/20210331224547.2217759-1-thomas@monjalon.net/
> 
> typedef int (*rte_dev_dma_map_t)(struct rte_device *dev,
> 				 void *addr, uint64_t iova, size_t len);

Thanks, is there a reason to prefer pointer type? 

Thoma's patch looks good, will rebase on it once accepted.

> 
> > --
> > 2.25.1



More information about the dev mailing list