Introduce Intel FPGA BUS
PATCH v6 3/5 iFPGA: Add Intel FPGA BUS Rawdev Driver
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.
--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 597 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 1 + 7 files changed, 677 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
config/common_base +1 -0
@@ -151,6 +151,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y # Compile the Intel FPGA bus # CONFIG_RTE_LIBRTE_IFPGA_BUS=y +CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y # # Compile ARK PMD
drivers/raw/Makefile +1 -0
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk # DIRS-$(<configuration>) += <directory> DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifpga_rawdev.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_kvargs +LDLIBS += -lrte_bus_pci +LDLIBS += -lrte_bus_ifpga + +EXPORT_MAP := rte_ifpga_rawdev_version.map + +LIBABIVER := 1 + +VPATH += $(SRCDIR)/base + +include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +597 -0
597 lines not on this page · raw message
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_RAWDEV_PMD_FUNC_TRACE () IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>") + +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY , +IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) +{ +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +1 -0
@@ -249,6 +249,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev endif # CONFIG_RTE_LIBRTE_RAWDEV
Signature · 1 line
1.8.3.1
Re: [PATCH v6 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver
Hello Rosen,
Sorry for multiple review iterations, but, in the v7, can you take care of these as well:
Quoted 22 lines · Rosen
From: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on
librte_rawdevlibrary.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Yanglong Wu <[email protected]>Signed-off-by Figo zhang <[email protected]>--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 597 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 1 + 7 files changed, 677 insertions(+)create mode 100644
drivers/raw/ifpga_rawdev/Makefile
create mode 100644drivers/raw/ifpga_rawdev/ifpga_rawdev.ccreate mode 100644drivers/raw/ifpga_rawdev/ifpga_rawdev.hcreate mode 100644drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
[...]
Quoted 20 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +20
-0+static int +fpga_pr (struct rte_rawdev *raw_dev,u32 port_id,u64 *buffer,u32 size, +u64 *status) +{ + +struct opae_adapter *adapter; +struct opae_manager *mgr; +struct opae_accelerator *acc; +struct opae_bridge *br; +int ret; + + adapter =ifpga_rawdev_get_priv (raw_dev); +if (!adapter) +return -ENODEV ; + + mgr =opae_adapter_get_mgr (adapter); +if (!mgr) +return -ENODEV ; + + acc =opae_adapter_get_acc (adapter, port_id);
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 197
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+if (!acc) +return -ENODEV ; + + br =opae_acc_get_br (acc); +if (!br) +return -ENODEV ; + + ret =opae_manager_flash (mgr, port_id, buffer, size, status); +if (ret) { +printf ("%s pr error %d\n" , __func__, ret);
Please use the debugging or error macros.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 201
Quoted 4 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +4
-0+return ret; + } + +usleep (100 );
Hmm, is that some caveat or a stray line left from some debugging?
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 204
Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3
-0+ ret =opae_bridge_reset (br); +if (ret) { +printf ("%s reset port:%d error %d\n" , __func__, port_id, ret);
Same - debugging/error macros.
Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13
-0+return ret; + } + +return ret; +} + +static int rte_fpga_do_pr (struct rte_rawdev *rawdev,int port_id, +const char *file_name) +{ +struct stat file_stat; +int file_fd; +int ret =0 ; +u32 buffer_size;
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 227
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+void *buffer; +u64 pr_error; + +if (!file_name) +return -EINVAL ; + + file_fd =open (file_name,O_RDONLY ); +if (file_fd <0 ) { +printf ("%s: open file error: %s\n" , __func__, file_name); +printf ("Message : %s\n" ,strerror (errno));
Same - debug/error macros
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 232
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+return -EINVAL ; + } + ret =stat (file_name, &file_stat); +if (ret) { +printf ("stat on bitstream file failed: %s\n" , file_name);
One more (same is applicable across the file).
Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13
-0+return -EINVAL ; + } + buffer_size = file_stat.st_size; +printf ("bitstream file size: %u\n" , buffer_size); + buffer =rte_malloc (NULL , buffer_size,0 ); +if (!buffer) { + ret = -ENOMEM ; + goto close_fd; + } + +/*read the raw data*/ +if (buffer_size !=read (file_fd, (void *)buffer, buffer_size)) { + ret = -EINVAL ;
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 255
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ goto free_buffer; + } + +/*do PR now*/ + ret =fpga_pr (rawdev, port_id, buffer, buffer_size, &pr_error); +printf ("downloading to device port %d....%s.\n" , port_id, + ret ?"failed" :"success" ); +if (ret) { + ret = -EINVAL ; +//raw_dev->ops->show_pr_error(pr_error);
I am guessing this is stray from some debugging attempt. Same for the printf above.
Quoted 28 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +28
-0+ goto free_buffer; + } + +free_buffer: +if (buffer) +rte_free (buffer); +close_fd: +close (file_fd); + file_fd =0 ; +return ret; +} + +static int ifpga_rawdev_pr (struct rte_rawdev *dev, +rte_rawdev_obj_t pr_conf) +{ +struct opae_adapter *adapter; +struct rte_afu_pr_conf *afu_pr_conf; +int ret; +struct uuid uuid; +struct opae_accelerator *acc; + +IFPGA_RAWDEV_PMD_FUNC_TRACE (); + + adapter =ifpga_rawdev_get_priv (dev); +if (!adapter) +return -ENODEV ; + +if (!pr_conf)
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 293
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+return -EINVAL ; + + afu_pr_conf = pr_conf; + +if (afu_pr_conf->pr_enable) { + ret =rte_fpga_do_pr (dev, + afu_pr_conf->afu_id.port, + afu_pr_conf->bs_path); +if (ret) { +printf ("do pr error %d\n" , ret);
One more
Quoted 8 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +8
-0+return ret; + } + } + + acc =opae_adapter_get_acc (adapter, afu_pr_conf->afu_id.port); +if (!acc) +return -ENODEV ; +
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 311
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ ret =opae_acc_get_uuid (acc, &uuid); +if (ret) +return ret; + +memcpy (&afu_pr_conf->afu_id.uuid_low, uuid.b,sizeof (u64)); +memcpy (&afu_pr_conf->afu_id.uuid_high, uuid.b +8 ,sizeof (u64)); + +printf ("%s: uuid_l=0x%lx, uuid_h=0x%lx\n" , __func__, + (u64 )afu_pr_conf->afu_id.uuid_low, + (u64 )afu_pr_conf->afu_id.uuid_high);
debug/error macros
Quoted 48 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +48
-0+ +return 0 ; +} + +static const struct rte_rawdev_ops ifpga_rawdev_ops = { + .dev_info_get = ifpga_rawdev_info_get, + .dev_configure =NULL , + .dev_start = ifpga_rawdev_start, + .dev_stop = ifpga_rawdev_stop, + .dev_close = ifpga_rawdev_close, + .dev_reset = ifpga_rawdev_reset, + + .queue_def_conf =NULL , + .queue_setup =NULL , + .queue_release =NULL , + + .attr_get =NULL , + .attr_set =NULL , + + .enqueue_bufs =NULL , + .dequeue_bufs =NULL , + + .dump =NULL , + + .xstats_get =NULL , + .xstats_get_names =NULL , + .xstats_get_by_name =NULL , + .xstats_reset =NULL , + + .firmware_status_get =NULL , + .firmware_version_get =NULL , + .firmware_load = ifpga_rawdev_pr, + .firmware_unload =NULL , + + .dev_selftest =NULL , +}; + +static int +ifpga_rawdev_create (struct rte_pci_device *pci_dev, +int socket_id) +{ +int ret =0 ; +struct rte_rawdev *rawdev =NULL ; +struct opae_adapter *adapter; +struct opae_manager *mgr; +struct opae_adapter_data_pci *data; +char name[RTE_RAWDEV_NAME_MAX_LEN ]; +int i;
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 369
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ +if (!pci_dev) { +IFPGA_RAWDEV_PMD_ERR ("Invalid pci_dev of the device!" ); + ret = -EINVAL ; + goto cleanup; + } + +memset (name,0 ,sizeof (name)); +snprintf (name,RTE_RAWDEV_NAME_MAX_LEN ,"IFPGA:%x:%02x.%x" , + pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);
Alignment issue... 'pci_dev->addr.bus ... ' would start from underneath arguments of snprintf.
Quoted 6 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +6
-0+ +IFPGA_RAWDEV_PMD_INFO ("Init %s on NUMA node %d" , name,rte_socket_id ()); + +/* Allocate device structure */ + rawdev =rte_rawdev_pmd_allocate (name,sizeof (struct opae_adapter ), + socket_id);
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 385
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+if (rawdev ==NULL ) { +IFPGA_RAWDEV_PMD_ERR ("Unable to allocate rawdevice" ); + ret = -EINVAL ; + goto cleanup; + } + +/* alloc OPAE_FPGA_PCI data to register to OPAE hardware level API */ + data =opae_adapter_data_alloc (OPAE_FPGA_PCI ); +if (!data) +return -ENOMEM ;
What about jumping to cleanup here? (pmd_release())
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ +/* init opae_adapter_data_pci for device specific information */ +for (i =0 ; i <PCI_MAX_RESOURCE ; i++) { + data->region[i].phys_addr = pci_dev->mem_resource[i].phys_addr; + data->region[i].len = pci_dev->mem_resource[i].len;
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 400
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ data->region[i].addr = pci_dev->mem_resource[i].addr; + } + data->device_id = pci_dev->id.device_id; + data->vendor_id = pci_dev->id.vendor_id; + +/* create a opae_adapter based on above device data */ + adapter =opae_adapter_alloc (pci_dev->device.name, data); +if (!adapter) { +opae_adapter_data_free (data); +return -ENOMEM ;
Same - you are not performing cleanup here.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 412
Quoted 12 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +12
-0+ } + + rawdev->dev_ops = &ifpga_rawdev_ops; + rawdev->device = &pci_dev->device; + rawdev->driver_name = pci_dev->device.driver->name; + + rawdev->dev_private = adapter; + +/* must enumerate the adapter before use it */ + ret =opae_adapter_enumerate (adapter); +if (ret) +return ret;
Cleanup to be performed here.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 417
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ +/* set opae_manager to rawdev */ + mgr =opae_adapter_get_mgr (adapter); +if (mgr) { +/*PF function*/
/*<space>PF function<space>*/
Quoted 50 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +50
-0+IFPGA_RAWDEV_PMD_INFO ("this is a PF function" ); + } + +return ret; + +cleanup: +if (rawdev) +rte_rawdev_pmd_release (rawdev); + +return ret; +} + +static int +ifpga_rawdev_destroy (struct rte_pci_device *pci_dev) +{ +int ret; +struct rte_rawdev *rawdev; +char name[RTE_RAWDEV_NAME_MAX_LEN ]; +struct opae_adapter *adapter; + +if (!pci_dev) { +IFPGA_RAWDEV_PMD_ERR ("Invalid pci_dev of the device!" ); + ret = -EINVAL ; +return ret; + } + +memset (name,0 ,sizeof (name)); +snprintf (name,RTE_RAWDEV_NAME_MAX_LEN ,"IFPGA:%x:%02x.%x" , + pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); + +IFPGA_RAWDEV_PMD_INFO ("Closing %s on NUMA node %d" , + name,rte_socket_id ()); + + rawdev =rte_rawdev_pmd_get_named_dev (name); +if (!rawdev) { +IFPGA_RAWDEV_PMD_ERR ("Invalid device name (%s)" , name); +return -EINVAL ; + } + + adapter =ifpga_rawdev_get_priv (rawdev); +if (!adapter) +return -ENODEV ; + +opae_adapter_data_free (adapter->data); +opae_adapter_free (adapter); + +/* rte_rawdev_close is called by pmd_release */ + ret =rte_rawdev_pmd_release (rawdev); +if (ret) +IFPGA_RAWDEV_PMD_DEBUG ("Device cleanup failed" );
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 477
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ +return 0 ; +} + +static int +ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, +struct rte_pci_device *pci_dev) +{ + +printf ("## %s\n" , __func__);
One more.
Quoted 75 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +75
-0+return ifpga_rawdev_create (pci_dev,rte_socket_id ()); +} + +static int ifpga_rawdev_pci_remove (struct rte_pci_device *pci_dev) +{ +return ifpga_rawdev_destroy (pci_dev); +} + +static struct rte_pci_driver rte_ifpga_rawdev_pmd = { + .id_table = pci_ifpga_map, + .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC , + .probe = ifpga_rawdev_pci_probe, + .remove = ifpga_rawdev_pci_remove, +}; + +RTE_PMD_REGISTER_PCI (ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd); +RTE_PMD_REGISTER_PCI_TABLE (ifpga_rawdev_pci_driver, rte_ifpga_rawdev_pmd); +RTE_PMD_REGISTER_KMOD_DEP (ifpga_rawdev_pci_driver,"* igb_uio | uio_pci_generic | vfio-pci" ); + +RTE_INIT (ifpga_rawdev_init_log); +static void +ifpga_rawdev_init_log (void ) +{ + ifpga_rawdev_logtype =rte_log_register ("driver.raw.init" ); +if (ifpga_rawdev_logtype >=0 ) +rte_log_set_level (ifpga_rawdev_logtype,RTE_LOG_NOTICE ); +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +static int +ifpga_cfg_probe (struct rte_vdev_device *dev) +{ +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +int port; +char *name =NULL ; +char dev_name[RTE_RAWDEV_NAME_MAX_LEN +8 ]; + + devargs = dev->device.devargs; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_RAWDEV_PMD_LOG (ERR ,"error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &ifpga_get_string_arg, &name) <0 ) { +IFPGA_RAWDEV_PMD_ERR ("error to parse %s" , +IFPGA_ARG_NAME ); + goto end; + } + }else { +IFPGA_RAWDEV_PMD_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist, +IFPGA_ARG_PORT , + &ifpga_get_integer32_arg, + &port) <0 ) { +IFPGA_RAWDEV_PMD_ERR ("error to parse %s" , +IFPGA_ARG_PORT );
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 562
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ goto end; + } + }else { +IFPGA_RAWDEV_PMD_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +memset (dev_name,0 ,sizeof (dev_name)); + snprintf(dev_name, (RTE_RAWDEV_NAME_MAX_LEN+8), "%d|%s",
Why did you do this? (adding 8 to RTE_RAWDEV_NAME_MAX_LEN)? Just add a patch to increase the value of RTE_RAWDEV_NAME_MAX_LEN.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 567
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ port, name); + +rte_eal_hotplug_add (RTE_STR (IFPGA_BUS_NAME ), + dev_name, + devargs->args);
Seems to be some alignment issue here...
Quoted 38 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +30
-0+end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +static int +ifpga_cfg_remove (struct rte_vdev_device *vdev) +{ +IFPGA_RAWDEV_PMD_INFO ("Remove ifpga_cfg %p" , + vdev); + +return 0 ; +} + +static struct rte_vdev_driver ifpga_cfg_driver = { + .probe = ifpga_cfg_probe, + .remove = ifpga_cfg_remove, +}; + +RTE_PMD_REGISTER_VDEV (net_ifpga_cfg, ifpga_cfg_driver); +RTE_PMD_REGISTER_ALIAS (net_ifpga_cfg, ifpga_cfg); +RTE_PMD_REGISTER_PARAM_STRING (net_ifpga_cfg, +"bdf=<string> " +"port=<int> " +"afu_bts=<path>" ); +drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +2
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation
drivers/raw/ifpga_rawdev/ifpga_rawdev.h line 12
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +10
-0+*/ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \ + __func__, ##args)
Just a trivial comment - you want all your logs, whether INFO, ERROR etc to be appended with function name? Its your choice, but ideally you should separate.
Quoted 41 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +25
-0+ +#define IFPGA_RAWDEV_PMD_FUNC_TRACE () IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>") + +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY , +IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) +{ +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */ drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4
-0@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};mk/rte.app.mk +0
-0
mk/rte.app.mk endif # CONFIG_RTE_LIBRTE_EVENTDEV · line 255
Quoted 7 lines
mk/rte.app.mk +1
-0@@ -249,6 +249,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev endif # CONFIG_RTE_LIBRTE_RAWDEV
How fast can you fix and push? I can spare time tomorrow (5/May) to re-review, if you can push by then. It might help in merging next week.
-
Shreyansh
Re: [PATCH v6 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver
Quoted 600 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Friday, May 4, 2018 5:15 PM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v6 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverHello Rosen,
Sorry for multiple review iterations, but, in the v7, can you take care of these as well:
Quoted 5 lines · Rosen
From: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on
librte_rawdevlibrary.Quoted 8 lines
Signed-off-by Rosen Xu <[email protected]>Signed-off-by Yanglong Wu <[email protected]>Signed-off-by Figo zhang <[email protected]>--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 597+++++++++++++++++++++
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 1 + 7 files changed, 677 insertions(+)create mode 100644
drivers/raw/ifpga_rawdev/Makefilecreate mode 100644drivers/raw/ifpga_rawdev/ifpga_rawdev.ccreate mode 100644drivers/raw/ifpga_rawdev/ifpga_rawdev.hcreate mode 100644drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map[...]
Quoted 20 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +20
-0+static int +fpga_pr (struct rte_rawdev *raw_dev,u32 port_id,u64 *buffer,u32 size, +u64 *status) +{ + +struct opae_adapter *adapter; +struct opae_manager *mgr; +struct opae_accelerator *acc; +struct opae_bridge *br; +int ret; + + adapter =ifpga_rawdev_get_priv (raw_dev); +if (!adapter) +return -ENODEV ; + + mgr =opae_adapter_get_mgr (adapter); +if (!mgr) +return -ENODEV ; + + acc =opae_adapter_get_acc (adapter, port_id);drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 197
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+if (!acc) +return -ENODEV ; + + br =opae_acc_get_br (acc); +if (!br) +return -ENODEV ; + + ret =opae_manager_flash (mgr, port_id, buffer, size, status); +if (ret) { +printf ("%s pr error %d\n" , __func__, ret);Please use the debugging or error macros.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 201
Quoted 4 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +4
-0+return ret; + } + +usleep (100 );Hmm, is that some caveat or a stray line left from some debugging?
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 204
Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3
-0+ ret =opae_bridge_reset (br); +if (ret) { +printf ("%s reset port:%d error %d\n" , __func__, port_id, ret);Same - debugging/error macros.
Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13
-0+return ret; + } + +return ret; +} + +static int rte_fpga_do_pr (struct rte_rawdev *rawdev,int port_id, +const char *file_name) +{ +struct stat file_stat; +int file_fd; +int ret =0 ; +u32 buffer_size;drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 227
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+void *buffer; +u64 pr_error; + +if (!file_name) +return -EINVAL ; + + file_fd =open (file_name,O_RDONLY ); +if (file_fd <0 ) { +printf ("%s: open file error: %s\n" , __func__, file_name); +printf ("Message : %s\n" ,strerror (errno));Same - debug/error macros
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 232
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+return -EINVAL ; + } + ret =stat (file_name, &file_stat); +if (ret) { +printf ("stat on bitstream file failed: %s\n" , file_name);One more (same is applicable across the file).
Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13
-0+return -EINVAL ; + } + buffer_size = file_stat.st_size; +printf ("bitstream file size: %u\n" , buffer_size); + buffer =rte_malloc (NULL , buffer_size,0 ); +if (!buffer) { + ret = -ENOMEM ; + goto close_fd; + } + +/*read the raw data*/ +if (buffer_size !=read (file_fd, (void *)buffer, buffer_size)) { + ret = -EINVAL ;drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 255
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ goto free_buffer; + } + +/*do PR now*/ + ret =fpga_pr (rawdev, port_id, buffer, buffer_size, &pr_error); +printf ("downloading to device port %d....%s.\n" , port_id, + ret ?"failed" :"success" ); +if (ret) { + ret = -EINVAL ; +//raw_dev->ops->show_pr_error(pr_error); I am guessing this is stray from some debugging attempt. Same for the printf above.
Quoted 28 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +28
-0+ goto free_buffer; + } + +free_buffer: +if (buffer) +rte_free (buffer); +close_fd: +close (file_fd); + file_fd =0 ; +return ret; +} + +static int ifpga_rawdev_pr (struct rte_rawdev *dev, +rte_rawdev_obj_t pr_conf) +{ +struct opae_adapter *adapter; +struct rte_afu_pr_conf *afu_pr_conf; +int ret; +struct uuid uuid; +struct opae_accelerator *acc; + +IFPGA_RAWDEV_PMD_FUNC_TRACE (); + + adapter =ifpga_rawdev_get_priv (dev); +if (!adapter) +return -ENODEV ; + +if (!pr_conf)drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 293
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+return -EINVAL ; + + afu_pr_conf = pr_conf; + +if (afu_pr_conf->pr_enable) { + ret =rte_fpga_do_pr (dev, + afu_pr_conf->afu_id.port, + afu_pr_conf->bs_path); +if (ret) { +printf ("do pr error %d\n" , ret);One more
Quoted 8 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +8
-0+return ret; + } + } + + acc =opae_adapter_get_acc (adapter, afu_pr_conf->afu_id.port); +if (!acc) +return -ENODEV ; +drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 311
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ ret =opae_acc_get_uuid (acc, &uuid); +if (ret) +return ret; + +memcpy (&afu_pr_conf->afu_id.uuid_low, uuid.b,sizeof (u64)); +memcpy (&afu_pr_conf->afu_id.uuid_high, uuid.b +8 ,sizeof (u64)); + +printf ("%s: uuid_l=0x%lx, uuid_h=0x%lx\n" , __func__, + (u64 )afu_pr_conf->afu_id.uuid_low, + (u64 )afu_pr_conf->afu_id.uuid_high);debug/error macros
Quoted 48 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +48
-0+ +return 0 ; +} + +static const struct rte_rawdev_ops ifpga_rawdev_ops = { + .dev_info_get = ifpga_rawdev_info_get, + .dev_configure =NULL , + .dev_start = ifpga_rawdev_start, + .dev_stop = ifpga_rawdev_stop, + .dev_close = ifpga_rawdev_close, + .dev_reset = ifpga_rawdev_reset, + + .queue_def_conf =NULL , + .queue_setup =NULL , + .queue_release =NULL , + + .attr_get =NULL , + .attr_set =NULL , + + .enqueue_bufs =NULL , + .dequeue_bufs =NULL , + + .dump =NULL , + + .xstats_get =NULL , + .xstats_get_names =NULL , + .xstats_get_by_name =NULL , + .xstats_reset =NULL , + + .firmware_status_get =NULL , + .firmware_version_get =NULL , + .firmware_load = ifpga_rawdev_pr, + .firmware_unload =NULL , + + .dev_selftest =NULL , +}; + +static int +ifpga_rawdev_create (struct rte_pci_device *pci_dev, +int socket_id) +{ +int ret =0 ; +struct rte_rawdev *rawdev =NULL ; +struct opae_adapter *adapter; +struct opae_manager *mgr; +struct opae_adapter_data_pci *data; +char name[RTE_RAWDEV_NAME_MAX_LEN ]; +int i;drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 369
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ +if (!pci_dev) { +IFPGA_RAWDEV_PMD_ERR ("Invalid pci_dev of the device!" ); + ret = -EINVAL ; + goto cleanup; + } + +memset (name,0 ,sizeof (name)); +snprintf (name,RTE_RAWDEV_NAME_MAX_LEN ,"IFPGA:%x:%02x.%x" , + pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function);Alignment issue... '
pci_dev->addr.bus... ' would start from underneath arguments of snprintf.Quoted 7 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +7
-0+ +IFPGA_RAWDEV_PMD_INFO ("Init %s on NUMA node %d" , name, +rte_socket_id ()); + +/* Allocate device structure */ + rawdev =rte_rawdev_pmd_allocate (name,sizeof (struct opae_adapter ), + socket_id);drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 385
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+if (rawdev ==NULL ) { +IFPGA_RAWDEV_PMD_ERR ("Unable to allocate rawdevice" ); + ret = -EINVAL ; + goto cleanup; + } + +/* alloc OPAE_FPGA_PCI data to register to OPAE hardware level API */ + data =opae_adapter_data_alloc (OPAE_FPGA_PCI ); +if (!data) +return -ENOMEM ;What about jumping to cleanup here? (
pmd_release())Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ +/* init opae_adapter_data_pci for device specific information */ +for (i =0 ; i <PCI_MAX_RESOURCE ; i++) { + data->region[i].phys_addr = pci_dev->mem_resource[i].phys_addr; + data->region[i].len = pci_dev->mem_resource[i].len;drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 400
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ data->region[i].addr = pci_dev->mem_resource[i].addr; + } + data->device_id = pci_dev->id.device_id; + data->vendor_id = pci_dev->id.vendor_id; + +/* create a opae_adapter based on above device data */ + adapter =opae_adapter_alloc (pci_dev->device.name, data); +if (!adapter) { +opae_adapter_data_free (data); +return -ENOMEM ;Same - you are not performing cleanup here.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 412
Quoted 12 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +12
-0+ } + + rawdev->dev_ops = &ifpga_rawdev_ops; + rawdev->device = &pci_dev->device; + rawdev->driver_name = pci_dev->device.driver->name; + + rawdev->dev_private = adapter; + +/* must enumerate the adapter before use it */ + ret =opae_adapter_enumerate (adapter); +if (ret) +return ret;Cleanup to be performed here.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 417
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ +/* set opae_manager to rawdev */ + mgr =opae_adapter_get_mgr (adapter); +if (mgr) { +/*PF function*/ /*<space>PF function<space>*/
Quoted 49 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +49
-0+IFPGA_RAWDEV_PMD_INFO ("this is a PF function" ); + } + +return ret; + +cleanup: +if (rawdev) +rte_rawdev_pmd_release (rawdev); + +return ret; +} + +static int +ifpga_rawdev_destroy (struct rte_pci_device *pci_dev) { +int ret; +struct rte_rawdev *rawdev; +char name[RTE_RAWDEV_NAME_MAX_LEN ]; +struct opae_adapter *adapter; + +if (!pci_dev) { +IFPGA_RAWDEV_PMD_ERR ("Invalid pci_dev of the device!" ); + ret = -EINVAL ; +return ret; + } + +memset (name,0 ,sizeof (name)); +snprintf (name,RTE_RAWDEV_NAME_MAX_LEN ,"IFPGA:%x:%02x.%x" , + pci_dev->addr.bus, pci_dev->addr.devid, pci_dev->addr.function); + +IFPGA_RAWDEV_PMD_INFO ("Closing %s on NUMA node %d" , + name,rte_socket_id ()); + + rawdev =rte_rawdev_pmd_get_named_dev (name); +if (!rawdev) { +IFPGA_RAWDEV_PMD_ERR ("Invalid device name (%s)" , name); +return -EINVAL ; + } + + adapter =ifpga_rawdev_get_priv (rawdev); +if (!adapter) +return -ENODEV ; + +opae_adapter_data_free (adapter->data); +opae_adapter_free (adapter); + +/* rte_rawdev_close is called by pmd_release */ + ret =rte_rawdev_pmd_release (rawdev); +if (ret) +IFPGA_RAWDEV_PMD_DEBUG ("Device cleanup failed" );drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 477
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ +return 0 ; +} + +static int +ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, +struct rte_pci_device *pci_dev) +{ + +printf ("## %s\n" , __func__);One more.
drivers/raw/ifpga_rawdev/ifpga_rawdev.c
Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13
-0+return ifpga_rawdev_create (pci_dev,rte_socket_id ()); } + +static int ifpga_rawdev_pci_remove (struct rte_pci_device *pci_dev) { +return ifpga_rawdev_destroy (pci_dev); } + +static struct rte_pci_driver rte_ifpga_rawdev_pmd = { + .id_table = pci_ifpga_map, + .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC , + .probe = ifpga_rawdev_pci_probe, + .remove = ifpga_rawdev_pci_remove, +}; + +RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver,
rte_ifpga_rawdev_pmd);Quoted 59 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +59
-0+RTE_PMD_REGISTER_PCI_TABLE (ifpga_rawdev_pci_driver, +rte_ifpga_rawdev_pmd); +RTE_PMD_REGISTER_KMOD_DEP(ifpga_rawdev_pci_driver, "* igb_uio | +uio_pci_generic | vfio-pci"); + +RTE_INIT(ifpga_rawdev_init_log); +static void +ifpga_rawdev_init_log (void ) +{ + ifpga_rawdev_logtype =rte_log_register ("driver.raw.init" ); +if (ifpga_rawdev_logtype >=0 ) +rte_log_set_level (ifpga_rawdev_logtype,RTE_LOG_NOTICE ); } + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +static int +ifpga_cfg_probe (struct rte_vdev_device *dev) { +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +int port; +char *name =NULL ; +char dev_name[RTE_RAWDEV_NAME_MAX_LEN +8 ]; + + devargs = dev->device.devargs; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_RAWDEV_PMD_LOG (ERR ,"error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &ifpga_get_string_arg, &name) <0 ) { +IFPGA_RAWDEV_PMD_ERR ("error to parse %s" , +IFPGA_ARG_NAME ); + goto end; + } + }else { +IFPGA_RAWDEV_PMD_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist, +IFPGA_ARG_PORT , + &ifpga_get_integer32_arg, + &port) <0 ) { +IFPGA_RAWDEV_PMD_ERR ("error to parse %s" , +IFPGA_ARG_PORT );drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 562
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+ goto end; + } + }else { +IFPGA_RAWDEV_PMD_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +memset (dev_name,0 ,sizeof (dev_name)); + snprintf(dev_name, (RTE_RAWDEV_NAME_MAX_LEN+8), "%d|%s",Why did you do this? (adding 8 to
RTE_RAWDEV_NAME_MAX_LEN)? Just add a patch to increase the value ofRTE_RAWDEV_NAME_MAX_LEN.drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 567
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ port, name); + +rte_eal_hotplug_add (RTE_STR (IFPGA_BUS_NAME ), + dev_name, + devargs->args);Seems to be some alignment issue here...
Quoted 37 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +29
-0+end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +static int +ifpga_cfg_remove (struct rte_vdev_device *vdev) { +IFPGA_RAWDEV_PMD_INFO ("Remove ifpga_cfg %p" , + vdev); + +return 0 ; +} + +static struct rte_vdev_driver ifpga_cfg_driver = { + .probe = ifpga_cfg_probe, + .remove = ifpga_cfg_remove, +}; + +RTE_PMD_REGISTER_VDEV (net_ifpga_cfg, ifpga_cfg_driver); +RTE_PMD_REGISTER_ALIAS (net_ifpga_cfg, ifpga_cfg); +RTE_PMD_REGISTER_PARAM_STRING (net_ifpga_cfg, +"bdf=<string> " +"port=<int> " +"afu_bts=<path>" ); +drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +1
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause drivers/raw/ifpga_rawdev/ifpga_rawdev.h line 11
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +10
-0+* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \ + __func__, ##args)Just a trivial comment - you want all your logs, whether INFO, ERROR etc to be appended with function name? Its your choice, but ideally you should separate.
drivers/raw/ifpga_rawdev/ifpga_rawdev.h line 13
Quoted 2 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +2
-0+ +#define IFPGA_RAWDEV_PMD_FUNC_TRACE ()IFPGA_RAWDEV_PMD_LOG(DEBUG,
Quoted 39 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +23
-0+">>") + +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) #define +IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) #define +IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) #define +IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY , +IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) { +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */ drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4
-0@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};mk/rte.app.mk index 9de2edb..4a76890 renamed from mk/rte.app.mk +0
-0100644
mk/rte.app.mk endif # CONFIG_RTE_LIBRTE_EVENTDEV · line 252
Quoted 5 lines
mk/rte.app.mk +1
-1@@ -249,6 +249,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) +=-lrte_ifpga_rawdev
mk/rte.app.mk endif # CONFIG_RTE_LIBRTE_EVENTDEV · line 254
Quoted 4 lines
mk/rte.app.mk +0
-0endif # CONFIG_RTE_LIBRTE_RAWDEV
Quoted 5 lines
How fast can you fix and push? I can spare time tomorrow (5/May) to re-review, if you can push by then. It might help in merging next week.
-
Shreyansh
Hi Shreyansh:
Thank you for your review, we will fix and push at next day.
Best
Tianfei
PATCH v6 4/5 iFPGA: add meson build
In reply to Xu, RosenFrom: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
--- drivers/meson.build | 3 ++- drivers/raw/ifpga_rawdev/base/meson.build | 34 +++++++++++++++++++++++++++++++ drivers/raw/ifpga_rawdev/meson.build | 13 ++++++++++++ drivers/raw/meson.build | 6 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/meson.build
drivers/meson.build +2 -1
@@ -7,7 +7,8 @@ driver_classes = ['common', 'mempool', # depends on common and bus. 'net', # depends on common, bus and mempool. 'crypto', # depends on common, bus and mempool (net in future). - 'event'] # depends on common, bus, mempool and net. + 'event', # depends on common, bus, mempool and net. + 'raw'] foreach class:driver_classes drivers = []
drivers/raw/ifpga_rawdev/base/meson.build new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +sources = [ + 'ifpga_api.c', + 'ifpga_enumerate.c', + 'ifpga_feature_dev.c', + 'ifpga_fme.c', + 'ifpga_fme_iperf.c', + 'ifpga_fme_dperf.c', + 'ifpga_fme_error.c', + 'ifpga_port.c', + 'ifpga_port_error.c', + 'ifpga_fme_pr.c', + 'opae_hw_api.c', + 'opae_ifpga_hw_api.c', + 'opae_debug.c' +] + +error_cflags = ['-Wno-sign-compare', '-Wno-unused-value', + '-Wno-format', '-Wno-unused-but-set-variable', + '-Wno-strict-aliasing' +] +c_args = cflags +foreach flag: error_cflags + if cc.has_argument(flag) + c_args += flag + endif +endforeach + +base_lib = static_library('ifpga_rawdev_base', sources, + dependencies: static_rte_eal, + c_args: c_args) +base_objs = base_lib.extract_all_objects()
drivers/raw/ifpga_rawdev/meson.build new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +version = 1 + +subdir('base') +objs = [base_objs] + +deps += ['rawdev', 'pci', 'bus_pci', 'kvargs', + 'bus_vdev', 'bus_ifpga'] +sources = files('ifpga_rawdev.c') + +includes += include_directories('base')
drivers/raw/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'
Signature · 1 line
1.8.3.1
Re: [PATCH v6 4/5] iFPGA: add meson build
Quoted 29 lines · Rosen
From: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
Signed-off-by Figo Zhang <[email protected]>--- drivers/meson.build | 3 ++- drivers/raw/ifpga_rawdev/base/meson.build | 34 +++++++++++++++++++++++++++++++ drivers/raw/ifpga_rawdev/meson.build | 13 ++++++++++++ drivers/raw/meson.build | 6 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-)create mode 100644
drivers/raw/ifpga_rawdev/base/meson.buildcreate mode 100644drivers/raw/ifpga_rawdev/meson.buildcreate mode 100644drivers/raw/meson.builddrivers/meson.build +2
-1@@ -7,7 +7,8 @@ driver_classes = ['common', 'mempool', # depends on common and bus. 'net', # depends on common, bus and mempool. 'crypto', # depends on common, bus and mempool (net in future). - 'event'] # depends on common, bus, mempool and net. + 'event', # depends on common, bus, mempool and net. + 'raw'] foreach class:driver_classes drivers = []
[...]
drivers/raw/meson.build line 6
Quoted 13 lines
drivers/raw/meson.build new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'
Just a heads-up for Thomas/Ferruh: Either this or patches from Nipun [1] would conflict here as drivers/raw/meson.build is being introduced by both.
Re: [PATCH v6 4/5] iFPGA: add meson build
Quoted 63 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, May 2, 2018 5:47 PM
To: Xu, Rosen <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 4/5] iFPGA: add meson buildQuoted 8 lines · Rosen
From: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
Signed-off-by Figo Zhang <[email protected]>--- drivers/meson.build | 3 ++- drivers/raw/ifpga_rawdev/base/meson.build | 34+++++++++++++++++++++++++++++++
Quoted 12 lines
drivers/raw/ifpga_rawdev/meson.build | 13 ++++++++++++ drivers/raw/meson.build | 6 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-)create mode 100644
drivers/raw/ifpga_rawdev/base/meson.buildcreate mode 100644drivers/raw/ifpga_rawdev/meson.buildcreate mode 100644drivers/raw/meson.builddrivers/meson.build index renamed from drivers/meson.build +0
-0b146f09..b7fc0d6 100644
drivers/meson.build driver_classes = ['common', · line 9
Quoted 3 lines
drivers/meson.build +0
-0@@ -7,7 +7,8 @@ driver_classes = ['common', 'mempool', # depends on common and bus. 'net', # depends on common, bus and mempool. 'crypto', # depends on common, bus and mempool (netin future).
Quoted 6 lines
drivers/meson.build +2
-1- 'event'] # depends on common, bus, mempool and net. + 'event', # depends on common, bus, mempool and net. + 'raw'] foreach class:driver_classes drivers = [][...]
drivers/raw/meson.build line 6
Quoted 12 lines
drivers/raw/meson.build new renamed from drivers/raw/meson.build +0
-0file mode 100644 index 0000000..410f908
drivers/raw/meson.build new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel +Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'Just a heads-up for Thomas/Ferruh: Either this or patches from Nipun [1] would conflict here as
drivers/raw/meson.buildis being introduced by both.
Quoted 1 line
Thomas and Ferruh's patch has merged into mainline?
We will rebase to latest master branch and send the V7 patches soon.
Re: [PATCH v6 4/5] iFPGA: add meson build
Quoted 63 lines · Tianfei
Quoted 63 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, May 2, 2018 5:47 PM
To: Xu, Rosen <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 4/5] iFPGA: add meson buildQuoted 8 lines · Rosen
From: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
Signed-off-by Figo Zhang <[email protected]>--- drivers/meson.build | 3 ++- drivers/raw/ifpga_rawdev/base/meson.build | 34+++++++++++++++++++++++++++++++
Quoted 12 lines
drivers/raw/ifpga_rawdev/meson.build | 13 ++++++++++++ drivers/raw/meson.build | 6 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-)create mode 100644
drivers/raw/ifpga_rawdev/base/meson.buildcreate mode 100644drivers/raw/ifpga_rawdev/meson.buildcreate mode 100644drivers/raw/meson.builddrivers/meson.build index renamed from drivers/meson.build +0
-0b146f09..b7fc0d6 100644
drivers/meson.build driver_classes = ['common', · line 9
Quoted 3 lines
drivers/meson.build +0
-0@@ -7,7 +7,8 @@ driver_classes = ['common', 'mempool', # depends on common and bus. 'net', # depends on common, bus and mempool. 'crypto', # depends on common, bus and mempool (netin future).
Quoted 6 lines
drivers/meson.build +2
-1- 'event'] # depends on common, bus, mempool and net. + 'event', # depends on common, bus, mempool and net. + 'raw'] foreach class:driver_classes drivers = [][...]
drivers/raw/meson.build line 6
Quoted 12 lines
drivers/raw/meson.build new renamed from drivers/raw/meson.build +0
-0file mode 100644 index 0000000..410f908
drivers/raw/meson.build new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel +Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'Just a heads-up for Thomas/Ferruh: Either this or patches from Nipun [1] would conflict here as
drivers/raw/meson.buildis being introduced by both.
Quoted 5 lines
Quoted 1 line
Thomas and Ferruh's patch has merged into mainline?
We will rebase to latest master branch and send the V7 patches soon.
In the weekly call, it was decided that qdma patches are almost ready. So, can you rebase your patches over that? You will have to remove the drivers/raw/meson.build and add your entry into the one added by qdma driver [1]. You might have to wait for a couple of days.
Re: [PATCH v6 4/5] iFPGA: add meson build
Quoted 84 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Thursday, May 3, 2018 5:13 PM
To: Zhang, Tianfei <[email protected]>; Xu, Rosen <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 4/5] iFPGA: add meson buildQuoted 48 lines · Tianfei
Quoted 48 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, May 2, 2018 5:47 PM
To: Xu, Rosen <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 4/5] iFPGA: add meson buildQuoted 8 lines · Rosen
From: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
Signed-off-by Figo Zhang <[email protected]>--- drivers/meson.build | 3 ++- drivers/raw/ifpga_rawdev/base/meson.build | 34+++++++++++++++++++++++++++++++
Quoted 12 lines
drivers/raw/ifpga_rawdev/meson.build | 13 ++++++++++++ drivers/raw/meson.build | 6 ++++++ 4 files changed, 55 insertions(+), 1 deletion(-)create mode 100644
drivers/raw/ifpga_rawdev/base/meson.buildcreate mode 100644drivers/raw/ifpga_rawdev/meson.buildcreate mode 100644drivers/raw/meson.builddrivers/meson.build index renamed from drivers/meson.build +0
-0b146f09..b7fc0d6 100644
drivers/meson.build driver_classes = ['common', · line 9
Quoted 3 lines
drivers/meson.build +0
-0@@ -7,7 +7,8 @@ driver_classes = ['common', 'mempool', # depends on common and bus. 'net', # depends on common, bus and mempool. 'crypto', # depends on common, bus and mempool (netin future).
Quoted 6 lines
drivers/meson.build +2
-1- 'event'] # depends on common, bus, mempool and net. + 'event', # depends on common, bus, mempool and net. + 'raw'] foreach class:driver_classes drivers = [][...]
Quoted 15 lines
Quoted 7 lines
Quoted 7 lines
drivers/raw/meson.build new renamed from drivers/raw/meson.build +0
-0file mode 100644 index 0000000..410f908
drivers/raw/meson.build new file +2
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel +CorporationQuoted 8 lines
drivers/raw/meson.build line 6
Quoted 5 lines
drivers/raw/meson.build new file +4
-0+ +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'Just a heads-up for Thomas/Ferruh: Either this or patches from Nipun
[1] would conflict here asdrivers/raw/meson.buildis being introduced byboth.
Quoted 6 lines
Quoted 2 lines
Thomas and Ferruh's patch has merged into mainline?
We will rebase to latest master branch and send the V7 patches soon.
Quoted 7 lines
In the weekly call, it was decided that qdma patches are almost ready. So, can you rebase your patches over that? You will have to remove the
drivers/raw/meson.buildand add your entry into the one added by qdma driver [1].
You might have to wait for a couple of days.
Sure. By now we have prepare our v7 patches and will send this days, and fix some comments by some community guys.
When this patch has merged into mainline, we will rebase over it.
PATCH v6 5/5 iFPGA: add document for iFPGA driver
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
--- doc/guides/index.rst | 1 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rawdevs/index.rst | 11 ++++ doc/guides/rel_notes/release_18_05.rst | 13 ++++ 4 files changed, 137 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 doc/guides/rawdevs/index.rst
doc/guides/index.rst +1 -0
@@ -20,6 +20,7 @@ DPDK documentation eventdevs/index mempool/index platform/index + rawdevs/index contributing/index rel_notes/index faq/index
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0
113 lines not on this page · raw message
doc/guides/rawdevs/index.rst new file +11 -0
@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation + +Raw Device Drivers +======================= + +.. toctree:: + :maxdepth: 2 + :numbered: + + ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +13 -0
@@ -140,6 +140,19 @@ New Features stats/xstats on shared memory from secondary process, and also pdump packets on those virtual devices. +* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel FPGA device with + the DPDK framework. It provides Intel FPGA Partial Bit Stream AFU(Accelerated + Function Unit) scan and drivers prove. + +* **Added IFPGA(Intel FPGA) Rawdev Driver.** + + Added a new Rawdev driver called IFPGA(Intel FPGA) Rawdev Driver, which cooperates + with OPAE(Open Programmable Acceleration Engine) share code provides common FPGA + management ops for FPGA operation. + + See the :doc:`../rawdevs/ifpga_rawdev` programmer's guide for more details. API Changes -----------
Signature · 1 line
1.8.3.1
v7 cover Introduce Intel FPGA BUS
In reply to Rosen XuFrom: "Xu, Rosen" <[email protected]>
Intel FPGA BUS in DPDK
-------------------------
This patch set introduces Intel FPGA BUS support in DPDK.
v7 updates:
==========
- Fix some comments from DPDK community
- Fix the CLANG compile error
- Fix the meson build warring.
v6 updates:
===========
- Add documentation
- Add meson build script
- Split new patch for OPAE share code
v5 updates:
===========
- Fixed SHARED LIB Build issue
- Changed command name to IFPGA Rawdev name,
so remove pci library datastruct and function.
- Fixed PATCH v2/v3/v4 comments
v4 updates:
===========
- Remove all modifications from eal
- Create vdev to take IFPGA parameters configuration
- AFU Device Driver bind to AFU Device by uuid
- Take more test in scenario of Multi-FPGA System
v3 updates:
===========
- Remove all modifications of bus scan and probe
- FPGA BUS Scan is trigged by hotplug of Rawdev
- Took Modifications of comments
- Move AFU Device to IFPGA
- FPGA BUS Scan depend on it¡¯s IFPGA Rawdev
- Add Build Macros for FPGA BUS and IFPGA Rawdev
Questions
=========
Why not PCI Bus?
All of the AFUs of one FPGA may share same PCI BDF. Why not vdev Bus?
Because AFUs depend on Rawdev, and it's hardware specpic.
Motivation
==========
FPGA is used more and more widely in Cloud and NFV, one primary reason is that FPGA not only provide ASIC performance but also it's more flexible than ASIC. FPGA use Partial Reconfigure(PR) Parts of Bitstream to achieve its flexibility. Another reason is that one FPGA can be shared by different Users, and each User can use some of AFUs of One FPGA.
That means One FPGA Device Bitstream is divided into many Parts of Bitstream(each Part of Bitstream is defined as AFU-Accelerated Function Unit), and each AFU is a Hardware Acceleration Unit and it can dynamically Reload respectively.
Proposed Solution
=================
- Involve Rawdev to take FPGA Partial Configuration(Download/PR)
- Defined FPGA-BUS for Acceleration Drivers of AFUs
- FPGA PCI Scan(1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver. FPGA-BUS scan is called, but AFU depend on Rawdev, so this scan doesn't trig AFU device create.
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their dirves are also probed.
Scope
=====
The Intel FPGA BUS implementation is target towards various FPGA Devices use PR to provide many Acceleration Function. Specific PMDs may also bind to its AFU. And Applications don't care they are using ASIC Acceleration or FPGA AFU Acceleration.
Status
=====
With integrating Intel PSG FPGA Software Stack OPAE(Open Programmable Acceleration Engine) Share Code, Intel FPGA BUS runs well in Intel PSG FPGA Cards.
Figo Zhang (2):
iFPGA: add meson build
iFPGA: add document for iFPGA driver
Rosen Xu (3):
bus/ifpga: Add Intel FPGA BUS Library
iFPGA: Add Intel FPGA OPAE Share Code
iFPGA: Add Intel FPGA BUS Rawdev Driver
config/common_base | 6 + doc/guides/index.rst | 1 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 ++ doc/guides/rawdevs/index.rst | 11 + doc/guides/rel_notes/release_18_05.rst | 13 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 + drivers/bus/ifpga/ifpga_bus.c | 500 ++++++ drivers/bus/ifpga/ifpga_common.c | 88 ++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 + drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 ++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- drivers/meson.build | 3 +- drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 + drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/meson.build | 34 + drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 599 +++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 + drivers/raw/ifpga_rawdev/meson.build | 15 + .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + drivers/raw/meson.build | 6 + mk/rte.app.mk | 3 + 52 files changed, 9745 insertions(+), 2 deletions(-) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 doc/guides/rawdevs/index.rst create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map create mode 100644 drivers/raw/meson.build
Signature · 1 line
1.8.3.1
PATCH v7 1/5 bus/ifpga: Add Intel FPGA BUS Library
From: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce rte_afu_device which describe the AFU device listed in the FPGA-BUS.
--- config/common_base | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 500 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 2 + 12 files changed, 856 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
config/common_base +5 -0
@@ -149,6 +149,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y CONFIG_RTE_LIBRTE_VDEV_BUS=y # +# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile ARK PMD # CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
@@ -9,5 +9,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +500 -0
500 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.c new file +88 -0
88 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_unsigned_long (const char *str,int base); +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) +#define IFPGA_BUS_INFO(fmt, args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */
drivers/bus/ifpga/meson.build new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2018 Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = true
drivers/bus/ifpga/rte_bus_ifpga.h new file +160 -0
160 lines not on this page · raw message
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10 -0
@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + ifpga_get_integer32_arg; + ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};
drivers/bus/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +2 -0
@@ -107,6 +107,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER) += -lrte_reorder _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED) += -lrte_sched +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga + ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI) += -lrte_kni endif
Signature · 1 line
1.8.3.1
PATCH v7 2/5 iFPGA: Add Intel FPGA OPAE Share Code
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
This patch adds Intel FPGA Open Programmable Acceleration Engine (OPAE)[1] base driver code, in order to support Intel FPGA devices under DPDK. The base code currently supports Intel FPGA solutions including integrated solution (Intel(R) Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA devices in the future. Please refer to [1][2] for more introduction on OPAE and Intel FPGAs.
[1] https://01.org/OPAE
[2] https://www.altera.com/solutions/acceleration-hub/overview.html
--- drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + 27 files changed, 8016 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +30 -0
@@ -0,0 +1,30 @@ +#SPDX-License-Identifier: BSD-3-Clause +#Copyright(c) 2010-2018 Intel Corporation + +ifneq ($(CONFIG_RTE_LIBRTE_EAL),) +OSDEP := osdep_rte +else +OSDEP := osdep_raw +endif + +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev/base/$(OSDEP) + +SRCS-y += ifpga_api.c +SRCS-y += ifpga_enumerate.c +SRCS-y += ifpga_feature_dev.c +SRCS-y += ifpga_fme.c +SRCS-y += ifpga_fme_iperf.c +SRCS-y += ifpga_fme_dperf.c +SRCS-y += ifpga_fme_error.c +SRCS-y += ifpga_port.c +SRCS-y += ifpga_port_error.c +SRCS-y += opae_hw_api.c +SRCS-y += opae_ifpga_hw_api.c +SRCS-y += opae_debug.c +SRCS-y += ifpga_fme_pr.c + +ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y) + CFLAGS_ifpga_fme_pr.o += -march=knl +endif + +SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/README new file +31 -0
@@ -0,0 +1,31 @@ +.. + +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2018 Intel Corporation + */ + +Intel® iFPGA driver +================== + +This directory contains source code of Intel FPGA driver released by +the team which develops Intel FPGA Open Programmable Acceleration Engine (OPAE). +The directory of base/ contains the original source package. The base code +currently supports Intel FPGA solutions including integrated solution (Intel(R) +Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration +Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA +devices in the future. + +Please refer to [1][2] for more introduction on OPAE and Intel FPGAs. + +[1] https://01.org/OPAE +[2] https://www.altera.com/solutions/acceleration-hub/overview.html + + +Updating the driver +=================== + +NOTE: The source code in this directory should not be modified apart from +the following file(s): + + osdep_raw/osdep_generic.h + osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +294 -0
294 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_API_H_ +#define _IFPGA_API_H_ + +#include "opae_hw_api.h" +#include "ifpga_hw.h" + +extern struct opae_adapter_ops ifpga_adapter_ops; +extern struct opae_manager_ops ifpga_mgr_ops; +extern struct opae_bridge_ops ifpga_br_ops; +extern struct opae_accelerator_ops ifpga_acc_ops; + +/* common APIs */ +int ifpga_get_prop (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +struct feature_prop *prop); +int ifpga_set_prop (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +struct feature_prop *prop); +int ifpga_set_irq (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +u32 feature_id,void *irq_set); + +/* FME APIs */ +int ifpga_pr (struct ifpga_hw *hw,u32 port_id,void *buffer,u32 size, +u64 *status); + +#endif /* _IFPGA_API_H_ */
drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +57 -0
57 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_defines.h new file +1661 -0
1,661 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c new file +824 -0
824 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_ENUMERATE_H_ +#define _IFPGA_ENUMERATE_H_ + +int ifpga_bus_init (struct ifpga_hw *hw); +int ifpga_bus_enumerate (struct ifpga_hw *hw); + +#endif /* _IFPGA_ENUMERATE_H_ */
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +314 -0
64 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +164 -0
164 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +734 -0
734 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +301 -0
301 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +403 -0
403 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +715 -0
715 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +372 -0
372 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +127 -0
127 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +408 -0
408 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_port_error.c new file +165 -0
165 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_debug.c new file +99 -0
99 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_debug.h new file +19 -0
Lines of this file are not shown. View the raw message.
drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +381 -0
381 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +253 -0
253 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +145 -0
145 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +279 -0
279 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +81 -0
81 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +75 -0
75 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +45 -0
45 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.
PATCH v7 3/5 iFPGA: Add Intel FPGA BUS Rawdev Driver
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.
--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 599 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 1 + 7 files changed, 679 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
config/common_base +1 -0
@@ -152,6 +152,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y # Compile the Intel FPGA bus # CONFIG_RTE_LIBRTE_IFPGA_BUS=y +CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y # # Compile ARK PMD
drivers/raw/Makefile +1 -0
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk # DIRS-$(<configuration>) += <directory> DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifpga_rawdev.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_kvargs +LDLIBS += -lrte_bus_pci +LDLIBS += -lrte_bus_ifpga + +EXPORT_MAP := rte_ifpga_rawdev_version.map + +LIBABIVER := 1 + +VPATH += $(SRCDIR)/base + +include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +599 -0
599 lines not on this page · raw message
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "ifgpa: " fmt "\n", \ + ##args) + +#define IFPGA_RAWDEV_PMD_FUNC_TRACE () IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>") + +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY , +IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) +{ +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +1 -0
@@ -253,6 +253,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev endif # CONFIG_RTE_LIBRTE_RAWDEV
Signature · 1 line
1.8.3.1
Re: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver
Hello Rosen,
Quoted 35 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yanglong Wu <[email protected]>
Subject: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on
librte_rawdevlibrary.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Yanglong Wu <[email protected]>Signed-off-by Figo zhang <[email protected]>--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 599 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 1 + 7 files changed, 679 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
[...]
Quoted 66 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +52
-0@@ -0,0 +1,599 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#include <string.h> +#include <dirent.h> +#include <sys/stat.h> +#include <unistd.h> +#include <sys/types.h> +#include <fcntl.h> +#include <rte_log.h> +#include <rte_bus.h> +#include <rte_eal_memconfig.h> +#include <rte_malloc.h> +#include <rte_devargs.h> +#include <rte_memcpy.h> +#include <rte_pci.h> +#include <rte_bus_pci.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include <rte_errno.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> +#include <rte_bus_vdev.h> + +#include "base/opae_hw_api.h" +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_common.h" +#include "ifpga_logs.h" +#include "ifpga_rawdev.h" + +int ifpga_rawdev_logtype; + +#define PCI_VENDOR_ID_INTEL 0x8086 +/* PCI Device ID */ +#define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD +#define PCIE_DEVICE_ID_PF_INT_6_X 0xBCC0 +#define PCIE_DEVICE_ID_PF_DSC_1_X 0x09C4 +/* VF Device */ +#define PCIE_DEVICE_ID_VF_INT_5_X 0xBCBF +#define PCIE_DEVICE_ID_VF_INT_6_X 0xBCC1 +#define PCIE_DEVICE_ID_VF_DSC_1_X 0x09C5 +#define RTE_MAX_RAW_DEVICE 10 + +static const struct rte_pci_id pci_ifpga_map[] = { + {RTE_PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCIE_DEVICE_ID_PF_INT_5_X )},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ {RTE_PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCIE_DEVICE_ID_VF_INT_5_X )},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ {RTE_PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCIE_DEVICE_ID_PF_INT_6_X )},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ {RTE_PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCIE_DEVICE_ID_VF_INT_6_X )},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ {RTE_PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCIE_DEVICE_ID_PF_DSC_1_X )},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ {RTE_PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCIE_DEVICE_ID_VF_DSC_1_X )},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 62
Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ { .vendor_id = 0, /* sentinel */ }, +}; + +static int ifpga_fill_afu_dev (struct opae_accelerator *acc, +struct rte_afu_device *afu_dev)
Sorry, for nitpicking, but the function definitions should follow [1] model where return types are different lines than name.
Something like:
static intifpga_fill_afu_dev(...)
[1] http://dpdk.org/doc/guides/contributing/coding_style.html#c-function-definition-declaration-and-use
This is valid for multiple function definitions. Can you please fix when you send v8 (which you might have to send for rebasing over master).
Quoted 44 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +44
-0+{ +struct rte_mem_resource *res = afu_dev->mem_resource; +struct opae_acc_region_info region_info; +struct opae_acc_info info; +unsigned long i; +int ret; + + ret =opae_acc_get_info (acc, &info); +if (ret) +return ret; + +if (info.num_regions >PCI_MAX_RESOURCE ) +return -EFAULT ; + + afu_dev->num_region = info.num_regions; + +for (i =0 ; i < info.num_regions; i++) { + region_info.index = i; + ret =opae_acc_get_region_info (acc, ®ion_info); +if (ret) +return ret; + +if ((region_info.flags &ACC_REGION_MMIO ) && + (region_info.flags &ACC_REGION_READ ) && + (region_info.flags &ACC_REGION_WRITE )) { + res[i].phys_addr = region_info.phys_addr; + res[i].len = region_info.len; + res[i].addr = region_info.addr; + }else +return -EFAULT ; + } + +return 0 ; +} + +static void ifpga_rawdev_info_get (struct rte_rawdev *dev, +rte_rawdev_obj_t dev_info) +{ +struct opae_adapter *adapter; +struct opae_accelerator *acc; +struct rte_afu_device *afu_dev; + +IFPGA_RAWDEV_PMD_FUNC_TRACE (); +
[...]
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 480
Quoted 7 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +7
-0+ +static int +ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, +struct rte_pci_device *pci_dev) +{ + +IFPGA_RAWDEV_PMD_INFO ("## %s\n" , __func__);
Actually, this is not INFO - this is debug. And, this seems like place for FUNC_TRACE call you have already defined in your log file.
Quoted 15 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +15
-0+return ifpga_rawdev_create (pci_dev,rte_socket_id ()); +} + +static int ifpga_rawdev_pci_remove (struct rte_pci_device *pci_dev) +{ +return ifpga_rawdev_destroy (pci_dev); +} + +static struct rte_pci_driver rte_ifpga_rawdev_pmd = { + .id_table = pci_ifpga_map, + .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC , + .probe = ifpga_rawdev_pci_probe, + .remove = ifpga_rawdev_pci_remove, +}; +
[...]
Quoted 19 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +11
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "ifgpa: " fmt"\n", \
drivers/raw/ifpga_rawdev/ifpga_rawdev.h line 12
Quoted 1 line
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +1
-0+ ##args)
Another one.
In many of your logs, you are adding '\n' in the end. Your PMD_LOG definition also has a '\n' - that is double new lines being printed for those logs.
Quoted 16 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +2
-0+ +#define IFPGA_RAWDEV_PMD_FUNC_TRACE () IFPGA_RAWDEV_PMD_LOG(DEBUG,">>")
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +13
-0+ +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY ,
drivers/raw/ifpga_rawdev/ifpga_rawdev.h line 37
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +10
-0+IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) +{ +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */
[...]
There are some nitpicks highlighted in mail above - but nothing major. I would have no more comments (as well as review) for this. In principle, I am OK with this. For v8, please feel free to use for this patch:
Thanks for the work and patience.
Re: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver
Quoted 274 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Sunday, May 6, 2018 2:43 AM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: RE: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverHello Rosen,
Quoted 35 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yanglong Wu <[email protected]>
Subject: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on
librte_rawdevlibrary.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Yanglong Wu <[email protected]>Signed-off-by Figo zhang <[email protected]>--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 599 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 1 + 7 files changed, 679 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map[...]
Quoted 44 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +41
-0@@ -0,0 +1,599 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <dirent.h> +#include <sys/stat.h> +#include <unistd.h> +#include <sys/types.h> +#include <fcntl.h> +#include <rte_log.h> +#include <rte_bus.h> +#include <rte_eal_memconfig.h> +#include <rte_malloc.h> +#include <rte_devargs.h> +#include <rte_memcpy.h> +#include <rte_pci.h> +#include <rte_bus_pci.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include <rte_errno.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> +#include <rte_bus_vdev.h> + +#include "base/opae_hw_api.h" +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_common.h" +#include "ifpga_logs.h" +#include "ifpga_rawdev.h" + +int ifpga_rawdev_logtype; + +#define PCI_VENDOR_ID_INTEL 0x8086 +/* PCI Device ID */ +#define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBDdrivers/raw/ifpga_rawdev/ifpga_rawdev.c line 51
Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10
-0+#define PCIE_DEVICE_ID_PF_INT_6_X 0xBCC0 +#define PCIE_DEVICE_ID_PF_DSC_1_X 0x09C4 +/* VF Device */ +#define PCIE_DEVICE_ID_VF_INT_5_X 0xBCBF +#define PCIE_DEVICE_ID_VF_INT_6_X 0xBCC1 +#define PCIE_DEVICE_ID_VF_DSC_1_X 0x09C5 +#define RTE_MAX_RAW_DEVICE 10 + +static const struct rte_pci_id pci_ifpga_map[] = { + { RTE_PCI_DEVICE(PCI_VENDOR_ID_INTEL,
PCIE_DEVICE_ID_PF_INT_5_X)drivers/raw/ifpga_rawdev/ifpga_rawdev.c
Quoted 2 lines
},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ { RTE_PCI_DEVICE(PCI_VENDOR_ID_INTEL,
PCIE_DEVICE_ID_VF_INT_5_X)drivers/raw/ifpga_rawdev/ifpga_rawdev.c
Quoted 2 lines
},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ { RTE_PCI_DEVICE(PCI_VENDOR_ID_INTEL,
PCIE_DEVICE_ID_PF_INT_6_X)drivers/raw/ifpga_rawdev/ifpga_rawdev.c
Quoted 2 lines
},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ { RTE_PCI_DEVICE(PCI_VENDOR_ID_INTEL,
PCIE_DEVICE_ID_VF_INT_6_X)drivers/raw/ifpga_rawdev/ifpga_rawdev.c
Quoted 2 lines
},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ { RTE_PCI_DEVICE(PCI_VENDOR_ID_INTEL,
PCIE_DEVICE_ID_PF_DSC_1_X)drivers/raw/ifpga_rawdev/ifpga_rawdev.c
Quoted 2 lines
},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1
-0+ { RTE_PCI_DEVICE(PCI_VENDOR_ID_INTEL,
PCIE_DEVICE_ID_VF_DSC_1_X)drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 62
Quoted 6 lines
},
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5
-0+ { .vendor_id = 0, /* sentinel */ }, +}; + +static int ifpga_fill_afu_dev (struct opae_accelerator *acc, +struct rte_afu_device *afu_dev)Sorry, for nitpicking, but the function definitions should follow [1] model where return types are different lines than name.
Something like:
static int
ifpga_fill_afu_dev(...)[1]
http://dpdk.org/doc/guides/contributing/coding_style.html#c-function-defi
nition-declaration-and-useThis is valid for multiple function definitions. Can you please fix when you send v8 (which you might have to send for rebasing over master).
Quoted 44 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +44
-0+{ +struct rte_mem_resource *res = afu_dev->mem_resource; +struct opae_acc_region_info region_info; +struct opae_acc_info info; +unsigned long i; +int ret; + + ret =opae_acc_get_info (acc, &info); +if (ret) +return ret; + +if (info.num_regions >PCI_MAX_RESOURCE ) +return -EFAULT ; + + afu_dev->num_region = info.num_regions; + +for (i =0 ; i < info.num_regions; i++) { + region_info.index = i; + ret =opae_acc_get_region_info (acc, ®ion_info); +if (ret) +return ret; + +if ((region_info.flags &ACC_REGION_MMIO ) && + (region_info.flags &ACC_REGION_READ ) && + (region_info.flags &ACC_REGION_WRITE )) { + res[i].phys_addr = region_info.phys_addr; + res[i].len = region_info.len; + res[i].addr = region_info.addr; + }else +return -EFAULT ; + } + +return 0 ; +} + +static void ifpga_rawdev_info_get (struct rte_rawdev *dev, +rte_rawdev_obj_t dev_info) +{ +struct opae_adapter *adapter; +struct opae_accelerator *acc; +struct rte_afu_device *afu_dev; + +IFPGA_RAWDEV_PMD_FUNC_TRACE (); +[...]
drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 480
Quoted 7 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +7
-0+ +static int +ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, +struct rte_pci_device *pci_dev) +{ + +IFPGA_RAWDEV_PMD_INFO ("## %s\n" , __func__);Actually, this is not INFO - this is debug. And, this seems like place for
FUNC_TRACEcall you have already defined in your log file.Quoted 12 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +12
-0+return ifpga_rawdev_create (pci_dev,rte_socket_id ()); } + +static int ifpga_rawdev_pci_remove (struct rte_pci_device *pci_dev) { +return ifpga_rawdev_destroy (pci_dev); } + +static struct rte_pci_driver rte_ifpga_rawdev_pmd = { + .id_table = pci_ifpga_map, + .drv_flags =RTE_PCI_DRV_NEED_MAPPING |RTE_PCI_DRV_INTR_LSC , + .probe = ifpga_rawdev_pci_probe, + .remove = ifpga_rawdev_pci_remove, +}; +[...]
Quoted 18 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +10
-0@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "ifgpa: " fmt"\n", \
drivers/raw/ifpga_rawdev/ifpga_rawdev.h line 12
Quoted 1 line
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +1
-0+ ##args)Another one.
In many of your logs, you are adding '\n' in the end. YourPMD_LOGdefinition also has a '\n' - that is double new lines being printed for those logs.drivers/raw/ifpga_rawdev/ifpga_rawdev.h
Quoted 2 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +2
-0+ +#define IFPGA_RAWDEV_PMD_FUNC_TRACE ()IFPGA_RAWDEV_PMD_LOG(DEBUG,
Quoted 23 lines
">>")
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +22
-0+ +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) #define +IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) #define +IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) #define +IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { + IFPGA_IDLE, + IFPGA_READY, + IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev) { + return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */[...]
Quoted 7 lines
There are some nitpicks highlighted in mail above - but nothing major. I would have no more comments (as well as review) for this.
In principle, I am OK with this. For v8, please feel free to use for this patch:Acked-by Shreyansh Jain <[email protected]>Thanks for the work and patience.
Thanks Shreyansh great support, we will send the v8 patches today.
Re: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver
In reply to Xu, RosenThough I had already acked this, I had a quick comment:
Quoted 20 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yanglong Wu <[email protected]>
Subject: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on
librte_rawdevlibrary.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Yanglong Wu <[email protected]>Signed-off-by Figo zhang <[email protected]>---
[...]
Quoted 11 lines
mk/rte.app.mk +0
-0@@ -253,6 +253,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -
lrte_pmd_skeleton_rawdev
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev
endif #CONFIG_RTE_LIBRTE_RAWDEV
This driver is dependent on CONFIG_RTE_LIBRTE_IFPGA_BUS and if someone disables that, it would lead to build issues. I think you should enclose the IFPGA_RAWDEV compilation into conditional for CONFIG_RTE_LIBRTE_IFPGA_BUS=y.
Though, I do faintly remember a discussion in past that such thing should/can be left to individual environment configuration and it can be safely assumed that such erroneous configuration would be user-responsibility (at least until a dependency based configuration system is available in DPDK). So, it is a good-to-have rather a necessity.
Quoted 4 lines
--
1.8.3.1
Re: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev Driver
Quoted 57 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Sunday, May 6, 2018 3:10 AM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: RE: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverThough I had already acked this, I had a quick comment:
Quoted 20 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Yanglong Wu <[email protected]>
Subject: [PATCH v7 3/5] iFPGA: Add Intel FPGA BUS Rawdev DriverFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on
librte_rawdevlibrary.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Yanglong Wu <[email protected]>Signed-off-by Figo zhang <[email protected]>---
[...]
Quoted 10 lines
mk/rte.app.mk index f47bbe8..b0a994f renamed from mk/rte.app.mk +0
-0100644
mk/rte.app.mk +0
-0@@ -253,6 +253,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -
lrte_pmd_skeleton_rawdev
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) +=-lrte_ifpga_rawdev
Quoted 1 line
endif #
CONFIG_RTE_LIBRTE_RAWDEVThis driver is dependent on
CONFIG_RTE_LIBRTE_IFPGA_BUSand if someone disables that, it would lead to build issues. I think you should enclose theIFPGA_RAWDEVcompilation into conditional forCONFIG_RTE_LIBRTE_IFPGA_BUS=y.
Quoted 5 lines
Though, I do faintly remember a discussion in past that such thing should/can be left to individual environment configuration and it can be safely assumed that such erroneous configuration would be user-responsibility (at least until a dependency based configuration system is available in DPDK). So, it is a good-to-have rather a necessity.
Good point, we will add RAWDEV condition in our Patch 1:
ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y)
_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga
endif # CONFIG_RTE_LIBRTE_RAWDEV
and add IFGA_BUS condition checking in Patch 3, like this:
ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y)
_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdevi
_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga
ifeq($(CONFIG_RTE_LIBRTE_IFPGA_BUS),y)
_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev
endif# CONFIG_RTE_LIBRTE_IFPGA_BUS
endif # CONFIG_RTE_LIBRTE_RAWDEV
PATCH v7 4/5 iFPGA: add meson build
In reply to Xu, RosenFrom: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
--- drivers/meson.build | 3 ++- drivers/raw/ifpga_rawdev/base/meson.build | 34 +++++++++++++++++++++++++++++++ drivers/raw/ifpga_rawdev/meson.build | 15 ++++++++++++++ drivers/raw/meson.build | 6 ++++++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/meson.build
drivers/meson.build +2 -1
@@ -7,7 +7,8 @@ driver_classes = ['common', 'mempool', # depends on common and bus. 'net', # depends on common, bus and mempool. 'crypto', # depends on common, bus and mempool (net in future). - 'event'] # depends on common, bus, mempool and net. + 'event', # depends on common, bus, mempool and net. + 'raw'] foreach class:driver_classes drivers = []
drivers/raw/ifpga_rawdev/base/meson.build new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +sources = [ + 'ifpga_api.c', + 'ifpga_enumerate.c', + 'ifpga_feature_dev.c', + 'ifpga_fme.c', + 'ifpga_fme_iperf.c', + 'ifpga_fme_dperf.c', + 'ifpga_fme_error.c', + 'ifpga_port.c', + 'ifpga_port_error.c', + 'ifpga_fme_pr.c', + 'opae_hw_api.c', + 'opae_ifpga_hw_api.c', + 'opae_debug.c' +] + +error_cflags = ['-Wno-sign-compare', '-Wno-unused-value', + '-Wno-format', '-Wno-unused-but-set-variable', + '-Wno-strict-aliasing' +] +c_args = cflags +foreach flag: error_cflags + if cc.has_argument(flag) + c_args += flag + endif +endforeach + +base_lib = static_library('ifpga_rawdev_base', sources, + dependencies: static_rte_eal, + c_args: c_args) +base_objs = base_lib.extract_all_objects()
drivers/raw/ifpga_rawdev/meson.build new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +version = 1 + +subdir('base') +objs = [base_objs] + +deps += ['rawdev', 'pci', 'bus_pci', 'kvargs', + 'bus_vdev', 'bus_ifpga'] +sources = files('ifpga_rawdev.c') + +includes += include_directories('base') + +allow_experimental_apis = true
drivers/raw/meson.build new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'
Signature · 1 line
1.8.3.1
Re: [PATCH v7 4/5] iFPGA: add meson build
Quoted 11 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v7 4/5] iFPGA: add meson build
[...]
Quoted 25 lines
index 0000000..6725687
drivers/raw/ifpga_rawdev/meson.build new file +15
-0@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +version = 1 + +subdir('base') +objs = [base_objs] + +deps += ['rawdev', 'pci', 'bus_pci', 'kvargs', + 'bus_vdev', 'bus_ifpga'] +sources = files('ifpga_rawdev.c') + +includes += include_directories('base') + +allow_experimental_apis = truedrivers/raw/meson.build new file +0
-0
drivers/raw/meson.build line 6
Quoted 6 lines
drivers/raw/meson.build new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2017 Intel Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'
I think you missed this again. From [1], you were to base your patch over cmdif so that this drivers/raw/meson.build introduction doesn't conflict.
Can you rebase and send once again, but *only* once cmdif patches have been merged?
Re: [PATCH v7 4/5] iFPGA: add meson build
Quoted 61 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Sunday, May 6, 2018 2:22 AM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [PATCH v7 4/5] iFPGA: add meson buildQuoted 11 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v7 4/5] iFPGA: add meson build[...]
Quoted 24 lines
index 0000000..6725687
drivers/raw/ifpga_rawdev/meson.build new file +15
-0@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel +Corporation + +version = 1 + +subdir('base') +objs = [base_objs] + +deps += ['rawdev', 'pci', 'bus_pci', 'kvargs', + 'bus_vdev', 'bus_ifpga'] +sources = files('ifpga_rawdev.c') + +includes += include_directories('base') + +allow_experimental_apis = truedrivers/raw/meson.build new renamed from drivers/raw/meson.build +0
-0file mode 100644 index 0000000..410f908
drivers/raw/meson.build line 6
Quoted 6 lines
drivers/raw/meson.build new file +6
-0@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel +Corporation + +drivers = ['ifpga_rawdev'] +config_flag_fmt = 'RTE_LIBRTE_@0@_PMD' +driver_name_fmt = 'rte_@0@'I think you missed this again. From [1], you were to base your patch over cmdif so that this
drivers/raw/meson.buildintroduction doesn't conflict.
Quoted 4 lines
Can you rebase and send once again, but *only* once cmdif patches have been merged?
Oh, we will modify it and send the v8 patches today.
PATCH v7 5/5 iFPGA: add document for iFPGA driver
In reply to Xu, RosenFrom: Figo Zhang <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
--- doc/guides/index.rst | 1 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rawdevs/index.rst | 11 ++++ doc/guides/rel_notes/release_18_05.rst | 13 ++++ 4 files changed, 137 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 doc/guides/rawdevs/index.rst
doc/guides/index.rst +1 -0
@@ -20,6 +20,7 @@ DPDK documentation eventdevs/index mempool/index platform/index + rawdevs/index contributing/index rel_notes/index faq/index
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0
113 lines not on this page · raw message
doc/guides/rawdevs/index.rst new file +11 -0
@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation + +Raw Device Drivers +======================= + +.. toctree:: + :maxdepth: 2 + :numbered: + + ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +13 -0
@@ -164,6 +164,19 @@ New Features stats/xstats on shared memory from secondary process, and also pdump packets on those virtual devices. +* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel FPGA device with + the DPDK framework. It provides Intel FPGA Partial Bit Stream AFU(Accelerated + Function Unit) scan and drivers prove. + +* **Added IFPGA(Intel FPGA) Rawdev Driver.** + + Added a new Rawdev driver called IFPGA(Intel FPGA) Rawdev Driver, which cooperates + with OPAE(Open Programmable Acceleration Engine) share code provides common FPGA + management ops for FPGA operation. + + See the :doc:`../rawdevs/ifpga_rawdev` programmer's guide for more details. API Changes -----------
Signature · 1 line
1.8.3.1
Re: [PATCH v7 5/5] iFPGA: add document for iFPGA driver
Some trivial comments inlined which can be fixed in v8 easily:
Quoted 60 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Friday, May 4, 2018 7:41 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v7 5/5] iFPGA: add document for iFPGA driverFrom: Figo Zhang <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
Signed-off-by Rosen Xu <[email protected]>Signed-off-by Figo Zhang <[email protected]>--- doc/guides/index.rst | 1 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rawdevs/index.rst | 11 ++++ doc/guides/rel_notes/release_18_05.rst | 13 ++++ 4 files changed, 137 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 doc/guides/rawdevs/index.rstdoc/guides/index.rst +1
-0@@ -20,6 +20,7 @@ DPDK documentation eventdevs/index mempool/index platform/index + rawdevs/index contributing/index rel_notes/index faq/indexdoc/guides/rawdevs/ifpga_rawdev.rst new file +7
-0@@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation. + +IFPGA Rawdev Driver +====================== + +FPGA is used more and more widely in Cloud and NFV, one primary reasonis
+that FPGA not only provides ASIC performance but also it's more flexibledoc/guides/rawdevs/ifpga_rawdev.rst new file +4
-0+than ASIC. + +FPGA uses Partial Reconfigure(PR) Parts of Bit Stream to achieve its +flexibility. That means one FPGA Device Bit Stream is divided into
Quoted 2 lines
many Parts
+of Bit Stream(each Part of Bit Stream is defined as AFU-Accelerated
^^^^^^
Stream<space>(each ...
Same at couple of places in below text as well.Quoted 8 lines
Function
+Unit), and each AFU is a hardware acceleration unit which can be dynamicallydoc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+reloaded respectively. + +By PR(Partial Reconfiguration) AFUs, one FPGA resources can be time-shared by
+different users. FPGA hot upgraded and fault tolerance can be provided
^^^^^^^^^^^^
Hot upgrade?Quoted 11 lines
easily.
doc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+ +The SW IFPGA Rawdev Driver (**ifpga_rawdev**) provides a Rawdev driver +that utilizes Intel FPGA Software Stack OPAE(Open ProgrammableAcceleration
doc/guides/rawdevs/ifpga_rawdev.rst new file +6
-0+Engine) for FPGA management. + +Implementation details +---------------------- + +Each instance of IFPGA Rawdev Driver is probed by Intel FpgaDev.
Quoted 1 line
Cooperated
Or, maybe you can use 'In coordination with...' in pace of 'Cooperated'.
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 11 lines
+with OPAE share code IFPGA Rawdev Driver provides common FPGA management ops
doc/guides/rawdevs/ifpga_rawdev.rst new file +9
-0+for FPGA operation, OPAE provides all following operations: +- FPGA PR(Partial Reconfiguration) management +- FPGA AFUs Identifying +- FPGA Thermal Management +- FPGA Power Management +- FPGA Performance reporting +- FPGA Remote Debug + +All configuration parameters is taken by vdev_ifpga_cfg driver.
^^^^
areQuoted 2 lines
Besides
+configuration,vdev_ifpga_cfgdriver also hot plugin AFUs in IFPGA
^^^^^^^^^^^^
also hot plugs
Quoted 49 lines
Bus.
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +All of the AFUs of one FPGA may share same PCI BDF and AFUs scandepend on
+IFPGA Rawdev Driver so IFPGA Bus takes AFU device scan and AFU drivers probe.
+All AFU device driver bind to AFU device by its UUID(Universally Uniquedoc/guides/rawdevs/ifpga_rawdev.rst new file +41
-0+Identifier). + +To avoid unnecessary code duplication and ensure maximum performance, +handling of AFU devices is left to different PMDs; all the design as +summarized by the following block diagram:: + + +---------------------------------------------------------------+ + | Application(s) | + +----------------------------.----------------------------------+ + | + | + +----------------------------'----------------------------------+ + | DPDK Framework (APIs) | + +----------|------------|--------.---------------------|--------+ + / \ | + / \ | + +-------'-------+ +-------'-------+ +--------'--------+ + | Eth PMD | | Crypto PMD | | | + +-------.-------+ +-------.-------+ | | + | | | | + | | | | + +-------'-------+ +-------'-------+ | IFPGA | + | Eth AFU Dev | |Crypto AFU Dev | | Rawdev Driver | + +-------.-------+ +-------.-------+ |(OPAE Share Code)| + | | | | + | | Rawdev | | + +-------'------------------'-------+ Ops | | + | IFPGA Bus | -------->| | + +-----------------.----------------+ +--------.--------+ + | | + Hot-plugin -->| | + | | + +-----------------'------------------+ +--------'--------+ + | vdev_ifpga_cfg driver | | Intel FpgaDev | + +------------------------------------+ +-----------------+ + +Build options +------------- + +- ``CONFIG_RTE_LIBRTE_IFPGA_BUS`` (default ``y``) +
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 10 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +10
-0+ Toggle compilation of IFPGA Bus library. + +- ``CONFIG_RTE_LIBRTE_IFPGA_RAWDEV`` (default ``y``) + + Toggle compilation of the ``ifpga_rawdev`` driver. + +Run-time parameters +------------------- + +This driver is invoked automatically in systems added Intel FPGA
^^^^^^^^^^^^^^
Maybe you meant "systems added with Intel FPGA,.."
Quoted 33 lines
system,
doc/guides/rawdevs/ifpga_rawdev.rst new file +8
-0+but PR and IFPGA Bus scan is trigged by command line using +``--vdev 'net_ifpga_cfg`` EAL option. + +The following device parameters are supported: + +- ``ifpga`` [string] + + Provide a specific Intel FPGA device PCI BDF. Can be providedmultiple
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ times for additional instances. + +- ``port`` [int] + + Each FPGA can provide many channels to PR AFU by software, eachchannels
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ is identified by this parameter. + +- ``afu_bts`` [string] + + If null, the AFU Bit Stream has been PR in FPGA, if not forces PRand
doc/guides/rawdevs/ifpga_rawdev.rst new file +1
-0+ identifies AFU Bit Stream file.doc/guides/rawdevs/index.rst new file +2
-0@@ -0,0 +1,11 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation
doc/guides/rawdevs/index.rst line 11
Quoted 10 lines
doc/guides/rawdevs/index.rst new file +9
-0+ +Raw Device Drivers +======================= + +.. toctree:: + :maxdepth: 2 + :numbered: + + ifpga_rawdev
This patch too would have to be rebased over cmdif patches as that already introduces the rawdevs/index.rst file.
Quoted 33 lines
doc/guides/rel_notes/release_18_05.rst +0
-0@@ -164,6 +164,19 @@ New Features stats/xstats on shared memory from secondary process, and also pdumppackets on
those virtual devices.doc/guides/rel_notes/release_18_05.rst +3
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any IntelFPGA device with
+ the DPDK framework. It provides Intel FPGA Partial Bit Stream AFU(Accelerateddoc/guides/rel_notes/release_18_05.rst +5
-0+ Function Unit) scan and drivers prove. + +* **Added IFPGA(Intel FPGA) Rawdev Driver.** + + Added a new Rawdev driver called IFPGA(Intel FPGA) Rawdev Driver,which cooperates
+ with OPAE(Open Programmable Acceleration Engine) share code provides common FPGAdoc/guides/rel_notes/release_18_05.rst +3
-0+ management ops for FPGA operation. + + See the :doc:`../rawdevs/ifpga_rawdev` programmer's guide for moredetails.
API Changes
-----------
--
1.8.3.1
v8 cover Introduce Intel FPGA BUS
In reply to Rosen XuFrom: "Xu, Rosen" <[email protected]>
Intel FPGA BUS in DPDK
-------------------------
This patch set introduces Intel FPGA BUS support in DPDK.
v8 updates:
==========
- Fix some comments from Shreyansh Jain
- Patch 3 and Patch 5 will continue rebase when qcom patches merging into mainline
- add Shreyansh Jain's Acked-by
v7 updates:
==========
- Fix some comments from DPDK community
- Fix the CLANG compile error
- Fix the meson build warring.
v6 updates:
===========
- Add documentation
- Add meson build script
- Split new patch for OPAE share code
v5 updates:
===========
- Fixed SHARED LIB Build issue
- Changed command name to IFPGA Rawdev name,
so remove pci library datastruct and function.
- Fixed PATCH v2/v3/v4 comments
v4 updates:
===========
- Remove all modifications from eal
- Create vdev to take IFPGA parameters configuration
- AFU Device Driver bind to AFU Device by uuid
- Take more test in scenario of Multi-FPGA System
v3 updates:
===========
- Remove all modifications of bus scan and probe
- FPGA BUS Scan is trigged by hotplug of Rawdev
- Took Modifications of comments
- Move AFU Device to IFPGA
- FPGA BUS Scan depend on it¡¯s IFPGA Rawdev
- Add Build Macros for FPGA BUS and IFPGA Rawdev
Questions
=========
Why not PCI Bus?
All of the AFUs of one FPGA may share same PCI BDF. Why not vdev Bus?
Because AFUs depend on Rawdev, and it's hardware specpic.
Motivation
==========
FPGA is used more and more widely in Cloud and NFV, one primary reason is that FPGA not only provide ASIC performance but also it's more flexible than ASIC. FPGA use Partial Reconfigure(PR) Parts of Bitstream to achieve its flexibility. Another reason is that one FPGA can be shared by different Users, and each User can use some of AFUs of One FPGA.
That means One FPGA Device Bitstream is divided into many Parts of Bitstream(each Part of Bitstream is defined as AFU-Accelerated Function Unit), and each AFU is a Hardware Acceleration Unit and it can dynamically Reload respectively.
Proposed Solution
=================
- Involve Rawdev to take FPGA Partial Configuration(Download/PR)
- Defined FPGA-BUS for Acceleration Drivers of AFUs
- FPGA PCI Scan(1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver. FPGA-BUS scan is called, but AFU depend on Rawdev, so this scan doesn't trig AFU device create.
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their dirves are also probed.
Scope
=====
The Intel FPGA BUS implementation is target towards various FPGA Devices use PR to provide many Acceleration Function. Specific PMDs may also bind to its AFU. And Applications don't care they are using ASIC Acceleration or FPGA AFU Acceleration.
Status
=====
With integrating Intel PSG FPGA Software Stack OPAE(Open Programmable Acceleration Engine) Share Code, Intel FPGA BUS runs well in Intel PSG FPGA Cards.
Figo Zhang (2):
iFPGA: add meson build
iFPGA: add document for iFPGA driver
Rosen Xu (3):
bus/ifpga: Add Intel FPGA BUS Library
iFPGA: Add Intel FPGA OPAE Share Code
iFPGA: Add Intel FPGA BUS Rawdev Driver
config/common_base | 6 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 ++ doc/guides/rel_notes/release_18_05.rst | 13 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 + drivers/bus/ifpga/ifpga_bus.c | 501 ++++++ drivers/bus/ifpga/ifpga_common.c | 88 ++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 + drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 ++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 + drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/meson.build | 34 + drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 608 +++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 + drivers/raw/ifpga_rawdev/meson.build | 15 + .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 5 +- 48 files changed, 9736 insertions(+), 2 deletions(-) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
PATCH v8 1/5 bus/ifpga: Add Intel FPGA BUS Library
From: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce rte_afu_device which describe the AFU device listed in the FPGA-BUS.
--- config/common_base | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 12 files changed, 856 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
config/common_base +5 -0
@@ -149,6 +149,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y CONFIG_RTE_LIBRTE_VDEV_BUS=y # +# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile ARK PMD # CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
@@ -9,5 +9,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +501 -0
501 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.c new file +88 -0
88 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_unsigned_long (const char *str,int base); +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) +#define IFPGA_BUS_INFO(fmt, args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */
drivers/bus/ifpga/meson.build new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2018 Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = true
drivers/bus/ifpga/rte_bus_ifpga.h new file +160 -0
160 lines not on this page · raw message
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10 -0
@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + ifpga_get_integer32_arg; + ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};
drivers/bus/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +1 -0
@@ -251,6 +251,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV
Signature · 1 line
1.8.3.1
PATCH v8 2/5 iFPGA: Add Intel FPGA OPAE Share Code
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
This patch adds Intel FPGA Open Programmable Acceleration Engine (OPAE)[1] base driver code, in order to support Intel FPGA devices under DPDK. The base code currently supports Intel FPGA solutions including integrated solution (Intel(R) Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA devices in the future. Please refer to [1][2] for more introduction on OPAE and Intel FPGAs.
[1] https://01.org/OPAE
[2] https://www.altera.com/solutions/acceleration-hub/overview.html
--- drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + 27 files changed, 8016 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +30 -0
@@ -0,0 +1,30 @@ +#SPDX-License-Identifier: BSD-3-Clause +#Copyright(c) 2010-2018 Intel Corporation + +ifneq ($(CONFIG_RTE_LIBRTE_EAL),) +OSDEP := osdep_rte +else +OSDEP := osdep_raw +endif + +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev/base/$(OSDEP) + +SRCS-y += ifpga_api.c +SRCS-y += ifpga_enumerate.c +SRCS-y += ifpga_feature_dev.c +SRCS-y += ifpga_fme.c +SRCS-y += ifpga_fme_iperf.c +SRCS-y += ifpga_fme_dperf.c +SRCS-y += ifpga_fme_error.c +SRCS-y += ifpga_port.c +SRCS-y += ifpga_port_error.c +SRCS-y += opae_hw_api.c +SRCS-y += opae_ifpga_hw_api.c +SRCS-y += opae_debug.c +SRCS-y += ifpga_fme_pr.c + +ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y) + CFLAGS_ifpga_fme_pr.o += -march=knl +endif + +SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/README new file +31 -0
@@ -0,0 +1,31 @@ +.. + +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2018 Intel Corporation + */ + +Intel® iFPGA driver +================== + +This directory contains source code of Intel FPGA driver released by +the team which develops Intel FPGA Open Programmable Acceleration Engine (OPAE). +The directory of base/ contains the original source package. The base code +currently supports Intel FPGA solutions including integrated solution (Intel(R) +Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration +Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA +devices in the future. + +Please refer to [1][2] for more introduction on OPAE and Intel FPGAs. + +[1] https://01.org/OPAE +[2] https://www.altera.com/solutions/acceleration-hub/overview.html + + +Updating the driver +=================== + +NOTE: The source code in this directory should not be modified apart from +the following file(s): + + osdep_raw/osdep_generic.h + osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +294 -0
294 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_API_H_ +#define _IFPGA_API_H_ + +#include "opae_hw_api.h" +#include "ifpga_hw.h" + +extern struct opae_adapter_ops ifpga_adapter_ops; +extern struct opae_manager_ops ifpga_mgr_ops; +extern struct opae_bridge_ops ifpga_br_ops; +extern struct opae_accelerator_ops ifpga_acc_ops; + +/* common APIs */ +int ifpga_get_prop (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +struct feature_prop *prop); +int ifpga_set_prop (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +struct feature_prop *prop); +int ifpga_set_irq (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +u32 feature_id,void *irq_set); + +/* FME APIs */ +int ifpga_pr (struct ifpga_hw *hw,u32 port_id,void *buffer,u32 size, +u64 *status); + +#endif /* _IFPGA_API_H_ */
drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +57 -0
57 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_defines.h new file +1661 -0
1,661 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c new file +824 -0
824 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_ENUMERATE_H_ +#define _IFPGA_ENUMERATE_H_ + +int ifpga_bus_init (struct ifpga_hw *hw); +int ifpga_bus_enumerate (struct ifpga_hw *hw); + +#endif /* _IFPGA_ENUMERATE_H_ */
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +314 -0
64 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +164 -0
164 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +734 -0
734 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +301 -0
301 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +403 -0
403 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +715 -0
715 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +372 -0
372 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +127 -0
127 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +408 -0
408 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_port_error.c new file +165 -0
165 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_debug.c new file +99 -0
99 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_debug.h new file +19 -0
Lines of this file are not shown. View the raw message.
drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +381 -0
381 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +253 -0
253 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +145 -0
145 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +279 -0
279 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +81 -0
81 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +75 -0
75 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +45 -0
45 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.
PATCH v8 3/5 iFPGA: Add Intel FPGA BUS Rawdev Driver
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.
--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 608 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map | 4 + mk/rte.app.mk | 4 +- 7 files changed, 690 insertions(+), 1 deletion(-) create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
config/common_base +1 -0
@@ -152,6 +152,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y # Compile the Intel FPGA bus # CONFIG_RTE_LIBRTE_IFPGA_BUS=y +CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y # # Compile ARK PMD
drivers/raw/Makefile +1 -0
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk # DIRS-$(<configuration>) += <directory> DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifpga_rawdev.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_kvargs +LDLIBS += -lrte_bus_pci +LDLIBS += -lrte_bus_ifpga + +EXPORT_MAP := rte_ifpga_rawdev_version.map + +LIBABIVER := 1 + +VPATH += $(SRCDIR)/base + +include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +608 -0
608 lines not on this page · raw message
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "ifgpa: " fmt, \ + ##args) + +#define IFPGA_RAWDEV_PMD_FUNC_TRACE () IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>") + +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY , +IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) +{ +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
mk/rte.app.mk +3 -1
@@ -252,9 +252,11 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev _LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga +ifeq ($(CONFIG_RTE_LIBRTE_IFPGA_BUS),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev +endif # CONFIG_RTE_LIBRTE_IFPGA_BUS endif # CONFIG_RTE_LIBRTE_RAWDEV - endif # !CONFIG_RTE_BUILD_SHARED_LIBS _LDLIBS-y += --no-whole-archive
Signature · 1 line
1.8.3.1
PATCH v8 4/5 iFPGA: add meson build
In reply to Xu, RosenFrom: Figo Zhang <[email protected]>
add meson build support for iFPGA driver.
--- drivers/raw/ifpga_rawdev/base/meson.build | 34 +++++++++++++++++++++++++++++++ drivers/raw/ifpga_rawdev/meson.build | 15 ++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/meson.build
drivers/raw/ifpga_rawdev/base/meson.build new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +sources = [ + 'ifpga_api.c', + 'ifpga_enumerate.c', + 'ifpga_feature_dev.c', + 'ifpga_fme.c', + 'ifpga_fme_iperf.c', + 'ifpga_fme_dperf.c', + 'ifpga_fme_error.c', + 'ifpga_port.c', + 'ifpga_port_error.c', + 'ifpga_fme_pr.c', + 'opae_hw_api.c', + 'opae_ifpga_hw_api.c', + 'opae_debug.c' +] + +error_cflags = ['-Wno-sign-compare', '-Wno-unused-value', + '-Wno-format', '-Wno-unused-but-set-variable', + '-Wno-strict-aliasing' +] +c_args = cflags +foreach flag: error_cflags + if cc.has_argument(flag) + c_args += flag + endif +endforeach + +base_lib = static_library('ifpga_rawdev_base', sources, + dependencies: static_rte_eal, + c_args: c_args) +base_objs = base_lib.extract_all_objects()
drivers/raw/ifpga_rawdev/meson.build new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +version = 1 + +subdir('base') +objs = [base_objs] + +deps += ['rawdev', 'pci', 'bus_pci', 'kvargs', + 'bus_vdev', 'bus_ifpga'] +sources = files('ifpga_rawdev.c') + +includes += include_directories('base') + +allow_experimental_apis = true
Signature · 1 line
1.8.3.1
PATCH v8 5/5 iFPGA: add document for iFPGA driver
In reply to Xu, RosenFrom: Figo Zhang <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
--- doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rel_notes/release_18_05.rst | 13 ++++ 2 files changed, 125 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0
@@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation. + +IFPGA Rawdev Driver +====================== + +FPGA is used more and more widely in Cloud and NFV, one primary reason is +that FPGA not only provides ASIC performance but also it's more flexible +than ASIC. + +FPGA uses Partial Reconfigure (PR) Parts of Bit Stream to achieve its +flexibility. That means one FPGA Device Bit Stream is divided into many Parts +of Bit Stream(each Part of Bit Stream is defined as AFU-Accelerated Function +Unit), and each AFU is a hardware acceleration unit which can be dynamically +reloaded respectively. + +By PR (Partial Reconfiguration) AFUs, one FPGA resources can be time-shared by +different users. FPGA hot upgrade and fault tolerance can be provided easily. + +The SW IFPGA Rawdev Driver (**ifpga_rawdev**) provides a Rawdev driver +that utilizes Intel FPGA Software Stack OPAE(Open Programmable Acceleration +Engine) for FPGA management. + +Implementation details +---------------------- + +Each instance of IFPGA Rawdev Driver is probed by Intel FpgaDev. In coordination +with OPAE share code IFPGA Rawdev Driver provides common FPGA management ops +for FPGA operation, OPAE provides all following operations: +- FPGA PR (Partial Reconfiguration) management +- FPGA AFUs Identifying +- FPGA Thermal Management +- FPGA Power Management +- FPGA Performance reporting +- FPGA Remote Debug + +All configuration parameters are taken by vdev_ifpga_cfg driver. Besides +configuration, vdev_ifpga_cfg driver also hot plugs in IFPGA Bus. + +All of the AFUs of one FPGA may share same PCI BDF and AFUs scan depend on +IFPGA Rawdev Driver so IFPGA Bus takes AFU device scan and AFU drivers probe. +All AFU device driver bind to AFU device by its UUID (Universally Unique +Identifier). + +To avoid unnecessary code duplication and ensure maximum performance, +handling of AFU devices is left to different PMDs; all the design as +summarized by the following block diagram:: + + +---------------------------------------------------------------+ + | Application(s) | + +----------------------------.----------------------------------+ + | + | + +----------------------------'----------------------------------+ + | DPDK Framework (APIs) | + +----------|------------|--------.---------------------|--------+ + / \ | + / \ | + +-------'-------+ +-------'-------+ +--------'--------+ + | Eth PMD | | Crypto PMD | | | + +-------.-------+ +-------.-------+ | | + | | | | + | | | | + +-------'-------+ +-------'-------+ | IFPGA | + | Eth AFU Dev | |Crypto AFU Dev | | Rawdev Driver | + +-------.-------+ +-------.-------+ |(OPAE Share Code)| + | | | | + | | Rawdev | | + +-------'------------------'-------+ Ops | | + | IFPGA Bus | -------->| | + +-----------------.----------------+ +--------.--------+ + | | + Hot-plugin -->| | + | | + +-----------------'------------------+ +--------'--------+ + | vdev_ifpga_cfg driver | | Intel FpgaDev | + +------------------------------------+ +-----------------+ + +Build options +------------- + +- ``CONFIG_RTE_LIBRTE_IFPGA_BUS`` (default ``y``) + + Toggle compilation of IFPGA Bus library. + +- ``CONFIG_RTE_LIBRTE_IFPGA_RAWDEV`` (default ``y``) + + Toggle compilation of the ``ifpga_rawdev`` driver. + +Run-time parameters +------------------- + +This driver is invoked automatically in systems added with Intel FPGA, +but PR and IFPGA Bus scan is trigged by command line using +``--vdev 'net_ifpga_cfg`` EAL option. + +The following device parameters are supported: + +- ``ifpga`` [string] + + Provide a specific Intel FPGA device PCI BDF. Can be provided multiple + times for additional instances. + +- ``port`` [int] + + Each FPGA can provide many channels to PR AFU by software, each channels + is identified by this parameter. + +- ``afu_bts`` [string] + + If null, the AFU Bit Stream has been PR in FPGA, if not forces PR and + identifies AFU Bit Stream file.
doc/guides/rel_notes/release_18_05.rst +13 -0
@@ -164,6 +164,19 @@ New Features stats/xstats on shared memory from secondary process, and also pdump packets on those virtual devices. +* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel FPGA device with + the DPDK framework. It provides Intel FPGA Partial Bit Stream AFU(Accelerated + Function Unit) scan and drivers prove. + +* **Added IFPGA(Intel FPGA) Rawdev Driver.** + + Added a new Rawdev driver called IFPGA(Intel FPGA) Rawdev Driver, which cooperates + with OPAE(Open Programmable Acceleration Engine) share code provides common FPGA + management ops for FPGA operation. + + See the :doc:`../rawdevs/ifpga_rawdev` programmer's guide for more details. API Changes -----------
Signature · 1 line
1.8.3.1
Re: [PATCH v8 5/5] iFPGA: add document for iFPGA driver
Hi Rosen,
Quoted 158 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Sunday, May 6, 2018 2:11 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v8 5/5] iFPGA: add document for iFPGA driverFrom: Figo Zhang <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
Signed-off-by Rosen Xu <[email protected]>Signed-off-by Figo Zhang <[email protected]>--- doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rel_notes/release_18_05.rst | 13 ++++ 2 files changed, 125 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rstdoc/guides/rawdevs/ifpga_rawdev.rst new file +7
-0@@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation. + +IFPGA Rawdev Driver +====================== + +FPGA is used more and more widely in Cloud and NFV, one primary reasonis
+that FPGA not only provides ASIC performance but also it's more flexibledoc/guides/rawdevs/ifpga_rawdev.rst new file +4
-0+than ASIC. + +FPGA uses Partial Reconfigure (PR) Parts of Bit Stream to achieve its +flexibility. That means one FPGA Device Bit Stream is divided intomany Parts
+of Bit Stream(each Part of Bit Stream is defined as AFU-Accelerated Function
+Unit), and each AFU is a hardware acceleration unit which can be dynamicallydoc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+reloaded respectively. + +By PR (Partial Reconfiguration) AFUs, one FPGA resources can be time-shared by
+different users. FPGA hot upgrade and fault tolerance can be provided easily.doc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+ +The SW IFPGA Rawdev Driver (**ifpga_rawdev**) provides a Rawdev driver +that utilizes Intel FPGA Software Stack OPAE(Open ProgrammableAcceleration
doc/guides/rawdevs/ifpga_rawdev.rst new file +6
-0+Engine) for FPGA management. + +Implementation details +---------------------- + +Each instance of IFPGA Rawdev Driver is probed by Intel FpgaDev. Incoordination
+with OPAE share code IFPGA Rawdev Driver provides common FPGA management opsdoc/guides/rawdevs/ifpga_rawdev.rst new file +9
-0+for FPGA operation, OPAE provides all following operations: +- FPGA PR (Partial Reconfiguration) management +- FPGA AFUs Identifying +- FPGA Thermal Management +- FPGA Power Management +- FPGA Performance reporting +- FPGA Remote Debug + +All configuration parameters are taken by vdev_ifpga_cfg driver.Besides
doc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+configuration, vdev_ifpga_cfg driver also hot plugs in IFPGA Bus. + +All of the AFUs of one FPGA may share same PCI BDF and AFUs scandepend on
+IFPGA Rawdev Driver so IFPGA Bus takes AFU device scan and AFU drivers probe.
+All AFU device driver bind to AFU device by its UUID (Universally Uniquedoc/guides/rawdevs/ifpga_rawdev.rst new file +59
-0+Identifier). + +To avoid unnecessary code duplication and ensure maximum performance, +handling of AFU devices is left to different PMDs; all the design as +summarized by the following block diagram:: + + +---------------------------------------------------------------+ + | Application(s) | + +----------------------------.----------------------------------+ + | + | + +----------------------------'----------------------------------+ + | DPDK Framework (APIs) | + +----------|------------|--------.---------------------|--------+ + / \ | + / \ | + +-------'-------+ +-------'-------+ +--------'--------+ + | Eth PMD | | Crypto PMD | | | + +-------.-------+ +-------.-------+ | | + | | | | + | | | | + +-------'-------+ +-------'-------+ | IFPGA | + | Eth AFU Dev | |Crypto AFU Dev | | Rawdev Driver | + +-------.-------+ +-------.-------+ |(OPAE Share Code)| + | | | | + | | Rawdev | | + +-------'------------------'-------+ Ops | | + | IFPGA Bus | -------->| | + +-----------------.----------------+ +--------.--------+ + | | + Hot-plugin -->| | + | | + +-----------------'------------------+ +--------'--------+ + | vdev_ifpga_cfg driver | | Intel FpgaDev | + +------------------------------------+ +-----------------+ + +Build options +------------- + +- ``CONFIG_RTE_LIBRTE_IFPGA_BUS`` (default ``y``) + + Toggle compilation of IFPGA Bus library. + +- ``CONFIG_RTE_LIBRTE_IFPGA_RAWDEV`` (default ``y``) + + Toggle compilation of the ``ifpga_rawdev`` driver. + +Run-time parameters +------------------- + +This driver is invoked automatically in systems added with Intel FPGA, +but PR and IFPGA Bus scan is trigged by command line using +``--vdev 'net_ifpga_cfg`` EAL option. + +The following device parameters are supported: + +- ``ifpga`` [string] + + Provide a specific Intel FPGA device PCI BDF. Can be providedmultiple
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ times for additional instances. + +- ``port`` [int] + + Each FPGA can provide many channels to PR AFU by software, eachchannels
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ is identified by this parameter. + +- ``afu_bts`` [string] + + If null, the AFU Bit Stream has been PR in FPGA, if not forces PR
Quoted 2 lines
and
+ identifies AFU Bit Stream file.
[...]
If you don't introduce this file into doc/guides/rawdevs/index.rst (like your v7), the doc index won't be generated.
I think you misunderstood my comment in [1] - I meant that you will have to rebase over CMDIF because it has already introduced the doc/guides/rawdevs/index.rst file. Your patch v7 was adding this file. It would have conflicted for Thomas' eventual merge.
[1] http://dpdk.org/ml/archives/dev/2018-May/100313.html
Unfortunately, you might have to send a v9 or maybe Thomas can take care of this while merging.
Re: [PATCH v8 5/5] iFPGA: add document for iFPGA driver
Quoted 203 lines
-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Sunday, May 6, 2018 7:54 PM
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [PATCH v8 5/5] iFPGA: add document for iFPGA driverHi Rosen,
Quoted 89 lines
-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Sunday, May 6, 2018 2:11 PM
To: [email protected]
Cc: [email protected]; [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v8 5/5] iFPGA: add document for iFPGA driverFrom: Figo Zhang <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
Signed-off-by Rosen Xu <[email protected]>Signed-off-by Figo Zhang <[email protected]>--- doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rel_notes/release_18_05.rst | 13 ++++ 2 files changed, 125 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rstdoc/guides/rawdevs/ifpga_rawdev.rst new file +8
-0@@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation. + +IFPGA Rawdev Driver +====================== + +FPGA is used more and more widely in Cloud and NFV, one primary +reasonis
+that FPGA not only provides ASIC performance but also it's more flexibledoc/guides/rawdevs/ifpga_rawdev.rst new file +4
-0+than ASIC. + +FPGA uses Partial Reconfigure (PR) Parts of Bit Stream to achieve its +flexibility. That means one FPGA Device Bit Stream is divided intomany Parts
+of Bit Stream(each Part of Bit Stream is defined as AFU-Accelerated Function
+Unit), and each AFU is a hardware acceleration unit which can be dynamicallydoc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+reloaded respectively. + +By PR (Partial Reconfiguration) AFUs, one FPGA resources can be time-shared by
+different users. FPGA hot upgrade and fault tolerance can be provided easily.doc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+ +The SW IFPGA Rawdev Driver (**ifpga_rawdev**) provides a Rawdev +driver that utilizes Intel FPGA Software Stack OPAE(Open ProgrammableAcceleration
doc/guides/rawdevs/ifpga_rawdev.rst new file +6
-0+Engine) for FPGA management. + +Implementation details +---------------------- + +Each instance of IFPGA Rawdev Driver is probed by Intel FpgaDev. Incoordination
+with OPAE share code IFPGA Rawdev Driver provides common FPGA management opsdoc/guides/rawdevs/ifpga_rawdev.rst new file +9
-0+for FPGA operation, OPAE provides all following operations: +- FPGA PR (Partial Reconfiguration) management +- FPGA AFUs Identifying +- FPGA Thermal Management +- FPGA Power Management +- FPGA Performance reporting +- FPGA Remote Debug + +All configuration parameters are taken by vdev_ifpga_cfg driver.Besides
doc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+configuration, vdev_ifpga_cfg driver also hot plugs in IFPGA Bus. + +All of the AFUs of one FPGA may share same PCI BDF and AFUs scandepend on
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+IFPGA Rawdev Driver so IFPGA Bus takes AFU device scan and AFU +driversprobe.
+All AFU device driver bind to AFU device by its UUID (Universally Uniquedoc/guides/rawdevs/ifpga_rawdev.rst
Quoted 3 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +3
-0+Identifier). + +To avoid unnecessary code duplication and ensure maximumperformance,
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 5 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+handling of AFU devices is left to different PMDs; all the design as +summarized by the following block diagram:: + + +---------------------------------------------------------------+ + | Application(s)|
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 5 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ +----------------------------.----------------------------------+ + | + | + +----------------------------'----------------------------------+ + | DPDK Framework (APIs)|
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +----------|------------|--------.---------------------|--------+ + / \|
Quoted 1 line
+ / \
|
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-------'-------+ +-------'-------+ +--------'--------+ + | Eth PMD | | Crypto PMD | ||
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-------.-------+ +-------.-------+ | | + | | ||
Quoted 1 line
+ | | |
|
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-------'-------+ +-------'-------+ | IFPGA | + | Eth AFU Dev | |Crypto AFU Dev | | RawdevDriver |
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-------.-------+ +-------.-------+ |(OPAE Share Code)| + | | ||
Quoted 1 line
+ | | Rawdev |
|
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-------'------------------'-------+ Ops | | + | IFPGA Bus | -------->||
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-----------------.----------------+ +--------.--------+ + ||
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ Hot-plugin -->| | + ||
doc/guides/rawdevs/ifpga_rawdev.rst
Quoted 2 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +2
-0+ +-----------------'------------------+ +--------'--------+ + | vdev_ifpga_cfg driver | | IntelFpgaDev |
Quoted 37 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +25
-0+ +------------------------------------+ +-----------------+ + +Build options +------------- + +- ``CONFIG_RTE_LIBRTE_IFPGA_BUS`` (default ``y``) + + Toggle compilation of IFPGA Bus library. + +- ``CONFIG_RTE_LIBRTE_IFPGA_RAWDEV`` (default ``y``) + + Toggle compilation of the ``ifpga_rawdev`` driver. + +Run-time parameters +------------------- + +This driver is invoked automatically in systems added with Intel +FPGA, but PR and IFPGA Bus scan is trigged by command line using +``--vdev 'net_ifpga_cfg`` EAL option. + +The following device parameters are supported: + +- ``ifpga`` [string] + + Provide a specific Intel FPGA device PCI BDF. Can be providedmultiple
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ times for additional instances. + +- ``port`` [int] + + Each FPGA can provide many channels to PR AFU by software, eachchannels
doc/guides/rawdevs/ifpga_rawdev.rst new file +5
-0+ is identified by this parameter. + +- ``afu_bts`` [string] + + If null, the AFU Bit Stream has been PR in FPGA, if not forces PRQuoted 2 lines
and
+ identifies AFU Bit Stream file.[...]
If you don't introduce this file into
doc/guides/rawdevs/index.rst(like your v7), the doc index won't be generated.
I think you misunderstood my comment in [1] - I meant that you will have to rebase over CMDIF because it has already introduced thedoc/guides/rawdevs/index.rstfile. Your patch v7 was adding this file. It would have conflicted for Thomas' eventual merge.
Quoted 4 lines
[1] http://dpdk.org/ml/archives/dev/2018-May/100313.html
Unfortunately, you might have to send a v9 or maybe Thomas can take care of this while merging.
Hi Shreyansh,
Do you mean we donot need this patch on V9.
Reset this patch when the CMDIF patches have merged into mainline, right?
v9 cover Introduce Intel FPGA BUS
In reply to Rosen XuFrom: "Xu, Rosen" <[email protected]>
Intel FPGA BUS in DPDK
-------------------------
This patch set introduces Intel FPGA BUS support in DPDK.
v9 updates:
==========
- Rebase ifpga_rawdev on QDMA and CMDIF driver
- Split and squash the patch 4(v8 patch) into patch 2 and patch 3
v8 updates:
==========
- Fix some comments from Shreyansh Jain
- Patch 3 and Patch 5 will continue rebase when qcom patches merging into mainline
- add Shreyansh Jain's Acked-by
v7 updates:
==========
- Fix some comments from DPDK community
- Fix the CLANG compile error
- Fix the meson build warring.
v6 updates:
===========
- Add documentation
- Add meson build script
- Split new patch for OPAE share code
v5 updates:
===========
- Fixed SHARED LIB Build issue
- Changed command name to IFPGA Rawdev name,
so remove pci library datastruct and function.
- Fixed PATCH v2/v3/v4 comments
v4 updates:
===========
- Remove all modifications from eal
- Create vdev to take IFPGA parameters configuration
- AFU Device Driver bind to AFU Device by uuid
- Take more test in scenario of Multi-FPGA System
v3 updates:
===========
- Remove all modifications of bus scan and probe
- FPGA BUS Scan is trigged by hotplug of Rawdev
- Took Modifications of comments
- Move AFU Device to IFPGA
- FPGA BUS Scan depend on it's IFPGA Rawdev
- Add Build Macros for FPGA BUS and IFPGA Rawdev
Questions
=========
Why not PCI Bus?
All of the AFUs of one FPGA may share same PCI BDF. Why not vdev Bus?
Because AFUs depend on Rawdev, and it's hardware specpic.
Motivation
==========
FPGA is used more and more widely in Cloud and NFV, one primary reason is that FPGA not only provide ASIC performance but also it's more flexible than ASIC. FPGA use Partial Reconfigure(PR) Parts of Bitstream to achieve its flexibility. Another reason is that one FPGA can be shared by different Users, and each User can use some of AFUs of One FPGA.
That means One FPGA Device Bitstream is divided into many Parts of Bitstream(each Part of Bitstream is defined as AFU-Accelerated Function Unit), and each AFU is a Hardware Acceleration Unit and it can dynamically Reload respectively.
Proposed Solution
=================
- Involve Rawdev to take FPGA Partial Configuration(Download/PR)
- Defined FPGA-BUS for Acceleration Drivers of AFUs
- FPGA PCI Scan(1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver. FPGA-BUS scan is called, but AFU depend on Rawdev, so this scan doesn't trig AFU device create.
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their dirves are also probed.
Scope
=====
The Intel FPGA BUS implementation is target towards various FPGA Devices use PR to provide many Acceleration Function. Specific PMDs may also bind to its AFU. And Applications don't care they are using ASIC Acceleration or FPGA AFU Acceleration.
Status
=====
With integrating Intel PSG FPGA Software Stack OPAE(Open Programmable Acceleration Engine) Share Code, Intel FPGA BUS runs well in Intel PSG FPGA Cards.
Figo Zhang (2):
iFPGA: Add Intel FPGA BUS Rawdev Driver
iFPGA: Add Intel FPGA OPAE Share Code
Rosen Xu (2):
bus/ifpga: Add Intel FPGA BUS Library
iFPGA: add document for iFPGA driver
config/common_base | 6 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 ++ doc/guides/rawdevs/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 13 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 + drivers/bus/ifpga/ifpga_bus.c | 501 ++++++ drivers/bus/ifpga/ifpga_common.c | 88 ++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 + drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 ++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 + drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/meson.build | 34 + drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 608 +++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 + drivers/raw/ifpga_rawdev/meson.build | 15 + .../ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map | 4 + drivers/raw/meson.build | 2 +- mk/rte.app.mk | 5 +- 50 files changed, 9738 insertions(+), 3 deletions(-) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
PATCH v9 1/4 bus/ifpga: Add Intel FPGA BUS Library
From: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce rte_afu_device which describe the AFU device listed in the FPGA-BUS.
--- config/common_base | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 12 files changed, 856 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
config/common_base +5 -0
@@ -149,6 +149,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y CONFIG_RTE_LIBRTE_VDEV_BUS=y # +# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile ARK PMD # CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
@@ -9,5 +9,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +501 -0
501 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.c new file +88 -0
88 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_unsigned_long (const char *str,int base); +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) +#define IFPGA_BUS_INFO(fmt, args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */
drivers/bus/ifpga/meson.build new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2018 Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = true
drivers/bus/ifpga/rte_bus_ifpga.h new file +160 -0
160 lines not on this page · raw message
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10 -0
@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + ifpga_get_integer32_arg; + ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};
drivers/bus/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +1 -0
@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV
Signature · 1 line
1.8.3.1
Re: [PATCH v9 1/4] bus/ifpga: Add Intel FPGA BUS Library
08/05/2018 16:19, Xu, Rosen:
drivers/bus/ifpga/rte_bus_ifpga_version.map line 7
Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +4
-0+ ifpga_get_integer32_arg; + ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister;
All exported symbols must start with rte_
drivers/bus/meson.build line 4
Quoted 4 lines
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga']
Would be better sorted in alphabetical order (between fslmc and pci). Same comment in files config/common_base and drivers/bus/Makefile.
Re: [PATCH v9 1/4] bus/ifpga: Add Intel FPGA BUS Library
Hi Thomas,
Quoted 13 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, May 08, 2018 22:43
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [PATCH v9 1/4] bus/ifpga: Add Intel FPGA BUS Library08/05/2018 16:19, Xu, Rosen:
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map line 7
Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +4
-0+ ifpga_get_integer32_arg; + ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister;All exported symbols must start with
rte_
I will fix it in v10.
Quoted 8 lines
drivers/bus/meson.build line 4
Quoted 5 lines
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga']Would be better sorted in alphabetical order (between fslmc and pci). Same comment in files config/common_base and
drivers/bus/Makefile.
I will fix in in v10.
PATCH v9 2/4 iFPGA: Add Intel FPGA OPAE Share Code
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
This patch adds Intel FPGA Open Programmable Acceleration Engine (OPAE)[1] base driver code, in order to support Intel FPGA devices under DPDK. The base code currently supports Intel FPGA solutions including integrated solution (Intel(R) Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA devices in the future. Please refer to [1][2] for more introduction on OPAE and Intel FPGAs.
[1] https://01.org/OPAE
[2] https://www.altera.com/solutions/acceleration-hub/overview.html
--- drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/meson.build | 34 + drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + 28 files changed, 8050 insertions(+) create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +30 -0
@@ -0,0 +1,30 @@ +#SPDX-License-Identifier: BSD-3-Clause +#Copyright(c) 2010-2018 Intel Corporation + +ifneq ($(CONFIG_RTE_LIBRTE_EAL),) +OSDEP := osdep_rte +else +OSDEP := osdep_raw +endif + +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev/base/$(OSDEP) + +SRCS-y += ifpga_api.c +SRCS-y += ifpga_enumerate.c +SRCS-y += ifpga_feature_dev.c +SRCS-y += ifpga_fme.c +SRCS-y += ifpga_fme_iperf.c +SRCS-y += ifpga_fme_dperf.c +SRCS-y += ifpga_fme_error.c +SRCS-y += ifpga_port.c +SRCS-y += ifpga_port_error.c +SRCS-y += opae_hw_api.c +SRCS-y += opae_ifpga_hw_api.c +SRCS-y += opae_debug.c +SRCS-y += ifpga_fme_pr.c + +ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y) + CFLAGS_ifpga_fme_pr.o += -march=knl +endif + +SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/README new file +31 -0
@@ -0,0 +1,31 @@ +.. + +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2018 Intel Corporation + */ + +Intel® iFPGA driver +================== + +This directory contains source code of Intel FPGA driver released by +the team which develops Intel FPGA Open Programmable Acceleration Engine (OPAE). +The directory of base/ contains the original source package. The base code +currently supports Intel FPGA solutions including integrated solution (Intel(R) +Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration +Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA +devices in the future. + +Please refer to [1][2] for more introduction on OPAE and Intel FPGAs. + +[1] https://01.org/OPAE +[2] https://www.altera.com/solutions/acceleration-hub/overview.html + + +Updating the driver +=================== + +NOTE: The source code in this directory should not be modified apart from +the following file(s): + + osdep_raw/osdep_generic.h + osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +294 -0
294 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +28 -0
@@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_API_H_ +#define _IFPGA_API_H_ + +#include "opae_hw_api.h" +#include "ifpga_hw.h" + +extern struct opae_adapter_ops ifpga_adapter_ops; +extern struct opae_manager_ops ifpga_mgr_ops; +extern struct opae_bridge_ops ifpga_br_ops; +extern struct opae_accelerator_ops ifpga_acc_ops; + +/* common APIs */ +int ifpga_get_prop (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +struct feature_prop *prop); +int ifpga_set_prop (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +struct feature_prop *prop); +int ifpga_set_irq (struct ifpga_hw *hw,u32 fiu_id,u32 port_id, +u32 feature_id,void *irq_set); + +/* FME APIs */ +int ifpga_pr (struct ifpga_hw *hw,u32 port_id,void *buffer,u32 size, +u64 *status); + +#endif /* _IFPGA_API_H_ */
drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +57 -0
57 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_defines.h new file +1661 -0
1,661 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c new file +824 -0
824 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_ENUMERATE_H_ +#define _IFPGA_ENUMERATE_H_ + +int ifpga_bus_init (struct ifpga_hw *hw); +int ifpga_bus_enumerate (struct ifpga_hw *hw); + +#endif /* _IFPGA_ENUMERATE_H_ */
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +314 -0
64 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +164 -0
164 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +734 -0
734 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +301 -0
301 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +403 -0
403 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +715 -0
715 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +372 -0
372 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +127 -0
127 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +408 -0
408 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/ifpga_port_error.c new file +165 -0
165 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/meson.build new file +34 -0
Lines of this file are not shown. View the raw message.
drivers/raw/ifpga_rawdev/base/opae_debug.c new file +99 -0
99 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_debug.h new file +19 -0
Lines of this file are not shown. View the raw message.
drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +381 -0
381 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +253 -0
253 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +145 -0
145 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +279 -0
279 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +81 -0
81 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +75 -0
75 lines not on this page · raw message
drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +45 -0
45 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v9 2/4] iFPGA: Add Intel FPGA OPAE Share Code
08/05/2018 16:19, Xu, Rosen:
drivers/raw/ifpga_rawdev/base/README line 8
Quoted 11 lines
drivers/raw/ifpga_rawdev/base/README new file +8
-0@@ -0,0 +1,31 @@ +.. + +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2018 Intel Corporation + */ + +Intel® iFPGA driver +==================
There is a strange character in this title. You can use (R) or nothing. Please make sure that the title is well underlined.
Re: [PATCH v9 2/4] iFPGA: Add Intel FPGA OPAE Share Code
Hi Thomas,
Quoted 13 lines
-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, May 08, 2018 22:45
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Xu, Yilun <[email protected]>
Subject: Re: [PATCH v9 2/4] iFPGA: Add Intel FPGA OPAE Share Code08/05/2018 16:19, Xu, Rosen:
Quoted 13 lines
drivers/raw/ifpga_rawdev/base/README line 7
Quoted 10 lines
drivers/raw/ifpga_rawdev/base/README new file +7
-0@@ -0,0 +1,31 @@ +.. + +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2018 Intel Corporation */ + +Intel® iFPGA driver +==================There is a strange character in this title. You can use (R) or nothing. Please make sure that the title is well underlined.
I will fix it in v10.
PATCH v9 3/4 iFPGA: Add Intel FPGA BUS Rawdev Driver
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.
--- config/common_base | 1 + drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 ++ drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 608 +++++++++++++++++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 ++ drivers/raw/ifpga_rawdev/meson.build | 15 + .../ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map | 4 + drivers/raw/meson.build | 2 +- mk/rte.app.mk | 4 +- 9 files changed, 706 insertions(+), 2 deletions(-) create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map
config/common_base +1 -0
@@ -152,6 +152,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y # Compile the Intel FPGA bus # CONFIG_RTE_LIBRTE_IFPGA_BUS=y +CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y # # Compile ARK PMD
drivers/raw/Makefile +1 -0
@@ -9,5 +9,6 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += dpaa2_cmdif DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += dpaa2_qdma endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
@@ -0,0 +1,36 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_ifpga_rawdev.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga +CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_bus_vdev +LDLIBS += -lrte_kvargs +LDLIBS += -lrte_bus_pci +LDLIBS += -lrte_bus_ifpga + +EXPORT_MAP := rte_pmd_ifpga_rawdev_version.map + +LIBABIVER := 1 + +VPATH += $(SRCDIR)/base + +include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile + +# +# all source are stored in SRCS-y +# +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +608 -0
608 lines not on this page · raw message
drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
@@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_RAWDEV_H_ +#define _IFPGA_RAWDEV_H_ + +extern int ifpga_rawdev_logtype; + +#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "ifgpa: " fmt, \ + ##args) + +#define IFPGA_RAWDEV_PMD_FUNC_TRACE () IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>") + +#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args) +#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args) +#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args) +#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \ + IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args) + +enum ifpga_rawdev_device_state { +IFPGA_IDLE , +IFPGA_READY , +IFPGA_ERROR +}; + +static inline struct opae_adapter * +ifpga_rawdev_get_priv (const struct rte_rawdev *rawdev) +{ +return rawdev->dev_private; +} + +#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/meson.build new file +15 -0
@@ -0,0 +1,15 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +version = 1 + +subdir('base') +objs = [base_objs] + +deps += ['rawdev', 'pci', 'bus_pci', 'kvargs', + 'bus_vdev', 'bus_ifpga'] +sources = files('ifpga_rawdev.c') + +includes += include_directories('base') + +allow_experimental_apis = true
drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map new file +4 -0
@@ -0,0 +1,4 @@ +DPDK_18.05 { + + local: *; +};
drivers/raw/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright 2018 NXP -drivers = ['skeleton_rawdev', 'dpaa2_cmdif', 'dpaa2_qdma'] +drivers = ['skeleton_rawdev', 'dpaa2_cmdif', 'dpaa2_qdma', 'ifpga_rawdev'] std_deps = ['rawdev'] config_flag_fmt = 'RTE_LIBRTE_PMD_@0@_RAWDEV' driver_name_fmt = 'rte_pmd_@0@'
mk/rte.app.mk +3 -1
@@ -256,9 +256,11 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS _LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga +ifeq ($(CONFIG_RTE_LIBRTE_IFPGA_BUS),y) +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += -lrte_ifpga_rawdev +endif # CONFIG_RTE_LIBRTE_IFPGA_BUS endif # CONFIG_RTE_LIBRTE_RAWDEV - endif # !CONFIG_RTE_BUILD_SHARED_LIBS _LDLIBS-y += --no-whole-archive
Signature · 1 line
1.8.3.1
PATCH v9 4/4 iFPGA: add document for iFPGA driver
In reply to Xu, RosenFrom: Rosen Xu <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
--- doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rawdevs/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 13 ++++ 3 files changed, 126 insertions(+) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0
@@ -0,0 +1,112 @@ +.. SPDX-License-Identifier: BSD-3-Clause + Copyright(c) 2018 Intel Corporation. + +IFPGA Rawdev Driver +====================== + +FPGA is used more and more widely in Cloud and NFV, one primary reason is +that FPGA not only provides ASIC performance but also it's more flexible +than ASIC. + +FPGA uses Partial Reconfigure (PR) Parts of Bit Stream to achieve its +flexibility. That means one FPGA Device Bit Stream is divided into many Parts +of Bit Stream(each Part of Bit Stream is defined as AFU-Accelerated Function +Unit), and each AFU is a hardware acceleration unit which can be dynamically +reloaded respectively. + +By PR (Partial Reconfiguration) AFUs, one FPGA resources can be time-shared by +different users. FPGA hot upgrade and fault tolerance can be provided easily. + +The SW IFPGA Rawdev Driver (**ifpga_rawdev**) provides a Rawdev driver +that utilizes Intel FPGA Software Stack OPAE(Open Programmable Acceleration +Engine) for FPGA management. + +Implementation details +---------------------- + +Each instance of IFPGA Rawdev Driver is probed by Intel FpgaDev. In coordination +with OPAE share code IFPGA Rawdev Driver provides common FPGA management ops +for FPGA operation, OPAE provides all following operations: +- FPGA PR (Partial Reconfiguration) management +- FPGA AFUs Identifying +- FPGA Thermal Management +- FPGA Power Management +- FPGA Performance reporting +- FPGA Remote Debug + +All configuration parameters are taken by vdev_ifpga_cfg driver. Besides +configuration, vdev_ifpga_cfg driver also hot plugs in IFPGA Bus. + +All of the AFUs of one FPGA may share same PCI BDF and AFUs scan depend on +IFPGA Rawdev Driver so IFPGA Bus takes AFU device scan and AFU drivers probe. +All AFU device driver bind to AFU device by its UUID (Universally Unique +Identifier). + +To avoid unnecessary code duplication and ensure maximum performance, +handling of AFU devices is left to different PMDs; all the design as +summarized by the following block diagram:: + + +---------------------------------------------------------------+ + | Application(s) | + +----------------------------.----------------------------------+ + | + | + +----------------------------'----------------------------------+ + | DPDK Framework (APIs) | + +----------|------------|--------.---------------------|--------+ + / \ | + / \ | + +-------'-------+ +-------'-------+ +--------'--------+ + | Eth PMD | | Crypto PMD | | | + +-------.-------+ +-------.-------+ | | + | | | | + | | | | + +-------'-------+ +-------'-------+ | IFPGA | + | Eth AFU Dev | |Crypto AFU Dev | | Rawdev Driver | + +-------.-------+ +-------.-------+ |(OPAE Share Code)| + | | | | + | | Rawdev | | + +-------'------------------'-------+ Ops | | + | IFPGA Bus | -------->| | + +-----------------.----------------+ +--------.--------+ + | | + Hot-plugin -->| | + | | + +-----------------'------------------+ +--------'--------+ + | vdev_ifpga_cfg driver | | Intel FpgaDev | + +------------------------------------+ +-----------------+ + +Build options +------------- + +- ``CONFIG_RTE_LIBRTE_IFPGA_BUS`` (default ``y``) + + Toggle compilation of IFPGA Bus library. + +- ``CONFIG_RTE_LIBRTE_IFPGA_RAWDEV`` (default ``y``) + + Toggle compilation of the ``ifpga_rawdev`` driver. + +Run-time parameters +------------------- + +This driver is invoked automatically in systems added with Intel FPGA, +but PR and IFPGA Bus scan is trigged by command line using +``--vdev 'net_ifpga_cfg`` EAL option. + +The following device parameters are supported: + +- ``ifpga`` [string] + + Provide a specific Intel FPGA device PCI BDF. Can be provided multiple + times for additional instances. + +- ``port`` [int] + + Each FPGA can provide many channels to PR AFU by software, each channels + is identified by this parameter. + +- ``afu_bts`` [string] + + If null, the AFU Bit Stream has been PR in FPGA, if not forces PR and + identifies AFU Bit Stream file.
doc/guides/rawdevs/index.rst +1 -0
@@ -13,3 +13,4 @@ application through rawdev API. dpaa2_cmdif dpaa2_qdma + ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +13 -0
@@ -183,6 +183,19 @@ New Features stats/xstats on shared memory from secondary process, and also pdump packets on those virtual devices. +* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel FPGA device with + the DPDK framework. It provides Intel FPGA Partial Bit Stream AFU(Accelerated + Function Unit) scan and drivers prove. + +* **Added IFPGA(Intel FPGA) Rawdev Driver.** + + Added a new Rawdev driver called IFPGA(Intel FPGA) Rawdev Driver, which cooperates + with OPAE(Open Programmable Acceleration Engine) share code provides common FPGA + management ops for FPGA operation. + + See the :doc:`../rawdevs/ifpga_rawdev` programmer's guide for more details. API Changes -----------
Signature · 1 line
1.8.3.1
Re: [PATCH v9 4/4] iFPGA: add document for iFPGA driver
08/05/2018 16:19, Xu, Rosen:
Quoted 9 lines
From: Rosen Xu <[email protected]>
add some introduction, motivation and usage for iFPGA driver.
Signed-off-by Rosen Xu <[email protected]>Signed-off-by Figo Zhang <[email protected]>--- doc/guides/rawdevs/ifpga_rawdev.rst | 112 +++++++++++++++++++++++++++++++++ doc/guides/rawdevs/index.rst | 1 +
Given the document size is small, it is better to squash it in the patch with the code itself.
Quoted 1 line
doc/guides/rel_notes/release_18_05.rst | 13 ++++
Better to squash the release notes parts in relevant patches (1 and 3).
You need also to update the MAINTAINERS file in patches 1, 2 and 3.
v10 cover Introduce Intel FPGA BUS
In reply to Rosen XuFrom: "Xu, Rosen" <[email protected]>
Intel FPGA BUS in DPDK
-------------------------
This patch set introduces Intel FPGA BUS support in DPDK.
v10 updates:
===========
- Add prefix rte_ for exported symbols
- Fix alphabetical order error
- Fix share code title well underlined comments
- Squash the release notes parts in relevant patches
- Update the MAINTAINERS file in patches 1, 2 and 3
v9 updates:
==========
- Rebase ifpga_rawdev on QDMA and CMDIF driver
- Split and squash the patch 4(v8 patch) into patch 2 and patch 3
v8 updates:
==========
- Fix some comments from Shreyansh Jain
- Patch 3 and Patch 5 will continue rebase when qcom patches merging into mainline
- add Shreyansh Jain's Acked-by
v7 updates:
==========
- Fix some comments from DPDK community
- Fix the CLANG compile error
- Fix the meson build warring.
v6 updates:
===========
- Add documentation
- Add meson build script
- Split new patch for OPAE share code
v5 updates:
===========
- Fixed SHARED LIB Build issue
- Changed command name to IFPGA Rawdev name,
so remove pci library datastruct and function.
- Fixed PATCH v2/v3/v4 comments
v4 updates:
===========
- Remove all modifications from eal
- Create vdev to take IFPGA parameters configuration
- AFU Device Driver bind to AFU Device by uuid
- Take more test in scenario of Multi-FPGA System
v3 updates:
===========
- Remove all modifications of bus scan and probe
- FPGA BUS Scan is trigged by hotplug of Rawdev
- Took Modifications of comments
- Move AFU Device to IFPGA
- FPGA BUS Scan depend on it's IFPGA Rawdev
- Add Build Macros for FPGA BUS and IFPGA Rawdev
Questions
=========
Why not PCI Bus?
All of the AFUs of one FPGA may share same PCI BDF. Why not vdev Bus?
Because AFUs depend on Rawdev, and it's hardware specpic.
Motivation
==========
FPGA is used more and more widely in Cloud and NFV, one primary reason is that FPGA not only provide ASIC performance but also it's more flexible than ASIC. FPGA use Partial Reconfigure(PR) Parts of Bitstream to achieve its flexibility. Another reason is that one FPGA can be shared by different Users, and each User can use some of AFUs of One FPGA.
That means One FPGA Device Bitstream is divided into many Parts of Bitstream(each Part of Bitstream is defined as AFU-Accelerated Function Unit), and each AFU is a Hardware Acceleration Unit and it can dynamically Reload respectively.
Proposed Solution
=================
- Involve Rawdev to take FPGA Partial Configuration(Download/PR)
- Defined FPGA-BUS for Acceleration Drivers of AFUs
- FPGA PCI Scan(1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver. FPGA-BUS scan is called, but AFU depend on Rawdev, so this scan doesn't trig AFU device create.
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their dirves are also probed.
Scope
=====
The Intel FPGA BUS implementation is target towards various FPGA Devices use PR to provide many Acceleration Function. Specific PMDs may also bind to its AFU. And Applications don't care they are using ASIC Acceleration or FPGA AFU Acceleration.
Status
=====
With integrating Intel PSG FPGA Software Stack OPAE(Open Programmable Acceleration Engine) Share Code, Intel FPGA BUS runs well in Intel PSG FPGA Cards.
Rosen Xu (2):
bus/ifpga: Add Intel FPGA BUS Library
iFPGA: Add Intel FPGA BUS Rawdev Driver
Tianfei Zhang (1):
iFPGA: Add Intel FPGA OPAE Share Code
MAINTAINERS | 11 + config/common_base | 10 + doc/guides/rawdevs/ifpga_rawdev.rst | 112 ++ doc/guides/rawdevs/index.rst | 1 + doc/guides/rel_notes/release_18_05.rst | 13 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 + drivers/bus/ifpga/ifpga_bus.c | 501 ++++++ drivers/bus/ifpga/ifpga_common.c | 88 ++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 + drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 ++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- drivers/raw/Makefile | 1 + drivers/raw/ifpga_rawdev/Makefile | 36 + drivers/raw/ifpga_rawdev/base/Makefile | 30 + drivers/raw/ifpga_rawdev/base/README | 31 + drivers/raw/ifpga_rawdev/base/ifpga_api.c | 294 ++++ drivers/raw/ifpga_rawdev/base/ifpga_api.h | 28 + drivers/raw/ifpga_rawdev/base/ifpga_compat.h | 57 + drivers/raw/ifpga_rawdev/base/ifpga_defines.h | 1661 ++++++++++++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c | 824 ++++++++++ drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h | 11 + drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c | 314 ++++ drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 164 ++ drivers/raw/ifpga_rawdev/base/ifpga_fme.c | 734 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c | 301 ++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c | 403 +++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c | 715 +++++++++ drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c | 372 +++++ drivers/raw/ifpga_rawdev/base/ifpga_hw.h | 127 ++ drivers/raw/ifpga_rawdev/base/ifpga_port.c | 408 +++++ drivers/raw/ifpga_rawdev/base/ifpga_port_error.c | 165 ++ drivers/raw/ifpga_rawdev/base/meson.build | 34 + drivers/raw/ifpga_rawdev/base/opae_debug.c | 99 ++ drivers/raw/ifpga_rawdev/base/opae_debug.h | 19 + drivers/raw/ifpga_rawdev/base/opae_hw_api.c | 381 +++++ drivers/raw/ifpga_rawdev/base/opae_hw_api.h | 253 +++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c | 145 ++ drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h | 279 ++++ drivers/raw/ifpga_rawdev/base/opae_osdep.h | 81 + .../ifpga_rawdev/base/osdep_raw/osdep_generic.h | 75 + .../ifpga_rawdev/base/osdep_rte/osdep_generic.h | 45 + drivers/raw/ifpga_rawdev/ifpga_rawdev.c | 608 +++++++ drivers/raw/ifpga_rawdev/ifpga_rawdev.h | 37 + drivers/raw/ifpga_rawdev/meson.build | 15 + .../ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map | 4 + drivers/raw/meson.build | 2 +- mk/rte.app.mk | 5 +- 51 files changed, 9753 insertions(+), 3 deletions(-) create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile create mode 100644 drivers/raw/ifpga_rawdev/base/README create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/meson.build create mode 100644 drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
PATCH v10 1/3 bus/ifpga: Add Intel FPGA BUS Library
From: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce rte_afu_device which describe the AFU device listed in the FPGA-BUS.
--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode 100644 drivers/bus/ifpga/Makefile create mode 100644 drivers/bus/ifpga/ifpga_bus.c create mode 100644 drivers/bus/ifpga/ifpga_common.c create mode 100644 drivers/bus/ifpga/ifpga_common.h create mode 100644 drivers/bus/ifpga/ifpga_logs.h create mode 100644 drivers/bus/ifpga/meson.build create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
MAINTAINERS +4 -0
@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers ----------- +Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]>
config/common_base +5 -0
@@ -139,6 +139,11 @@ CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n # +# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=y
doc/guides/rel_notes/release_18_05.rst +5 -0
@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, and also pdump packets on those virtual devices. +* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel FPGA device with + the DPDK framework. It provides Intel FPGA Partial Bit Stream AFU(Accelerated + Function Unit) scan and drivers prove. API Changes -----------
drivers/bus/Makefile +1 -0
@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa ifeq ($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
drivers/bus/ifpga/Makefile new file +32 -0
@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2018 Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +501 -0
501 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.c new file +88 -0
88 lines not on this page · raw message
drivers/bus/ifpga/ifpga_common.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_unsigned_long (const char *str,int base); +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation +*/ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) +#define IFPGA_BUS_INFO(fmt, args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */
drivers/bus/ifpga/meson.build new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright(c) 2010-2018 Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = true
drivers/bus/ifpga/rte_bus_ifpga.h new file +160 -0
160 lines not on this page · raw message
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10 -0
@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};
drivers/bus/meson.build +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +1 -0
@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV
Signature · 1 line
1.8.3.1
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Hi, Rosen
Few comments below.
Thanks
Jingjing
[......]
drivers/bus/ifpga/ifpga_bus.c line 70
Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7
-0+static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) +{ +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + if (rdev &&
rdev -> ifpage_dev ??
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+ ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ;
drivers/bus/ifpga/ifpga_bus.c line 85
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) +{ +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id))
Add checking afu_dev?
[...]
drivers/bus/ifpga/ifpga_bus.c line 448
Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7
-0+static int +ifpga_parse (const char *name,void *addr) +{ +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ;
According to coding style, we need to two lines for the definition like:
char *c1 = NULL;
char *c2 = NULL;
drivers/bus/ifpga/ifpga_bus.c line 457
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name;
According to coding style, spaces are required around opreations.
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2
-0+ c2 = c1+1 ; + }
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Hi Jingjing,
Quoted 14 lines
-----Original Message-----
From: Wu, Jingjing
Sent: Thursday, May 10, 2018 16:44
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Quoted 3 lines
Hi, Rosen
Few comments below.
Thanks a lot Jingjing.
Quoted 4 lines
Thanks
Jingjing
Quoted 8 lines
[......]
drivers/bus/ifpga/ifpga_bus.c line 70
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + if (rdev &&rdev ->
ifpage_dev??
Rdev doesn't has this variable.
Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c new file +8
-0+ ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device *
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 85
Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7
-0+ifpga_find_afu_dev(const struct rte_ifpga_device *ifpga_dev, + const struct rte_afu_id *afu_id) +{ + struct rte_afu_device *afu_dev = NULL; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id))Add checking
afu_dev?
Fixed.
Quoted 11 lines
[...]
drivers/bus/ifpga/ifpga_bus.c line 448
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ;According to coding style, we need to two lines for the definition like:
char *c1 = NULL;
char *c2 = NULL;
Fixed
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c line 457
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name;According to coding style, spaces are required around opreations.
Fixed.
Quoted 2 lines
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2
-0+ c2 = c1+1 ; + }
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Quoted 48 lines
-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 8:21 PM
To: Wu, Jingjing <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Jingjing,
Quoted 14 lines
-----Original Message-----
From: Wu, Jingjing
Sent: Thursday, May 10, 2018 16:44
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 3 lines
Hi, Rosen
Few comments below.
Thanks a lot Jingjing.
Quoted 4 lines
Thanks
JingjingQuoted 8 lines
[......]
drivers/bus/ifpga/ifpga_bus.c line 70
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + if (rdev &&rdev ->
ifpage_dev??
Quoted 1 line
Rdev doesn't has this variable.
I mean "if (ifpag_dev" & to replace "rdev"
Quoted 49 lines
Quoted 17 lines
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+ ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ;drivers/bus/ifpga/ifpga_bus.c line 85
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) +{ +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id))Add checking
afu_dev?Fixed.
Quoted 11 lines
[...]
drivers/bus/ifpga/ifpga_bus.c line 448
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ;According to coding style, we need to two lines for the definition like:
char *c1 = NULL;
char *c2 = NULL;Fixed
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c line 457
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name;According to coding style, spaces are required around opreations.
Fixed.
Quoted 2 lines
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2
-0+ c2 = c1+1 ; + }
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Hi Jingjing,
Quoted 68 lines
-----Original Message-----
From: Wu, Jingjing
Sent: Friday, May 11, 2018 6:40
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 52 lines
-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 8:21 PM
To: Wu, Jingjing <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Jingjing,
Quoted 16 lines
-----Original Message-----
From: Wu, Jingjing
Sent: Thursday, May 10, 2018 16:44
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 3 lines
Hi, Rosen
Few comments below.
Thanks a lot Jingjing.
Quoted 12 lines
Thanks
Jingjing[......]
drivers/bus/ifpga/ifpga_bus.c line 70
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + if (rdev &&rdev ->
ifpage_dev??
Quoted 2 lines
Quoted 1 line
Rdev doesn't has this variable.
I mean "if (
ifpag_dev" & to replace "rdev"
I will fixed it in patch v12.
Quoted 48 lines
Quoted 48 lines
Quoted 16 lines
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +4
-0+ ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + }drivers/bus/ifpga/ifpga_bus.c line 85
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) { +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id))Add checking
afu_dev?Fixed.
Quoted 11 lines
[...]
drivers/bus/ifpga/ifpga_bus.c line 448
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ;According to coding style, we need to two lines for the definition like:
char *c1 = NULL;
char *c2 = NULL;Fixed
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c line 457
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name;According to coding style, spaces are required around opreations.
Fixed.
Quoted 2 lines
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2
-0+ c2 = c1+1 ; + }
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
In reply to Xu, RosenHi Rosen:
Quoted 247 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Wednesday, May 9, 2018 3:43 PM
To: [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryFrom: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce
rte_afu_devicewhich describe the AFU device listed in the FPGA-BUS.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode 100644
drivers/bus/ifpga/Makefilecreate mode 100644drivers/bus/ifpga/ifpga_bus.ccreate mode 100644drivers/bus/ifpga/ifpga_common.ccreate mode 100644drivers/bus/ifpga/ifpga_common.hcreate mode 100644drivers/bus/ifpga/ifpga_logs.hcreate mode 100644drivers/bus/ifpga/meson.buildcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga.hcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga_version.mapMAINTAINERS +4
-0@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers ----------- +Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]> diff --gita/config/common_base b/config/common_base index 0d181ac..1440316 100644
config/common_base +0
-0@@ -139,6 +139,11 @@
CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n#
config/common_base +5
-0+# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=ydoc/guides/rel_notes/release_18_05.rst +0
-0@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, and also pdumppackets on
those virtual devices.doc/guides/rel_notes/release_18_05.rst +5
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel FPGA + device with the DPDK framework. It provides Intel FPGA Partial Bit + Stream AFU(Accelerated Function Unit) scan and drivers prove. API Changes -----------drivers/bus/Makefile index renamed from drivers/bus/Makefile +0
-0c251b65..ef7f247 100644
drivers/bus/Makefile +1
-0@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa ifeq ($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdevdrivers/bus/ifpga/Makefile new file renamed from drivers/bus/ifpga/Makefile +0
-0mode 100644 index 0000000..3ff3bdb
drivers/bus/ifpga/Makefile new file +32
-0@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel +Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mkdrivers/bus/ifpga/ifpga_bus.c new renamed from drivers/bus/ifpga/ifpga_bus.c +0
-0file mode 100644 index 0000000..e144c01
drivers/bus/ifpga/ifpga_bus.c new file +90
-0@@ -0,0 +1,501 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int ifpga_bus_logtype; + +/* Forward declaration to access Intel FPGA bus +* on which iFPGA devices are connected */ static struct rte_bus +rte_ifpga_bus; + +/** Double linked list of IFPGA device. */ +TAILQ_HEAD (ifpga_device_list, rte_ifpga_device); + +static struct ifpga_device_list ifpga_device_list = +TAILQ_HEAD_INITIALIZER (ifpga_device_list); +static struct afu_driver_list afu_driver_list = +TAILQ_HEAD_INITIALIZER (afu_driver_list); + + +/* register a ifpga bus based driver */ void +rte_ifpga_driver_register (struct rte_afu_driver *driver) { +RTE_VERIFY (driver); + +TAILQ_INSERT_TAIL (&afu_driver_list, driver, next); } + +/* un-register a fpga bus based driver */ void +rte_ifpga_driver_unregister (struct rte_afu_driver *driver) { +TAILQ_REMOVE (&afu_driver_list, driver, next); } + +static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { +if (rdev && + ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) +{ +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id)) +return afu_dev; + } +return NULL ; +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS ,
drivers/bus/ifpga/ifpga_bus.c line 100
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ NULL +}; + +/* +* Scan the content of the FPGA bus, and the devices in the devices +* list +*/ +static struct rte_afu_device * +ifpga_scan_one (struct rte_devargs *devargs, +struct rte_ifpga_device *ifpga_dev)
usually ifpag_dev should be the first parameter here, and devargs follows
Quoted 100 lines
drivers/bus/ifpga/ifpga_bus.c new file +100
-0+{ +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_pr_conf afu_pr_conf; +int ret =0 ; +char *path =NULL ; + +memset (&afu_pr_conf,0 ,sizeof (struct rte_afu_pr_conf )); + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_PORT , + &rte_ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_PORT ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_AFU_BTS ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_AFU_BTS , + &rte_ifpga_get_string_arg, &path) <0 ) { +IFPGA_BUS_ERR ("Failed to parse %s" , +IFPGA_AFU_BTS ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_AFU_BTS ); + goto end; + } + + afu_pr_conf.afu_id.uuid.uuid_low =0 ; + afu_pr_conf.afu_id.uuid.uuid_high =0 ; + afu_pr_conf.pr_enable = path?1 :0 ; + + rawdev = ifpga_dev->rdev; +if (ifpga_find_afu_dev (ifpga_dev, &afu_pr_conf.afu_id)) + goto end; + + afu_dev =calloc (1 ,sizeof (*afu_dev)); +if (!afu_dev) + goto end; + + afu_dev->device.devargs = devargs; + afu_dev->device.numa_node =SOCKET_ID_ANY ; + afu_dev->device.name = devargs->name; + afu_dev->rawdev = rawdev; + afu_dev->id.uuid.uuid_low =0 ; + afu_dev->id.uuid.uuid_high =0 ; + afu_dev->id.port = afu_pr_conf.afu_id.port; + afu_dev->ifpga_dev = ifpga_dev; + +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) + rawdev->dev_ops->dev_info_get (rawdev, afu_dev); + +if (rawdev->dev_ops && + rawdev->dev_ops->dev_start && + rawdev->dev_ops->dev_start (rawdev)) + goto free_dev; + +strncpy (afu_pr_conf.bs_path, path,sizeof (afu_pr_conf.bs_path)); +if (rawdev->dev_ops->firmware_load && + rawdev->dev_ops->firmware_load (rawdev, + &afu_pr_conf)){ +IFPGA_BUS_ERR ("firmware load error %d\n" , ret); + goto free_dev; + } + afu_dev->id.uuid.uuid_low = afu_pr_conf.afu_id.uuid.uuid_low; + afu_dev->id.uuid.uuid_high = afu_pr_conf.afu_id.uuid.uuid_high; + +return afu_dev; + +free_dev: +free (afu_dev); +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (path) +free (path); + +return NULL ; +} + +/* +* Scan the content of the FPGA bus, and the devices in the devices +* list +*/ +static int +ifpga_scan (void )
drivers/bus/ifpga/ifpga_bus.c line 217
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+{ +struct rte_ifpga_device *ifpga_dev; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +char *name =NULL ; +char name1[RTE_RAWDEV_NAME_MAX_LEN ]; +struct rte_afu_device *afu_dev =NULL ; + +/* for FPGA devices we scan the devargs_list populated via cmdline */
I didn't see "--ifpga" is supported by cmdline, either you need to add corresponding parser or correct the comment here.
drivers/bus/ifpga/ifpga_bus.c line 218
Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1
-0+ RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
IFPGA_BUS_NAME to replace "ifpga" here.
Quoted 34 lines
drivers/bus/ifpga/ifpga_bus.c new file +24
-0+if (devargs->bus != &rte_ifpga_bus) +continue ; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &rte_ifpga_get_string_arg, &name) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_NAME ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +memset (name1,0 ,sizeof (name1)); + snprintf(name1, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s",name);
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+ + rawdev =rte_rawdev_pmd_get_named_dev (name1); +if (!rawdev) + goto end; + +if (ifpga_find_ifpga_dev (rawdev)) +continue ; + + ifpga_dev =calloc (1 ,sizeof (*ifpga_dev));
drivers/bus/ifpga/ifpga_bus.c line 261
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (!ifpga_dev) + goto end; + + ifpga_dev->rdev = rawdev; +TAILQ_INIT (&ifpga_dev->afu_list); + +TAILQ_INSERT_TAIL (&ifpga_device_list, ifpga_dev, next); + afu_dev =ifpga_scan_one (devargs, ifpga_dev); +if (afu_dev !=NULL ) +TAILQ_INSERT_TAIL (&ifpga_dev->afu_list, afu_dev, next);
I don't understand why we need afu_list?, seems we only add a new afu_dev into the list after create a new ifpga_dev, Is there any another place that we add one to list to make it reasonable? it looks like either a 1:1 or 1:0 for ifpga_dev:afu_dev?
Quoted 136 lines
drivers/bus/ifpga/ifpga_bus.c new file +136
-0+ } + +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +/* +* Match the AFU Driver and AFU Device using the ID Table */ static +int rte_afu_match (const struct rte_afu_driver *afu_drv, +const struct rte_afu_device *afu_dev) { +const struct rte_afu_uuid *id_table; + +for (id_table = afu_drv->id_table; + ((id_table->uuid_low !=0 ) && (id_table->uuid_high !=0 )); + id_table++) { +/* check if device's identifiers match the driver's ones */ +if ((id_table->uuid_low != afu_dev->id.uuid.uuid_low) || + id_table->uuid_high != + afu_dev->id.uuid.uuid_high) +continue ; + +return 1 ; + } + +return 0 ; +} + +static int +ifpga_probe_one_driver (struct rte_afu_driver *drv, +struct rte_afu_device *afu_dev) +{ +int ret; + +if (!rte_afu_match (drv, afu_dev)) +/* Match of device and driver failed */ +return 1 ; + +/* reference driver structure */ + afu_dev->driver = drv; + afu_dev->device.driver = &drv->driver; + +/* call the driver probe() function */ + ret = drv->probe (afu_dev); +if (ret) { + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + } + +return ret; +} + +static int +ifpga_probe_all_drivers (struct rte_afu_device *afu_dev) { +struct rte_afu_driver *drv =NULL ; +int ret =0 ; + +if (afu_dev ==NULL ) +return -1 ; + +/* Check if a driver is already loaded */ +if (afu_dev->driver !=NULL ) +return 0 ; + + TAILQ_FOREACH(drv, &afu_driver_list, next) { +if (ifpga_probe_one_driver (drv, afu_dev)) { + ret =-1 ; +break ; + } + } +return ret; +} + +/* +* Scan the content of the Intel FPGA bus, and call the probe() +function for +* all registered drivers that have a matching entry in its id_table +* for discovered devices. +*/ +static int +ifpga_probe (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev =NULL ; +int ret =0 ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { + +if (afu_dev->device.driver) +continue ; + + ret =ifpga_probe_all_drivers (afu_dev); +if (ret <0 ) +IFPGA_BUS_ERR ("failed to initialize %s device\n" , +rte_ifpga_device_name (afu_dev)); + } + } + +return ret; +} + +static int +ifpga_plug (struct rte_device *dev) +{ +return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); +} + +static int +ifpga_remove_driver (struct rte_afu_device *afu_dev) { +const char *name; +const struct rte_afu_driver *driver; + + name =rte_ifpga_device_name (afu_dev); +if (!afu_dev->device.driver) { +IFPGA_BUS_DEBUG ("no driver attach to device %s\n" , name); +return 1 ; + } + + driver =RTE_DRV_TO_AFU_CONST (afu_dev->device.driver); +return driver->remove (afu_dev); +} + +static int +ifpga_unplug (struct rte_device *dev) +{ +struct rte_ifpga_device *ifpga_dev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_devargs *devargs =NULL ; +int ret; + +if (dev ==NULL )
drivers/bus/ifpga/ifpga_bus.c line 411
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+return -EINVAL ; + + afu_dev =RTE_DEV_TO_AFU (dev); +if (!dev) +return -ENOENT ; + + ifpga_dev = afu_dev->ifpga_dev; + devargs = dev->devargs; + + ret =ifpga_remove_driver (afu_dev);
So what is the device type that be plugged into the ifgpa bus? ifpga_dev or afu_dev? If its afu_dev, why we need ifpga_dev? If it is ifpga_dev, we need remove ifpga_dev from ifpga_device_list here.
Quoted 348 lines
drivers/bus/ifpga/ifpga_bus.c new file +88
-0+if (ret) +return ret; + +TAILQ_REMOVE (&ifpga_dev->afu_list, afu_dev, next); + +rte_devargs_remove (devargs->bus->name, devargs->name); +free (afu_dev); +return 0 ; + +} + +static struct rte_device * +ifpga_find_device (const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (start && &afu_dev->device == start) { + start =NULL ; +continue ; + } +if (cmp (&afu_dev->device, data) ==0 ) +return &afu_dev->device; + } + } +return NULL ; +} +static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ; +int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name; + c2 = c1+1 ; + } + +if (str_port_len <8 && + str_port_len >0 ) { +memcpy (str_port, name, str_port_len); + ret =sscanf (str_port,"%d" , &port); +if (ret ==-1 ) +return 0 ; + } + +memset (rawdev_name,0 ,sizeof (rawdev_name)); +snprintf (rawdev_name,RTE_RAWDEV_NAME_MAX_LEN ,"IFPGA:%s" , c2); + rawdev =rte_rawdev_pmd_get_named_dev (rawdev_name); + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev && + (addr !=NULL )) + *out = port; + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev) +return 0 ; +else +return 1 ; +} + +static struct rte_bus rte_ifpga_bus = { + .scan = ifpga_scan, + .probe = ifpga_probe, + .find_device = ifpga_find_device, + .plug = ifpga_plug, + .unplug = ifpga_unplug, + .parse = ifpga_parse, +}; + +RTE_REGISTER_BUS (IFPGA_BUS_NAME , rte_ifpga_bus); + +RTE_INIT (ifpga_init_log) +{ + ifpga_bus_logtype =rte_log_register ("bus.ifpga" ); +if (ifpga_bus_logtype >=0 ) +rte_log_set_level (ifpga_bus_logtype,RTE_LOG_NOTICE ); }drivers/bus/ifpga/ifpga_common.c new file +86
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(int *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args) +{ +if (!value || !extra_args) +return -EINVAL ; + + *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_unsigned_long (const char *str,int base) { +unsigned long num; +char *end =NULL ; + + errno =0 ; + + num =strtoul (str, &end, base); +if ((str[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ) || (errno !=0 )) +return -1 ; + +return num; +} + +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1) +{ +if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && + (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && + (afu_id0->port == afu_id1->port)) { +return 0 ; + }else +return 1 ; +}drivers/bus/ifpga/ifpga_common.h new file +17
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args); +int ifpga_get_unsigned_long (const char *str,int base);int +ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */ drivers/bus/ifpga/ifpga_logs.h new file +30
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) +#define IFPGA_BUS_INFO(fmt, args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */ drivers/bus/ifpga/meson.build new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 Intel +Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = truedrivers/bus/ifpga/rte_bus_ifpga.h new file +88
-0@@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _RTE_BUS_IFPGA_H_ +#define _RTE_BUS_IFPGA_H_ + +/** + * @file + * + * RTE Intel FPGA Bus Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_bus.h> +#include <rte_pci.h> + +/** Name of Intel FPGA Bus */ +#define IFPGA_BUS_NAME ifpga + +/* Forward declarations */ +struct rte_afu_device; + +/** List of Intel AFU devices */ +TAILQ_HEAD(afu_device_list, rte_afu_device); +/** Double linked list of AFU device drivers. */ +TAILQ_HEAD(afu_driver_list, rte_afu_driver); + +#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256 + +struct rte_afu_uuid { + uint64_t uuid_low; + uint64_t uuid_high; +} __attribute__ ((packed)); + +#define IFPGA_BUS_DEV_PORT_MAX 4 + +/** + * A structure describing an ID for a AFU driver. Each driver provides +a + * table of these IDs for each device that it supports. + */ +struct rte_afu_id { + struct rte_afu_uuid uuid; + int port; /**< port number */ +} __attribute__ ((packed)); + +/** + * A structure PR (Partial Reconfiguration) configuration AFU driver. + */ + +struct rte_afu_pr_conf { + struct rte_afu_id afu_id; + int pr_enable; + char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +}; + +#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8) + +/** + * A structure describing a fpga device. + */ +struct rte_ifpga_device { + TAILQ_ENTRY(rte_ifpga_device) next; /**< Next in device list. */ + struct rte_rawdev *rdev; + struct afu_device_list afu_list; /**< List of AFU devices */ }; + +/** + * A structure describing a AFU device. + */ +struct rte_afu_device { + TAILQ_ENTRY(rte_afu_device) next; /**< Next in device list. */ + struct rte_device device; /**< Inherit core device */ + struct rte_rawdev *rawdev; /**< Point Rawdev */ + struct rte_ifpga_device *ifpga_dev; /**< Point ifpga device */ + struct rte_afu_id id; /**< AFU id within FPGA. */ + uint32_t num_region; /**< number of regions found */ + struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE]; + /**< AFU Memory Resource */ + struct rte_intr_handle intr_handle; /**< Interrupt handle */ + struct rte_afu_driver *driver; /**< Associated driver */ + char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +} __attribute__ ((packed)); + +/** + * @internal
drivers/bus/ifpga/rte_bus_ifpga.h line 98
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+* Helper macro for drivers that need to convert to struct rte_afu_device. +*/ +#define RTE_DEV_TO_AFU (ptr) \ + container_of(ptr, struct rte_afu_device, device) + +#define RTE_DRV_TO_AFU_CONST (ptr) \ + container_of(ptr, const struct rte_afu_driver, driver) + +/** +* Initialisation function for the driver called during FPGA BUS probing.
typo: Initialization
drivers/bus/ifpga/rte_bus_ifpga.h line 104
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+*/ +typedef int (afu_probe_t )(struct rte_afu_device *); + +/** +* Uninitialisation function for the driver called during hotplugging.
typo: Unintialization
Quoted 13 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +typedef int (afu_remove_t )(struct rte_afu_device *); + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_driver { +TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ +struct rte_driver driver;/**< Inherit core driver. */ +afu_probe_t *probe;/**< Device Probe function. */
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/rte_bus_ifpga.h line 117
Quoted 2 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +2
-0+const struct rte_afu_uuid *id_table;/**< AFU uuid within FPGA. */ +uint32_t drv_flags;/**< Flags contolling handling of device. */
Typo Controlling
And what is "flags controlling handling of device?"
Quoted 84 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +40
-0+}; + +static inline const char * +rte_ifpga_device_name (const struct rte_afu_device *afu) { +if (afu && afu->device.name) +return afu->device.name; +return NULL ; +} + +/** +* Register a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be registered. +*/ +void rte_ifpga_driver_register (struct rte_afu_driver *driver); + +/** +* Unregister a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be unregistered. +*/ +void rte_ifpga_driver_unregister (struct rte_afu_driver *driver); + +#define RTE_PMD_REGISTER_AFU (nm, afudrv)\ RTE_INIT(afudrvinitfn_ +##afudrv);\ static const char *afudrvinit_ ## nm ## _alias;\ static +void afudrvinitfn_ ##afudrv(void)\ {\ + (afudrv).driver.name = RTE_STR(nm);\ + (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\ + rte_ifpga_driver_register(&afudrv);\ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#define RTE_PMD_REGISTER_AFU_ALIAS (nm, alias)\ static const char +*afudrvinit_ ## nm ## _alias = RTE_STR(alias) + +#endif /* _RTE_BUS_IFPGA_H_ */ drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10
-0@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};drivers/bus/meson.build index renamed from drivers/bus/meson.build +0
-058dfbe2..52c755d 100644
drivers/bus/meson.build +0
-0@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 IntelCorporation
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'mk/rte.app.mk +1
-3@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV --
Quoted 1 line
1.8.3.1
Regards
Qi
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Hi Qi,
Quoted 268 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 20:27
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Rosen:
Quoted 252 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Wednesday, May 9, 2018 3:43 PM
To: [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryFrom: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce
rte_afu_devicewhich describe the AFU device listed in the FPGA-BUS.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode100644
drivers/bus/ifpga/Makefilecreate mode 100644drivers/bus/ifpga/ifpga_bus.ccreate mode 100644drivers/bus/ifpga/ifpga_common.ccreate mode 100644drivers/bus/ifpga/ifpga_common.hcreate mode 100644drivers/bus/ifpga/ifpga_logs.hcreate mode 100644drivers/bus/ifpga/meson.buildcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga.hcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga_version.mapMAINTAINERS +4
-0@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers ----------- +Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]> diff --gita/config/common_base b/config/common_base index 0d181ac..1440316 100644
config/common_base +0
-0@@ -139,6 +139,11 @@
CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n#
config/common_base +5
-0+# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=ydoc/guides/rel_notes/release_18_05.rst +0
-0@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, and alsopdump packets on
those virtual devices.doc/guides/rel_notes/release_18_05.rst +5
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel + FPGA device with the DPDK framework. It provides Intel FPGA Partial + Bit Stream AFU(Accelerated Function Unit) scan and drivers prove. API Changes -----------drivers/bus/Makefile index renamed from drivers/bus/Makefile +0
-0c251b65..ef7f247 100644
drivers/bus/Makefile +1
-0@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa ifeq ($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdevdrivers/bus/ifpga/Makefile new file +32
-0@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel +Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk(quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_bus.cnew file mode 100644 index 0000000..e144c01drivers/bus/ifpga/ifpga_bus.c new file +94
-0@@ -0,0 +1,501 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int ifpga_bus_logtype; + +/* Forward declaration to access Intel FPGA bus +* on which iFPGA devices are connected */ static struct rte_bus +rte_ifpga_bus; + +/** Double linked list of IFPGA device. */ +TAILQ_HEAD (ifpga_device_list, rte_ifpga_device); + +static struct ifpga_device_list ifpga_device_list = +TAILQ_HEAD_INITIALIZER (ifpga_device_list); +static struct afu_driver_list afu_driver_list = +TAILQ_HEAD_INITIALIZER (afu_driver_list); + + +/* register a ifpga bus based driver */ void +rte_ifpga_driver_register (struct rte_afu_driver *driver) { +RTE_VERIFY (driver); + +TAILQ_INSERT_TAIL (&afu_driver_list, driver, next); } + +/* un-register a fpga bus based driver */ void +rte_ifpga_driver_unregister (struct rte_afu_driver *driver) { +TAILQ_REMOVE (&afu_driver_list, driver, next); } + +static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { +if (rdev && + ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) +{ +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id)) +return afu_dev; + } +return NULL ; +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +/*
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 107
Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6
-0+* Scan the content of the FPGA bus, and the devices in the devices +* list +*/ +static struct rte_afu_device * +ifpga_scan_one (struct rte_devargs *devargs, +struct rte_ifpga_device *ifpga_dev)usually
ifpag_devshould be the first parameter here, and devargs follows
Fixed.
Quoted 107 lines
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+{ +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_pr_conf afu_pr_conf; +int ret =0 ; +char *path =NULL ; + +memset (&afu_pr_conf,0 ,sizeof (struct rte_afu_pr_conf ));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_PORT , + &rte_ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) <0 ){
Quoted 87 lines
drivers/bus/ifpga/ifpga_bus.c new file +87
-0+IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_PORT ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_AFU_BTS ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_AFU_BTS , + &rte_ifpga_get_string_arg, &path) <0 ) { +IFPGA_BUS_ERR ("Failed to parse %s" , +IFPGA_AFU_BTS ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_AFU_BTS ); + goto end; + } + + afu_pr_conf.afu_id.uuid.uuid_low =0 ; + afu_pr_conf.afu_id.uuid.uuid_high =0 ; + afu_pr_conf.pr_enable = path?1 :0 ; + + rawdev = ifpga_dev->rdev; +if (ifpga_find_afu_dev (ifpga_dev, &afu_pr_conf.afu_id)) + goto end; + + afu_dev =calloc (1 ,sizeof (*afu_dev)); +if (!afu_dev) + goto end; + + afu_dev->device.devargs = devargs; + afu_dev->device.numa_node =SOCKET_ID_ANY ; + afu_dev->device.name = devargs->name; + afu_dev->rawdev = rawdev; + afu_dev->id.uuid.uuid_low =0 ; + afu_dev->id.uuid.uuid_high =0 ; + afu_dev->id.port = afu_pr_conf.afu_id.port; + afu_dev->ifpga_dev = ifpga_dev; + +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) + rawdev->dev_ops->dev_info_get (rawdev, afu_dev); + +if (rawdev->dev_ops && + rawdev->dev_ops->dev_start && + rawdev->dev_ops->dev_start (rawdev)) + goto free_dev; + +strncpy (afu_pr_conf.bs_path, path,sizeof (afu_pr_conf.bs_path)); +if (rawdev->dev_ops->firmware_load && + rawdev->dev_ops->firmware_load (rawdev, + &afu_pr_conf)){ +IFPGA_BUS_ERR ("firmware load error %d\n" , ret); + goto free_dev; + } + afu_dev->id.uuid.uuid_low = afu_pr_conf.afu_id.uuid.uuid_low; + afu_dev->id.uuid.uuid_high = afu_pr_conf.afu_id.uuid.uuid_high; + +return afu_dev; + +free_dev: +free (afu_dev); +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (path) +free (path); + +return NULL ; +} + +/* +* Scan the content of the FPGA bus, and the devices in the devices +* list +*/ +static int +ifpga_scan (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +char *name =NULL ;
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 275
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+char name1[RTE_RAWDEV_NAME_MAX_LEN ]; +struct rte_afu_device *afu_dev =NULL ; + +/* for FPGA devices we scan the devargs_list populated via cmdline +*/ I didn't see "--ifpga" is supported by cmdline, either you need to add corresponding parser or correct the comment here.
To be honestly, ifpga_scan() is called by hotplug, lib_rte hotplug function will construct it.
Quoted 52 lines
drivers/bus/ifpga/ifpga_bus.c line 218
Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1
-0+ RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
IFPGA_BUS_NAMEto replace "ifpga" here.Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +14
-0+if (devargs->bus != &rte_ifpga_bus) +continue ; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &rte_ifpga_get_string_arg, &name) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_NAME );drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +memset (name1,0 ,sizeof (name1)); + snprintf(name1, RTE_RAWDEV_NAME_MAX_LEN,"IFPGA:%s",
Quoted 10 lines
name);
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+ + rawdev =rte_rawdev_pmd_get_named_dev (name1); +if (!rawdev) + goto end; + +if (ifpga_find_ifpga_dev (rawdev)) +continue ; + + ifpga_dev =calloc (1 ,sizeof (*ifpga_dev));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (!ifpga_dev) + goto end; + + ifpga_dev->rdev = rawdev; +TAILQ_INIT (&ifpga_dev->afu_list); + +TAILQ_INSERT_TAIL (&ifpga_device_list, ifpga_dev, next); + afu_dev =ifpga_scan_one (devargs, ifpga_dev); +if (afu_dev !=NULL ) + TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,next);
Quoted 4 lines
I don't understand why we need
afu_list?, seems we only add a newafu_devinto the list after create a newifpga_dev, Is there any another place that we add one to list to make it reasonable? it looks like either a 1:1 or 1:0 for ifpga_dev:afu_dev?
One FPAG may support more than one AFU.
Quoted 143 lines
Quoted 89 lines
drivers/bus/ifpga/ifpga_bus.c new file +89
-0+ } + +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +/* +* Match the AFU Driver and AFU Device using the ID Table */ static +int rte_afu_match (const struct rte_afu_driver *afu_drv, +const struct rte_afu_device *afu_dev) { +const struct rte_afu_uuid *id_table; + +for (id_table = afu_drv->id_table; + ((id_table->uuid_low !=0 ) && (id_table->uuid_high !=0 )); + id_table++) { +/* check if device's identifiers match the driver's ones */ +if ((id_table->uuid_low != afu_dev->id.uuid.uuid_low) || + id_table->uuid_high != + afu_dev->id.uuid.uuid_high) +continue ; + +return 1 ; + } + +return 0 ; +} + +static int +ifpga_probe_one_driver (struct rte_afu_driver *drv, +struct rte_afu_device *afu_dev) +{ +int ret; + +if (!rte_afu_match (drv, afu_dev)) +/* Match of device and driver failed */ +return 1 ; + +/* reference driver structure */ + afu_dev->driver = drv; + afu_dev->device.driver = &drv->driver; + +/* call the driver probe() function */ + ret = drv->probe (afu_dev); +if (ret) { + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + } + +return ret; +} + +static int +ifpga_probe_all_drivers (struct rte_afu_device *afu_dev) { +struct rte_afu_driver *drv =NULL ; +int ret =0 ; + +if (afu_dev ==NULL ) +return -1 ; + +/* Check if a driver is already loaded */ +if (afu_dev->driver !=NULL ) +return 0 ; + + TAILQ_FOREACH(drv, &afu_driver_list, next) { +if (ifpga_probe_one_driver (drv, afu_dev)) { + ret =-1 ; +break ; + } + } +return ret; +} + +/* +* Scan the content of the Intel FPGA bus, and call the probe() +function for +* all registered drivers that have a matching entry in its id_table +* for discovered devices. +*/ +static int +ifpga_probe (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev =NULL ; +int ret =0 ;drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { + +if (afu_dev->device.driver) +continue ; + + ret =ifpga_probe_all_drivers (afu_dev); +if (ret <0 ) + IFPGA_BUS_ERR("failed to initialize %sdevice\n",
Quoted 43 lines
drivers/bus/ifpga/ifpga_bus.c new file +43
-0+ rte_ifpga_device_name(afu_dev)); + } + } + +return ret; +} + +static int +ifpga_plug (struct rte_device *dev) +{ +return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); +} + +static int +ifpga_remove_driver (struct rte_afu_device *afu_dev) { +const char *name; +const struct rte_afu_driver *driver; + + name =rte_ifpga_device_name (afu_dev); +if (!afu_dev->device.driver) { +IFPGA_BUS_DEBUG ("no driver attach to device %s\n" , name); +return 1 ; + } + + driver =RTE_DRV_TO_AFU_CONST (afu_dev->device.driver); +return driver->remove (afu_dev); +} + +static int +ifpga_unplug (struct rte_device *dev) +{ +struct rte_ifpga_device *ifpga_dev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_devargs *devargs =NULL ; +int ret; + +if (dev ==NULL ) +return -EINVAL ; + + afu_dev =RTE_DEV_TO_AFU (dev); +if (!dev) +return -ENOENT ; +
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 411
Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4
-0+ ifpga_dev = afu_dev->ifpga_dev; + devargs = dev->devargs; + + ret =ifpga_remove_driver (afu_dev);So what is the device type that be plugged into the ifgpa bus?
ifpga_devorafu_dev? If itsafu_dev, why we needifpga_dev? If it isifpga_dev, we need removeifpga_devfromifpga_device_listhere.
The device type that be plugged into the ifpga bus is afu_dev. And each afu_dev will be added into one ifpga_dev. Each FPGA device bind to ifpga_dev.
Quoted 353 lines
Quoted 47 lines
drivers/bus/ifpga/ifpga_bus.c new file +47
-0+if (ret) +return ret; + +TAILQ_REMOVE (&ifpga_dev->afu_list, afu_dev, next); + +rte_devargs_remove (devargs->bus->name, devargs->name); +free (afu_dev); +return 0 ; + +} + +static struct rte_device * +ifpga_find_device (const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) { +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (start && &afu_dev->device == start) { + start =NULL ; +continue ; + } +if (cmp (&afu_dev->device, data) ==0 ) +return &afu_dev->device; + } + } +return NULL ; +} +static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ; +int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name; + c2 = c1+1 ; + } +drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (str_port_len <8 && + str_port_len >0 ) { +memcpy (str_port, name, str_port_len); + ret =sscanf (str_port,"%d" , &port); +if (ret ==-1 ) +return 0 ; + } + +memset (rawdev_name,0 ,sizeof (rawdev_name)); + snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s",c2);
Quoted 272 lines
drivers/bus/ifpga/ifpga_bus.c new file +30
-0+ rawdev =rte_rawdev_pmd_get_named_dev (rawdev_name); + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev && + (addr !=NULL )) + *out = port; + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev) +return 0 ; +else +return 1 ; +} + +static struct rte_bus rte_ifpga_bus = { + .scan = ifpga_scan, + .probe = ifpga_probe, + .find_device = ifpga_find_device, + .plug = ifpga_plug, + .unplug = ifpga_unplug, + .parse = ifpga_parse, +}; + +RTE_REGISTER_BUS (IFPGA_BUS_NAME , rte_ifpga_bus); + +RTE_INIT (ifpga_init_log) +{ + ifpga_bus_logtype =rte_log_register ("bus.ifpga" ); +if (ifpga_bus_logtype >=0 ) +rte_log_set_level (ifpga_bus_logtype,RTE_LOG_NOTICE ); }drivers/bus/ifpga/ifpga_common.c new file +83
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(int *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_unsigned_long (const char *str,int base) { +unsigned long num; +char *end =NULL ; + + errno =0 ; + + num =strtoul (str, &end, base); +if ((str[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ) || (errno !=0 )) +return -1 ; + +return num; +} + +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1) +{ +if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && + (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && + (afu_id0->port == afu_id1->port)) { +return 0 ; + }else +return 1 ; +}drivers/bus/ifpga/ifpga_common.h new file +17
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_unsigned_long (const char *str,int base);int +ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */ (quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_logs.hnew file mode 100644 index 0000000..873e0a4drivers/bus/ifpga/ifpga_logs.h new file +30
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) +#define IFPGA_BUS_INFO(fmt, args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */ (quoted diff) +0
-0b/drivers/bus/ifpga/meson.build new file mode 100644 index 0000000..c9b08c8
drivers/bus/ifpga/meson.build new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 +Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = truedrivers/bus/ifpga/rte_bus_ifpga.h new file +71
-0@@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _RTE_BUS_IFPGA_H_ +#define _RTE_BUS_IFPGA_H_ + +/** + * @file + * + * RTE Intel FPGA Bus Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_bus.h> +#include <rte_pci.h> + +/** Name of Intel FPGA Bus */ +#define IFPGA_BUS_NAME ifpga + +/* Forward declarations */ +struct rte_afu_device; + +/** List of Intel AFU devices */ +TAILQ_HEAD(afu_device_list, rte_afu_device); +/** Double linked list of AFU device drivers. */ +TAILQ_HEAD(afu_driver_list, rte_afu_driver); + +#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256 + +struct rte_afu_uuid { + uint64_t uuid_low; + uint64_t uuid_high; +} __attribute__ ((packed)); + +#define IFPGA_BUS_DEV_PORT_MAX 4 + +/** + * A structure describing an ID for a AFU driver. Each driver +provides a + * table of these IDs for each device that it supports. + */ +struct rte_afu_id { + struct rte_afu_uuid uuid; + int port; /**< port number */ +} __attribute__ ((packed)); + +/** + * A structure PR (Partial Reconfiguration) configuration AFU driver. + */ + +struct rte_afu_pr_conf { + struct rte_afu_id afu_id; + int pr_enable; + char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +}; + +#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8) + +/** + * A structure describing a fpga device. + */ +struct rte_ifpga_device { + TAILQ_ENTRY(rte_ifpga_device) next; /**< Next in device list. */ + struct rte_rawdev *rdev; + struct afu_device_list afu_list; /**< List of AFU devices */ }; + +/** + * A structure describing a AFU device.drivers/bus/ifpga/rte_bus_ifpga.h line 81
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +struct rte_afu_device { +TAILQ_ENTRY (rte_afu_device) next;/**< Next in device list. */ +struct rte_device device;/**< Inherit core device */ +struct rte_rawdev *rawdev;/**< Point Rawdev */ +struct rte_ifpga_device *ifpga_dev;/**< Point ifpga device */ +struct rte_afu_id id;/**< AFU id within FPGA. */ +uint32_t num_region;/**< number of regions found */ +struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ]; +/**< AFU Memory Resource */
Quoted 12 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +12
-0+struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_afu_driver *driver;/**< Associated driver */ +char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; +} __attribute__ ((packed)); + +/** +* @internal +* Helper macro for drivers that need to convert to struct rte_afu_device. +*/ +#define RTE_DEV_TO_AFU (ptr) \ + container_of(ptr, struct rte_afu_device, device) +
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 99
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+#define RTE_DRV_TO_AFU_CONST (ptr) \ + container_of(ptr, const struct rte_afu_driver, driver) + +/** +* Initialisation function for the driver called during FPGA BUS probing. typo: Initialization
Fixed.
Quoted 7 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 104
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+*/ +typedef int (afu_probe_t )(struct rte_afu_device *); + +/** +* Uninitialisation function for the driver called during hotplugging. typo: Unintialization
Fixed.
Quoted 10 lines
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +typedef int (afu_remove_t )(struct rte_afu_device *); + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_driver { +TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ +struct rte_driver driver;/**< Inherit core driver. */ +afu_probe_t *probe;/**< Device Probe function.
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 117
Quoted 5 lines
*/
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/rte_bus_ifpga.h new file +2
-0+const struct rte_afu_uuid *id_table;/**< AFU uuid within FPGA. */ +uint32_t drv_flags;/**< Flags contolling handling of device. */ Typo Controlling
And what is "flags controlling handling of device?"
This variable is not used, so I have removed it.
Quoted 89 lines
Quoted 85 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +40
-0+}; + +static inline const char * +rte_ifpga_device_name (const struct rte_afu_device *afu) { +if (afu && afu->device.name) +return afu->device.name; +return NULL ; +} + +/** +* Register a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be registered. +*/ +void rte_ifpga_driver_register (struct rte_afu_driver *driver); + +/** +* Unregister a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be unregistered. +*/ +void rte_ifpga_driver_unregister (struct rte_afu_driver *driver); + +#define RTE_PMD_REGISTER_AFU (nm, afudrv)\ RTE_INIT(afudrvinitfn_ +##afudrv);\ static const char *afudrvinit_ ## nm ## _alias;\ static +void afudrvinitfn_ ##afudrv(void)\ {\ + (afudrv).driver.name = RTE_STR(nm);\ + (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\ + rte_ifpga_driver_register(&afudrv);\ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#define RTE_PMD_REGISTER_AFU_ALIAS (nm, alias)\ static const char +*afudrvinit_ ## nm ## _alias = RTE_STR(alias) + +#endif /* _RTE_BUS_IFPGA_H_ */ drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10
-0@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};drivers/bus/meson.build index renamed from drivers/bus/meson.build +0
-058dfbe2..52c755d 100644
drivers/bus/meson.build +0
-0@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 IntelCorporation
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'mk/rte.app.mk index 26f3563..3861e1a renamed from mk/rte.app.mk +0
-0100644
mk/rte.app.mk +1
-3@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV --Quoted 1 line
1.8.3.1
Regards
Qi
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Quoted 417 lines
-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 9:29 PM
To: Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Qi,
Quoted 4 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 20:27
To: Xu, Rosen <[email protected]>; [email protected];Quoted 109 lines
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Rosen:
Quoted 97 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Wednesday, May 9, 2018 3:43 PM
To: [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryFrom: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce
rte_afu_devicewhich describe the AFU device listed in the FPGA-BUS.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode100644
drivers/bus/ifpga/Makefilecreate mode 100644drivers/bus/ifpga/ifpga_bus.ccreate mode 100644drivers/bus/ifpga/ifpga_common.ccreate mode 100644drivers/bus/ifpga/ifpga_common.hcreate mode 100644drivers/bus/ifpga/ifpga_logs.hcreate mode 100644drivers/bus/ifpga/meson.buildcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga.hcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga_version.mapMAINTAINERS +4
-0@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers ----------- +Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]> diff --gita/config/common_base b/config/common_base index 0d181ac..1440316 100644
config/common_base +0
-0@@ -139,6 +139,11 @@
CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n#
config/common_base +5
-0+# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=ydoc/guides/rel_notes/release_18_05.rst +0
-0@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, and alsopdump packets on
those virtual devices.Quoted 5 lines
doc/guides/rel_notes/release_18_05.rst
Quoted 5 lines
doc/guides/rel_notes/release_18_05.rst +5
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel + FPGA device with the DPDK framework. It provides Intel FPGA + Partial Bit Stream AFU(Accelerated Function Unit) scan and driversprove.
Quoted 152 lines
Quoted 152 lines
API Changes
-----------drivers/bus/Makefile index renamed from drivers/bus/Makefile +0
-0c251b65..ef7f247 100644
drivers/bus/Makefile +1
-0@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa ifeq ($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdevdrivers/bus/ifpga/Makefile new file +32
-0@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel +Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk(quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_bus.cnew file mode 100644 index 0000000..e144c01drivers/bus/ifpga/ifpga_bus.c new file +95
-0@@ -0,0 +1,501 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int ifpga_bus_logtype; + +/* Forward declaration to access Intel FPGA bus +* on which iFPGA devices are connected */ static struct rte_bus +rte_ifpga_bus; + +/** Double linked list of IFPGA device. */ +TAILQ_HEAD (ifpga_device_list, rte_ifpga_device); + +static struct ifpga_device_list ifpga_device_list = +TAILQ_HEAD_INITIALIZER (ifpga_device_list); +static struct afu_driver_list afu_driver_list = +TAILQ_HEAD_INITIALIZER (afu_driver_list); + + +/* register a ifpga bus based driver */ void +rte_ifpga_driver_register (struct rte_afu_driver *driver) { +RTE_VERIFY (driver); + +TAILQ_INSERT_TAIL (&afu_driver_list, driver, next); } + +/* un-register a fpga bus based driver */ void +rte_ifpga_driver_unregister (struct rte_afu_driver *driver) { +TAILQ_REMOVE (&afu_driver_list, driver, next); } + +static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { +if (rdev && + ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) +{ +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id)) +return afu_dev; + } +return NULL ; +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +/* +* Scan the content of the FPGA bus, and the devices in the devices Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 107
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+* list +*/ +static struct rte_afu_device * +ifpga_scan_one (struct rte_devargs *devargs, +struct rte_ifpga_device *ifpga_dev)usually
ifpag_devshould be the first parameter here, and devargs followsFixed.
Quoted 107 lines
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+{ +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_pr_conf afu_pr_conf; +int ret =0 ; +char *path =NULL ; + +memset (&afu_pr_conf,0 ,sizeof (struct rte_afu_pr_conf ));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_PORT , + &rte_ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) <0 ){
Quoted 87 lines
drivers/bus/ifpga/ifpga_bus.c new file +87
-0+IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_PORT ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_AFU_BTS ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_AFU_BTS , + &rte_ifpga_get_string_arg, &path) <0 ) { +IFPGA_BUS_ERR ("Failed to parse %s" , +IFPGA_AFU_BTS ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_AFU_BTS ); + goto end; + } + + afu_pr_conf.afu_id.uuid.uuid_low =0 ; + afu_pr_conf.afu_id.uuid.uuid_high =0 ; + afu_pr_conf.pr_enable = path?1 :0 ; + + rawdev = ifpga_dev->rdev; +if (ifpga_find_afu_dev (ifpga_dev, &afu_pr_conf.afu_id)) + goto end; + + afu_dev =calloc (1 ,sizeof (*afu_dev)); +if (!afu_dev) + goto end; + + afu_dev->device.devargs = devargs; + afu_dev->device.numa_node =SOCKET_ID_ANY ; + afu_dev->device.name = devargs->name; + afu_dev->rawdev = rawdev; + afu_dev->id.uuid.uuid_low =0 ; + afu_dev->id.uuid.uuid_high =0 ; + afu_dev->id.port = afu_pr_conf.afu_id.port; + afu_dev->ifpga_dev = ifpga_dev; + +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) + rawdev->dev_ops->dev_info_get (rawdev, afu_dev); + +if (rawdev->dev_ops && + rawdev->dev_ops->dev_start && + rawdev->dev_ops->dev_start (rawdev)) + goto free_dev; + +strncpy (afu_pr_conf.bs_path, path,sizeof (afu_pr_conf.bs_path)); +if (rawdev->dev_ops->firmware_load && + rawdev->dev_ops->firmware_load (rawdev, + &afu_pr_conf)){ +IFPGA_BUS_ERR ("firmware load error %d\n" , ret); + goto free_dev; + } + afu_dev->id.uuid.uuid_low = afu_pr_conf.afu_id.uuid.uuid_low; + afu_dev->id.uuid.uuid_high = afu_pr_conf.afu_id.uuid.uuid_high; + +return afu_dev; + +free_dev: +free (afu_dev); +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (path) +free (path); + +return NULL ; +} + +/* +* Scan the content of the FPGA bus, and the devices in the devices +* list +*/ +static int +ifpga_scan (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +char *name =NULL ;Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 275
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+char name1[RTE_RAWDEV_NAME_MAX_LEN ]; +struct rte_afu_device *afu_dev =NULL ; + +/* for FPGA devices we scan the devargs_list populated via cmdline +*/ I didn't see "--ifpga" is supported by cmdline, either you need to add corresponding parser or correct the comment here.
Quoted 2 lines
To be honestly,
ifpga_scan()is called by hotplug,lib_rtehotplug function will construct it.
OK, after review patch 3, I saw it, that make sense.
Quoted 53 lines
Quoted 53 lines
drivers/bus/ifpga/ifpga_bus.c line 218
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +1
-0+ RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
IFPGA_BUS_NAMEto replace "ifpga" here.Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +14
-0+if (devargs->bus != &rte_ifpga_bus) +continue ; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &rte_ifpga_get_string_arg, &name) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_NAME );drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +memset (name1,0 ,sizeof (name1)); + snprintf(name1, RTE_RAWDEV_NAME_MAX_LEN,"IFPGA:%s",
Quoted 10 lines
name);
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+ + rawdev =rte_rawdev_pmd_get_named_dev (name1); +if (!rawdev) + goto end; + +if (ifpga_find_ifpga_dev (rawdev)) +continue ; + + ifpga_dev =calloc (1 ,sizeof (*ifpga_dev));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (!ifpga_dev) + goto end; + + ifpga_dev->rdev = rawdev; +TAILQ_INIT (&ifpga_dev->afu_list); + +TAILQ_INSERT_TAIL (&ifpga_device_list, ifpga_dev, next); + afu_dev =ifpga_scan_one (devargs, ifpga_dev); +if (afu_dev !=NULL ) + TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,next);
Quoted 6 lines
Quoted 4 lines
I don't understand why we need
afu_list?, seems we only add a newafu_devinto the list after create a newifpga_dev, Is there any another place that we add one to list to make it reasonable? it looks like either a 1:1 or 1:0 for ifpga_dev:afu_dev?One FPAG may support more than one AFU.
But in your implementation, it is not possible that an ifpga_dev contains multiple afu_dev
Quoted 153 lines
Quoted 144 lines
Quoted 91 lines
drivers/bus/ifpga/ifpga_bus.c new file +90
-0+ } + +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +/* +* Match the AFU Driver and AFU Device using the ID Table */ +static int rte_afu_match (const struct rte_afu_driver *afu_drv, +const struct rte_afu_device *afu_dev) { +const struct rte_afu_uuid *id_table; + +for (id_table = afu_drv->id_table; + ((id_table->uuid_low !=0 ) && (id_table->uuid_high !=0 )); + id_table++) { +/* check if device's identifiers match the driver's ones */ +if ((id_table->uuid_low != afu_dev->id.uuid.uuid_low) || + id_table->uuid_high != + afu_dev->id.uuid.uuid_high) +continue ; + +return 1 ; + } + +return 0 ; +} + +static int +ifpga_probe_one_driver (struct rte_afu_driver *drv, +struct rte_afu_device *afu_dev) +{ +int ret; + +if (!rte_afu_match (drv, afu_dev)) +/* Match of device and driver failed */ +return 1 ; + +/* reference driver structure */ + afu_dev->driver = drv; + afu_dev->device.driver = &drv->driver; + +/* call the driver probe() function */ + ret = drv->probe (afu_dev); +if (ret) { + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + } + +return ret; +} + +static int +ifpga_probe_all_drivers (struct rte_afu_device *afu_dev) { +struct rte_afu_driver *drv =NULL ; +int ret =0 ; + +if (afu_dev ==NULL ) +return -1 ; + +/* Check if a driver is already loaded */ +if (afu_dev->driver !=NULL ) +return 0 ; + + TAILQ_FOREACH(drv, &afu_driver_list, next) { +if (ifpga_probe_one_driver (drv, afu_dev)) { + ret =-1 ; +break ; + } + } +return ret; +} + +/* +* Scan the content of the Intel FPGA bus, and call the probe() +function for +* all registered drivers that have a matching entry in its +id_table +* for discovered devices. +*/ +static int +ifpga_probe (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev =NULL ; +int ret =0 ;drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { + +if (afu_dev->device.driver) +continue ; + + ret =ifpga_probe_all_drivers (afu_dev); +if (ret <0 ) + IFPGA_BUS_ERR("failed to initialize %sdevice\n",
Quoted 42 lines
drivers/bus/ifpga/ifpga_bus.c new file +42
-0+ rte_ifpga_device_name(afu_dev)); + } + } + +return ret; +} + +static int +ifpga_plug (struct rte_device *dev) +{ +return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); +} + +static int +ifpga_remove_driver (struct rte_afu_device *afu_dev) { +const char *name; +const struct rte_afu_driver *driver; + + name =rte_ifpga_device_name (afu_dev); +if (!afu_dev->device.driver) { +IFPGA_BUS_DEBUG ("no driver attach to device %s\n" , name); +return 1 ; + } + + driver =RTE_DRV_TO_AFU_CONST (afu_dev->device.driver); +return driver->remove (afu_dev); +} + +static int +ifpga_unplug (struct rte_device *dev) { +struct rte_ifpga_device *ifpga_dev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_devargs *devargs =NULL ; +int ret; + +if (dev ==NULL ) +return -EINVAL ; + + afu_dev =RTE_DEV_TO_AFU (dev); +if (!dev) +return -ENOENT ; +Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 411
Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4
-0+ ifpga_dev = afu_dev->ifpga_dev; + devargs = dev->devargs; + + ret =ifpga_remove_driver (afu_dev);So what is the device type that be plugged into the ifgpa bus?
ifpga_devorafu_dev? If itsafu_dev, why we needifpga_dev? If it isifpga_dev, we need removeifpga_devfromifpga_device_listhere.
Quoted 1 line
The device type that be plugged into the ifpga bus is
afu_dev.
In DPDK, we have rte_pci_device for pci bus
and rte_vdev_device for vdev bus
Now we have rte_ifpga_device not for ifgpa bus but rte_afu_device, it is a little bit confuse here
Quoted 2 lines
And each
afu_devwill be added into oneifpga_dev. Each FPGA device bind toifpga_dev.
So what is the relationship between ifpga_dev and raw_dev?
Quoted 485 lines
Quoted 354 lines
Quoted 48 lines
drivers/bus/ifpga/ifpga_bus.c new file +47
-0+if (ret) +return ret; + +TAILQ_REMOVE (&ifpga_dev->afu_list, afu_dev, next); + +rte_devargs_remove (devargs->bus->name, devargs->name); +free (afu_dev); +return 0 ; + +} + +static struct rte_device * +ifpga_find_device (const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) { +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (start && &afu_dev->device == start) { + start =NULL ; +continue ; + } +if (cmp (&afu_dev->device, data) ==0 ) +return &afu_dev->device; + } + } +return NULL ; +} +static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ; +int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name; + c2 = c1+1 ; + } +drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (str_port_len <8 && + str_port_len >0 ) { +memcpy (str_port, name, str_port_len); + ret =sscanf (str_port,"%d" , &port); +if (ret ==-1 ) +return 0 ; + } + +memset (rawdev_name,0 ,sizeof (rawdev_name)); + snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s",c2);
Quoted 272 lines
drivers/bus/ifpga/ifpga_bus.c new file +30
-0+ rawdev =rte_rawdev_pmd_get_named_dev (rawdev_name); + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev && + (addr !=NULL )) + *out = port; + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev) +return 0 ; +else +return 1 ; +} + +static struct rte_bus rte_ifpga_bus = { + .scan = ifpga_scan, + .probe = ifpga_probe, + .find_device = ifpga_find_device, + .plug = ifpga_plug, + .unplug = ifpga_unplug, + .parse = ifpga_parse, +}; + +RTE_REGISTER_BUS (IFPGA_BUS_NAME , rte_ifpga_bus); + +RTE_INIT (ifpga_init_log) +{ + ifpga_bus_logtype =rte_log_register ("bus.ifpga" ); +if (ifpga_bus_logtype >=0 ) +rte_log_set_level (ifpga_bus_logtype,RTE_LOG_NOTICE ); }drivers/bus/ifpga/ifpga_common.c new file +83
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(int *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_unsigned_long (const char *str,int base) { +unsigned long num; +char *end =NULL ; + + errno =0 ; + + num =strtoul (str, &end, base); +if ((str[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ) || (errno !=0 )) +return -1 ; + +return num; +} + +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1) +{ +if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && + (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && + (afu_id0->port == afu_id1->port)) { +return 0 ; + }else +return 1 ; +}drivers/bus/ifpga/ifpga_common.h new file +17
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_unsigned_long (const char *str,int base);int +ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */ (quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_logs.hnew file mode 100644 index 0000000..873e0a4drivers/bus/ifpga/ifpga_logs.h new file +30
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) #define IFPGA_BUS_INFO(fmt, +args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */ (quoted diff) +0
-0b/drivers/bus/ifpga/meson.build new file mode 100644 index 0000000..c9b08c8
drivers/bus/ifpga/meson.build new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 +Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = truedrivers/bus/ifpga/rte_bus_ifpga.h new file +71
-0@@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _RTE_BUS_IFPGA_H_ +#define _RTE_BUS_IFPGA_H_ + +/** + * @file + * + * RTE Intel FPGA Bus Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_bus.h> +#include <rte_pci.h> + +/** Name of Intel FPGA Bus */ +#define IFPGA_BUS_NAME ifpga + +/* Forward declarations */ +struct rte_afu_device; + +/** List of Intel AFU devices */ +TAILQ_HEAD(afu_device_list, rte_afu_device); +/** Double linked list of AFU device drivers. */ +TAILQ_HEAD(afu_driver_list, rte_afu_driver); + +#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256 + +struct rte_afu_uuid { + uint64_t uuid_low; + uint64_t uuid_high; +} __attribute__ ((packed)); + +#define IFPGA_BUS_DEV_PORT_MAX 4 + +/** + * A structure describing an ID for a AFU driver. Each driver +provides a + * table of these IDs for each device that it supports. + */ +struct rte_afu_id { + struct rte_afu_uuid uuid; + int port; /**< port number */ +} __attribute__ ((packed)); + +/** + * A structure PR (Partial Reconfiguration) configuration AFU driver. + */ + +struct rte_afu_pr_conf { + struct rte_afu_id afu_id; + int pr_enable; + char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +}; + +#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8) + +/** + * A structure describing a fpga device. + */ +struct rte_ifpga_device { + TAILQ_ENTRY(rte_ifpga_device) next; /**< Next in device list. */ + struct rte_rawdev *rdev; + struct afu_device_list afu_list; /**< List of AFU devices */ }; + +/** + * A structure describing a AFU device.drivers/bus/ifpga/rte_bus_ifpga.h line 81
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +struct rte_afu_device { +TAILQ_ENTRY (rte_afu_device) next;/**< Next in device list. */ +struct rte_device device;/**< Inherit core device */ +struct rte_rawdev *rawdev;/**< Point Rawdev */ +struct rte_ifpga_device *ifpga_dev;/**< Point ifpga device */ +struct rte_afu_id id;/**< AFU id within FPGA. */ +uint32_t num_region;/**< number of regions found */ +struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ]; +/**< AFU Memory Resource */
Quoted 12 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +12
-0+struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_afu_driver *driver;/**< Associated driver */ +char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; +} __attribute__ ((packed)); + +/** +* @internal +* Helper macro for drivers that need to convert to struct rte_afu_device. +*/ +#define RTE_DEV_TO_AFU (ptr) \ + container_of(ptr, struct rte_afu_device, device) +Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 99
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+#define RTE_DRV_TO_AFU_CONST (ptr) \ + container_of(ptr, const struct rte_afu_driver, driver) + +/** +* Initialisation function for the driver called during FPGA BUS probing. typo: Initialization
Fixed.
Quoted 7 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 104
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+*/ +typedef int (afu_probe_t )(struct rte_afu_device *); + +/** +* Uninitialisation function for the driver called during hotplugging. typo: Unintialization
Fixed.
Quoted 10 lines
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +typedef int (afu_remove_t )(struct rte_afu_device *); + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_driver { +TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ +struct rte_driver driver;/**< Inherit core driver. */ +afu_probe_t *probe;/**< Device Probe function. Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 117
Quoted 5 lines
*/
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/rte_bus_ifpga.h new file +2
-0+const struct rte_afu_uuid *id_table;/**< AFU uuid within FPGA. */ +uint32_t drv_flags;/**< Flags contolling handling of device. */ Typo Controlling
And what is "flags controlling handling of device?"This variable is not used, so I have removed it.
Quoted 89 lines
Quoted 85 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +40
-0+}; + +static inline const char * +rte_ifpga_device_name (const struct rte_afu_device *afu) { +if (afu && afu->device.name) +return afu->device.name; +return NULL ; +} + +/** +* Register a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be registered. +*/ +void rte_ifpga_driver_register (struct rte_afu_driver *driver); + +/** +* Unregister a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be unregistered. +*/ +void rte_ifpga_driver_unregister (struct rte_afu_driver *driver); + +#define RTE_PMD_REGISTER_AFU (nm, afudrv)\ RTE_INIT(afudrvinitfn_ +##afudrv);\ static const char *afudrvinit_ ## nm ## _alias;\ static +void afudrvinitfn_ ##afudrv(void)\ {\ + (afudrv).driver.name = RTE_STR(nm);\ + (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\ + rte_ifpga_driver_register(&afudrv);\ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#define RTE_PMD_REGISTER_AFU_ALIAS (nm, alias)\ static const char +*afudrvinit_ ## nm ## _alias = RTE_STR(alias) + +#endif /* _RTE_BUS_IFPGA_H_ */ drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10
-0@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};drivers/bus/meson.build index renamed from drivers/bus/meson.build +0
-058dfbe2..52c755d 100644
drivers/bus/meson.build +0
-0@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 IntelCorporation
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'mk/rte.app.mk index 26f3563..3861e1a renamed from mk/rte.app.mk +0
-0100644
mk/rte.app.mk +1
-3@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV --Quoted 1 line
1.8.3.1
Regards
Qi
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Hi Qi,
Quoted 500 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 21:49
To: Xu, Rosen <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 15 lines
-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 9:29 PM
To: Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 41 lines
Hi Qi,
Quoted 4 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 20:27
To: Xu, Rosen <[email protected]>; [email protected];Quoted 34 lines
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Rosen:
Quoted 21 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Wednesday, May 9, 2018 3:43 PM
To: [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryFrom: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following
patches.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce
rte_afu_devicewhich describe the AFU device listed in the FPGA-BUS.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode100644
drivers/bus/ifpga/Makefilecreate mode 100644drivers/bus/ifpga/ifpga_bus.ccreate mode 100644drivers/bus/ifpga/ifpga_common.ccreate mode 100644drivers/bus/ifpga/ifpga_common.hcreate mode 100644drivers/bus/ifpga/ifpga_logs.hcreate mode 100644drivers/bus/ifpga/meson.buildcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga.hcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga_version.mapMAINTAINERS index 7105920..fa0c5b1 renamed from MAINTAINERS +0
-0100644
MAINTAINERS +0
-0@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers -----------Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
MAINTAINERS +4
-0+Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]> diff --gita/config/common_base b/config/common_base index
0d181ac..1440316
Quoted 34 lines
Quoted 26 lines
Quoted 26 lines
100644
config/common_base +0
-0@@ -139,6 +139,11 @@
CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n#
config/common_base +5
-0+# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=ydoc/guides/rel_notes/release_18_05.rst +0
-0@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, and alsopdump packets on
those virtual devices.Quoted 6 lines
doc/guides/rel_notes/release_18_05.rst
Quoted 6 lines
doc/guides/rel_notes/release_18_05.rst +6
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any + Intel FPGA device with the DPDK framework. It provides Intel + FPGA Partial Bit Stream AFU(Accelerated Function Unit) scan and + driversprove.
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/bus/Makefile DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
Quoted 7 lines
API Changes
-----------drivers/bus/Makefile index renamed from drivers/bus/Makefile +0
-0c251b65..ef7f247 100644
drivers/bus/Makefile +0
-0@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaaifeq
Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
drivers/bus/Makefile +1
-0($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev(quoted diff) +0
-0b/drivers/bus/ifpga/Makefile new file mode 100644 index 0000000..3ff3bdb
drivers/bus/ifpga/Makefile new file +19
-0@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel +Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += +$(WERROR_FLAGS) LDLIBS += -lrte_eal LDLIBS += -lrte_rawdev LDLIBS ++= -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/Makefile
Quoted 8 lines
drivers/bus/ifpga/Makefile new file +8
-0+ +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include +=
rte_bus_ifpga.hQuoted 231 lines
Quoted 103 lines
Quoted 103 lines
drivers/bus/ifpga/Makefile new file +2
-0+ +include $(RTE_SDK)/mk/rte.lib.mk(quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_bus.cnew file mode 100644 index 0000000..e144c01drivers/bus/ifpga/ifpga_bus.c new file +95
-0@@ -0,0 +1,501 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int ifpga_bus_logtype; + +/* Forward declaration to access Intel FPGA bus +* on which iFPGA devices are connected */ static struct rte_bus +rte_ifpga_bus; + +/** Double linked list of IFPGA device. */ +TAILQ_HEAD (ifpga_device_list, rte_ifpga_device); + +static struct ifpga_device_list ifpga_device_list = +TAILQ_HEAD_INITIALIZER (ifpga_device_list); +static struct afu_driver_list afu_driver_list = +TAILQ_HEAD_INITIALIZER (afu_driver_list); + + +/* register a ifpga bus based driver */ void +rte_ifpga_driver_register (struct rte_afu_driver *driver) { +RTE_VERIFY (driver); + +TAILQ_INSERT_TAIL (&afu_driver_list, driver, next); } + +/* un-register a fpga bus based driver */ void +rte_ifpga_driver_unregister (struct rte_afu_driver *driver) { +TAILQ_REMOVE (&afu_driver_list, driver, next); } + +static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { +if (rdev && + ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) { +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id)) +return afu_dev; + } +return NULL ; +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +/* +* Scan the content of the FPGA bus, and the devices in the +devices Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 107
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+* list +*/ +static struct rte_afu_device * +ifpga_scan_one (struct rte_devargs *devargs, +struct rte_ifpga_device *ifpga_dev)usually
ifpag_devshould be the first parameter here, and devargs followsFixed.
Quoted 108 lines
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+{ +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_pr_conf afu_pr_conf; +int ret =0 ; +char *path =NULL ; + +memset (&afu_pr_conf,0 ,sizeof (struct rte_afu_pr_conf ));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_PORT , + &rte_ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) <0 ){
Quoted 88 lines
drivers/bus/ifpga/ifpga_bus.c new file +88
-0+IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_PORT ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_AFU_BTS ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_AFU_BTS , + &rte_ifpga_get_string_arg, &path) <0 ) { +IFPGA_BUS_ERR ("Failed to parse %s" , +IFPGA_AFU_BTS ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_AFU_BTS ); + goto end; + } + + afu_pr_conf.afu_id.uuid.uuid_low =0 ; + afu_pr_conf.afu_id.uuid.uuid_high =0 ; + afu_pr_conf.pr_enable = path?1 :0 ; + + rawdev = ifpga_dev->rdev; +if (ifpga_find_afu_dev (ifpga_dev, &afu_pr_conf.afu_id)) + goto end; + + afu_dev =calloc (1 ,sizeof (*afu_dev)); +if (!afu_dev) + goto end; + + afu_dev->device.devargs = devargs; + afu_dev->device.numa_node =SOCKET_ID_ANY ; + afu_dev->device.name = devargs->name; + afu_dev->rawdev = rawdev; + afu_dev->id.uuid.uuid_low =0 ; + afu_dev->id.uuid.uuid_high =0 ; + afu_dev->id.port = afu_pr_conf.afu_id.port; + afu_dev->ifpga_dev = ifpga_dev; + +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) + rawdev->dev_ops->dev_info_get (rawdev, afu_dev); + +if (rawdev->dev_ops && + rawdev->dev_ops->dev_start && + rawdev->dev_ops->dev_start (rawdev)) + goto free_dev; + +strncpy (afu_pr_conf.bs_path, path,sizeof (afu_pr_conf.bs_path)); +if (rawdev->dev_ops->firmware_load && + rawdev->dev_ops->firmware_load (rawdev, + &afu_pr_conf)){ +IFPGA_BUS_ERR ("firmware load error %d\n" , ret); + goto free_dev; + } + afu_dev->id.uuid.uuid_low = afu_pr_conf.afu_id.uuid.uuid_low; + afu_dev->id.uuid.uuid_high = afu_pr_conf.afu_id.uuid.uuid_high; + +return afu_dev; + +free_dev: +free (afu_dev); +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (path) +free (path); + +return NULL ; +} + +/* +* Scan the content of the FPGA bus, and the devices in the +devices +* list +*/ +static int +ifpga_scan (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +char *name =NULL ;Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+char name1[RTE_RAWDEV_NAME_MAX_LEN ]; +struct rte_afu_device *afu_dev =NULL ; + +/* for FPGA devices we scan the devargs_list populated via +cmdline */ I didn't see "--ifpga" is supported by cmdline, either you need to add corresponding parser or correct the comment here.
Quoted 2 lines
To be honestly,
ifpga_scan()is called by hotplug,lib_rtehotplug function will construct it.OK, after review patch 3, I saw it, that make sense.
Quoted 58 lines
Quoted 57 lines
drivers/bus/ifpga/ifpga_bus.c line 218
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +1
-0+ RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
IFPGA_BUS_NAMEto replace "ifpga" here.Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +14
-0+if (devargs->bus != &rte_ifpga_bus) +continue ; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &rte_ifpga_get_string_arg, &name) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_NAME );drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +memset (name1,0 ,sizeof (name1)); + snprintf(name1, RTE_RAWDEV_NAME_MAX_LEN,"IFPGA:%s",
Quoted 10 lines
name);
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+ + rawdev =rte_rawdev_pmd_get_named_dev (name1); +if (!rawdev) + goto end; + +if (ifpga_find_ifpga_dev (rawdev)) +continue ; + + ifpga_dev =calloc (1 ,sizeof (*ifpga_dev));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (!ifpga_dev) + goto end; + + ifpga_dev->rdev = rawdev; +TAILQ_INIT (&ifpga_dev->afu_list); + +TAILQ_INSERT_TAIL (&ifpga_device_list, ifpga_dev, next); + afu_dev =ifpga_scan_one (devargs, ifpga_dev); +if (afu_dev !=NULL ) + TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,next);
I don't understand why we need
afu_list?, seems we only add a newafu_devinto the list after create a newifpga_dev, Is there any another place that we add one to list to make it reasonable? it looks like either a 1:1 or 1:0 for ifpga_dev:afu_dev?
Quoted 4 lines
Quoted 1 line
One FPAG may support more than one AFU.
But in your implementation, it is not possible that an
ifpga_devcontains multipleafu_dev
All afu_devs are listed to ifpga_dev, and each afu_dev can be added and deleted by user.
Quoted 151 lines
Quoted 151 lines
Quoted 150 lines
Quoted 90 lines
drivers/bus/ifpga/ifpga_bus.c new file +89
-0+ } + +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +/* +* Match the AFU Driver and AFU Device using the ID Table */ +static int rte_afu_match (const struct rte_afu_driver *afu_drv, +const struct rte_afu_device *afu_dev) { +const struct rte_afu_uuid *id_table; + +for (id_table = afu_drv->id_table; + ((id_table->uuid_low !=0 ) && (id_table->uuid_high !=0 )); + id_table++) { +/* check if device's identifiers match the driver's ones */ +if ((id_table->uuid_low != afu_dev->id.uuid.uuid_low) || + id_table->uuid_high != + afu_dev->id.uuid.uuid_high) +continue ; + +return 1 ; + } + +return 0 ; +} + +static int +ifpga_probe_one_driver (struct rte_afu_driver *drv, +struct rte_afu_device *afu_dev) { +int ret; + +if (!rte_afu_match (drv, afu_dev)) +/* Match of device and driver failed */ +return 1 ; + +/* reference driver structure */ + afu_dev->driver = drv; + afu_dev->device.driver = &drv->driver; + +/* call the driver probe() function */ + ret = drv->probe (afu_dev); +if (ret) { + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + } + +return ret; +} + +static int +ifpga_probe_all_drivers (struct rte_afu_device *afu_dev) { +struct rte_afu_driver *drv =NULL ; +int ret =0 ; + +if (afu_dev ==NULL ) +return -1 ; + +/* Check if a driver is already loaded */ +if (afu_dev->driver !=NULL ) +return 0 ; + + TAILQ_FOREACH(drv, &afu_driver_list, next) { +if (ifpga_probe_one_driver (drv, afu_dev)) { + ret =-1 ; +break ; + } + } +return ret; +} + +/* +* Scan the content of the Intel FPGA bus, and call the probe() +function for +* all registered drivers that have a matching entry in its +id_table +* for discovered devices. +*/ +static int +ifpga_probe (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev =NULL ; +int ret =0 ;drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { + +if (afu_dev->device.driver) +continue ; + + ret =ifpga_probe_all_drivers (afu_dev); +if (ret <0 ) + IFPGA_BUS_ERR("failed to initialize %sdevice\n",
Quoted 35 lines
drivers/bus/ifpga/ifpga_bus.c new file +35
-0+ rte_ifpga_device_name(afu_dev)); + } + } + +return ret; +} + +static int +ifpga_plug (struct rte_device *dev) { +return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); +} + +static int +ifpga_remove_driver (struct rte_afu_device *afu_dev) { +const char *name; +const struct rte_afu_driver *driver; + + name =rte_ifpga_device_name (afu_dev); +if (!afu_dev->device.driver) { +IFPGA_BUS_DEBUG ("no driver attach to device %s\n" , name); +return 1 ; + } + + driver =RTE_DRV_TO_AFU_CONST (afu_dev->device.driver); +return driver->remove (afu_dev); +} + +static int +ifpga_unplug (struct rte_device *dev) { +struct rte_ifpga_device *ifpga_dev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_devargs *devargs =NULL ; +int ret; + +if (dev ==NULL )drivers/bus/ifpga/ifpga_bus.c line 411
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+return -EINVAL ; + + afu_dev =RTE_DEV_TO_AFU (dev); +if (!dev) +return -ENOENT ; + + ifpga_dev = afu_dev->ifpga_dev; + devargs = dev->devargs; + + ret =ifpga_remove_driver (afu_dev);So what is the device type that be plugged into the ifgpa bus?
ifpga_devorafu_dev? If itsafu_dev, why we needifpga_dev? If it isifpga_dev, we need removeifpga_devfromifpga_device_listhere.
Quoted 5 lines
Quoted 1 line
The device type that be plugged into the ifpga bus is
afu_dev.In DPDK, we have
rte_pci_devicefor pci bus andrte_vdev_devicefor vdev bus Now we haverte_ifpga_devicenot for ifgpa bus butrte_afu_device, it is a little bit confuse here
The relationship of this items is descripted in ifpga_rawdev.rst.
Quoted 4 lines
Quoted 2 lines
And each
afu_devwill be added into oneifpga_dev. Each FPGA device bind toifpga_dev.So what is the relationship between
ifpga_devandraw_dev?
One FPGA as a PCI device will probe ifpga_rawdev. For management afu_dev, we create ifpga_dev in ifpga_bus.
Quoted 485 lines
Quoted 341 lines
Quoted 341 lines
Quoted 48 lines
drivers/bus/ifpga/ifpga_bus.c new file +47
-0+if (ret) +return ret; + +TAILQ_REMOVE (&ifpga_dev->afu_list, afu_dev, next); + +rte_devargs_remove (devargs->bus->name, devargs->name); +free (afu_dev); +return 0 ; + +} + +static struct rte_device * +ifpga_find_device (const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) { +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (start && &afu_dev->device == start) { + start =NULL ; +continue ; + } +if (cmp (&afu_dev->device, data) ==0 ) +return &afu_dev->device; + } + } +return NULL ; +} +static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ; +int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name; + c2 = c1+1 ; + } +drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (str_port_len <8 && + str_port_len >0 ) { +memcpy (str_port, name, str_port_len); + ret =sscanf (str_port,"%d" , &port); +if (ret ==-1 ) +return 0 ; + } + +memset (rawdev_name,0 ,sizeof (rawdev_name)); + snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s",c2);
Quoted 271 lines
drivers/bus/ifpga/ifpga_bus.c new file +30
-0+ rawdev =rte_rawdev_pmd_get_named_dev (rawdev_name); + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev && + (addr !=NULL )) + *out = port; + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev) +return 0 ; +else +return 1 ; +} + +static struct rte_bus rte_ifpga_bus = { + .scan = ifpga_scan, + .probe = ifpga_probe, + .find_device = ifpga_find_device, + .plug = ifpga_plug, + .unplug = ifpga_unplug, + .parse = ifpga_parse, +}; + +RTE_REGISTER_BUS (IFPGA_BUS_NAME , rte_ifpga_bus); + +RTE_INIT (ifpga_init_log) +{ + ifpga_bus_logtype =rte_log_register ("bus.ifpga" ); +if (ifpga_bus_logtype >=0 ) +rte_log_set_level (ifpga_bus_logtype,RTE_LOG_NOTICE ); }drivers/bus/ifpga/ifpga_common.c new file +82
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(int *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_unsigned_long (const char *str,int base) { +unsigned long num; +char *end =NULL ; + + errno =0 ; + + num =strtoul (str, &end, base); +if ((str[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ) || (errno !=0 )) +return -1 ; + +return num; +} + +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1) { +if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && + (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && + (afu_id0->port == afu_id1->port)) { +return 0 ; + }else +return 1 ; +}drivers/bus/ifpga/ifpga_common.h new file +17
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_unsigned_long (const char *str,int base);int +ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */ (quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_logs.hnew file mode 100644 index 0000000..873e0a4drivers/bus/ifpga/ifpga_logs.h new file +30
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) #define IFPGA_BUS_INFO(fmt, +args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) #define IFPGA_BUS_ERR(fmt, +args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) #define IFPGA_BUS_WARN(fmt, +args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */ (quoted diff) +0
-0b/drivers/bus/ifpga/meson.build new file mode 100644 index 0000000..c9b08c8
drivers/bus/ifpga/meson.build new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 +Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = truedrivers/bus/ifpga/rte_bus_ifpga.h new file +71
-0@@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _RTE_BUS_IFPGA_H_ +#define _RTE_BUS_IFPGA_H_ + +/** + * @file + * + * RTE Intel FPGA Bus Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_bus.h> +#include <rte_pci.h> + +/** Name of Intel FPGA Bus */ +#define IFPGA_BUS_NAME ifpga + +/* Forward declarations */ +struct rte_afu_device; + +/** List of Intel AFU devices */ +TAILQ_HEAD(afu_device_list, rte_afu_device); +/** Double linked list of AFU device drivers. */ +TAILQ_HEAD(afu_driver_list, rte_afu_driver); + +#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256 + +struct rte_afu_uuid { + uint64_t uuid_low; + uint64_t uuid_high; +} __attribute__ ((packed)); + +#define IFPGA_BUS_DEV_PORT_MAX 4 + +/** + * A structure describing an ID for a AFU driver. Each driver +provides a + * table of these IDs for each device that it supports. + */ +struct rte_afu_id { + struct rte_afu_uuid uuid; + int port; /**< port number */ +} __attribute__ ((packed)); + +/** + * A structure PR (Partial Reconfiguration) configuration AFU driver. + */ + +struct rte_afu_pr_conf { + struct rte_afu_id afu_id; + int pr_enable; + char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +}; + +#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8) + +/** + * A structure describing a fpga device. + */ +struct rte_ifpga_device { + TAILQ_ENTRY(rte_ifpga_device) next; /**< Next in device list. */ + struct rte_rawdev *rdev; + struct afu_device_list afu_list; /**< List of AFU devices */ }; + +/** + * A structure describing a AFU device.drivers/bus/ifpga/rte_bus_ifpga.h line 81
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +struct rte_afu_device { +TAILQ_ENTRY (rte_afu_device) next;/**< Next in device list. */ +struct rte_device device;/**< Inherit core device */ +struct rte_rawdev *rawdev;/**< Point Rawdev */ +struct rte_ifpga_device *ifpga_dev;/**< Point ifpga device */ +struct rte_afu_id id;/**< AFU id within FPGA. */ +uint32_t num_region;/**< number of regions found */ +struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ]; +/**< AFU Memory Resource */
Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +8
-0+struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_afu_driver *driver;/**< Associated driver */ +char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; +} __attribute__ ((packed)); + +/** +* @internal +* Helper macro for drivers that need to convert to struct
rte_afu_device.Quoted 135 lines
Quoted 4 lines
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +4
-0+*/ +#define RTE_DEV_TO_AFU (ptr) \ + container_of(ptr, struct rte_afu_device, device) +Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 99
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+#define RTE_DRV_TO_AFU_CONST (ptr) \ + container_of(ptr, const struct rte_afu_driver, driver) + +/** +* Initialisation function for the driver called during FPGA BUS probing. typo: Initialization
Fixed.
Quoted 7 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 104
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+*/ +typedef int (afu_probe_t )(struct rte_afu_device *); + +/** +* Uninitialisation function for the driver called during hotplugging. typo: Unintialization
Fixed.
Quoted 10 lines
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +typedef int (afu_remove_t )(struct rte_afu_device *); + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_driver { +TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ +struct rte_driver driver;/**< Inherit core driver. */ +afu_probe_t *probe;/**< Device Probe function. Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 117
Quoted 5 lines
*/
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/rte_bus_ifpga.h new file +2
-0+const struct rte_afu_uuid *id_table;/**< AFU uuid within FPGA. */ +uint32_t drv_flags;/**< Flags contolling handling of device. */ Typo Controlling
And what is "flags controlling handling of device?"This variable is not used, so I have removed it.
Quoted 89 lines
Quoted 85 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +40
-0+}; + +static inline const char * +rte_ifpga_device_name (const struct rte_afu_device *afu) { +if (afu && afu->device.name) +return afu->device.name; +return NULL ; +} + +/** +* Register a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be registered. +*/ +void rte_ifpga_driver_register (struct rte_afu_driver *driver); + +/** +* Unregister a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be unregistered. +*/ +void rte_ifpga_driver_unregister (struct rte_afu_driver *driver); + +#define RTE_PMD_REGISTER_AFU (nm, afudrv)\ RTE_INIT(afudrvinitfn_ +##afudrv);\ static const char *afudrvinit_ ## nm ## _alias;\ +static void afudrvinitfn_ ##afudrv(void)\ {\ + (afudrv).driver.name = RTE_STR(nm);\ + (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\ + rte_ifpga_driver_register(&afudrv);\ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#define RTE_PMD_REGISTER_AFU_ALIAS (nm, alias)\ static const char +*afudrvinit_ ## nm ## _alias = RTE_STR(alias) + +#endif /* _RTE_BUS_IFPGA_H_ */ drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10
-0@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};drivers/bus/meson.build +0
-0@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017Intel Corporation
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'mk/rte.app.mk index 26f3563..3861e1a renamed from mk/rte.app.mk +0
-0100644
mk/rte.app.mk +1
-3@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV --Quoted 1 line
1.8.3.1
Regards
Qi
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
Quoted 522 lines
-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 9:58 PM
To: Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Qi,
Quoted 4 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 21:49
To: Xu, Rosen <[email protected]>; [email protected];Quoted 499 lines
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 15 lines
-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 9:29 PM
To: Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryQuoted 42 lines
Hi Qi,
Quoted 4 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 20:27
To: Xu, Rosen <[email protected]>; [email protected];Quoted 35 lines
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Rosen:
Quoted 22 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Wednesday, May 9, 2018 3:43 PM
To: [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryFrom: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following
patches.
Quoted 43 lines
Quoted 43 lines
Quoted 43 lines
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce
rte_afu_devicewhich describe the AFU device listed in the FPGA-BUS.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode100644
drivers/bus/ifpga/Makefilecreate mode 100644drivers/bus/ifpga/ifpga_bus.ccreate mode 100644drivers/bus/ifpga/ifpga_common.ccreate mode 100644drivers/bus/ifpga/ifpga_common.hcreate mode 100644drivers/bus/ifpga/ifpga_logs.hcreate mode 100644drivers/bus/ifpga/meson.buildcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga.hcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga_version.mapMAINTAINERS index 7105920..fa0c5b1 renamed from MAINTAINERS +0
-0100644
MAINTAINERS +0
-0@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers -----------Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
MAINTAINERS +4
-0+Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]> diff --gita/config/common_base b/config/common_base index
0d181ac..1440316
Quoted 34 lines
Quoted 26 lines
Quoted 26 lines
100644
config/common_base +0
-0@@ -139,6 +139,11 @@
CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n#
config/common_base +5
-0+# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=ydoc/guides/rel_notes/release_18_05.rst +0
-0@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, andalso pdump packets on
those virtual devices.Quoted 6 lines
doc/guides/rel_notes/release_18_05.rst
Quoted 6 lines
doc/guides/rel_notes/release_18_05.rst +6
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any + Intel FPGA device with the DPDK framework. It provides Intel + FPGA Partial Bit Stream AFU(Accelerated Function Unit) scan + and driversprove.
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 7 lines
drivers/bus/Makefile DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
Quoted 7 lines
API Changes
-----------drivers/bus/Makefile index renamed from drivers/bus/Makefile +0
-0c251b65..ef7f247 100644
drivers/bus/Makefile +0
-0@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaaifeq
Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
drivers/bus/Makefile +1
-0($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev(quoted diff) +0
-0b/drivers/bus/ifpga/Makefile new file mode 100644 index 0000000..3ff3bdb
drivers/bus/ifpga/Makefile new file +20
-0@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 +Intel Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += +$(WERROR_FLAGS) LDLIBS += -lrte_eal LDLIBS += -lrte_rawdev +LDLIBS ++= -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/Makefile
Quoted 8 lines
drivers/bus/ifpga/Makefile new file +8
-0+ +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include +=
rte_bus_ifpga.hQuoted 232 lines
Quoted 103 lines
Quoted 103 lines
drivers/bus/ifpga/Makefile new file +2
-0+ +include $(RTE_SDK)/mk/rte.lib.mk(quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_bus.cnew file mode 100644 index 0000000..e144c01drivers/bus/ifpga/ifpga_bus.c new file +95
-0@@ -0,0 +1,501 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int ifpga_bus_logtype; + +/* Forward declaration to access Intel FPGA bus +* on which iFPGA devices are connected */ static struct +rte_bus rte_ifpga_bus; + +/** Double linked list of IFPGA device. */ +TAILQ_HEAD (ifpga_device_list, rte_ifpga_device); + +static struct ifpga_device_list ifpga_device_list = +TAILQ_HEAD_INITIALIZER (ifpga_device_list); +static struct afu_driver_list afu_driver_list = +TAILQ_HEAD_INITIALIZER (afu_driver_list); + + +/* register a ifpga bus based driver */ void +rte_ifpga_driver_register (struct rte_afu_driver *driver) { +RTE_VERIFY (driver); + +TAILQ_INSERT_TAIL (&afu_driver_list, driver, next); } + +/* un-register a fpga bus based driver */ void +rte_ifpga_driver_unregister (struct rte_afu_driver *driver) { +TAILQ_REMOVE (&afu_driver_list, driver, next); } + +static struct rte_ifpga_device *ifpga_find_ifpga_dev (const +struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { +if (rdev && + ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) { +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id)) +return afu_dev; + } +return NULL ; +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +/* +* Scan the content of the FPGA bus, and the devices in the +devices Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 107
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+* list +*/ +static struct rte_afu_device * +ifpga_scan_one (struct rte_devargs *devargs, +struct rte_ifpga_device *ifpga_dev)usually
ifpag_devshould be the first parameter here, and devargs followsFixed.
Quoted 109 lines
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+{ +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_pr_conf afu_pr_conf; +int ret =0 ; +char *path =NULL ; + +memset (&afu_pr_conf,0 ,sizeof (struct rte_afu_pr_conf ));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_PORT , + &rte_ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) <0 ){
Quoted 89 lines
drivers/bus/ifpga/ifpga_bus.c new file +89
-0+IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_PORT ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_AFU_BTS ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_AFU_BTS , + &rte_ifpga_get_string_arg, &path) <0 ) { +IFPGA_BUS_ERR ("Failed to parse %s" , +IFPGA_AFU_BTS ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_AFU_BTS ); + goto end; + } + + afu_pr_conf.afu_id.uuid.uuid_low =0 ; + afu_pr_conf.afu_id.uuid.uuid_high =0 ; + afu_pr_conf.pr_enable = path?1 :0 ; + + rawdev = ifpga_dev->rdev; +if (ifpga_find_afu_dev (ifpga_dev, &afu_pr_conf.afu_id)) + goto end; + + afu_dev =calloc (1 ,sizeof (*afu_dev)); +if (!afu_dev) + goto end; + + afu_dev->device.devargs = devargs; + afu_dev->device.numa_node =SOCKET_ID_ANY ; + afu_dev->device.name = devargs->name; + afu_dev->rawdev = rawdev; + afu_dev->id.uuid.uuid_low =0 ; + afu_dev->id.uuid.uuid_high =0 ; + afu_dev->id.port = afu_pr_conf.afu_id.port; + afu_dev->ifpga_dev = ifpga_dev; + +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) + rawdev->dev_ops->dev_info_get (rawdev, afu_dev); + +if (rawdev->dev_ops && + rawdev->dev_ops->dev_start && + rawdev->dev_ops->dev_start (rawdev)) + goto free_dev; + +strncpy (afu_pr_conf.bs_path, path,sizeof (afu_pr_conf.bs_path)); +if (rawdev->dev_ops->firmware_load && + rawdev->dev_ops->firmware_load (rawdev, + &afu_pr_conf)){ +IFPGA_BUS_ERR ("firmware load error %d\n" , ret); + goto free_dev; + } + afu_dev->id.uuid.uuid_low = afu_pr_conf.afu_id.uuid.uuid_low; + afu_dev->id.uuid.uuid_high = +afu_pr_conf.afu_id.uuid.uuid_high; + +return afu_dev; + +free_dev: +free (afu_dev); +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (path) +free (path); + +return NULL ; +} + +/* +* Scan the content of the FPGA bus, and the devices in the +devices +* list +*/ +static int +ifpga_scan (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +char *name =NULL ;Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+char name1[RTE_RAWDEV_NAME_MAX_LEN ]; +struct rte_afu_device *afu_dev =NULL ; + +/* for FPGA devices we scan the devargs_list populated via +cmdline */ I didn't see "--ifpga" is supported by cmdline, either you need to add corresponding parser or correct the comment here.
Quoted 2 lines
To be honestly,
ifpga_scan()is called by hotplug,lib_rtehotplug function will construct it.OK, after review patch 3, I saw it, that make sense.
Quoted 58 lines
Quoted 57 lines
drivers/bus/ifpga/ifpga_bus.c line 218
Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +1
-0+ RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
IFPGA_BUS_NAMEto replace "ifpga" here.Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +14
-0+if (devargs->bus != &rte_ifpga_bus) +continue ; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &rte_ifpga_get_string_arg, &name) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_NAME );drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +memset (name1,0 ,sizeof (name1)); + snprintf(name1, RTE_RAWDEV_NAME_MAX_LEN,"IFPGA:%s",
Quoted 10 lines
name);
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+ + rawdev =rte_rawdev_pmd_get_named_dev (name1); +if (!rawdev) + goto end; + +if (ifpga_find_ifpga_dev (rawdev)) +continue ; + + ifpga_dev =calloc (1 ,sizeof (*ifpga_dev));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (!ifpga_dev) + goto end; + + ifpga_dev->rdev = rawdev; +TAILQ_INIT (&ifpga_dev->afu_list); + +TAILQ_INSERT_TAIL (&ifpga_device_list, ifpga_dev, next); + afu_dev =ifpga_scan_one (devargs, ifpga_dev); +if (afu_dev !=NULL ) + TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,next);
I don't understand why we need
afu_list?, seems we only add a newafu_devinto the list after create a newifpga_dev, Is there any another place that we add one to list to make it reasonable? it looks like either a 1:1 or 1:0 for ifpga_dev:afu_dev?
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
One FPAG may support more than one AFU.
But in your implementation, it is not possible that an
ifpga_devcontains multipleafu_devAll
afu_devsare listed toifpga_dev, and eachafu_devcan be added and deleted by user.
Could you show me an example, how this happen, what APIs user can add an rte_afu_device to an rte_ifpga_device?
Quoted 159 lines
Quoted 151 lines
Quoted 151 lines
Quoted 150 lines
Quoted 91 lines
drivers/bus/ifpga/ifpga_bus.c new file +89
-0+ } + +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +/* +* Match the AFU Driver and AFU Device using the ID Table */ +static int rte_afu_match (const struct rte_afu_driver *afu_drv, +const struct rte_afu_device *afu_dev) { +const struct rte_afu_uuid *id_table; + +for (id_table = afu_drv->id_table; + ((id_table->uuid_low !=0 ) && (id_table->uuid_high !=0 )); + id_table++) { +/* check if device's identifiers match the driver's ones */ +if ((id_table->uuid_low != afu_dev->id.uuid.uuid_low) || + id_table->uuid_high != + afu_dev->id.uuid.uuid_high) +continue ; + +return 1 ; + } + +return 0 ; +} + +static int +ifpga_probe_one_driver (struct rte_afu_driver *drv, +struct rte_afu_device *afu_dev) { +int ret; + +if (!rte_afu_match (drv, afu_dev)) +/* Match of device and driver failed */ +return 1 ; + +/* reference driver structure */ + afu_dev->driver = drv; + afu_dev->device.driver = &drv->driver; + +/* call the driver probe() function */ + ret = drv->probe (afu_dev); +if (ret) { + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + } + +return ret; +} + +static int +ifpga_probe_all_drivers (struct rte_afu_device *afu_dev) { +struct rte_afu_driver *drv =NULL ; +int ret =0 ; + +if (afu_dev ==NULL ) +return -1 ; + +/* Check if a driver is already loaded */ +if (afu_dev->driver !=NULL ) +return 0 ; + + TAILQ_FOREACH(drv, &afu_driver_list, next) { +if (ifpga_probe_one_driver (drv, afu_dev)) { + ret =-1 ; +break ; + } + } +return ret; +} + +/* +* Scan the content of the Intel FPGA bus, and call the probe() +function for +* all registered drivers that have a matching entry in its +id_table +* for discovered devices. +*/ +static int +ifpga_probe (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev =NULL ; +int ret =0 ;drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { + +if (afu_dev->device.driver) +continue ; + + ret =ifpga_probe_all_drivers (afu_dev); +if (ret <0 ) + IFPGA_BUS_ERR("failed to initialize %sdevice\n",
Quoted 34 lines
drivers/bus/ifpga/ifpga_bus.c new file +34
-0+ rte_ifpga_device_name(afu_dev)); + } + } + +return ret; +} + +static int +ifpga_plug (struct rte_device *dev) { +return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); +} + +static int +ifpga_remove_driver (struct rte_afu_device *afu_dev) { +const char *name; +const struct rte_afu_driver *driver; + + name =rte_ifpga_device_name (afu_dev); +if (!afu_dev->device.driver) { +IFPGA_BUS_DEBUG ("no driver attach to device %s\n" , name); +return 1 ; + } + + driver =RTE_DRV_TO_AFU_CONST (afu_dev->device.driver); +return driver->remove (afu_dev); } + +static int +ifpga_unplug (struct rte_device *dev) { +struct rte_ifpga_device *ifpga_dev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_devargs *devargs =NULL ; +int ret; + +if (dev ==NULL )drivers/bus/ifpga/ifpga_bus.c line 411
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+return -EINVAL ; + + afu_dev =RTE_DEV_TO_AFU (dev); +if (!dev) +return -ENOENT ; + + ifpga_dev = afu_dev->ifpga_dev; + devargs = dev->devargs; + + ret =ifpga_remove_driver (afu_dev);So what is the device type that be plugged into the ifgpa bus?
ifpga_devorafu_dev? If itsafu_dev, why we needifpga_dev? If it isifpga_dev, we need removeifpga_devfromifpga_device_listhere.Quoted 5 lines
Quoted 1 line
The device type that be plugged into the ifpga bus is
afu_dev.In DPDK, we have
rte_pci_devicefor pci bus andrte_vdev_devicefor vdev bus Now we haverte_ifpga_devicenot for ifgpa bus butrte_afu_device, it is a little bit confuse hereThe relationship of this items is descripted in
ifpga_rawdev.rst.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
And each
afu_devwill be added into oneifpga_dev. Each FPGA device bind toifpga_dev.So what is the relationship between
ifpga_devandraw_dev?One FPGA as a PCI device will probe
ifpga_rawdev. For managementafu_dev, we createifpga_devinifpga_bus.
So 1 ifpga_dev map to 1 raw device?
Quoted 496 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
Quoted 51 lines
drivers/bus/ifpga/ifpga_bus.c new file +49
-0+if (ret) +return ret; + +TAILQ_REMOVE (&ifpga_dev->afu_list, afu_dev, next); + +rte_devargs_remove (devargs->bus->name, devargs->name); +free (afu_dev); +return 0 ; + +} + +static struct rte_device * +ifpga_find_device (const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) { +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (start && &afu_dev->device == start) { + start =NULL ; +continue ; + } +if (cmp (&afu_dev->device, data) ==0 ) +return &afu_dev->device; + } + } +return NULL ; +} +static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ; +int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name; + c2 = c1+1 ; + } + +if (str_port_len <8 && + str_port_len >0 ) {Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c
Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c new file +8
-0+memcpy (str_port, name, str_port_len); + ret =sscanf (str_port,"%d" , &port); +if (ret ==-1 ) +return 0 ; + } + +memset (rawdev_name,0 ,sizeof (rawdev_name)); + snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN,"IFPGA:%s",
Quoted 258 lines
Quoted 258 lines
Quoted 258 lines
c2);
Quoted 257 lines
drivers/bus/ifpga/ifpga_bus.c new file +30
-0+ rawdev =rte_rawdev_pmd_get_named_dev (rawdev_name); + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev && + (addr !=NULL )) + *out = port; + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev) +return 0 ; +else +return 1 ; +} + +static struct rte_bus rte_ifpga_bus = { + .scan = ifpga_scan, + .probe = ifpga_probe, + .find_device = ifpga_find_device, + .plug = ifpga_plug, + .unplug = ifpga_unplug, + .parse = ifpga_parse, +}; + +RTE_REGISTER_BUS (IFPGA_BUS_NAME , rte_ifpga_bus); + +RTE_INIT (ifpga_init_log) +{ + ifpga_bus_logtype =rte_log_register ("bus.ifpga" ); +if (ifpga_bus_logtype >=0 ) +rte_log_set_level (ifpga_bus_logtype,RTE_LOG_NOTICE ); }drivers/bus/ifpga/ifpga_common.c new file +82
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(int *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_unsigned_long (const char *str,int base) { +unsigned long num; +char *end =NULL ; + + errno =0 ; + + num =strtoul (str, &end, base); +if ((str[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ) || (errno !=0 )) +return -1 ; + +return num; +} + +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1) { +if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && + (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && + (afu_id0->port == afu_id1->port)) { +return 0 ; + }else +return 1 ; +}drivers/bus/ifpga/ifpga_common.h new file +17
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_unsigned_long (const char *str,int base);int +ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */ (quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_logs.hnew file mode 100644 index 0000000..873e0a4drivers/bus/ifpga/ifpga_logs.h new file +30
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) #define IFPGA_BUS_INFO(fmt, +args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) #define IFPGA_BUS_ERR(fmt, +args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) #define IFPGA_BUS_WARN(fmt, +args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */ (quoted diff) +0
-0b/drivers/bus/ifpga/meson.build new file mode 100644 index 0000000..c9b08c8
drivers/bus/ifpga/meson.build new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) +2010-2018 Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = truedrivers/bus/ifpga/rte_bus_ifpga.h new file +57
-0@@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _RTE_BUS_IFPGA_H_ +#define _RTE_BUS_IFPGA_H_ + +/** + * @file + * + * RTE Intel FPGA Bus Interface */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_bus.h> +#include <rte_pci.h> + +/** Name of Intel FPGA Bus */ +#define IFPGA_BUS_NAME ifpga + +/* Forward declarations */ +struct rte_afu_device; + +/** List of Intel AFU devices */ TAILQ_HEAD(afu_device_list, +rte_afu_device); +/** Double linked list of AFU device drivers. */ +TAILQ_HEAD(afu_driver_list, rte_afu_driver); + +#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256 + +struct rte_afu_uuid { + uint64_t uuid_low; + uint64_t uuid_high; +} __attribute__ ((packed)); + +#define IFPGA_BUS_DEV_PORT_MAX 4 + +/** + * A structure describing an ID for a AFU driver. Each driver +provides a + * table of these IDs for each device that it supports. + */ +struct rte_afu_id { + struct rte_afu_uuid uuid; + int port; /**< port number */ +} __attribute__ ((packed)); + +/** + * A structure PR (Partial Reconfiguration) configuration AFU driver. + */ + +struct rte_afu_pr_conf { + struct rte_afu_id afu_id; + int pr_enable; + char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +};Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +8
-0+ +#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8) + +/** +* A structure describing a fpga device. +*/ +struct rte_ifpga_device { +TAILQ_ENTRY (rte_ifpga_device) next;/**< Next in device list. */
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 9 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +9
-0+struct rte_rawdev *rdev; +struct afu_device_list afu_list;/**< List of AFU devices */ +}; + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_device { +TAILQ_ENTRY (rte_afu_device) next;/**< Next in device list. */
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +4
-0+struct rte_device device;/**< Inherit core device */ +struct rte_rawdev *rawdev;/**< Point Rawdev */ +struct rte_ifpga_device *ifpga_dev;/**< Point ifpga device */ +struct rte_afu_id id;/**< AFU id within FPGA. */
Quoted 38 lines
Quoted 4 lines
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 3 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +3
-0+uint32_t num_region;/**< number of regions found */ +struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ]; +/**< AFU Memory Resource */
Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +8
-0+struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_afu_driver *driver;/**< Associated driver */ +char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; +} __attribute__ ((packed)); + +/** +* @internal +* Helper macro for drivers that need to convert to struct
rte_afu_device.Quoted 25 lines
Quoted 4 lines
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +4
-0+*/ +#define RTE_DEV_TO_AFU (ptr) \ + container_of(ptr, struct rte_afu_device, device) +Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 99
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+#define RTE_DRV_TO_AFU_CONST (ptr) \ + container_of(ptr, const struct rte_afu_driver, driver) + +/** +* Initialisation function for the driver called during FPGA BUS probing. typo: Initialization
Fixed.
Quoted 7 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 104
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+*/ +typedef int (afu_probe_t )(struct rte_afu_device *); + +/** +* Uninitialisation function for the driver called during hotplugging. typo: Unintialization
Fixed.
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +typedef int (afu_remove_t )(struct rte_afu_device *); + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_driver { +TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ +struct rte_driver driver;/**< Inherit core driver. */ +afu_probe_t *probe;/**< Device Probe function.
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 4 lines
*/
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+const struct rte_afu_uuid *id_table;/**< AFU uuid within FPGA. */
Quoted 1 line
Quoted 1 line
Quoted 1 line
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 1 line
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+uint32_t drv_flags;/**< Flags contolling handling of device. */
Quoted 29 lines
Quoted 29 lines
Quoted 3 lines
Typo Controlling
And what is "flags controlling handling of device?"This variable is not used, so I have removed it.
Quoted 23 lines
Quoted 23 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +23
-0+}; + +static inline const char * +rte_ifpga_device_name (const struct rte_afu_device *afu) { +if (afu && afu->device.name) +return afu->device.name; +return NULL ; +} + +/** +* Register a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be registered. +*/ +void rte_ifpga_driver_register (struct rte_afu_driver *driver); + +/** +* Unregister a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h
Quoted 8 lines
+ * to be unregistered.
+ */drivers/bus/ifpga/rte_bus_ifpga.h new file +6
-0+void rte_ifpga_driver_unregister (struct rte_afu_driver +*driver); + +#define RTE_PMD_REGISTER_AFU (nm, afudrv)\ +RTE_INIT(afudrvinitfn_ ##afudrv);\ static const char +*afudrvinit_ ## nm ## _alias;\ static void afudrvinitfn_ ##afudrv(void)\{\
Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
Quoted 56 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+ (afudrv).driver.name =RTE_STR (nm);\ + (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\ + rte_ifpga_driver_register(&afudrv);\ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#define RTE_PMD_REGISTER_AFU_ALIAS (nm, alias)\ static const +char *afudrvinit_ ## nm ## _alias = RTE_STR(alias) + +#endif /* _RTE_BUS_IFPGA_H_ */ drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10
-0@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};drivers/bus/meson.build +0
-0@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017Intel Corporation
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'mk/rte.app.mk index renamed from mk/rte.app.mk +0
-026f3563..3861e1a
100644mk/rte.app.mk +1
-3@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV --Quoted 1 line
1.8.3.1
Regards
Qi
Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library
In reply to Xu, RosenHi Qi,
I miss one comment, so I fix it in this email.
Quoted 416 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Thursday, May 10, 2018 21:29
To: Zhang, Qi Z <[email protected]>; [email protected]; [email protected]
Cc: Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Qi,
Quoted 4 lines
-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 20:27
To: Xu, Rosen <[email protected]>; [email protected];Quoted 109 lines
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryHi Rosen:
Quoted 97 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Wednesday, May 9, 2018 3:43 PM
To: [email protected]; [email protected]
Cc: Xu, Rosen <[email protected]>; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: [dpdk-dev] [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS LibraryFrom: Rosen Xu <[email protected]>
Defined FPGA-BUS for Acceleration Drivers of AFUs
1. FPGA PCI Scan (1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver, it will be covered in following patches.
2. AFU Scan(2nd Scan) bind DPDK driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their drivers are also probed.
This patch will introduce
rte_afu_devicewhich describe the AFU device listed in the FPGA-BUS.Signed-off-by Rosen Xu <[email protected]>Signed-off-by Tianfei Zhang <[email protected]>--- MAINTAINERS | 4 + config/common_base | 5 + doc/guides/rel_notes/release_18_05.rst | 5 + drivers/bus/Makefile | 1 + drivers/bus/ifpga/Makefile | 32 ++ drivers/bus/ifpga/ifpga_bus.c | 501 ++++++++++++++++++++++++++++ drivers/bus/ifpga/ifpga_common.c | 88 +++++ drivers/bus/ifpga/ifpga_common.h | 18 + drivers/bus/ifpga/ifpga_logs.h | 31 ++ drivers/bus/ifpga/meson.build | 8 + drivers/bus/ifpga/rte_bus_ifpga.h | 160 +++++++++ drivers/bus/ifpga/rte_bus_ifpga_version.map | 10 + drivers/bus/meson.build | 2 +- mk/rte.app.mk | 1 + 14 files changed, 865 insertions(+), 1 deletion(-) create mode100644
drivers/bus/ifpga/Makefilecreate mode 100644drivers/bus/ifpga/ifpga_bus.ccreate mode 100644drivers/bus/ifpga/ifpga_common.ccreate mode 100644drivers/bus/ifpga/ifpga_common.hcreate mode 100644drivers/bus/ifpga/ifpga_logs.hcreate mode 100644drivers/bus/ifpga/meson.buildcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga.hcreate mode 100644drivers/bus/ifpga/rte_bus_ifpga_version.mapMAINTAINERS +4
-0@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/ Bus Drivers ----------- +Intel FPGA buses +M: Rosen Xu <[email protected]> +F: drivers/bus/ifpga/ + NXP buses M: Hemant Agrawal <[email protected]> M: Shreyansh Jain <[email protected]> diff --gita/config/common_base b/config/common_base index 0d181ac..1440316 100644
config/common_base +0
-0@@ -139,6 +139,11 @@
CONFIG_RTE_ETHDEV_PROFILE_ITT_WASTED_RX_ITERATIONS=n
CONFIG_RTE_ETHDEV_TX_PREPARE_NOOP=n#
config/common_base +5
-0+# Compile the Intel FPGA bus +# +CONFIG_RTE_LIBRTE_IFPGA_BUS=y + +# # Compile PCI bus driver # CONFIG_RTE_LIBRTE_PCI_BUS=ydoc/guides/rel_notes/release_18_05.rst +0
-0@@ -183,6 +183,11 @@ New Features stats/xstats on shared memory from secondary process, and alsopdump packets on
those virtual devices.Quoted 5 lines
doc/guides/rel_notes/release_18_05.rst
Quoted 5 lines
doc/guides/rel_notes/release_18_05.rst +5
-0+* **Added Ifpga Bus, a generic Intel FPGA Bus library.** + + The Ifpga Bus library provides support for integrating any Intel + FPGA device with the DPDK framework. It provides Intel FPGA + Partial Bit Stream AFU(Accelerated Function Unit) scan and driversprove.
Quoted 152 lines
Quoted 152 lines
API Changes
-----------drivers/bus/Makefile index renamed from drivers/bus/Makefile +0
-0c251b65..ef7f247 100644
drivers/bus/Makefile +1
-0@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa ifeq ($(CONFIG_RTE_EAL_VFIO),y) DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc endif +DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdevdrivers/bus/ifpga/Makefile new file +32
-0@@ -0,0 +1,32 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel +Corporation + +include $(RTE_SDK)/mk/rte.vars.mk + +# +# library name +# +LIB = librte_bus_ifpga.a + +CFLAGS += -DALLOW_EXPERIMENTAL_API +CFLAGS += -O3 +CFLAGS += $(WERROR_FLAGS) +LDLIBS += -lrte_eal +LDLIBS += -lrte_rawdev +LDLIBS += -lrte_kvargs + +# versioning export map +EXPORT_MAP := rte_bus_ifpga_version.map + +# library version +LIBABIVER := 1 + +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_bus.c +SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga_common.c + +# +# Export include files +# +SYMLINK-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)-include += rte_bus_ifpga.h + +include $(RTE_SDK)/mk/rte.lib.mk(quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_bus.cnew file mode 100644 index 0000000..e144c01drivers/bus/ifpga/ifpga_bus.c new file +95
-0@@ -0,0 +1,501 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_rawdev.h" +#include "rte_rawdev_pmd.h" +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int ifpga_bus_logtype; + +/* Forward declaration to access Intel FPGA bus +* on which iFPGA devices are connected */ static struct rte_bus +rte_ifpga_bus; + +/** Double linked list of IFPGA device. */ +TAILQ_HEAD (ifpga_device_list, rte_ifpga_device); + +static struct ifpga_device_list ifpga_device_list = +TAILQ_HEAD_INITIALIZER (ifpga_device_list); +static struct afu_driver_list afu_driver_list = +TAILQ_HEAD_INITIALIZER (afu_driver_list); + + +/* register a ifpga bus based driver */ void +rte_ifpga_driver_register (struct rte_afu_driver *driver) { +RTE_VERIFY (driver); + +TAILQ_INSERT_TAIL (&afu_driver_list, driver, next); } + +/* un-register a fpga bus based driver */ void +rte_ifpga_driver_unregister (struct rte_afu_driver *driver) { +TAILQ_REMOVE (&afu_driver_list, driver, next); } + +static struct rte_ifpga_device * +ifpga_find_ifpga_dev (const struct rte_rawdev *rdev) { +struct rte_ifpga_device *ifpga_dev =NULL ; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { +if (rdev && + ifpga_dev->rdev && + ifpga_dev->rdev == rdev) +return ifpga_dev; + } +return NULL ; +} + +static struct rte_afu_device * +ifpga_find_afu_dev (const struct rte_ifpga_device *ifpga_dev, +const struct rte_afu_id *afu_id) +{ +struct rte_afu_device *afu_dev =NULL ; + + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (!ifpga_afu_id_cmp (&afu_dev->id, afu_id)) +return afu_dev; + } +return NULL ; +} + +static const char *const valid_args[] = { +#define IFPGA_ARG_NAME "ifpga" +IFPGA_ARG_NAME , +#define IFPGA_ARG_PORT "port" +IFPGA_ARG_PORT , +#define IFPGA_AFU_BTS "afu_bts" +IFPGA_AFU_BTS , +NULL +}; + +/* +* Scan the content of the FPGA bus, and the devices in the devices Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 107
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+* list +*/ +static struct rte_afu_device * +ifpga_scan_one (struct rte_devargs *devargs, +struct rte_ifpga_device *ifpga_dev)usually
ifpag_devshould be the first parameter here, and devargs followsFixed.
Quoted 107 lines
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+{ +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_afu_pr_conf afu_pr_conf; +int ret =0 ; +char *path =NULL ; + +memset (&afu_pr_conf,0 ,sizeof (struct rte_afu_pr_conf ));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_PORT ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_PORT , + &rte_ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) <0 ){
Quoted 87 lines
drivers/bus/ifpga/ifpga_bus.c new file +87
-0+IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_PORT ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_PORT ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_AFU_BTS ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_AFU_BTS , + &rte_ifpga_get_string_arg, &path) <0 ) { +IFPGA_BUS_ERR ("Failed to parse %s" , +IFPGA_AFU_BTS ); + goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_AFU_BTS ); + goto end; + } + + afu_pr_conf.afu_id.uuid.uuid_low =0 ; + afu_pr_conf.afu_id.uuid.uuid_high =0 ; + afu_pr_conf.pr_enable = path?1 :0 ; + + rawdev = ifpga_dev->rdev; +if (ifpga_find_afu_dev (ifpga_dev, &afu_pr_conf.afu_id)) + goto end; + + afu_dev =calloc (1 ,sizeof (*afu_dev)); +if (!afu_dev) + goto end; + + afu_dev->device.devargs = devargs; + afu_dev->device.numa_node =SOCKET_ID_ANY ; + afu_dev->device.name = devargs->name; + afu_dev->rawdev = rawdev; + afu_dev->id.uuid.uuid_low =0 ; + afu_dev->id.uuid.uuid_high =0 ; + afu_dev->id.port = afu_pr_conf.afu_id.port; + afu_dev->ifpga_dev = ifpga_dev; + +if (rawdev->dev_ops && rawdev->dev_ops->dev_info_get) + rawdev->dev_ops->dev_info_get (rawdev, afu_dev); + +if (rawdev->dev_ops && + rawdev->dev_ops->dev_start && + rawdev->dev_ops->dev_start (rawdev)) + goto free_dev; + +strncpy (afu_pr_conf.bs_path, path,sizeof (afu_pr_conf.bs_path)); +if (rawdev->dev_ops->firmware_load && + rawdev->dev_ops->firmware_load (rawdev, + &afu_pr_conf)){ +IFPGA_BUS_ERR ("firmware load error %d\n" , ret); + goto free_dev; + } + afu_dev->id.uuid.uuid_low = afu_pr_conf.afu_id.uuid.uuid_low; + afu_dev->id.uuid.uuid_high = afu_pr_conf.afu_id.uuid.uuid_high; + +return afu_dev; + +free_dev: +free (afu_dev); +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (path) +free (path); + +return NULL ; +} + +/* +* Scan the content of the FPGA bus, and the devices in the devices +* list +*/ +static int +ifpga_scan (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_devargs *devargs; +struct rte_kvargs *kvlist =NULL ; +struct rte_rawdev *rawdev =NULL ; +char *name =NULL ;Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 275
Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5
-0+char name1[RTE_RAWDEV_NAME_MAX_LEN ]; +struct rte_afu_device *afu_dev =NULL ; + +/* for FPGA devices we scan the devargs_list populated via cmdline +*/ I didn't see "--ifpga" is supported by cmdline, either you need to add corresponding parser or correct the comment here.
Quoted 7 lines
To be honestly,
ifpga_scan()is called by hotplug,lib_rtehotplug function will construct it.Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c line 218
Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1
-0+ RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
IFPGA_BUS_NAMEto replace "ifpga" here.
IFPGA_BUS_NAME is used in some Macros, so I use IFPGA_ARG_NAME.
Quoted 694 lines
Quoted 47 lines
Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +14
-0+if (devargs->bus != &rte_ifpga_bus) +continue ; + + kvlist =rte_kvargs_parse (devargs->args, valid_args); +if (!kvlist) { +IFPGA_BUS_ERR ("error when parsing param" ); + goto end; + } + +if (rte_kvargs_count (kvlist,IFPGA_ARG_NAME ) ==1 ) { +if (rte_kvargs_process (kvlist,IFPGA_ARG_NAME , + &rte_ifpga_get_string_arg, &name) <0 ) { +IFPGA_BUS_ERR ("error to parse %s" , +IFPGA_ARG_NAME );drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ goto end; + } + }else { +IFPGA_BUS_ERR ("arg %s is mandatory for ifpga bus" , +IFPGA_ARG_NAME ); + goto end; + } + +memset (name1,0 ,sizeof (name1)); + snprintf(name1, RTE_RAWDEV_NAME_MAX_LEN,"IFPGA:%s",
Quoted 10 lines
name);
drivers/bus/ifpga/ifpga_bus.c new file +9
-0+ + rawdev =rte_rawdev_pmd_get_named_dev (name1); +if (!rawdev) + goto end; + +if (ifpga_find_ifpga_dev (rawdev)) +continue ; + + ifpga_dev =calloc (1 ,sizeof (*ifpga_dev));drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (!ifpga_dev) + goto end; + + ifpga_dev->rdev = rawdev; +TAILQ_INIT (&ifpga_dev->afu_list); + +TAILQ_INSERT_TAIL (&ifpga_device_list, ifpga_dev, next); + afu_dev =ifpga_scan_one (devargs, ifpga_dev); +if (afu_dev !=NULL ) + TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,next);
Quoted 4 lines
I don't understand why we need
afu_list?, seems we only add a newafu_devinto the list after create a newifpga_dev, Is there any another place that we add one to list to make it reasonable? it looks like either a 1:1 or 1:0 for ifpga_dev:afu_dev?One FPAG may support more than one AFU.
Quoted 143 lines
Quoted 90 lines
drivers/bus/ifpga/ifpga_bus.c new file +90
-0+ } + +end: +if (kvlist) +rte_kvargs_free (kvlist); +if (name) +free (name); + +return 0 ; +} + +/* +* Match the AFU Driver and AFU Device using the ID Table */ +static int rte_afu_match (const struct rte_afu_driver *afu_drv, +const struct rte_afu_device *afu_dev) { +const struct rte_afu_uuid *id_table; + +for (id_table = afu_drv->id_table; + ((id_table->uuid_low !=0 ) && (id_table->uuid_high !=0 )); + id_table++) { +/* check if device's identifiers match the driver's ones */ +if ((id_table->uuid_low != afu_dev->id.uuid.uuid_low) || + id_table->uuid_high != + afu_dev->id.uuid.uuid_high) +continue ; + +return 1 ; + } + +return 0 ; +} + +static int +ifpga_probe_one_driver (struct rte_afu_driver *drv, +struct rte_afu_device *afu_dev) +{ +int ret; + +if (!rte_afu_match (drv, afu_dev)) +/* Match of device and driver failed */ +return 1 ; + +/* reference driver structure */ + afu_dev->driver = drv; + afu_dev->device.driver = &drv->driver; + +/* call the driver probe() function */ + ret = drv->probe (afu_dev); +if (ret) { + afu_dev->driver =NULL ; + afu_dev->device.driver =NULL ; + } + +return ret; +} + +static int +ifpga_probe_all_drivers (struct rte_afu_device *afu_dev) { +struct rte_afu_driver *drv =NULL ; +int ret =0 ; + +if (afu_dev ==NULL ) +return -1 ; + +/* Check if a driver is already loaded */ +if (afu_dev->driver !=NULL ) +return 0 ; + + TAILQ_FOREACH(drv, &afu_driver_list, next) { +if (ifpga_probe_one_driver (drv, afu_dev)) { + ret =-1 ; +break ; + } + } +return ret; +} + +/* +* Scan the content of the Intel FPGA bus, and call the probe() +function for +* all registered drivers that have a matching entry in its +id_table +* for discovered devices. +*/ +static int +ifpga_probe (void ) +{ +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev =NULL ; +int ret =0 ;drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+ + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { + +if (afu_dev->device.driver) +continue ; + + ret =ifpga_probe_all_drivers (afu_dev); +if (ret <0 ) + IFPGA_BUS_ERR("failed to initialize %sdevice\n",
Quoted 42 lines
drivers/bus/ifpga/ifpga_bus.c new file +42
-0+ rte_ifpga_device_name(afu_dev)); + } + } + +return ret; +} + +static int +ifpga_plug (struct rte_device *dev) +{ +return ifpga_probe_all_drivers (RTE_DEV_TO_AFU (dev)); +} + +static int +ifpga_remove_driver (struct rte_afu_device *afu_dev) { +const char *name; +const struct rte_afu_driver *driver; + + name =rte_ifpga_device_name (afu_dev); +if (!afu_dev->device.driver) { +IFPGA_BUS_DEBUG ("no driver attach to device %s\n" , name); +return 1 ; + } + + driver =RTE_DRV_TO_AFU_CONST (afu_dev->device.driver); +return driver->remove (afu_dev); +} + +static int +ifpga_unplug (struct rte_device *dev) { +struct rte_ifpga_device *ifpga_dev =NULL ; +struct rte_afu_device *afu_dev =NULL ; +struct rte_devargs *devargs =NULL ; +int ret; + +if (dev ==NULL ) +return -EINVAL ; + + afu_dev =RTE_DEV_TO_AFU (dev); +if (!dev) +return -ENOENT ; +Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c line 411
Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4
-0+ ifpga_dev = afu_dev->ifpga_dev; + devargs = dev->devargs; + + ret =ifpga_remove_driver (afu_dev);So what is the device type that be plugged into the ifgpa bus?
ifpga_devorafu_dev? If itsafu_dev, why we needifpga_dev? If it isifpga_dev, we need removeifpga_devfromifpga_device_listhere.The device type that be plugged into the ifpga bus is
afu_dev. And eachafu_devwill be added into oneifpga_dev. Each FPGA device bind toifpga_dev.Quoted 353 lines
Quoted 47 lines
drivers/bus/ifpga/ifpga_bus.c new file +47
-0+if (ret) +return ret; + +TAILQ_REMOVE (&ifpga_dev->afu_list, afu_dev, next); + +rte_devargs_remove (devargs->bus->name, devargs->name); +free (afu_dev); +return 0 ; + +} + +static struct rte_device * +ifpga_find_device (const struct rte_device *start, +rte_dev_cmp_t cmp,const void *data) { +struct rte_ifpga_device *ifpga_dev; +struct rte_afu_device *afu_dev; + + TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) { + TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) { +if (start && &afu_dev->device == start) { + start =NULL ; +continue ; + } +if (cmp (&afu_dev->device, data) ==0 ) +return &afu_dev->device; + } + } +return NULL ; +} +static int +ifpga_parse (const char *name,void *addr) { +int *out = addr; +struct rte_rawdev *rawdev =NULL ; +char rawdev_name[RTE_RAWDEV_NAME_MAX_LEN ]; +char *c1 =NULL , *c2 =NULL ; +int port =IFPGA_BUS_DEV_PORT_MAX ; +char str_port[8 ]; +int str_port_len =0 ; +int ret; + +memset (str_port,0 ,8 ); + c1 =strchr (name,'|' ); +if (c1 !=NULL ) { + str_port_len = c1-name; + c2 = c1+1 ; + } +drivers/bus/ifpga/ifpga_bus.c
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10
-0+if (str_port_len <8 && + str_port_len >0 ) { +memcpy (str_port, name, str_port_len); + ret =sscanf (str_port,"%d" , &port); +if (ret ==-1 ) +return 0 ; + } + +memset (rawdev_name,0 ,sizeof (rawdev_name)); + snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s",c2);
Quoted 272 lines
drivers/bus/ifpga/ifpga_bus.c new file +30
-0+ rawdev =rte_rawdev_pmd_get_named_dev (rawdev_name); + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev && + (addr !=NULL )) + *out = port; + +if ((port <IFPGA_BUS_DEV_PORT_MAX ) && + rawdev) +return 0 ; +else +return 1 ; +} + +static struct rte_bus rte_ifpga_bus = { + .scan = ifpga_scan, + .probe = ifpga_probe, + .find_device = ifpga_find_device, + .plug = ifpga_plug, + .unplug = ifpga_unplug, + .parse = ifpga_parse, +}; + +RTE_REGISTER_BUS (IFPGA_BUS_NAME , rte_ifpga_bus); + +RTE_INIT (ifpga_init_log) +{ + ifpga_bus_logtype =rte_log_register ("bus.ifpga" ); +if (ifpga_bus_logtype >=0 ) +rte_log_set_level (ifpga_bus_logtype,RTE_LOG_NOTICE ); }drivers/bus/ifpga/ifpga_common.c new file +83
-0@@ -0,0 +1,88 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#include <string.h> +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include <sys/queue.h> +#include <sys/mman.h> +#include <sys/types.h> +#include <unistd.h> +#include <fcntl.h> + +#include <rte_errno.h> +#include <rte_bus.h> +#include <rte_per_lcore.h> +#include <rte_memory.h> +#include <rte_memzone.h> +#include <rte_eal.h> +#include <rte_common.h> + +#include <rte_devargs.h> +#include <rte_kvargs.h> +#include <rte_alarm.h> + +#include "rte_bus_ifpga.h" +#include "ifpga_logs.h" +#include "ifpga_common.h" + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(char **)extra_args =strdup (value); + +if (!*(char **)extra_args) +return -ENOMEM ; + +return 0 ; +} +int rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(int *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args) { +if (!value || !extra_args) +return -EINVAL ; + + *(uint64_t *)extra_args =strtoull (value,NULL ,0 ); + +return 0 ; +} +int ifpga_get_unsigned_long (const char *str,int base) { +unsigned long num; +char *end =NULL ; + + errno =0 ; + + num =strtoul (str, &end, base); +if ((str[0 ] =='\0' ) || (end ==NULL ) || (*end !='\0' ) || (errno !=0 )) +return -1 ; + +return num; +} + +int ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1) +{ +if ((afu_id0->uuid.uuid_low == afu_id1->uuid.uuid_low) && + (afu_id0->uuid.uuid_high == afu_id1->uuid.uuid_high) && + (afu_id0->port == afu_id1->port)) { +return 0 ; + }else +return 1 ; +}drivers/bus/ifpga/ifpga_common.h new file +17
-0@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_COMMON_H_ +#define _IFPGA_COMMON_H_ + +int rte_ifpga_get_string_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +rte_ifpga_get_integer32_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_integer64_arg(const char *key __rte_unused, +const char *value,void *extra_args);int +ifpga_get_unsigned_long (const char *str,int base);int +ifpga_afu_id_cmp (const struct rte_afu_id *afu_id0, +const struct rte_afu_id *afu_id1); + +#endif /* _IFPGA_COMMON_H_ */ (quoted diff) +0
-0
b/drivers/bus/ifpga/ifpga_logs.hnew file mode 100644 index 0000000..873e0a4drivers/bus/ifpga/ifpga_logs.h new file +30
-0@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _IFPGA_LOGS_H_ +#define _IFPGA_LOGS_H_ + +#include <rte_log.h> + +extern int ifpga_bus_logtype; + +#define IFPGA_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_LOG(level, fmt, args...) \ + rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \ + __func__, ##args) + +#define IFPGA_BUS_FUNC_TRACE () IFPGA_BUS_LOG(DEBUG, ">>") + +#define IFPGA_BUS_DEBUG(fmt, args...) \ + IFPGA_BUS_LOG(DEBUG, fmt, ## args) #define IFPGA_BUS_INFO(fmt, +args...) \ + IFPGA_BUS_LOG(INFO, fmt, ## args) +#define IFPGA_BUS_ERR(fmt, args...) \ + IFPGA_BUS_LOG(ERR, fmt, ## args) +#define IFPGA_BUS_WARN(fmt, args...) \ + IFPGA_BUS_LOG(WARNING, fmt, ## args) + +#endif /* _IFPGA_BUS_LOGS_H_ */ (quoted diff) +0
-0b/drivers/bus/ifpga/meson.build new file mode 100644 index 0000000..c9b08c8
drivers/bus/ifpga/meson.build new file +8
-0@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2010-2018 +Intel Corporation + +deps += ['pci', 'kvargs', 'rawdev'] +install_headers('rte_bus_ifpga.h') +sources = files('ifpga_common.c', 'ifpga_bus.c') + +allow_experimental_apis = truedrivers/bus/ifpga/rte_bus_ifpga.h new file +71
-0@@ -0,0 +1,160 @@ +/* SPDX-License-Identifier: BSD-3-Clause +* Copyright(c) 2010-2018 Intel Corporation */ + +#ifndef _RTE_BUS_IFPGA_H_ +#define _RTE_BUS_IFPGA_H_ + +/** + * @file + * + * RTE Intel FPGA Bus Interface + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <rte_bus.h> +#include <rte_pci.h> + +/** Name of Intel FPGA Bus */ +#define IFPGA_BUS_NAME ifpga + +/* Forward declarations */ +struct rte_afu_device; + +/** List of Intel AFU devices */ +TAILQ_HEAD(afu_device_list, rte_afu_device); +/** Double linked list of AFU device drivers. */ +TAILQ_HEAD(afu_driver_list, rte_afu_driver); + +#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256 + +struct rte_afu_uuid { + uint64_t uuid_low; + uint64_t uuid_high; +} __attribute__ ((packed)); + +#define IFPGA_BUS_DEV_PORT_MAX 4 + +/** + * A structure describing an ID for a AFU driver. Each driver +provides a + * table of these IDs for each device that it supports. + */ +struct rte_afu_id { + struct rte_afu_uuid uuid; + int port; /**< port number */ +} __attribute__ ((packed)); + +/** + * A structure PR (Partial Reconfiguration) configuration AFU driver. + */ + +struct rte_afu_pr_conf { + struct rte_afu_id afu_id; + int pr_enable; + char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN]; +}; + +#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8) + +/** + * A structure describing a fpga device. + */ +struct rte_ifpga_device { + TAILQ_ENTRY(rte_ifpga_device) next; /**< Next in device list. */ + struct rte_rawdev *rdev; + struct afu_device_list afu_list; /**< List of AFU devices */ }; + +/** + * A structure describing a AFU device.drivers/bus/ifpga/rte_bus_ifpga.h line 81
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +struct rte_afu_device { +TAILQ_ENTRY (rte_afu_device) next;/**< Next in device list. */ +struct rte_device device;/**< Inherit core device */ +struct rte_rawdev *rawdev;/**< Point Rawdev */ +struct rte_ifpga_device *ifpga_dev;/**< Point ifpga device */ +struct rte_afu_id id;/**< AFU id within FPGA. */ +uint32_t num_region;/**< number of regions found */ +struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE ]; +/**< AFU Memory Resource */
Quoted 12 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +12
-0+struct rte_intr_handle intr_handle;/**< Interrupt handle */ +struct rte_afu_driver *driver;/**< Associated driver */ +char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN ]; +} __attribute__ ((packed)); + +/** +* @internal +* Helper macro for drivers that need to convert to struct rte_afu_device. +*/ +#define RTE_DEV_TO_AFU (ptr) \ + container_of(ptr, struct rte_afu_device, device) +Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 99
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+#define RTE_DRV_TO_AFU_CONST (ptr) \ + container_of(ptr, const struct rte_afu_driver, driver) + +/** +* Initialisation function for the driver called during FPGA BUS probing. typo: Initialization
Fixed.
Quoted 7 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 104
Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5
-0+*/ +typedef int (afu_probe_t )(struct rte_afu_device *); + +/** +* Uninitialisation function for the driver called during hotplugging. typo: Unintialization
Fixed.
Quoted 10 lines
Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10
-0+*/ +typedef int (afu_remove_t )(struct rte_afu_device *); + +/** +* A structure describing a AFU device. +*/ +struct rte_afu_driver { +TAILQ_ENTRY (rte_afu_driver) next;/**< Next afu driver. */ +struct rte_driver driver;/**< Inherit core driver. */ +afu_probe_t *probe;/**< Device Probe function. Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h line 117
Quoted 5 lines
*/
drivers/bus/ifpga/rte_bus_ifpga.h new file +1
-0+afu_remove_t *remove;/**< Device Remove function. */
drivers/bus/ifpga/rte_bus_ifpga.h new file +2
-0+const struct rte_afu_uuid *id_table;/**< AFU uuid within FPGA. */ +uint32_t drv_flags;/**< Flags contolling handling of device. */ Typo Controlling
And what is "flags controlling handling of device?"This variable is not used, so I have removed it.
Quoted 89 lines
Quoted 85 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +40
-0+}; + +static inline const char * +rte_ifpga_device_name (const struct rte_afu_device *afu) { +if (afu && afu->device.name) +return afu->device.name; +return NULL ; +} + +/** +* Register a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be registered. +*/ +void rte_ifpga_driver_register (struct rte_afu_driver *driver); + +/** +* Unregister a ifpga afu device driver. +* +* @param driver +* A pointer to a rte_afu_driver structure describing the driver +* to be unregistered. +*/ +void rte_ifpga_driver_unregister (struct rte_afu_driver *driver); + +#define RTE_PMD_REGISTER_AFU (nm, afudrv)\ RTE_INIT(afudrvinitfn_ +##afudrv);\ static const char *afudrvinit_ ## nm ## _alias;\ static +void afudrvinitfn_ ##afudrv(void)\ {\ + (afudrv).driver.name = RTE_STR(nm);\ + (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\ + rte_ifpga_driver_register(&afudrv);\ +} \ +RTE_PMD_EXPORT_NAME(nm, __COUNTER__) + +#define RTE_PMD_REGISTER_AFU_ALIAS (nm, alias)\ static const char +*afudrvinit_ ## nm ## _alias = RTE_STR(alias) + +#endif /* _RTE_BUS_IFPGA_H_ */ drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10
-0@@ -0,0 +1,10 @@ +DPDK_18.05 { + global: + + rte_ifpga_get_integer32_arg; + rte_ifpga_get_string_arg; + rte_ifpga_driver_register; + rte_ifpga_driver_unregister; + + local: *; +};drivers/bus/meson.build index renamed from drivers/bus/meson.build +0
-058dfbe2..52c755d 100644
drivers/bus/meson.build +0
-0@@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 IntelCorporation
drivers/bus/meson.build +1
-1-drivers = ['dpaa', 'fslmc', 'pci', 'vdev'] +drivers = ['dpaa', 'fslmc', 'ifpga', 'pci', 'vdev'] std_deps = ['eal'] config_flag_fmt = 'RTE_LIBRTE_@0@_BUS' driver_name_fmt = 'rte_bus_@0@'mk/rte.app.mk index 26f3563..3861e1a renamed from mk/rte.app.mk +0
-0100644
mk/rte.app.mk +1
-3@@ -255,6 +255,7 @@ ifeq ($(CONFIG_RTE_EAL_VFIO)$(CONFIG_RTE_LIBRTE_FSLMC_BUS),yy) _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) += -lrte_pmd_dpaa2_cmdif _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) += -lrte_pmd_dpaa2_qdma endif # CONFIG_RTE_LIBRTE_FSLMC_BUS +_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += -lrte_bus_ifpga endif # CONFIG_RTE_LIBRTE_RAWDEV --Quoted 1 line
1.8.3.1
Regards
Qi