introduce prgdev abstraction library
cover introduce prgdev abstraction library
These patch set intend to introduce a DPDK generic programming device layer, called prgdev, to provide an abstract, generic APIs for applications to program hardware without knowing the details of programmable devices. From driver's perspective, they'll try to adapt their functions to the abstract APIs defined in prgdev.
The major purpose of prgdev is to help DPDK users to dynamically load/upgrade RTL images for FPGA devices, or upgrade firmware for programmble NICs, without breaking DPDK application running.
Chen Jing D(Mark) (5):
prgdev: introduce new library
prgdev: add debug macro for prgdev
prgdev: add bus probe and remove functions
prgdev: add prgdev API exposed to application
prgdev: add ABI control info
Chen, Jing D (1):
doc: introduction to prgdev
config/common_base | 7 + doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/prgdev_lib.rst | 465 ++++++++++++++++++++++++++++++ lib/Makefile | 1 + lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_prgdev/Makefile | 57 ++++ lib/librte_prgdev/rte_prgdev.c | 459 +++++++++++++++++++++++++++++ lib/librte_prgdev/rte_prgdev.h | 401 ++++++++++++++++++++++++++ lib/librte_prgdev/rte_prgdev_version.map | 19 ++ mk/rte.app.mk | 1 + 10 files changed, 1412 insertions(+), 0 deletions(-) create mode 100644 doc/guides/prog_guide/prgdev_lib.rst create mode 100644 lib/librte_prgdev/Makefile create mode 100644 lib/librte_prgdev/rte_prgdev.c create mode 100644 lib/librte_prgdev/rte_prgdev.h create mode 100644 lib/librte_prgdev/rte_prgdev_version.map
Signature · 1 line
1.7.7.6
PATCH 1/6 prgdev: introduce new library
Change configuration files, add new library prgdev into compile system.
--- config/common_base | 7 +++++ lib/Makefile | 1 + lib/librte_prgdev/Makefile | 57 ++++++++++++++++++++++++++++++++++++++++++++ mk/rte.app.mk | 1 + 4 files changed, 66 insertions(+), 0 deletions(-) create mode 100644 lib/librte_prgdev/Makefile create mode 100644 lib/librte_prgdev/rte_prgdev.c create mode 100644 lib/librte_prgdev/rte_prgdev.h
config/common_base +7 -0
@@ -377,6 +377,13 @@ CONFIG_RTE_CRYPTO_MAX_DEVS=64 CONFIG_RTE_CRYPTODEV_NAME_LEN=64 # +# Compile generic prgdev device library +# +CONFIG_RTE_LIBRTE_PRGDEV=y +CONFIG_RTE_LIBRTE_PRGDEV_DEBUG=n +CONFIG_RTE_PRGDEV_MAX_DEVS=128 + +# # Compile PMD for ARMv8 Crypto device # CONFIG_RTE_LIBRTE_PMD_ARMV8_CRYPTO=n
lib/Makefile +1 -0
@@ -59,6 +59,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TABLE) += librte_table DIRS-$(CONFIG_RTE_LIBRTE_PIPELINE) += librte_pipeline DIRS-$(CONFIG_RTE_LIBRTE_REORDER) += librte_reorder DIRS-$(CONFIG_RTE_LIBRTE_PDUMP) += librte_pdump +DIRS-$(CONFIG_RTE_LIBRTE_PRGDEV) += librte_prgdev ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y) DIRS-$(CONFIG_RTE_LIBRTE_KNI) += librte_kni
lib/librte_prgdev/Makefile new file +57 -0
57 lines not on this page · raw message
lib/librte_prgdev/rte_prgdev.c new file +0 -0
lib/librte_prgdev/rte_prgdev.h new file +0 -0
mk/rte.app.mk +1 -0
@@ -99,6 +99,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_RING) += -lrte_ring _LDLIBS-$(CONFIG_RTE_LIBRTE_EAL) += -lrte_eal _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder +_LDLIBS-$(CONFIG_RTE_LIBRTE_PRGDEV) += -lrte_prgdev ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n) # plugins (link only if static libraries)
Signature · 1 line
1.7.7.6
PATCH 2/6 prgdev: add debug macro for prgdev
In reply to Chen Jing D(Mark)Add debug macro in rte_log.h to support prgdev.
Add debug message macro for debugging.
--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_prgdev/rte_prgdev.h | 67 +++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 0 deletions(-)
lib/librte_eal/common/include/rte_log.h +1 -0
@@ -80,6 +80,7 @@ struct rte_logs {#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ #define RTE_LOGTYPE_CRYPTODEV 0x00020000/**< Log related to cryptodev. */ #define RTE_LOGTYPE_EFD 0x00040000/**< Log related to EFD. */ +#define RTE_LOGTYPE_PRG 0x00080000/**< Log related to prg device. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */
lib/librte_prgdev/rte_prgdev.h +67 -0
67 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH 3/6 prgdev: add bus probe and remove functions
In reply to Chen Jing D(Mark)This patch adds 4 major functions: pci_probe/pci_remove, prgdev_allocate/prgdev_release to help drivers registering programmable devices.
pci_probe functions helps drivers to allocate prgdev structures and trigger an initialization function that drivers provided. This function will be called when bus scan action performed or hotplug occured.
prgdev_allocate will allocate a prgdev structures, but won't perform an intialization of the device. Comparing pci_probe function which will be triggered by bus scan, it can be called at any time by driver.
--- lib/librte_prgdev/rte_prgdev.c | 233 ++++++++++++++++++++++++++++++++++++++++ lib/librte_prgdev/rte_prgdev.h | 228 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 461 insertions(+), 0 deletions(-)
lib/librte_prgdev/rte_prgdev.c +233 -0
@@ -0,0 +1,233 @@ +/*- +* BSD LICENSE +* +* Copyright(c) 2016-2017 Intel Corporation. All rights reserved. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* * Neither the name of Intel Corporation nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include <ctype.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <errno.h> +#include <stdint.h> +#include <inttypes.h> +#include <netinet/in.h> + +#include <rte_log.h> +#include <rte_debug.h> +#include <rte_pci.h> +#include <rte_memory.h> +#include <rte_memcpy.h> +#include <rte_memzone.h> +#include <rte_launch.h> +#include <rte_eal.h> +#include <rte_per_lcore.h> +#include <rte_lcore.h> +#include <rte_common.h> +#include <rte_mempool.h> +#include <rte_malloc.h> +#include <rte_mbuf.h> +#include <rte_errno.h> +#include "rte_prgdev.h" + +static struct rte_prgdev rte_prgdev_devices[RTE_PRGDEV_MAX_DEVS ]; +static uint8_t nb_devs; + +static struct rte_prgdev *rte_prgdev_allocated (char *name); + +int +rte_prgdev_pci_probe (struct rte_pci_driver *pci_drv, +struct rte_pci_device *pci_dev) +{ +struct prgdev_driver *prgdrv; +struct rte_prgdev *prgdev; +char prgdev_name[PRGDEV_NAME_MAX_LEN ]; +int retval; + +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (-EINVAL ); + + prgdrv = (struct prgdev_driver *)pci_drv; +if (prgdrv ==NULL ) +return -ENODEV ; + +rte_eal_pci_device_name (&pci_dev->addr, prgdev_name, +sizeof (prgdev_name)); + + prgdev =rte_prgdev_allocate (prgdev_name); +if (prgdev ==NULL ) +return -1 ; + + prgdev->dev_data.dev_private = +rte_zmalloc_socket ( +"prgdevprivate structure" , + prgdrv->dev_private_size, +RTE_CACHE_LINE_SIZE , +rte_socket_id ()); + +if (prgdev->dev_data.dev_private ==NULL ) +rte_panic ("Cannot allocate memzone for private " +"device data" ); + + prgdev->device = &pci_dev->device; + prgdev->driver = prgdrv; + + +/* Invoke PMD device initialization function */ + retval = (*prgdrv->prgdev_init)(prgdev); +if (retval ==0 ) +return 0 ; + +PRG_LOG_ERR ("driver %s: prgdev_init(vendor_id=0x%x device_id=0x%x)" +" failed" , pci_drv->driver.name, + (unsigned ) pci_dev->id.vendor_id, + (unsigned ) pci_dev->id.device_id); + +rte_free (prgdev->dev_data.dev_private); + +rte_prgdev_release (prgdev); + +return -ENXIO ; +} + +int +rte_prgdev_pci_remove (struct rte_pci_device *pci_dev) +{ +struct prgdev_driver *prgdrv; +struct rte_prgdev *prgdev; +char prgdev_name[PRGDEV_NAME_MAX_LEN ]; +int ret; + +if (pci_dev ==NULL ) +return -EINVAL ; + +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (-EINVAL ); + +rte_eal_pci_device_name (&pci_dev->addr, prgdev_name, +sizeof (prgdev_name)); + + + prgdev =rte_prgdev_allocated (prgdev_name); +if (prgdev ==NULL ) +return -ENODEV ; + + prgdrv = (struct prgdev_driver *)pci_dev->driver; +if (prgdrv ==NULL ) +return -ENODEV ; + +/* Invoke device uninit function */ +if (*prgdrv->prgdev_uninit) { + ret = (*prgdrv->prgdev_uninit)(prgdev); +if (ret) +return ret; + } + +/* free prgdev device */ +rte_prgdev_release (prgdev); + +rte_free (prgdev->dev_data.dev_private); + +return 0 ; +} + +static uint8_t +prgdev_find_free_dev_slot (void ) +{ +unsigned i; + +for (i =0 ; i <RTE_PRGDEV_MAX_DEVS ; i++) { +if (rte_prgdev_devices[i].attached ==PRGDEV_DETACHED ) +return i; + } +return RTE_PRGDEV_MAX_DEVS ; +} + +static struct rte_prgdev * +rte_prgdev_allocated (char *name) +{ +unsigned i; + +for (i =0 ; i <RTE_PRGDEV_MAX_DEVS ; i++) { +if ((rte_prgdev_devices[i].attached ==PRGDEV_ATTACHED ) && +strcmp (rte_prgdev_devices[i].dev_data.name, name) ==0 ) +return &rte_prgdev_devices[i]; + } +return NULL ; +} + +struct rte_prgdev * +rte_prgdev_allocate (char *name) +{ +uint8_t dev_id; +struct rte_prgdev *prg_dev; + +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (NULL ); + dev_id =prgdev_find_free_dev_slot (); +if (dev_id ==RTE_PRGDEV_MAX_DEVS ) { +PRG_LOG_DEBUG ("Reached maximum number of prgdev numbers" ); +return NULL ; + } + +if (rte_prgdev_allocated (name) !=NULL ) { +PRG_LOG_DEBUG ("Prgdev Device with name %s already allocated!\n" , + name); +return NULL ; + } + + prg_dev = &rte_prgdev_devices[dev_id]; +memset (prg_dev,0 ,sizeof (*prg_dev)); + prg_dev->attached =PRGDEV_ATTACHED ; +snprintf (prg_dev->dev_data.name,sizeof (prg_dev->dev_data.name),"%s" , + name); + prg_dev->dev_data.devid = dev_id; + prg_dev->dev_data.numa_node =rte_socket_id (); + nb_devs++; +return prg_dev; +} + +int +rte_prgdev_release (struct rte_prgdev *prg_dev) +{ +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (-EINVAL ); + +if (prg_dev ==NULL ) +return -EINVAL ; + + prg_dev->attached =PRGDEV_ATTACHED ; + prg_dev->dev_ops =NULL ; + prg_dev->driver =NULL ; + nb_devs--; +return 0 ; +} +
lib/librte_prgdev/rte_prgdev.h +228 -0
240 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH 4/6 prgdev: add prgdev API exposed to application
In reply to Chen Jing D(Mark)Add a series of API and implementations that application can operate on a programmble device. The major functions are download and upload an image to/from device.
--- lib/librte_prgdev/rte_prgdev.c | 226 ++++++++++++++++++++++++++++++++++++++++ lib/librte_prgdev/rte_prgdev.h | 106 +++++++++++++++++++ 2 files changed, 332 insertions(+), 0 deletions(-)
lib/librte_prgdev/rte_prgdev.c +226 -0
@@ -231,3 +231,229 @@ struct rte_prgdev *return 0 ; } +int +rte_prgdev_is_valid_dev (uint8_t dev_id) +{ +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (-EINVAL ); +RTE_PRG_VALID_DEVID_OR_ERR_RET (dev_id, -EINVAL ); + +if (dev_id >=RTE_PRGDEV_MAX_DEVS || + rte_prgdev_devices[dev_id].attached !=PRGDEV_ATTACHED ) +return 0 ; +else +return 1 ; +} + +uint8_t +rte_prgdev_count (void ) +{ +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (-EINVAL ); + +return nb_devs; +} + +static inline int +prgdev_devid_check (uint8_t dev_id,struct rte_prgdev **dev) +{ +/* Not support secondary process to operate on prgdev */ +RTE_PRG_PRIMARY_PROC_OR_ERR_RET (-EINVAL ); +RTE_PRG_VALID_DEVID_OR_ERR_RET (dev_id, -EINVAL ); + +if (dev_id >= nb_devs) { +PRG_LOG_ERR ("Invalid dev_id=%d" , dev_id); +return -EINVAL ; + } + + *dev = &rte_prgdev_devices[dev_id]; +return 0 ; +} + +int +rte_prgdev_info_get (uint8_t dev_id, +struct rte_prgdev_info *info) +{ +struct rte_prgdev *dev; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +memset (info,0 ,sizeof (*info)); + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); + (*dev->dev_ops->prg_infos_get)(dev, info); + + info->pci_dev =RTE_DEV_TO_PCI (dev->device); +if (dev->driver) + info->driver_name = dev->driver->pci_drv.driver.name; +return 0 ; +} + +int +rte_prgdev_open (uint8_t dev_id) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_open, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +if (dev_info.status !=RTE_PRG_STAT_READY ) +return -1 ; + +return (*dev->dev_ops->prg_open)(dev); +} + +int +rte_prgdev_img_download (uint8_t dev_id, +uint8_t *buffer_ptr,uint32_t buf_len) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +if (buffer_ptr ==NULL || buf_len ==0 ) +return -EINVAL ; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_download, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +if (dev_info.status !=RTE_PRG_STAT_OPEN ) +return -1 ; + +return (*dev->dev_ops->prg_download)(dev, buffer_ptr, buf_len); +} + +int +rte_prgdev_img_upload (uint8_t dev_id,uint8_t *buffer_ptr, +uint32_t buf_len,uint32_t *act_len) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +if (buffer_ptr ==NULL || buf_len ==0 || act_len ==NULL ) +return -EINVAL ; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_upload, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +if (dev_info.status !=RTE_PRG_STAT_OPEN ) +return -1 ; + +return (*dev->dev_ops->prg_upload)(dev, buffer_ptr, buf_len, act_len); +} + +int +rte_prgdev_check_stat (uint8_t dev_id,enum rte_prg_fwstat *stat) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_check_stat, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +/* Only can check downloaded image running status after device is open, +* but prgdev doesn't has the capability to check whether an image is +* downloaded prior to this operation. +*/ +if (dev_info.status !=RTE_PRG_STAT_OPEN ) +return -EINVAL ; + +return (*dev->dev_ops->prg_check_stat)(dev, stat); +} + +int +rte_prgdev_close (uint8_t dev_id) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_close, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +if (dev_info.status !=RTE_PRG_STAT_OPEN ) +return -EINVAL ; + +return (*dev->dev_ops->prg_close)(dev); +} + +int +rte_prgdev_bind (uint8_t dev_id) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_bind, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +if (dev_info.status !=RTE_PRG_STAT_READY ) +return -EINVAL ; + +return (*dev->dev_ops->prg_bind)(dev); +} + +int +rte_prgdev_unbind (uint8_t dev_id) +{ +struct rte_prgdev *dev; +struct rte_prgdev_info dev_info; +int ret; + + ret =prgdev_devid_check (dev_id, &dev); +if (ret) +return ret; + +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_infos_get, -ENOTSUP ); +RTE_PRG_FUNC_PTR_OR_ERR_RET (*dev->dev_ops->prg_unbind, -ENOTSUP ); + + (*dev->dev_ops->prg_infos_get)(dev, &dev_info); + +if (dev_info.status !=RTE_PRG_STAT_READY ) +return -EINVAL ; + +return (*dev->dev_ops->prg_unbind)(dev); +}
lib/librte_prgdev/rte_prgdev.h +106 -0
112 lines not on this page · raw message
Signature · 1 line
1.7.7.6
PATCH 5/6 prgdev: add ABI control info
In reply to Chen Jing D(Mark)Add rte_prgdev_version.map file.
--- lib/librte_prgdev/rte_prgdev_version.map | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) create mode 100644 lib/librte_prgdev/rte_prgdev_version.map
lib/librte_prgdev/rte_prgdev_version.map new file +19 -0
@@ -0,0 +1,19 @@ +DPDK_17.05 { + global: + + rte_prgdev_pci_probe; + rte_prgdev_pci_remove; + rte_prgdev_allocate; + rte_prgdev_release; + rte_prgdev_info_get; + rte_prgdev_is_valid_dev; + rte_prgdev_open; + rte_prgdev_img_download; + rte_prgdev_img_upload; + rte_prgdev_check_stat; + rte_prgdev_close; + rte_prgdev_bind; + rte_prgdev_unbind; + + local: *; +};
Signature · 1 line
1.7.7.6
PATCH 6/6 doc: introduction to prgdev
In reply to Chen Jing D(Mark)From: "Chen, Jing D" <[email protected]>
This is the documentation to describe what prgdev is, how to use prgdev API and accomplish an image download.
--- doc/guides/prog_guide/index.rst | 1 + doc/guides/prog_guide/prgdev_lib.rst | 465 ++++++++++++++++++++++++++++++++++ 2 files changed, 466 insertions(+), 0 deletions(-) create mode 100644 doc/guides/prog_guide/prgdev_lib.rst
doc/guides/prog_guide/index.rst +1 -0
@@ -60,6 +60,7 @@ Programmer's Guide qos_framework power_man packet_classif_access_ctrl + prgdev_lib packet_framework vhost_lib port_hotplug_framework
doc/guides/prog_guide/prgdev_lib.rst new file +465 -0
465 lines not on this page · raw message
Signature · 1 line
1.7.7.6
Re: [PATCH 6/6] doc: introduction to prgdev
2017-03-02 12:03, Chen Jing D:
Quoted 2 lines
+Overview
+========
I think the first review pass of this series must be focused on the overview you give here (thanks for the detailed explanations).
I'll try to sum up while commenting.
[...]
The target is programmable devices.
doc/guides/prog_guide/prgdev_lib.rst line 17
Quoted 2 lines
doc/guides/prog_guide/prgdev_lib.rst new file +2
-0+The major purpose of prgdev is to help DPDK users to load/upgrade RTL images +for FPGA devices, or upgrade firmware for programmble NICs.
This is a control plane feature.
You want to have it in DPDK to allow dynamic programmation while running the device, right?
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+When the set of APIs is introduced, a general question is why we need it in +DPDK community?
Good question :)
[...]
Quoted 6 lines
doc/guides/prog_guide/prgdev_lib.rst new file +6
-0+Any devices, having the capability to store/load a piece of info to/from +the deivce then changed hardware behavior, and applicable to prgdev programming +model, could be registered as a prgdev device. + +The device can be programmed (dynamic) within DPDK or have been prior programmed +(static) prior to a DPDK application being launched.
[...]
doc/guides/prog_guide/prgdev_lib.rst line 74
Quoted 5 lines
doc/guides/prog_guide/prgdev_lib.rst new file +5
-0+Besides the simple API to upload/download image, the prgdev also introduces a +mechanism internally to switch drivers and register/unregister device on the +fly. With this mechanism, apps can use the programmable device, unbind other +personalities on demand, then program it and bind it back with new personalities. +Apps can follow below examples to simply complete the whole process.
I disagree about the specific bind/unbind for prgdev. We must improve binding inside DPDK for every devices.
doc/guides/prog_guide/prgdev_lib.rst line 80
Quoted 5 lines
doc/guides/prog_guide/prgdev_lib.rst new file +5
-0+Note that bind/unbind actions are different concept from that a whole device +attach/detach. For example, ``rte_eal_dev_detach()``, which will try to detach the +drivers with device and remove the whole device from specific class of devices +(ethdev, for example). Then, the whole device is invisible until a new 'probe' +is activated.
I do not understand.
doc/guides/prog_guide/prgdev_lib.rst line 92
Quoted 11 lines
doc/guides/prog_guide/prgdev_lib.rst new file +11
-0+During the whole procedure of image upload/download, prgdev handler is always +valid and apps can use it operate on programmable device. The reason why unbind +is necessary is it may break the hardware when programming is in progress while +other functions are active. Using programmble NIC as an example, it's a little +impossible to receive/forward packets for hardware while updating firmware. In +this case, apps need to detach ethdev function before firmware upgrading. Again, +prgdev handler is still valid, it's function-level detach, different from +device-level detach. After finishing image download, original function needs to +attach back, either use same or different drivers, depends on personalities +changed or not. For a programmble NIC, the driver may be the same. For FPGA, it +may not, see below examples to get more details.
If the personality of the device is changed, it must be seen as a new device from e.g. the ethdev point of view, while keeping the same prgdev device. In other words, a device can have several interfaces at the same time (ethdev, cryptodev, eventdev, prgdev, whatever).
I think we can dynamically create/destroy some interfaces while keeping track of the underlying device.
doc/guides/prog_guide/prgdev_lib.rst line 102
Quoted 9 lines
doc/guides/prog_guide/prgdev_lib.rst new file +9
-0+Another reason to provide bind/unbind action is programmble devices, like FPGA, +are not identified driver by 'vendor ID' and 'device ID', they might not be +changed in all the ways, even FPGA is fully programmed. So, it depends on +internal mechanism of FPGA, not 'vendor ID' and 'device ID' to identify proper +drivers, either a register value or signature, depending on FPGA hardware +design. In this case, EAL or other bus driver doesn't have the capability to +identify proper driver for FPGA device. With prgdev introduced, while FPGA is +always a prgdev, FPGA can use prgdev as primary driver, to find proper function +driver.
You mean prgdev should help the bus layer to map the right driver interface? It looks weird and dangerous. The standard way to identify a PCI device is to look at its IDs. Other unknown methods must be strongly discussed.
Re: [PATCH 6/6] doc: introduction to prgdev
Hi, Thomas,
Quoted 22 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, March 6, 2017 11:27 PM
To: Chen, Jing D <[email protected]>
Cc: [email protected]; Liang, Cunming <[email protected]>; Rogers, Gerald <[email protected]>; Wiles, Keith <[email protected]>; Richardson, Bruce <[email protected]>; Mcnamara, John <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 6/6] doc: introduction to prgdev2017-03-02 12:03, Chen Jing D:
Quoted 2 lines
+Overview
+========I think the first review pass of this series must be focused on the overview you give here (thanks for the detailed explanations).
I'll try to sum up while commenting.
[...]
The target is programmable devices.
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+The major purpose of prgdev is to help DPDK users to load/upgrade RTL +images for FPGA devices, or upgrade firmware for programmble NICs.This is a control plane feature.
You want to have it in DPDK to allow dynamic programmation while running the device, right?
Exactly right.
Quoted 21 lines
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+When the set of APIs is introduced, a general question is why we need +it in DPDK community?Good question :)
[...]
Quoted 7 lines
(quoted diff) +7
-0+Any devices, having the capability to store/load a piece of info +to/from the deivce then changed hardware behavior, and applicable to +prgdev programming model, could be registered as a prgdev device. + +The device can be programmed (dynamic) within DPDK or have been prior +programmed +(static) prior to a DPDK application being launched.[...]
Review
Quoted 4 lines
(quoted diff) +4
-0+Besides the simple API to upload/download image, the prgdev also +introduces a mechanism internally to switch drivers and +register/unregister device on the fly. With this mechanism, apps can +use the programmable device, unbind other personalities on demand,then program it and bind it back with new personalities.
Quoted 4 lines
Quoted 1 line
+Apps can follow below examples to simply complete the whole process.
I disagree about the specific bind/unbind for prgdev. We must improve binding inside DPDK for every devices.
First of all, let us try to imagine what is the safe status for device before apps intending to download some image to it - apps wouldn't operate on the device, any behaviors like configuring registers, receive/transmit data may impair the device or make the download failed.
Following first answer to prevent app accessing device during image downloading, how can we achieve that? Detach drivers with device is a smart idea, right? But the problem is how can apps use prgdev API to download image after all drivers detached with the device?
So, the final question is how can we just detached others driver except prgdev one? I can't find answer in current DPDK framework, that's why I'd like to introduce bind/unbind functions to detach other drivers from the device.
I'm open to this problem. If any suggestion or mechanism can help on it, I can remove these 2.
BTW, not all devices or image download actions need the device to detach the device, depending on hardware implementation.
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+Note that bind/unbind actions are different concept from that a whole +device attach/detach. For example, ``rte_eal_dev_detach()``, which +will try to detach the drivers with device and remove the whole +device from specific class of devices (ethdev, for example). Then, thewhole device is invisible until a new 'probe'
Quoted 1 line
+is activated.
I do not understand.
See above explanations.
Quoted 15 lines
Review
Quoted 12 lines
(quoted diff) +11
-0+During the whole procedure of image upload/download, prgdev handler +is always valid and apps can use it operate on programmable device. +The reason why unbind is necessary is it may break the hardware when +programming is in progress while other functions are active. Using +programmble NIC as an example, it's a little impossible to +receive/forward packets for hardware while updating firmware. In this +case, apps need to detach ethdev function before firmware upgrading. +Again, prgdev handler is still valid, it's function-level detach, +different from device-level detach. After finishing image download, +original function needs to attach back, either use same or different +drivers, depends on personalities changed or not. For a programmble NIC,the driver may be the same. For FPGA, it may not, see below examples to get more details.
Quoted 6 lines
If the personality of the device is changed, it must be seen as a new device from e.g. the ethdev point of view, while keeping the same prgdev device. In other words, a device can have several interfaces at the same time (ethdev, cryptodev, eventdev, prgdev, whatever).
I think we can dynamically create/destroy some interfaces while keeping track of the underlying device.
Fully agree. But current PCI device with 'vendor_id' and 'device_id' ony can be bind to single driver at a time. So I add 'rte_prgdev_allocate/release' to support register/unregister prgdev dynamically without BDF.
Quoted 12 lines
Review
Quoted 10 lines
(quoted diff) +9
-0+Another reason to provide bind/unbind action is programmble devices, +like FPGA, are not identified driver by 'vendor ID' and 'device ID', +they might not be changed in all the ways, even FPGA is fully +programmed. So, it depends on internal mechanism of FPGA, not 'vendor +ID' and 'device ID' to identify proper drivers, either a register +value or signature, depending on FPGA hardware design. In this case, +EAL or other bus driver doesn't have the capability to identify +proper driver for FPGA device. With prgdev introduced, while FPGA is +always a prgdev, FPGA can use prgdev as primary driver, to find properfunction driver.
Quoted 3 lines
You mean prgdev should help the bus layer to map the right driver interface? It looks weird and dangerous. The standard way to identify a PCI device is to look at its IDs. Other unknown methods must be strongly discussed.
For programmable Ethernet device, it's not truce. But for FPGA, it's. When FPGA is produced, the device ID indicate what model it is and won't be changed anyway, even being reprogrammed. It used some not-generic mechanism, like AFU id to distinguish the personalities. So, for FPGA, a prgdev driver can be used as primary driver to identify personalities and then register to specific devices.
Re: [PATCH 6/6] doc: introduction to prgdev
Quoted 131 lines · Jing D
Hi, Thomas,
Quoted 22 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Monday, March 6, 2017 11:27 PM
To: Chen, Jing D <[email protected]>
Cc: [email protected]; Liang, Cunming <[email protected]>; Rogers, Gerald <[email protected]>; Wiles, Keith <[email protected]>; Richardson, Bruce <[email protected]>; Mcnamara, John <[email protected]>
Subject: Re: [dpdk-dev] [PATCH 6/6] doc: introduction to prgdev2017-03-02 12:03, Chen Jing D:
Quoted 2 lines
+Overview
+========I think the first review pass of this series must be focused on the overview you give here (thanks for the detailed explanations).
I'll try to sum up while commenting.
[...]
The target is programmable devices.Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+The major purpose of prgdev is to help DPDK users to load/upgrade RTL +images for FPGA devices, or upgrade firmware for programmble NICs.This is a control plane feature.
You want to have it in DPDK to allow dynamic programmation while running the device, right?Exactly right.
Quoted 21 lines
[...]
Review
Quoted 2 lines
(quoted diff) +2
-0+When the set of APIs is introduced, a general question is why we need +it in DPDK community?Good question :)
[...]
Quoted 7 lines
(quoted diff) +7
-0+Any devices, having the capability to store/load a piece of info +to/from the deivce then changed hardware behavior, and applicable to +prgdev programming model, could be registered as a prgdev device. + +The device can be programmed (dynamic) within DPDK or have been prior +programmed +(static) prior to a DPDK application being launched.[...]
Review
Quoted 4 lines
(quoted diff) +4
-0+Besides the simple API to upload/download image, the prgdev also +introduces a mechanism internally to switch drivers and +register/unregister device on the fly. With this mechanism, apps can +use the programmable device, unbind other personalities on demand,then program it and bind it back with new personalities.
Quoted 4 lines
Quoted 1 line
+Apps can follow below examples to simply complete the whole process.
I disagree about the specific bind/unbind for prgdev. We must improve binding inside DPDK for every devices.
First of all, let us try to imagine what is the safe status for device before apps intending to download some image to it - apps wouldn't operate on the device, any behaviors like configuring registers, receive/transmit data may impair the device or make the download failed.
Following first answer to prevent app accessing device during image downloading, how can we achieve that? Detach drivers with device is a smart idea, right? But the problem is how can apps use prgdev API to download image after all drivers detached with the device?
So, the final question is how can we just detached others driver except prgdev one? I can't find answer in current DPDK framework, that's why I'd like to introduce bind/unbind functions to detach other drivers from the device.I'm open to this problem. If any suggestion or mechanism can help on it, I can remove these 2.
BTW, not all devices or image download actions need the device to detach the device, depending on hardware implementation.
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+Note that bind/unbind actions are different concept from that a whole +device attach/detach. For example, ``rte_eal_dev_detach()``, which +will try to detach the drivers with device and remove the whole +device from specific class of devices (ethdev, for example). Then, thewhole device is invisible until a new 'probe'
Quoted 1 line
+is activated.
I do not understand.
See above explanations.
Quoted 15 lines
Review
Quoted 12 lines
(quoted diff) +11
-0+During the whole procedure of image upload/download, prgdev handler +is always valid and apps can use it operate on programmable device. +The reason why unbind is necessary is it may break the hardware when +programming is in progress while other functions are active. Using +programmble NIC as an example, it's a little impossible to +receive/forward packets for hardware while updating firmware. In this +case, apps need to detach ethdev function before firmware upgrading. +Again, prgdev handler is still valid, it's function-level detach, +different from device-level detach. After finishing image download, +original function needs to attach back, either use same or different +drivers, depends on personalities changed or not. For a programmble NIC,the driver may be the same. For FPGA, it may not, see below examples to get more details.
Quoted 6 lines
If the personality of the device is changed, it must be seen as a new device from e.g. the ethdev point of view, while keeping the same prgdev device. In other words, a device can have several interfaces at the same time (ethdev, cryptodev, eventdev, prgdev, whatever).
I think we can dynamically create/destroy some interfaces while keeping track of the underlying device.Fully agree. But current PCI device with '
vendor_id' and 'device_id' ony can be bind to single driver at a time. So I add 'rte_prgdev_allocate/release' to support register/unregister prgdev dynamically without BDF.Quoted 12 lines
Review
Quoted 10 lines
(quoted diff) +9
-0+Another reason to provide bind/unbind action is programmble devices, +like FPGA, are not identified driver by 'vendor ID' and 'device ID', +they might not be changed in all the ways, even FPGA is fully +programmed. So, it depends on internal mechanism of FPGA, not 'vendor +ID' and 'device ID' to identify proper drivers, either a register +value or signature, depending on FPGA hardware design. In this case, +EAL or other bus driver doesn't have the capability to identify +proper driver for FPGA device. With prgdev introduced, while FPGA is +always a prgdev, FPGA can use prgdev as primary driver, to find properfunction driver.
Quoted 3 lines
You mean prgdev should help the bus layer to map the right driver interface? It looks weird and dangerous. The standard way to identify a PCI device is to look at its IDs. Other unknown methods must be strongly discussed.
Quoted 5 lines
For programmable Ethernet device, it's not truce. But for FPGA, it's. When FPGA is produced, the device ID indicate what model it is and won't be changed anyway, even being reprogrammed. It used some not-generic mechanism, like AFU id to distinguish the personalities. So, for FPGA, a prgdev driver can be used as primary driver to identify personalities and then register to specific devices.
Sounds like we would need an FPGA bus driver in that case. I think that would be a better solution than having a specific device driver loading other drivers.
/Bruce
Re: [PATCH 6/6] doc: introduction to prgdev
2017-03-07 11:12, Bruce Richardson:
Quoted 32 lines · Jing D
Quoted 31 lines
From: Thomas Monjalon
Quoted 13 lines
Quoted 7 lines
(quoted diff) +7
-0+Any devices, having the capability to store/load a piece of info +to/from the deivce then changed hardware behavior, and applicable to +prgdev programming model, could be registered as a prgdev device. + +The device can be programmed (dynamic) within DPDK or have been prior +programmed +(static) prior to a DPDK application being launched.[...]
Review
Quoted 4 lines
(quoted diff) +4
-0+Besides the simple API to upload/download image, the prgdev also +introduces a mechanism internally to switch drivers and +register/unregister device on the fly. With this mechanism, apps can +use the programmable device, unbind other personalities on demand,then program it and bind it back with new personalities.
Quoted 4 lines
Quoted 1 line
+Apps can follow below examples to simply complete the whole process.
I disagree about the specific bind/unbind for prgdev. We must improve binding inside DPDK for every devices.
First of all, let us try to imagine what is the safe status for device before apps intending to download some image to it - apps wouldn't operate on the device, any behaviors like configuring registers, receive/transmit data may impair the device or make the download failed.
Following first answer to prevent app accessing device during image downloading, how can we achieve that? Detach drivers with device is a smart idea, right? But the problem is how can apps use prgdev API to download image after all drivers detached with the device?
So, the final question is how can we just detached others driver except prgdev one? I can't find answer in current DPDK framework, that's why I'd like to introduce bind/unbind functions to detach other drivers from the device.
Quoted 5 lines
Quoted 5 lines
I'm open to this problem. If any suggestion or mechanism can help on it, I can remove these 2.
BTW, not all devices or image download actions need the device to detach the device, depending on hardware implementation.
Thanks for the explanations.
It sounds interesting.
Quoted 21 lines
Quoted 15 lines
Quoted 11 lines
Review
Quoted 9 lines
(quoted diff) +9
-0+Another reason to provide bind/unbind action is programmble devices, +like FPGA, are not identified driver by 'vendor ID' and 'device ID', +they might not be changed in all the ways, even FPGA is fully +programmed. So, it depends on internal mechanism of FPGA, not 'vendor +ID' and 'device ID' to identify proper drivers, either a register +value or signature, depending on FPGA hardware design. In this case, +EAL or other bus driver doesn't have the capability to identify +proper driver for FPGA device. With prgdev introduced, while FPGA is +always a prgdev, FPGA can use prgdev as primary driver, to find properfunction driver.
Quoted 3 lines
You mean prgdev should help the bus layer to map the right driver interface? It looks weird and dangerous. The standard way to identify a PCI device is to look at its IDs. Other unknown methods must be strongly discussed.
Quoted 5 lines
For programmable Ethernet device, it's not truce. But for FPGA, it's. When FPGA is produced, the device ID indicate what model it is and won't be changed anyway, even being reprogrammed. It used some not-generic mechanism, like AFU id to distinguish the personalities. So, for FPGA, a prgdev driver can be used as primary driver to identify personalities and then register to specific devices.
Quoted 3 lines
Sounds like we would need an FPGA bus driver in that case. I think that would be a better solution than having a specific device driver loading other drivers.
Good suggestion. What do you think of a FPGA bus to consider more parameters than the PCI BDF when matching a device driver?
How other systems manage the drivers for a FPGA-programmed device?
Re: [PATCH 6/6] doc: introduction to prgdev
In reply to Bruce RichardsonQuoted 24 lines
Quoted 13 lines
Quoted 13 lines
Review
Quoted 11 lines
(quoted diff) +10
-0+Another reason to provide bind/unbind action is programmble +devices, like FPGA, are not identified driver by 'vendor ID' and +'device ID', they might not be changed in all the ways, even FPGA +is fully programmed. So, it depends on internal mechanism of +FPGA, not 'vendor ID' and 'device ID' to identify proper drivers, +either a register value or signature, depending on FPGA hardware +design. In this case, EAL or other bus driver doesn't have the +capability to identify proper driver for FPGA device. With prgdev +introduced, while FPGA is always a prgdev, FPGA can use prgdev as +primary driver, to find properfunction driver.
Quoted 1 line
Quoted 1 line
You mean prgdev should help the bus layer to map the right driver
interface?
Quoted 2 lines
Quoted 2 lines
It looks weird and dangerous. The standard way to identify a PCI device is to look at its IDs. Other unknown methods must be strongly
discussed.
Quoted 6 lines
For programmable Ethernet device, it's not truce. But for FPGA, it's. When FPGA is produced, the device ID indicate what model it is and won't be changed anyway, even being reprogrammed. It used some not-generic mechanism, like AFU id to distinguish the personalities. So, for FPGA, a prgdev driver can be used as primary driver to identify
Quoted 5 lines
personalities and then register to specific devices.
Sounds like we would need an FPGA bus driver in that case. I think that would be a better solution than having a specific device driver loading other drivers.
I don't object to introduce a pseudo bus for FPGA, but it's a matter of work that FPGA driver needs to consider, not in scope of prgdev.
Besides that, I can see DPDK EAL will do other bus probe first, then PCI bus probe, which is not friendly to introduce pseudo bus for an actual PCI device.
Quoted 1 line
/Bruce