Skip to contentSkip to conversation

Introduce Intel FPGA BUS

PATCH Superseded Rosen Xu 11 participants 149 messages Mar 20, 2018 – May 23, 2018 Arm/Amlogic Meson SoC support Page 3 of 3

lore
Share & tools
lore
#112 lore raw

Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library

In reply to Xu, Rosen
Quoted 443 lines

-----Original Message-----
From: Xu, Rosen
Sent: Thursday, May 10, 2018 9:51 PM
To: Xu, Rosen <[email protected]>; 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 Library

Hi Qi,

I miss one comment, so I fix it in this email.

Quoted 15 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 Library

Quoted 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];

[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 Library

Hi 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 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.

Quoted 85 lines
Quoted 77 lines
Quoted 77 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_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 index 7105920..fa0c5b1 renamed from MAINTAINERS +0 -0

100644

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]> diff --git

a/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=y
doc/guides/rel_notes/release_18_05.rst +0 -0
index 7187348..265950a 100644
@@ -183,6 +183,11 @@ New Features
   stats/xstats on shared memory from secondary process, and also

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
+ drivers

prove.

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 -0

c251b65..ef7f247 100644

drivers/bus/Makefile +0 -0
@@ -7,6 +7,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa

ifeq

Quoted 273 lines
Quoted 142 lines
Quoted 142 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 -0

b/drivers/bus/ifpga/Makefile new file mode 100644 index 0000000..3ff3bdb

drivers/bus/ifpga/Makefile new file +29 -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.c new file mode 100644 index 0000000..e144c01

drivers/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_dev should be the first parameter here, and devargs follows

Fixed.

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.

To be honestly, ifpga_scan() is called by hotplug, lib_rte hotplug function will construct it.

Quoted 6 lines
Quoted 4 lines
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_NAME to replace "ifpga" here.

IFPGA_BUS_NAME is used in some Macros, so I use IFPGA_ARG_NAME.

Though they have the same value, but different meanings, the first argument of RTE_EAL_DEVARGS_FOREACH actually is "busname", we should parse bus name here. Though not a big deal, but I don't know why we can't use IFPGA_BUS_NAME?

Quoted 700 lines
Quoted 258 lines
Quoted 48 lines
Quoted 15 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 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?

One FPAG may support more than one AFU.

Quoted 141 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 %s

device\n",

Quoted 41 lines
drivers/bus/ifpga/ifpga_bus.c new file +41 -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_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.

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 49 lines
Quoted 49 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

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 259 lines
Quoted 259 lines

c2);

Quoted 258 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
new file mode 100644
index 0000000..78e2eae
@@ -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
new file mode 100644
index 0000000..f9254b9
@@ -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.h new file mode 100644 index 0000000..873e0a4

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_ */
(quoted diff) +0 -0

b/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 = true
drivers/bus/ifpga/rte_bus_ifpga.h new file +58 -0
new file mode 100644
index 0000000..5c559e1
@@ -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

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 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_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

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 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

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

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

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 95 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 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
new file mode 100644
index 0000000..a027979
@@ -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
index 58dfbe2..52c755d 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause  # Copyright(c) 2017

Intel 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 -0

100644

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

#113 lore raw

Re: [PATCH v10 1/3] bus/ifpga: Add Intel FPGA BUS Library

In reply to Xu, Rosen

10/05/2018 15:51, Xu, Rosen:

Quoted 3 lines

Hi Qi,

I miss one comment, so I fix it in this email.

In order to avoid missing comments, and to ease reading for others, please remove the useless context lines when replying.

author
#114 lore raw

PATCH v10 2/3 iFPGA: Add Intel FPGA OPAE Share Code

In reply to Xu, Rosen

From: Tianfei Zhang <[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

---
 MAINTAINERS                                        |    4 +
 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 +
 29 files changed, 8054 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
MAINTAINERS +4 -0
index fa0c5b1..9c27d5a 100644
@@ -850,6 +850,10 @@ F: doc/guides/eventdevs/opdl.rst
 Rawdev Drivers
 --------------
 
+Intel FPGA
+M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/base/
+
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
 F: drivers/raw/dpaa2_qdma/
drivers/raw/ifpga_rawdev/base/Makefile new file +30 -0
new file mode 100644
index 0000000..ade3551
@@ -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
new file mode 100644
index 0000000..5bc2ed0
@@ -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
new file mode 100644
index 0000000..dae7ca1
@@ -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
new file mode 100644
index 0000000..14131e3
@@ -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

54 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
new file mode 100644
index 0000000..cb65535

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
new file mode 100644
index 0000000..a03dff9

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.

author
#115 lore raw

PATCH v10 3/3 iFPGA: Add Intel FPGA BUS Rawdev Driver

In reply to Xu, Rosen

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

---
 MAINTAINERS                                        |   3 +
 config/common_base                                 |   5 +
 doc/guides/rawdevs/ifpga_rawdev.rst                | 112 ++++
 doc/guides/rawdevs/index.rst                       |   1 +
 doc/guides/rel_notes/release_18_05.rst             |   8 +
 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 +-
 13 files changed, 834 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst
 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
MAINTAINERS +3 -0
index 9c27d5a..a93ce9f 100644
@@ -851,8 +851,11 @@ Rawdev Drivers
 --------------
 
 Intel FPGA
+M: Rosen Xu <[email protected]>
 M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/
 F: drivers/raw/ifpga_rawdev/base/
+F: doc/guides/rawdevs/ifpga_rawdev.rst
 
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
config/common_base +5 -0
index 1440316..017a15a 100644
@@ -633,6 +633,11 @@ CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV=n
 CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n
 
 #
+# Compile PMD for Intel FPGA raw device
+#
+CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0

112 lines not on this page · raw message

doc/guides/rawdevs/index.rst +1 -0
index 7769083..7c3bd95 100644
@@ -13,3 +13,4 @@ application through rawdev API.
 
     dpaa2_cmdif
     dpaa2_qdma
+    ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +8 -0
index 265950a..f5241a1 100644
@@ -189,6 +189,14 @@ New Features
   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
 -----------
 
drivers/raw/Makefile +1 -0
index 2eb2787..8e29b4a 100644
@@ -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_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
new file mode 100644
index 0000000..f3b9d5e
@@ -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_pmd_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_PMD_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
new file mode 100644
index 0000000..c7759b8
@@ -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
new file mode 100644
index 0000000..6725687
@@ -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
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
drivers/raw/meson.build +1 -1
index 34dfac4..a61cdcc 100644
@@ -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
index 3861e1a..acc0ec3 100644
@@ -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_PMD_IFPGA_RAWDEV)   += -lrte_pmd_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
#116 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

09/05/2018 09:43, Xu, Rosen:

Quoted 9 lines

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

I have a compilation error:

	drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c:10:15: error:
	instruction requires: AVX-512 ISA

because of vmovdqu64:

#if defined(RTE_ARCH_X86_64)
static inline void copy512(const void *src, void *dst)

{
    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
}
#else
static inline void copy512(const void *src, void *dst)
{
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);
}

#endif

I suggest to fix it quickly without waiting a v11 with this:

static inline void copy512(const void *src, void *dst) {

#ifdef CC_SUPPORT_AVX512F
    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
#else
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);

#endif
}

It does not make any runtime detection, but it's better than previously.

#117 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 60 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, May 9, 2018 10:47 PM
To: Xu, Rosen <[email protected]>
Cc: [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]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

09/05/2018 09:43, Xu, Rosen:

Quoted 9 lines

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

I have a compilation error:

	drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c:10:15: error:
	instruction requires: AVX-512 ISA

because of vmovdqu64:

#if defined(RTE_ARCH_X86_64)

static inline void copy512(const void *src, void *dst) {
    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
}
#else
static inline void copy512(const void *src, void *dst) {
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);
}

#endif

I suggest to fix it quickly without waiting a v11 with this:

static inline void copy512(const void *src, void *dst) { #ifdef CC_SUPPORT_AVX512F

    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
#else
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);
Quoted 5 lines

#endif
}

It does not make any runtime detection, but it's better than previously.

Which linux distribution are you use? We can compile it on Ubuntu 16.04 and RHEL 7.4. We will fix it on V11.

#118 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 63 lines · Tianfei
Quoted 63 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, May 9, 2018 10:47 PM
To: Xu, Rosen <[email protected]>
Cc: [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]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

09/05/2018 09:43, Xu, Rosen:

Quoted 9 lines

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

I have a compilation error:

	drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c:10:15: error:
	instruction requires: AVX-512 ISA

because of vmovdqu64:

#if defined(RTE_ARCH_X86_64)

static inline void copy512(const void *src, void *dst) {
    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
}
#else
static inline void copy512(const void *src, void *dst) {
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);
}

#endif

I suggest to fix it quickly without waiting a v11 with this:

static inline void copy512(const void *src, void *dst) { #ifdef CC_SUPPORT_AVX512F

    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
#else
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);

#endif
}

Quoted 6 lines
Quoted 2 lines

It does not make any runtime detection, but it's better than previously.

Which linux distribution are you use? We can compile it on Ubuntu 16.04 and RHEL 7.4. We will fix it on V11.

This shows up with meson builds for non-avx-512 architectures using clang. The makefile has the following snippet that doesn't have an equivalent in the meson.build file.

26 ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)$
27 >-------CFLAGS_ifpga_fme_pr.o += -march=knl$
28 endif$

However, it does also bring up the questions as to the unconditional use of AVX-512 code? What happens if this code is run on a system without AVX-512 support?

Regards,
/Bruce

#119 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 93 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 9, 2018 11:37 PM
To: Zhang, Tianfei <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Xu, Rosen <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 64 lines · Tianfei
Quoted 64 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, May 9, 2018 10:47 PM
To: Xu, Rosen <[email protected]>
Cc: [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]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

09/05/2018 09:43, Xu, Rosen:

Quoted 9 lines

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

I have a compilation error:

	drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c:10:15: error:
	instruction requires: AVX-512 ISA

because of vmovdqu64:

#if defined(RTE_ARCH_X86_64)

static inline void copy512(const void *src, void *dst) {
    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
}
#else
static inline void copy512(const void *src, void *dst) {
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);
}

#endif

I suggest to fix it quickly without waiting a v11 with this:

static inline void copy512(const void *src, void *dst) { #ifdef CC_SUPPORT_AVX512F

    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst));
#else
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);

#endif
}

Quoted 4 lines
Quoted 2 lines

It does not make any runtime detection, but it's better than previously.

Which linux distribution are you use? We can compile it on Ubuntu 16.04

and RHEL 7.4.

Quoted 2 lines

We will fix it on V11.

This shows up with meson builds for non-avx-512 architectures using clang. The makefile has the following snippet that doesn't have an equivalent in the meson.build file.

Quoted 7 lines

26 ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)$
27 >-------CFLAGS_ifpga_fme_pr.o += -march=knl$
28 endif$

However, it does also bring up the questions as to the unconditional use of AVX-512 code? What happens if this code is run on a system without AVX-512 support?

This function is for SKY MCP platform (Xeon + FPGA integrated chip) which can accelerate the PR (partial reconfiguration ) function on FPGA. So the SKY support the AVX-512 instruction set.

author
#120 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Hi Thomas and Bruce,

To improve PR speed we involved AVX-512, but AVX-512 is not available in all IA platforms, besides this after we have tested several times, using AVX-512 only improve 1 ms. So this patch we don't use it.

Quoted 117 lines

-----Original Message-----
From: Zhang, Tianfei
Sent: Wednesday, May 09, 2018 23:58
To: Richardson, Bruce <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Xu, Rosen <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 89 lines

-----Original Message-----
From: Richardson, Bruce
Sent: Wednesday, May 9, 2018 11:37 PM
To: Zhang, Tianfei <[email protected]>
Cc: Thomas Monjalon <[email protected]>; Xu, Rosen <[email protected]>; [email protected]; Zhang, Roy Fan <[email protected]>; Doherty, Declan <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Liu, Song <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 61 lines · Tianfei
Quoted 61 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Wednesday, May 9, 2018 10:47 PM
To: Xu, Rosen <[email protected]>
Cc: [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]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

09/05/2018 09:43, Xu, Rosen:

Quoted 9 lines

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

I have a compilation error:

	drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c:10:15: error:
	instruction requires: AVX-512 ISA

because of vmovdqu64:

#if defined(RTE_ARCH_X86_64)

static inline void copy512(const void *src, void *dst) {
    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst)); } #else static inline void
copy512(const void *src, void *dst) {
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);
}

#endif

I suggest to fix it quickly without waiting a v11 with this:

static inline void copy512(const void *src, void *dst) { #ifdef CC_SUPPORT_AVX512F

    asm volatile("vmovdqu64 (%0), %%zmm0;"
             "vmovntdq %%zmm0, (%1);"
             :
             : "r"(src), "r"(dst)); #else
    UNUSED(src);
    UNUSED(dst);
    WARN_ON(1);

#endif
}

Quoted 5 lines
Quoted 2 lines

It does not make any runtime detection, but it's better than previously.

Which linux distribution are you use? We can compile it on Ubuntu 16.04

and RHEL 7.4.

Quoted 2 lines

We will fix it on V11.

This shows up with meson builds for non-avx-512 architectures using clang. The makefile has the following snippet that doesn't have an equivalent in the meson.build file.

Quoted 8 lines

26 ifeq ($(CONFIG_RTE_TOOLCHAIN_CLANG),y)$
27 >-------CFLAGS_ifpga_fme_pr.o += -march=knl$
28 endif$

However, it does also bring up the questions as to the unconditional use of
AVX-512 code? What happens if this code is run on a system without AVX-512 support?

This function is for SKY MCP platform (Xeon + FPGA integrated chip) which can accelerate the PR (partial reconfiguration ) function on FPGA. So the SKY support the AVX-512 instruction set.

#121 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

In reply to Xu, Rosen

Hi, Rosen

Few comments below.

Thanks
Jingjing

[...]

Quoted 4 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +4 -0
+static int
+ifpga_rawdev_start(struct rte_rawdev *dev)
+{
+	int ret = 0;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 146

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	struct opae_adapter *adapter;
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+
+	RTE_FUNC_PTR_OR_ERR_RET(dev, -EINVAL);
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return -ENODEV;
+

Set dev->started?

Quoted 2 lines
(quoted diff) +2 -0
+	return ret;
+}

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 321

Quoted 4 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +4 -0
+
+static const struct rte_rawdev_ops ifpga_rawdev_ops = {
+	.dev_info_get = ifpga_rawdev_info_get,
+	.dev_configure = NULL,

If go the declaration of rte_rawdev_configure, you will see "This function must be invoked first before any other function in the API." So I think we need to function for it, even it does nothing.

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 500

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+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,

Is RTE_PCI_DRV_INTR_LSC supported?

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 602

Quoted 6 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +6 -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);

I think prefix net_ would mean the device is net device (eth_dev)? How about to change the prefix to raw_?

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 605

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+RTE_PMD_REGISTER_ALIAS(net_ifpga_cfg, ifpga_cfg);
+RTE_PMD_REGISTER_PARAM_STRING(net_ifpga_cfg,
+	"bdf=<string> "

ifpga=<string>?

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+	"port=<int> "
+	"afu_bts=<path>");
+
author
#122 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Hi Jingjing,

Quoted 14 lines

-----Original Message-----
From: Wu, Jingjing
Sent: Thursday, May 10, 2018 17:21
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]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 3 lines

Hi, Rosen

Few comments below.

Thanks a lot.

Quoted 5 lines

Thanks
Jingjing

[...]

Quoted 14 lines

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 146

Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13 -0
+static int
+ifpga_rawdev_start(struct rte_rawdev *dev) {
+	int ret = 0;
+	struct opae_adapter *adapter;
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+
+	RTE_FUNC_PTR_OR_ERR_RET(dev, -EINVAL);
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return -ENODEV;
+

Set dev->started?

Rawdev lib enable it.

Quoted 6 lines
Quoted 2 lines
(quoted diff) +2 -0
+	return ret;
+}

[...]

Quoted 7 lines

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 321

Quoted 4 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +4 -0
+
+static const struct rte_rawdev_ops ifpga_rawdev_ops = {
+	.dev_info_get = ifpga_rawdev_info_get,
+	.dev_configure = NULL,

If go the declaration of rte_rawdev_configure, you will see "This function must be invoked first before any other function in the API." So I think we need to function for it, even it does nothing.

For other Rawdev Drivers, no used function pointer is initialized with NULL.

Quoted 11 lines

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+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,
Is RTE_PCI_DRV_INTR_LSC supported?

[...]

Quoted 8 lines

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 602

Quoted 6 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +6 -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);

I think prefix net_ would mean the device is net device (eth_dev)? How about to change the prefix to raw_?

I have fixed it both in code and document.

Quoted 7 lines

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 605

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+RTE_PMD_REGISTER_ALIAS(net_ifpga_cfg, ifpga_cfg);
+RTE_PMD_REGISTER_PARAM_STRING(net_ifpga_cfg,
+	"bdf=<string> "

ifpga=<string>?

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+	"port=<int> "
+	"afu_bts=<path>");
+
author
#123 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

In reply to Wu, Jingjing

Hi Jingjing,

After we have aligned this morning, I will reply your email again.

Quoted 37 lines

-----Original Message-----
From: Wu, Jingjing
Sent: Thursday, May 10, 2018 17:21
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]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Hi, Rosen

Few comments below.

Thanks
Jingjing

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 146

Quoted 13 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +13 -0
+static int
+ifpga_rawdev_start(struct rte_rawdev *dev) {
+	int ret = 0;
+	struct opae_adapter *adapter;
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+
+	RTE_FUNC_PTR_OR_ERR_RET(dev, -EINVAL);
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return -ENODEV;
+

Set dev->started?

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+	return ret;
+}

Fixed.

Quoted 10 lines

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 321

Quoted 4 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +4 -0
+
+static const struct rte_rawdev_ops ifpga_rawdev_ops = {
+	.dev_info_get = ifpga_rawdev_info_get,
+	.dev_configure = NULL,

If go the declaration of rte_rawdev_configure, you will see "This function must be invoked first before any other function in the API." So I think we need to function for it, even it does nothing.

Yes, the rte_rawdev_configure function should not NULL. I have fill it.

Quoted 8 lines

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+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,
Is RTE_PCI_DRV_INTR_LSC supported?

Not supported, and I removed it.

Quoted 11 lines

[...]

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 602

Quoted 6 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +6 -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);

I think prefix net_ would mean the device is net device (eth_dev)? How about to change the prefix to raw_?

Quoted 4 lines

drivers/raw/ifpga_rawdev/ifpga_rawdev.c line 605

Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+RTE_PMD_REGISTER_ALIAS(net_ifpga_cfg, ifpga_cfg);
+RTE_PMD_REGISTER_PARAM_STRING(net_ifpga_cfg,
+	"bdf=<string> "

ifpga=<string>?

Fixed.

Quoted 3 lines
Quoted 3 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +3 -0
+	"port=<int> "
+	"afu_bts=<path>");
+
#124 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

In reply to Xu, Rosen

Hi Rosen:

After read this patch, I have below suggestion

1. rte_ifgpa_device is not necessary, since we already have ifgpa bus, it manages all devices on that bus, we don't need another abstraction to manage afu devices, and user can add to or remove from the bus.
2. rename rte_afu_device to rte_ifpga_device , we follow the name rule.
3. data structure looks like below.

	Struct rte_ifpga_deivce {
		rte_device device /* backing device */
		Rte_raw_device *device /* link to raw pci device */
		Struct Rte_afu_info info; /* afu information */
	}

	struct rte_afu_info {
        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 */
        ....
		...
	}

Regards
Qi

Quoted 1,021 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]; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

---
 MAINTAINERS                                        |   3 +
 config/common_base                                 |   5 +
 doc/guides/rawdevs/ifpga_rawdev.rst                | 112 ++++
 doc/guides/rawdevs/index.rst                       |   1 +
 doc/guides/rel_notes/release_18_05.rst             |   8 +
 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 +-
 13 files changed, 834 insertions(+), 2 deletions(-)  create mode 100644
doc/guides/rawdevs/ifpga_rawdev.rst
 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

MAINTAINERS +3 -0
index 9c27d5a..a93ce9f 100644
@@ -851,8 +851,11 @@ Rawdev Drivers
 --------------
 
 Intel FPGA
+M: Rosen Xu <[email protected]>
 M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/
 F: drivers/raw/ifpga_rawdev/base/
+F: doc/guides/rawdevs/ifpga_rawdev.rst
 
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
config/common_base index renamed from config/common_base +0 -0

1440316..017a15a 100644

config/common_base +0 -0
@@ -633,6 +633,11 @@

CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV=n
CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n

#

config/common_base +4 -0
+# Compile PMD for Intel FPGA raw device #
+CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
doc/guides/rawdevs/ifpga_rawdev.rst new file +18 -0
new file mode 100644
index 0000000..37ae4cc
@@ -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.

doc/guides/rawdevs/ifpga_rawdev.rst new file +12 -0
+
+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
doc/guides/rawdevs/ifpga_rawdev.rst new file +6 -0
+
+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.

doc/guides/rawdevs/ifpga_rawdev.rst new file +9 -0
+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)

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +5 -0
+     +----------------------------.----------------------------------+
+                                  |
+                                  |
+     +----------------------------'----------------------------------+
+     |                    DPDK Framework (APIs)

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +5 -0
+     +----------|------------|--------.---------------------|--------+
+               /              \                             |
+              /                \                            |
+     +-------'-------+  +-------'-------+          +--------'--------+
+     |    Eth PMD    |  |   Crypto PMD  |          |

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------.-------+  +-------.-------+          |                 |
+             |                  |                  |

|
+ | | |
|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------'-------+  +-------'-------+          |      IFPGA      |
+     |  Eth AFU Dev  |  |Crypto AFU Dev |          |  Rawdev Driver

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------.-------+  +-------.-------+          |(OPAE Share Code)|
+             |                  |                  |

|
+ | | Rawdev |
|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------'------------------'-------+    Ops   |                 |
+     |              IFPGA Bus           | -------->|

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +6 -0
+     +-----------------.----------------+          +--------.--------+
+                       |                                    |
+         Hot-plugin -->|                                    |
+                       |                                    |
+     +-----------------'------------------+        +--------'--------+
+     |        vdev_ifpga_cfg driver       |        |  Intel FpgaDev

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +36 -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 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
index 7769083..7c3bd95 100644
@@ -13,3 +13,4 @@ application through rawdev API.
 
     dpaa2_cmdif
     dpaa2_qdma
+    ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +0 -0
index 265950a..f5241a1 100644
@@ -189,6 +189,14 @@ New Features
   the DPDK framework. It provides Intel FPGA Partial Bit Stream

AFU(Accelerated
Function Unit) scan and drivers prove.

doc/guides/rel_notes/release_18_05.rst +7 -0
+* **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.

doc/guides/rel_notes/release_18_05.rst +1 -0
+
 API Changes
 -----------
drivers/raw/Makefile index renamed from drivers/raw/Makefile +0 -0

2eb2787..8e29b4a 100644

drivers/raw/Makefile +0 -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

drivers/raw/Makefile +1 -0
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
new file mode 100644
index 0000000..f3b9d5e
@@ -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_pmd_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_PMD_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +51 -0
new file mode 100644
index 0000000..32e811c
@@ -0,0 +1,608 @@
+/* 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 new file +193 -0
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static int
+ifpga_fill_afu_dev(struct opae_accelerator *acc,
+		struct rte_afu_device *afu_dev)
+{
+	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, &region_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();
+
+	if (!dev_info) {
+		IFPGA_RAWDEV_PMD_ERR("Invalid request");
+		return;
+	}
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return;
+
+	afu_dev = dev_info;
+	afu_dev->rawdev = dev;
+
+	/* find opae_accelerator and fill info into afu_device */
+	opae_adapter_for_each_acc(adapter, acc) {
+		if (acc->index != afu_dev->id.port)
+			continue;
+
+		if (ifpga_fill_afu_dev(acc, afu_dev)) {
+			IFPGA_RAWDEV_PMD_ERR("cannot get info\n");
+			return;
+		}
+	}
+}
+
+static int
+ifpga_rawdev_start(struct rte_rawdev *dev) {
+	int ret = 0;
+	struct opae_adapter *adapter;
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+
+	RTE_FUNC_PTR_OR_ERR_RET(dev, -EINVAL);
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return -ENODEV;
+
+	return ret;
+}
+
+static void
+ifpga_rawdev_stop(struct rte_rawdev *dev) {
+	dev->started = 0;
+}
+
+static int
+ifpga_rawdev_close(struct rte_rawdev *dev) {
+	return dev ? 0:1;
+}
+
+static int
+ifpga_rawdev_reset(struct rte_rawdev *dev) {
+	return dev ? 0:1;
+}
+
+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);
+	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) {
+		IFPGA_RAWDEV_PMD_ERR("%s pr error %d\n", __func__, ret);
+		return ret;
+	}
+
+	ret = opae_bridge_reset(br);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("%s reset port:%d error %d\n",
+				__func__, port_id, ret);
+		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;
+	void *buffer;
+	u64 pr_error;
+
+	if (!file_name)
+		return -EINVAL;
+
+	file_fd = open(file_name, O_RDONLY);
+	if (file_fd < 0) {
+		IFPGA_RAWDEV_PMD_ERR("%s: open file error: %s\n",
+				__func__, file_name);
+		IFPGA_RAWDEV_PMD_ERR("Message : %s\n", strerror(errno));
+		return -EINVAL;
+	}
+	ret = stat(file_name, &file_stat);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("stat on bitstream file failed: %s\n",
+				file_name);
+		return -EINVAL;
+	}
+	buffer_size = file_stat.st_size;
+	IFPGA_RAWDEV_PMD_INFO("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;
+		goto free_buffer;
+	}
+
+	/*do PR now*/
+	ret = fpga_pr(rawdev, port_id, buffer, buffer_size, &pr_error);
+	IFPGA_RAWDEV_PMD_INFO("downloading to device port %d....%s.\n",

port_id,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +58 -0
+		ret ? "failed" : "success");
+	if (ret) {
+		ret = -EINVAL;
+		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)
+		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) {
+			IFPGA_RAWDEV_PMD_ERR("do pr error %d\n", ret);
+			return ret;
+		}
+	}
+
+	acc = opae_adapter_get_acc(adapter, afu_pr_conf->afu_id.port);
+	if (!acc)
+		return -ENODEV;
+
+	ret = opae_acc_get_uuid(acc, &uuid);
+	if (ret)
+		return ret;
+
+	memcpy(&afu_pr_conf->afu_id.uuid.uuid_low, uuid.b, sizeof(u64));
+	memcpy(&afu_pr_conf->afu_id.uuid.uuid_high, uuid.b + 8, sizeof(u64));
+
+	IFPGA_RAWDEV_PMD_INFO("%s: uuid_l=0x%lx, uuid_h=0x%lx\n",

__func__,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +293 -0
+		(u64)afu_pr_conf->afu_id.uuid.uuid_low,
+		(u64)afu_pr_conf->afu_id.uuid.uuid_high);
+
+	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 = NULL;
+	struct opae_manager *mgr = NULL;
+	struct opae_adapter_data_pci *data = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	int i;
+
+	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);
+
+	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);
+	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) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	/* 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;
+		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) {
+		ret = -ENOMEM;
+		goto free_adapter_data;
+	}
+
+	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)
+		goto free_adapter;
+
+	/* get opae_manager to rawdev */
+	mgr = opae_adapter_get_mgr(adapter);
+	if (mgr) {
+		/* PF function */
+		IFPGA_RAWDEV_PMD_INFO("this is a PF function");
+	}
+
+	return ret;
+
+free_adapter:
+	if (adapter)
+		opae_adapter_free(adapter);
+free_adapter_data:
+	if (data)
+		opae_adapter_data_free(data);
+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");
+
+	return ret;
+}
+
+static int
+ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	struct rte_pci_device *pci_dev)
+{
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+	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];
+
+	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,
+				       &rte_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,
+			&rte_ifpga_get_integer32_arg,
+			&port) < 0) {
+			IFPGA_RAWDEV_PMD_ERR("error to parse %s",
+				IFPGA_ARG_PORT);
+			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, "%d|%s",
+	port, name);
+
+	rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
+			dev_name, devargs->args);
+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 +13 -0
new file mode 100644
index 0000000..c7759b8
@@ -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, ">>")

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_ */
drivers/raw/ifpga_rawdev/meson.build new file +15 -0
new file mode 100644
index 0000000..6725687
@@ -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
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
drivers/raw/meson.build index renamed from drivers/raw/meson.build +0 -0

34dfac4..a61cdcc 100644

drivers/raw/meson.build +2 -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 +0 -0
@@ -256,9 +256,11 @@

_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) +=

mk/rte.app.mk +3 -5
-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_PMD_IFPGA_RAWDEV)   +=
-lrte_pmd_ifpga_rawdev
+endif # CONFIG_RTE_LIBRTE_IFPGA_BUS
 endif # CONFIG_RTE_LIBRTE_RAWDEV
 
-
 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
 
 _LDLIBS-y += --no-whole-archive
--

1.8.3.1

author
#125 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Hi Qi,

Quoted 14 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 22:24
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]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 7 lines

Hi Rosen:

After read this patch, I have below suggestion

1. rte_ifgpa_device is not necessary, since we already have ifgpa bus,
it manages all devices on that bus, we don't need another abstraction to manage afu devices, and user can add to or remove from the bus.

Remove no used definition of rte_ifgpa_device

Quoted 2 lines

2. rename rte_afu_device to rte_ifpga_device , we follow the name
rule.

AFU is partial bit stream of FPGA, so AFU and FPGA are different definition. But we define global variables: ifpga_afu_dev_list

Quoted 15 lines

3. data structure looks like below.

	Struct rte_ifpga_deivce {
		rte_device device /* backing device */
		Rte_raw_device *device /* link to raw pci device */
		Struct Rte_afu_info info; /* afu information */
	}

	struct rte_afu_info {
        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 */
        ....
		...
	}

For there is not ifpga definition in our patch, so I still keep the definition of rte_afu_dev. Is it ok?

Quoted 1,048 lines

Regards
Qi

Quoted 106 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]; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

---
 MAINTAINERS                                        |   3 +
 config/common_base                                 |   5 +
 doc/guides/rawdevs/ifpga_rawdev.rst                | 112 ++++
 doc/guides/rawdevs/index.rst                       |   1 +
 doc/guides/rel_notes/release_18_05.rst             |   8 +
 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 +-
 13 files changed, 834 insertions(+), 2 deletions(-)  create mode
100644 doc/guides/rawdevs/ifpga_rawdev.rst
 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

MAINTAINERS +3 -0
@@ -851,8 +851,11 @@ Rawdev Drivers
 --------------
 
 Intel FPGA
+M: Rosen Xu <[email protected]>
 M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/
 F: drivers/raw/ifpga_rawdev/base/
+F: doc/guides/rawdevs/ifpga_rawdev.rst
 
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
config/common_base index renamed from config/common_base +0 -0

1440316..017a15a 100644

config/common_base +0 -0
@@ -633,6 +633,11 @@

CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV=n
CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n

#

config/common_base +4 -0
+# Compile PMD for Intel FPGA raw device #
+CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
doc/guides/rawdevs/ifpga_rawdev.rst new file +19 -0
new file mode 100644
index 0000000..37ae4cc
@@ -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.

doc/guides/rawdevs/ifpga_rawdev.rst new file +1 -0
+

doc/guides/rawdevs/ifpga_rawdev.rst

Quoted 10 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +10 -0
+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

Quoted 16 lines

+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
doc/guides/rawdevs/ifpga_rawdev.rst new file +7 -0
+
+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.

doc/guides/rawdevs/ifpga_rawdev.rst

Quoted 4 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +4 -0
+All AFU device driver bind to AFU device by its UUID (Universally
+Unique Identifier).
+
+To avoid unnecessary code duplication and ensure maximum

performance,

Quoted 113 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 new file +5 -0
+     +----------------------------.----------------------------------+
+                                  |
+                                  |
+     +----------------------------'----------------------------------+
+     |                    DPDK Framework (APIs)

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +5 -0
+     +----------|------------|--------.---------------------|--------+
+               /              \                             |
+              /                \                            |
+     +-------'-------+  +-------'-------+          +--------'--------+
+     |    Eth PMD    |  |   Crypto PMD  |          |

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------.-------+  +-------.-------+          |                 |
+             |                  |                  |

|
+ | | |
|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------'-------+  +-------'-------+          |      IFPGA      |
+     |  Eth AFU Dev  |  |Crypto AFU Dev |          |  Rawdev Driver

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------.-------+  +-------.-------+          |(OPAE Share Code)|
+             |                  |                  |

|
+ | | Rawdev |
|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------'------------------'-------+    Ops   |                 |
+     |              IFPGA Bus           | -------->|

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +6 -0
+     +-----------------.----------------+          +--------.--------+
+                       |                                    |
+         Hot-plugin -->|                                    |
+                       |                                    |
+     +-----------------'------------------+        +--------'--------+
+     |        vdev_ifpga_cfg driver       |        |  Intel FpgaDev

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +36 -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 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.
(quoted diff) +0 -0

b/doc/guides/rawdevs/index.rst index 7769083..7c3bd95 100644

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 +0 -0
index 265950a..f5241a1 100644
@@ -189,6 +189,14 @@ New Features
   the DPDK framework. It provides Intel FPGA Partial Bit Stream

AFU(Accelerated
Function Unit) scan and drivers prove.

doc/guides/rel_notes/release_18_05.rst +7 -0
+* **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.

doc/guides/rel_notes/release_18_05.rst +1 -0
+
 API Changes
 -----------
drivers/raw/Makefile index renamed from drivers/raw/Makefile +0 -0

2eb2787..8e29b4a 100644

drivers/raw/Makefile ifeq · line 10

Quoted 2 lines
drivers/raw/Makefile +0 -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

drivers/raw/Makefile ifeq · line 11

Quoted 1 line
drivers/raw/Makefile +0 -0
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) +=

dpaa2_qdma endif

Quoted 241 lines
drivers/raw/Makefile +1 -0
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
new file mode 100644
index 0000000..f3b9d5e
@@ -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_pmd_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_PMD_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +51 -0
new file mode 100644
index 0000000..32e811c
@@ -0,0 +1,608 @@
+/* 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 new file +126 -0
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static int
+ifpga_fill_afu_dev(struct opae_accelerator *acc,
+		struct rte_afu_device *afu_dev)
+{
+	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, &region_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();
+
+	if (!dev_info) {
+		IFPGA_RAWDEV_PMD_ERR("Invalid request");
+		return;
+	}
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return;
+
+	afu_dev = dev_info;
+	afu_dev->rawdev = dev;
+
+	/* find opae_accelerator and fill info into afu_device */
+	opae_adapter_for_each_acc(adapter, acc) {
+		if (acc->index != afu_dev->id.port)
+			continue;
+
+		if (ifpga_fill_afu_dev(acc, afu_dev)) {
+			IFPGA_RAWDEV_PMD_ERR("cannot get info\n");
+			return;
+		}
+	}
+}
+
+static int
+ifpga_rawdev_start(struct rte_rawdev *dev) {
+	int ret = 0;
+	struct opae_adapter *adapter;
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+
+	RTE_FUNC_PTR_OR_ERR_RET(dev, -EINVAL);
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return -ENODEV;
+
+	return ret;
+}
+
+static void
+ifpga_rawdev_stop(struct rte_rawdev *dev) {
+	dev->started = 0;
+}
+
+static int
+ifpga_rawdev_close(struct rte_rawdev *dev) {
+	return dev ? 0:1;
+}
+
+static int
+ifpga_rawdev_reset(struct rte_rawdev *dev) {
+	return dev ? 0:1;
+}
+
+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

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) {
+		IFPGA_RAWDEV_PMD_ERR("%s pr error %d\n", __func__,

ret);

Quoted 22 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +22 -0
+		return ret;
+	}
+
+	ret = opae_bridge_reset(br);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("%s reset port:%d error %d\n",
+				__func__, port_id, ret);
+		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;
+	void *buffer;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	u64 pr_error;
+
+	if (!file_name)
+		return -EINVAL;
+
+	file_fd = open(file_name, O_RDONLY);
+	if (file_fd < 0) {
+		IFPGA_RAWDEV_PMD_ERR("%s: open file error: %s\n",
+				__func__, file_name);
+		IFPGA_RAWDEV_PMD_ERR("Message : %s\n",

strerror(errno));

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5 -0
+		return -EINVAL;
+	}
+	ret = stat(file_name, &file_stat);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("stat on bitstream file

failed: %s\n",

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+				file_name);
+		return -EINVAL;
+	}
+	buffer_size = file_stat.st_size;
+	IFPGA_RAWDEV_PMD_INFO("bitstream file size: %u\n", buffer_size);
+	buffer = rte_malloc(NULL, buffer_size, 0);
+	if (!buffer) {
+		ret = -ENOMEM;
+		goto close_fd;
+	}

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+
+	/*read the raw data*/
+	if (buffer_size != read(file_fd, (void *)buffer, buffer_size)) {
+		ret = -EINVAL;
+		goto free_buffer;
+	}
+
+	/*do PR now*/
+	ret = fpga_pr(rawdev, port_id, buffer, buffer_size, &pr_error);
+	IFPGA_RAWDEV_PMD_INFO("downloading to device

port %d....%s.\n",

Quoted 110 lines

port_id,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +59 -0
+		ret ? "failed" : "success");
+	if (ret) {
+		ret = -EINVAL;
+		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)
+		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) {
+			IFPGA_RAWDEV_PMD_ERR("do pr error %d\n", ret);
+			return ret;
+		}
+	}
+
+	acc = opae_adapter_get_acc(adapter, afu_pr_conf->afu_id.port);
+	if (!acc)
+		return -ENODEV;
+
+	ret = opae_acc_get_uuid(acc, &uuid);
+	if (ret)
+		return ret;
+
+	memcpy(&afu_pr_conf->afu_id.uuid.uuid_low, uuid.b, sizeof(u64));
+	memcpy(&afu_pr_conf->afu_id.uuid.uuid_high, uuid.b + 8,
+sizeof(u64));
+
+	IFPGA_RAWDEV_PMD_INFO("%s: uuid_l=0x%lx, uuid_h=0x%lx\n",

__func__,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +49 -0
+		(u64)afu_pr_conf->afu_id.uuid.uuid_low,
+		(u64)afu_pr_conf->afu_id.uuid.uuid_high);
+
+	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 = NULL;
+	struct opae_manager *mgr = NULL;
+	struct opae_adapter_data_pci *data = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	int i;
+
+	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",

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 8 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1 -0
+		pci_dev->addr.bus, pci_dev->addr.devid, pci_dev-

addr.function);

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),

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 8 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +8 -0
+					 socket_id);
+	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

*/

Quoted 61 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +9 -0
+	data = opae_adapter_data_alloc(OPAE_FPGA_PCI);
+	if (!data) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	/* 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;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +51 -0
+		data->region[i].len = pci_dev->mem_resource[i].len;
+		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) {
+		ret = -ENOMEM;
+		goto free_adapter_data;
+	}
+
+	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)
+		goto free_adapter;
+
+	/* get opae_manager to rawdev */
+	mgr = opae_adapter_get_mgr(adapter);
+	if (mgr) {
+		/* PF function */
+		IFPGA_RAWDEV_PMD_INFO("this is a PF function");
+	}
+
+	return ret;
+
+free_adapter:
+	if (adapter)
+		opae_adapter_free(adapter);
+free_adapter_data:
+	if (data)
+		opae_adapter_data_free(data);
+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];

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	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",

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 9 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1 -0
+		pci_dev->addr.bus, pci_dev->addr.devid, pci_dev-

addr.function);

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +7 -0
+
+	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);

Quoted 23 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +23 -0
+		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");
+
+	return ret;
+}
+
+static int
+ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	struct rte_pci_device *pci_dev)
+{
+

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+	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,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5 -0
+	.probe     = ifpga_rawdev_pci_probe,
+	.remove    = ifpga_rawdev_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver,

rte_ifpga_rawdev_pmd);

Quoted 26 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +26 -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;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	struct rte_kvargs *kvlist = NULL;
+	int port;
+	char *name = NULL;
+	char dev_name[RTE_RAWDEV_NAME_MAX_LEN];
+
+	devargs = dev->device.devargs;
+
+	kvlist = rte_kvargs_parse(devargs->args, valid_args);
+	if (!kvlist) {
+		IFPGA_RAWDEV_PMD_LOG(ERR, "error when parsing

param");

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 12 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +12 -0
+		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_RAWDEV_PMD_ERR("error to parse %s",
+				     IFPGA_ARG_NAME);
+			goto end;
+		}
+	} else {
+		IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga

bus",

Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5 -0
+			  IFPGA_ARG_NAME);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+		if (rte_kvargs_process(kvlist,
+			IFPGA_ARG_PORT,
+			&rte_ifpga_get_integer32_arg,
+			&port) < 0) {
+			IFPGA_RAWDEV_PMD_ERR("error to parse %s",
+				IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga

bus",

Quoted 150 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +39 -0
+			  IFPGA_ARG_PORT);
+		goto end;
+	}
+
+	memset(dev_name, 0, sizeof(dev_name));
+	snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s",
+	port, name);
+
+	rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
+			dev_name, devargs->args);
+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 +13 -0
new file mode 100644
index 0000000..c7759b8
@@ -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, ">>")

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_ */
drivers/raw/ifpga_rawdev/meson.build new file +15 -0
new file mode 100644
index 0000000..6725687
@@ -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
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
drivers/raw/meson.build index renamed from drivers/raw/meson.build +0 -0

34dfac4..a61cdcc 100644

drivers/raw/meson.build +2 -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 index 3861e1a..acc0ec3 renamed from mk/rte.app.mk +0 -0

100644

mk/rte.app.mk +0 -0
@@ -256,9 +256,11 @@

_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) +=

mk/rte.app.mk +3 -5
-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_PMD_IFPGA_RAWDEV)   +=
-lrte_pmd_ifpga_rawdev
+endif # CONFIG_RTE_LIBRTE_IFPGA_BUS
 endif # CONFIG_RTE_LIBRTE_RAWDEV
 
-
 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
 
 _LDLIBS-y += --no-whole-archive
--

1.8.3.1

#126 lore raw

Re: [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Quoted 37 lines

-----Original Message-----
From: Xu, Rosen
Sent: Friday, May 11, 2018 11:17 AM
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]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Hi Qi,

Quoted 4 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Thursday, May 10, 2018 22:24
To: Xu, Rosen <[email protected]>; [email protected];

[email protected]

Quoted 13 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]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

Hi Rosen:

Quoted 8 lines
Quoted 5 lines

After read this patch, I have below suggestion

1. rte_ifgpa_device is not necessary, since we already have ifgpa
bus, it manages all devices on that bus, we don't need another abstraction to manage afu devices, and user can add to or remove from the

bus.

Remove no used definition of rte_ifgpa_device

OK

Quoted 6 lines
Quoted 3 lines

2. rename rte_afu_device to rte_ifpga_device , we follow the name
rule.

AFU is partial bit stream of FPGA, so AFU and FPGA are different definition. But we define global variables: ifpga_afu_dev_list

I think ifpga is an abstract bus, we could have rte_ifpga_device as an abstract device type, afu is the physical resource the abstract device link to,
Name rte_afu_device on ifpga bus looks not consistent to me.

Regards
Qi

Quoted 1,077 lines
Quoted 9 lines

3. data structure looks like below.

Struct rte_ifpga_deivce {
rte_device device /* backing device */ Rte_raw_device *device /* link to raw pci device */ Struct Rte_afu_info info; /* afu information */
}

Quoted 3 lines

struct rte_afu_info {
struct rte_ifpga_device *ifpga_dev; /**< Point ifpga device */
struct rte_afu_id id; /**< AFU id within FPGA.

*/

Quoted 4 lines
        uint32_t num_region;   /**< number of regions found */
        ....
		...
	}

For there is not ifpga definition in our patch, so I still keep the definition of rte_afu_dev.
Is it ok?

Quoted 159 lines

Regards
Qi

Quoted 107 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]; Wu, Yanglong <[email protected]>
Subject: [dpdk-dev] [PATCH v10 3/3] iFPGA: Add Intel FPGA BUS Rawdev Driver

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

---
 MAINTAINERS                                        |   3 +
 config/common_base                                 |   5 +
 doc/guides/rawdevs/ifpga_rawdev.rst                | 112 ++++
 doc/guides/rawdevs/index.rst                       |   1 +
 doc/guides/rel_notes/release_18_05.rst             |   8 +
 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 +-
 13 files changed, 834 insertions(+), 2 deletions(-)  create mode
100644 doc/guides/rawdevs/ifpga_rawdev.rst
 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

MAINTAINERS +3 -0
@@ -851,8 +851,11 @@ Rawdev Drivers
 --------------
 
 Intel FPGA
+M: Rosen Xu <[email protected]>
 M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/
 F: drivers/raw/ifpga_rawdev/base/
+F: doc/guides/rawdevs/ifpga_rawdev.rst
 
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]> diff --git

a/config/common_base b/config/common_base index 1440316..017a15a 100644

config/common_base +0 -0
@@ -633,6 +633,11 @@

CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV=n
CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n

#

config/common_base +4 -0
+# Compile PMD for Intel FPGA raw device #
+CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
doc/guides/rawdevs/ifpga_rawdev.rst new file +19 -0
new file mode 100644
index 0000000..37ae4cc
@@ -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.

doc/guides/rawdevs/ifpga_rawdev.rst new file +1 -0
+

doc/guides/rawdevs/ifpga_rawdev.rst

Quoted 10 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +10 -0
+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

Quoted 16 lines

+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
doc/guides/rawdevs/ifpga_rawdev.rst new file +7 -0
+
+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.

doc/guides/rawdevs/ifpga_rawdev.rst

Quoted 4 lines
doc/guides/rawdevs/ifpga_rawdev.rst new file +4 -0
+All AFU device driver bind to AFU device by its UUID (Universally
+Unique Identifier).
+
+To avoid unnecessary code duplication and ensure maximum

performance,

Quoted 17 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 new file +5 -0
+     +----------------------------.----------------------------------+
+                                  |
+                                  |
+     +----------------------------'----------------------------------+
+     |                    DPDK Framework (APIs)

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +5 -0
+     +----------|------------|--------.---------------------|--------+
+               /              \                             |
+              /                \                            |
+     +-------'-------+  +-------'-------+          +--------'--------+
+     |    Eth PMD    |  |   Crypto PMD  |          |
Quoted 8 lines

doc/guides/rawdevs/ifpga_rawdev.rst

Quoted 8 lines

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------.-------+  +-------.-------+          |                 |
+             |                  |                  |

|
+ | | |
|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------'-------+  +-------'-------+          |      IFPGA      |
+     |  Eth AFU Dev  |  |Crypto AFU Dev |          |  Rawdev

Driver

Quoted 7 lines
Quoted 7 lines

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +2 -0
+     +-------.-------+  +-------.-------+          |(OPAE Share Code)|
+             |                  |                  |

|
+ | | Rawdev |
|
+ +-------'------------------'-------+ Ops | |

Quoted 8 lines

doc/guides/rawdevs/ifpga_rawdev.rst

Quoted 8 lines

+ | IFPGA Bus | -------->|
|

doc/guides/rawdevs/ifpga_rawdev.rst new file +6 -0
+     +-----------------.----------------+          +--------.--------+
+                       |                                    |
+         Hot-plugin -->|                                    |
+                       |                                    |
+     +-----------------'------------------+        +--------'--------+
+     |        vdev_ifpga_cfg driver       |        |  Intel

FpgaDev

Quoted 56 lines
Quoted 56 lines

|

doc/guides/rawdevs/ifpga_rawdev.rst new file +36 -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 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.
(quoted diff) +0 -0

b/doc/guides/rawdevs/index.rst index 7769083..7c3bd95 100644

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 +0 -0
index 265950a..f5241a1 100644
@@ -189,6 +189,14 @@ New Features
   the DPDK framework. It provides Intel FPGA Partial Bit Stream

AFU(Accelerated
Function Unit) scan and drivers prove.

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(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.

Quoted 806 lines
Quoted 13 lines
doc/guides/rel_notes/release_18_05.rst +3 -0
+
+  See the :doc:`../rawdevs/ifpga_rawdev` programmer's guide for
+ more

details.

doc/guides/rel_notes/release_18_05.rst +1 -0
+
 API Changes
 -----------
drivers/raw/Makefile index renamed from drivers/raw/Makefile +0 -0

2eb2787..8e29b4a 100644

drivers/raw/Makefile ifeq · line 10

Quoted 2 lines
drivers/raw/Makefile +0 -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

drivers/raw/Makefile ifeq · line 11

Quoted 1 line
drivers/raw/Makefile +0 -0
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV) +=

dpaa2_qdma endif

Quoted 239 lines
drivers/raw/Makefile +1 -0
+DIRS-$(CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk diff --git

a/drivers/raw/ifpga_rawdev/Makefile
b/drivers/raw/ifpga_rawdev/Makefile
new file mode 100644
index 0000000..f3b9d5e

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_pmd_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_PMD_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +51 -0
new file mode 100644
index 0000000..32e811c
@@ -0,0 +1,608 @@
+/* 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 new file +124 -0
+	{ .vendor_id = 0, /* sentinel */ }, };
+
+static int
+ifpga_fill_afu_dev(struct opae_accelerator *acc,
+		struct rte_afu_device *afu_dev)
+{
+	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, &region_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();
+
+	if (!dev_info) {
+		IFPGA_RAWDEV_PMD_ERR("Invalid request");
+		return;
+	}
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return;
+
+	afu_dev = dev_info;
+	afu_dev->rawdev = dev;
+
+	/* find opae_accelerator and fill info into afu_device */
+	opae_adapter_for_each_acc(adapter, acc) {
+		if (acc->index != afu_dev->id.port)
+			continue;
+
+		if (ifpga_fill_afu_dev(acc, afu_dev)) {
+			IFPGA_RAWDEV_PMD_ERR("cannot get info\n");
+			return;
+		}
+	}
+}
+
+static int
+ifpga_rawdev_start(struct rte_rawdev *dev) {
+	int ret = 0;
+	struct opae_adapter *adapter;
+
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+
+	RTE_FUNC_PTR_OR_ERR_RET(dev, -EINVAL);
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter)
+		return -ENODEV;
+
+	return ret;
+}
+
+static void
+ifpga_rawdev_stop(struct rte_rawdev *dev) {
+	dev->started = 0;
+}
+
+static int
+ifpga_rawdev_close(struct rte_rawdev *dev) {
+	return dev ? 0:1;
+}
+
+static int
+ifpga_rawdev_reset(struct rte_rawdev *dev) {
+	return dev ? 0:1;
+}
+
+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

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) {
+		IFPGA_RAWDEV_PMD_ERR("%s pr error %d\n", __func__,

ret);

Quoted 22 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +22 -0
+		return ret;
+	}
+
+	ret = opae_bridge_reset(br);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("%s reset port:%d error %d\n",
+				__func__, port_id, ret);
+		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;
+	void *buffer;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	u64 pr_error;
+
+	if (!file_name)
+		return -EINVAL;
+
+	file_fd = open(file_name, O_RDONLY);
+	if (file_fd < 0) {
+		IFPGA_RAWDEV_PMD_ERR("%s: open file error: %s\n",
+				__func__, file_name);
+		IFPGA_RAWDEV_PMD_ERR("Message : %s\n",

strerror(errno));

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5 -0
+		return -EINVAL;
+	}
+	ret = stat(file_name, &file_stat);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("stat on bitstream file

failed: %s\n",

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+				file_name);
+		return -EINVAL;
+	}
+	buffer_size = file_stat.st_size;
+	IFPGA_RAWDEV_PMD_INFO("bitstream file size: %u\n", buffer_size);
+	buffer = rte_malloc(NULL, buffer_size, 0);
+	if (!buffer) {
+		ret = -ENOMEM;
+		goto close_fd;
+	}

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+
+	/*read the raw data*/
+	if (buffer_size != read(file_fd, (void *)buffer, buffer_size)) {
+		ret = -EINVAL;
+		goto free_buffer;
+	}
+
+	/*do PR now*/
+	ret = fpga_pr(rawdev, port_id, buffer, buffer_size, &pr_error);
+	IFPGA_RAWDEV_PMD_INFO("downloading to device

port %d....%s.\n",

Quoted 110 lines

port_id,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +59 -0
+		ret ? "failed" : "success");
+	if (ret) {
+		ret = -EINVAL;
+		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)
+		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) {
+			IFPGA_RAWDEV_PMD_ERR("do pr error %d\n", ret);
+			return ret;
+		}
+	}
+
+	acc = opae_adapter_get_acc(adapter, afu_pr_conf->afu_id.port);
+	if (!acc)
+		return -ENODEV;
+
+	ret = opae_acc_get_uuid(acc, &uuid);
+	if (ret)
+		return ret;
+
+	memcpy(&afu_pr_conf->afu_id.uuid.uuid_low, uuid.b, sizeof(u64));
+	memcpy(&afu_pr_conf->afu_id.uuid.uuid_high, uuid.b + 8,
+sizeof(u64));
+
+	IFPGA_RAWDEV_PMD_INFO("%s: uuid_l=0x%lx, uuid_h=0x%lx\n",

__func__,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +49 -0
+		(u64)afu_pr_conf->afu_id.uuid.uuid_low,
+		(u64)afu_pr_conf->afu_id.uuid.uuid_high);
+
+	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 = NULL;
+	struct opae_manager *mgr = NULL;
+	struct opae_adapter_data_pci *data = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	int i;
+
+	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",

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 8 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1 -0
+		pci_dev->addr.bus, pci_dev->addr.devid, pci_dev-

addr.function);

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),

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 8 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +8 -0
+					 socket_id);
+	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

*/

Quoted 61 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +9 -0
+	data = opae_adapter_data_alloc(OPAE_FPGA_PCI);
+	if (!data) {
+		ret = -ENOMEM;
+		goto cleanup;
+	}
+
+	/* 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;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +51 -0
+		data->region[i].len = pci_dev->mem_resource[i].len;
+		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) {
+		ret = -ENOMEM;
+		goto free_adapter_data;
+	}
+
+	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)
+		goto free_adapter;
+
+	/* get opae_manager to rawdev */
+	mgr = opae_adapter_get_mgr(adapter);
+	if (mgr) {
+		/* PF function */
+		IFPGA_RAWDEV_PMD_INFO("this is a PF function");
+	}
+
+	return ret;
+
+free_adapter:
+	if (adapter)
+		opae_adapter_free(adapter);
+free_adapter_data:
+	if (data)
+		opae_adapter_data_free(data);
+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];

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	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",

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 9 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +1 -0
+		pci_dev->addr.bus, pci_dev->addr.devid, pci_dev-

addr.function);

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +7 -0
+
+	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);

Quoted 23 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +23 -0
+		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");
+
+	return ret;
+}
+
+static int
+ifpga_rawdev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
+	struct rte_pci_device *pci_dev)
+{
+

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	IFPGA_RAWDEV_PMD_FUNC_TRACE();
+	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,

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5 -0
+	.probe     = ifpga_rawdev_pci_probe,
+	.remove    = ifpga_rawdev_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(ifpga_rawdev_pci_driver,

rte_ifpga_rawdev_pmd);

Quoted 26 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +26 -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;

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+	struct rte_kvargs *kvlist = NULL;
+	int port;
+	char *name = NULL;
+	char dev_name[RTE_RAWDEV_NAME_MAX_LEN];
+
+	devargs = dev->device.devargs;
+
+	kvlist = rte_kvargs_parse(devargs->args, valid_args);
+	if (!kvlist) {
+		IFPGA_RAWDEV_PMD_LOG(ERR, "error when parsing

param");

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 12 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +12 -0
+		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_RAWDEV_PMD_ERR("error to parse %s",
+				     IFPGA_ARG_NAME);
+			goto end;
+		}
+	} else {
+		IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga

bus",

Quoted 5 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +5 -0
+			  IFPGA_ARG_NAME);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {

drivers/raw/ifpga_rawdev/ifpga_rawdev.c

Quoted 10 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +10 -0
+		if (rte_kvargs_process(kvlist,
+			IFPGA_ARG_PORT,
+			&rte_ifpga_get_integer32_arg,
+			&port) < 0) {
+			IFPGA_RAWDEV_PMD_ERR("error to parse %s",
+				IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_RAWDEV_PMD_ERR("arg %s is mandatory for ifpga

bus",

Quoted 151 lines
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +39 -0
+			  IFPGA_ARG_PORT);
+		goto end;
+	}
+
+	memset(dev_name, 0, sizeof(dev_name));
+	snprintf(dev_name, RTE_RAWDEV_NAME_MAX_LEN, "%d|%s",
+	port, name);
+
+	rte_eal_hotplug_add(RTE_STR(IFPGA_BUS_NAME),
+			dev_name, devargs->args);
+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 +13 -0
new file mode 100644
index 0000000..c7759b8
@@ -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, ">>")

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_ */
drivers/raw/ifpga_rawdev/meson.build new file +15 -0
new file mode 100644
index 0000000..6725687
@@ -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

diff --git a/drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map b/drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map new file mode 100644
index 0000000..9b9ab1a

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 index renamed from drivers/raw/meson.build +0 -0

34dfac4..a61cdcc 100644

drivers/raw/meson.build +2 -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 index 3861e1a..acc0ec3 renamed from mk/rte.app.mk +0 -0

100644

mk/rte.app.mk +0 -0
@@ -256,9 +256,11 @@

_LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV) +=

mk/rte.app.mk +3 -5
-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_PMD_IFPGA_RAWDEV)   +=
-lrte_pmd_ifpga_rawdev
+endif # CONFIG_RTE_LIBRTE_IFPGA_BUS
 endif # CONFIG_RTE_LIBRTE_RAWDEV
 
-
 endif # !CONFIG_RTE_BUILD_SHARED_LIBS
 
 _LDLIBS-y += --no-whole-archive
--

1.8.3.1

author
#127 lore raw

v11 cover Introduce Intel FPGA BUS

In reply to Rosen Xu

From: "Xu, Rosen" <[email protected]>

Intel FPGA BUS in DPDK
-------------------------

This patch set introduces Intel FPGA BUS support in DPDK.

v11 updates:
===========
- To improve PR speed OPAE Share Code involved AVX-512, but AVX-512 is not available in all IA platforms, besides this, after we have test several times, using AVX-512 only improve 1 ms.
So this patch we don't use it.
- Fix comments of patch 1 of Jingjing Wu and Qi Zhang.
- Updated configurations parameters form net_ifpga_cfg to ifpga_rawdev_cfg

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                      |  503 ++++++
 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                  |  159 ++
 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             |   26 +
 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       |   58 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1662 ++++++++++++++++++++
 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  |  255 +++
 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    |  381 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  715 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  352 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  127 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  388 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  144 ++
 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         |   79 +
 .../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, 9608 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
author
#128 lore raw

PATCH v11 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               | 503 ++++++++++++++++++++++++++++
 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           | 159 +++++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
 drivers/bus/meson.build                     |   2 +-
 mk/rte.app.mk                               |   1 +
 14 files changed, 866 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
index 7105920..d4870a6 100644
@@ -383,6 +383,10 @@ F: drivers/mempool/bucket/
 Bus Drivers
 -----------
 
+Intel FPGA bus
+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
index 0d181ac..1440316 100644
@@ -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
index 7187348..265950a 100644
@@ -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
index c251b65..ef7f247 100644
@@ -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
new file mode 100644
index 0000000..3ff3bdb
@@ -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 +503 -0

503 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
new file mode 100644
index 0000000..f9254b9
@@ -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
new file mode 100644
index 0000000..873e0a4
@@ -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
new file mode 100644
index 0000000..c9b08c8
@@ -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 +159 -0

159 lines not on this page · raw message

drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10 -0
new file mode 100644
index 0000000..a027979
@@ -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
index 58dfbe2..52c755d 100644
@@ -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
index 26f3563..3861e1a 100644
@@ -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
author
#129 lore raw

PATCH v11 2/3 iFPGA: Add Intel FPGA OPAE Share Code

In reply to Xu, Rosen

From: Tianfei Zhang <[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

---
 MAINTAINERS                                        |    4 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   26 +
 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       |   58 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1662 ++++++++++++++++++++
 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  |  255 +++
 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    |  381 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  715 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  352 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  127 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  388 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  144 ++
 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         |   79 +
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |   75 +
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   45 +
 29 files changed, 7908 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
MAINTAINERS +4 -0
index d4870a6..e1a1ef9 100644
@@ -850,6 +850,10 @@ F: doc/guides/eventdevs/opdl.rst
 Rawdev Drivers
 --------------
 
+Intel FPGA
+M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/base/
+
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
 F: drivers/raw/dpaa2_qdma/
drivers/raw/ifpga_rawdev/base/Makefile new file +26 -0
new file mode 100644
index 0000000..d79da72
@@ -0,0 +1,26 @@
+#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
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/README new file +31 -0
new file mode 100644
index 0000000..5bc2ed0
@@ -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
new file mode 100644
index 0000000..dae7ca1
@@ -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 +58 -0

58 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_defines.h new file +1662 -0

1,662 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
new file mode 100644
index 0000000..14131e3
@@ -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 +255 -0

56 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 +381 -0

381 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 +352 -0

352 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 +388 -0

388 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port_error.c new file +144 -0

144 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/meson.build new file +34 -0
new file mode 100644
index 0000000..cb65535

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
new file mode 100644
index 0000000..a03dff9

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 +79 -0

79 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.

author
#130 lore raw

PATCH v11 3/3 iFPGA: Add Intel FPGA BUS Rawdev Driver

In reply to Xu, Rosen

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

---
 MAINTAINERS                                        |   3 +
 config/common_base                                 |   5 +
 doc/guides/rawdevs/ifpga_rawdev.rst                | 112 ++++
 doc/guides/rawdevs/index.rst                       |   1 +
 doc/guides/rel_notes/release_18_05.rst             |   8 +
 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 +-
 13 files changed, 834 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst
 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
MAINTAINERS +3 -0
index e1a1ef9..2576f86 100644
@@ -851,8 +851,11 @@ Rawdev Drivers
 --------------
 
 Intel FPGA
+M: Rosen Xu <[email protected]>
 M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/
 F: drivers/raw/ifpga_rawdev/base/
+F: doc/guides/rawdevs/ifpga_rawdev.rst
 
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
config/common_base +5 -0
index 1440316..017a15a 100644
@@ -633,6 +633,11 @@ CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV=n
 CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n
 
 #
+# Compile PMD for Intel FPGA raw device
+#
+CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0

112 lines not on this page · raw message

doc/guides/rawdevs/index.rst +1 -0
index 7769083..7c3bd95 100644
@@ -13,3 +13,4 @@ application through rawdev API.
 
     dpaa2_cmdif
     dpaa2_qdma
+    ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +8 -0
index 265950a..f5241a1 100644
@@ -189,6 +189,14 @@ New Features
   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
 -----------
 
drivers/raw/Makefile +1 -0
index 2eb2787..8e29b4a 100644
@@ -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_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
new file mode 100644
index 0000000..f3b9d5e
@@ -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_pmd_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_PMD_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
new file mode 100644
index 0000000..c7759b8
@@ -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
new file mode 100644
index 0000000..6725687
@@ -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
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
drivers/raw/meson.build +1 -1
index 34dfac4..a61cdcc 100644
@@ -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
index 3861e1a..acc0ec3 100644
@@ -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_PMD_IFPGA_RAWDEV)   += -lrte_pmd_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
author
#131 lore raw

v12 cover Introduce Intel FPGA BUS

In reply to Rosen Xu

From: "Xu, Rosen" <[email protected]>

Intel FPGA BUS in DPDK
-------------------------

This patch set introduces Intel FPGA BUS support in DPDK.

v12 updates:
===========
- Remove redundancy data struct ifpga_dev
So all afu_dev list togeter.
- Fix comments from Jingjing Wu and Qi Zhang
- Fix compile issue in BSD flatform
- Take more test in IA platform

v11 updates:
===========
- To improve PR speed OPAE Share Code involved AVX-512, but AVX-512 is not available in all IA platforms, besides this, after we have test several times, using AVX-512 only improve 1 ms.
So this patch we don't use it.
- Fix comments of patch 1 of Jingjing Wu and Qi Zhang.
- Updated configurations parameters form net_ifpga_cfg to ifpga_rawdev_cfg

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                      |  464 ++++++
 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                  |  150 ++
 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             |   26 +
 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       |   58 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1662 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  821 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   11 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  253 +++
 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    |  381 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  715 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  352 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  127 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  388 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  144 ++
 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         |   79 +
 .../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            |  619 ++++++++
 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, 9566 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
author
#132 lore raw

PATCH v12 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               | 464 ++++++++++++++++++++++++++++
 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           | 150 +++++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
 drivers/bus/meson.build                     |   2 +-
 mk/rte.app.mk                               |   1 +
 14 files changed, 818 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
index 7cc8860..39c3988 100644
@@ -401,6 +401,10 @@ F: drivers/mempool/bucket/
 Bus Drivers
 -----------
 
+Intel FPGA bus
+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
index 28557ed..49704ad 100644
@@ -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
index 458b47f..1053311 100644
@@ -208,6 +208,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
index c251b65..ef7f247 100644
@@ -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
new file mode 100644
index 0000000..3ff3bdb
@@ -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 +464 -0

464 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
new file mode 100644
index 0000000..f9254b9
@@ -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
new file mode 100644
index 0000000..873e0a4
@@ -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
new file mode 100644
index 0000000..c9b08c8
@@ -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 +150 -0

150 lines not on this page · raw message

drivers/bus/ifpga/rte_bus_ifpga_version.map new file +10 -0
new file mode 100644
index 0000000..a027979
@@ -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
index 58dfbe2..52c755d 100644
@@ -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
index 6807663..290fdf2 100644
@@ -261,6 +261,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
author
#133 lore raw

PATCH v12 2/3 iFPGA: Add Intel FPGA OPAE Share Code

In reply to Xu, Rosen

From: Tianfei Zhang <[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

---
 MAINTAINERS                                        |    4 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   26 +
 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       |   58 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1662 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  821 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   11 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  253 +++
 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    |  381 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  715 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  352 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  127 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  388 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  144 ++
 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         |   79 +
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |   75 +
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   45 +
 29 files changed, 7903 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
MAINTAINERS +4 -0
index 39c3988..a872973 100644
@@ -880,6 +880,10 @@ F: doc/guides/eventdevs/opdl.rst
 Rawdev Drivers
 --------------
 
+Intel FPGA
+M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/base/
+
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
 F: drivers/raw/dpaa2_qdma/
drivers/raw/ifpga_rawdev/base/Makefile new file +26 -0
new file mode 100644
index 0000000..d79da72
@@ -0,0 +1,26 @@
+#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
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/README new file +31 -0
new file mode 100644
index 0000000..5bc2ed0
@@ -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
new file mode 100644
index 0000000..dae7ca1
@@ -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 +58 -0

58 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_defines.h new file +1662 -0

1,662 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c new file +821 -0

821 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +11 -0
new file mode 100644
index 0000000..14131e3
@@ -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 +253 -0

59 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 +381 -0

381 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 +352 -0

352 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 +388 -0

388 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port_error.c new file +144 -0

144 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/meson.build new file +34 -0
new file mode 100644
index 0000000..cb65535

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
new file mode 100644
index 0000000..a03dff9

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 +79 -0

79 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.

author
#134 lore raw

PATCH v12 3/3 iFPGA: Add Intel FPGA BUS Rawdev Driver

In reply to Xu, Rosen

From: Rosen Xu <[email protected]>

Add Intel FPGA BUS Rawdev Driver which is based on librte_rawdev library.

---
 MAINTAINERS                                        |   3 +
 config/common_base                                 |   5 +
 doc/guides/rawdevs/ifpga_rawdev.rst                | 112 ++++
 doc/guides/rawdevs/index.rst                       |   1 +
 doc/guides/rel_notes/release_18_05.rst             |   8 +
 drivers/raw/Makefile                               |   1 +
 drivers/raw/ifpga_rawdev/Makefile                  |  36 ++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 619 +++++++++++++++++++++
 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 +-
 13 files changed, 845 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst
 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
MAINTAINERS +3 -0
index a872973..61b7a35 100644
@@ -881,8 +881,11 @@ Rawdev Drivers
 --------------
 
 Intel FPGA
+M: Rosen Xu <[email protected]>
 M: Tianfei zhang <[email protected]>
+F: drivers/raw/ifpga_rawdev/
 F: drivers/raw/ifpga_rawdev/base/
+F: doc/guides/rawdevs/ifpga_rawdev.rst
 
 NXP DPAA2 QDMA
 M: Nipun Gupta <[email protected]>
config/common_base +5 -0
index 49704ad..452e800 100644
@@ -650,6 +650,11 @@ CONFIG_RTE_LIBRTE_PMD_DPAA2_CMDIF_RAWDEV=n
 CONFIG_RTE_LIBRTE_PMD_DPAA2_QDMA_RAWDEV=n
 
 #
+# Compile PMD for Intel FPGA raw device
+#
+CONFIG_RTE_LIBRTE_PMD_IFPGA_RAWDEV=y
+
+#
 # Compile librte_ring
 #
 CONFIG_RTE_LIBRTE_RING=y
doc/guides/rawdevs/ifpga_rawdev.rst new file +112 -0

112 lines not on this page · raw message

doc/guides/rawdevs/index.rst +1 -0
index 7769083..7c3bd95 100644
@@ -13,3 +13,4 @@ application through rawdev API.
 
     dpaa2_cmdif
     dpaa2_qdma
+    ifpga_rawdev
doc/guides/rel_notes/release_18_05.rst +8 -0
index 1053311..1257f17 100644
@@ -214,6 +214,14 @@ New Features
   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
 -----------
 
drivers/raw/Makefile +1 -0
index 2eb2787..8e29b4a 100644
@@ -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_PMD_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
new file mode 100644
index 0000000..f3b9d5e
@@ -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_pmd_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_PMD_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +619 -0

619 lines not on this page · raw message

drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
new file mode 100644
index 0000000..c7759b8
@@ -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
new file mode 100644
index 0000000..6725687
@@ -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
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
drivers/raw/meson.build +1 -1
index 34dfac4..a61cdcc 100644
@@ -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
index 290fdf2..9511f20 100644
@@ -262,9 +262,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_PMD_IFPGA_RAWDEV)   += -lrte_pmd_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
Reviewed-by on the v12 series
#135 lore raw
In reply to Xu, Rosen
Quoted 15 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Friday, May 11, 2018 4:31 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 v12 0/3] Introduce Intel FPGA BUS

Quoted 7 lines

From: "Xu, Rosen" <[email protected]>

Intel FPGA BUS in DPDK
-------------------------

This patch set introduces Intel FPGA BUS support in DPDK.

Though opens remains, overall is OK, no objection for merge.

author
#136 lore raw

Thanks Qi.

Quoted 41 lines

-----Original Message-----
From: Zhang, Qi Z
Sent: Friday, May 11, 2018 20:12
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 v12 0/3] Introduce Intel FPGA BUS

Quoted 13 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Friday, May 11, 2018 4:31 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 v12 0/3] Introduce Intel FPGA BUS

Quoted 7 lines

From: "Xu, Rosen" <[email protected]>

Intel FPGA BUS in DPDK
-------------------------

This patch set introduces Intel FPGA BUS support in DPDK.

Though opens remains, overall is OK, no objection for merge.

author
#138 lore raw

PATCH 1/1 raw/ifpga/base: fix compile error on ia32 icc compiler

In reply to Rosen Xu

From: "Zhang, Tianfei" <[email protected]>

fix compile error on ia32 icc compiler

Fixes 56bb54ea1bdf ("raw/ifpga: add Intel FPGA bus rawdev driver")
---
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h +7 -3
index cd114fb..7a39a58 100644
@@ -16,16 +16,20 @@
 	return &hw->port[port_id];
 }
 
-#define ifpga_for_each_feature(hw, feature)		\
+#define ifpga_for_each_fme_feature(hw, feature)		\
 	for ((feature) = (hw)->sub_feature;			\
 	   (feature) < (hw)->sub_feature + (FME_FEATURE_ID_MAX); (feature)++)
 
+#define ifpga_for_each_port_feature(hw, feature)		\
+	for ((feature) = (hw)->sub_feature;			\
+	   (feature) < (hw)->sub_feature + (PORT_FEATURE_ID_MAX); (feature)++)
+
 static inline struct feature *
 get_fme_feature_by_id(struct ifpga_fme_hw *fme, u64 id)
 {
 	struct feature *feature;
 
-	ifpga_for_each_feature(fme, feature) {
+	ifpga_for_each_fme_feature(fme, feature) {
 		if (feature->id == id)
 			return feature;
 	}
@@ -38,7 +42,7 @@
 {
 	struct feature *feature;
 
-	ifpga_for_each_feature(port, feature) {
+	ifpga_for_each_port_feature(port, feature) {
 		if (feature->id == id)
 			return feature;
 	}
Signature · 1 line
1.8.3.1
Tested-by Pablo de Lara on v1 1/1
#139 lore raw

Re: [PATCH] raw/ifpga/base: fix compile error on ia32 icc compiler

Quoted 16 lines

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Xu, Rosen
Sent: Monday, May 14, 2018 10:59 AM
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]; [email protected]
Subject: [dpdk-dev] [PATCH] raw/ifpga/base: fix compile error on ia32 icc compiler

Quoted 3 lines

From: "Zhang, Tianfei" <[email protected]>

fix compile error on ia32 icc compiler

This is also applicable for 64-bit icc compilation.

Quoted 3 lines
Fixes 56bb54ea1bdf ("raw/ifpga: add Intel FPGA bus rawdev driver")

No need to cc stable, as this is fixing code from this release.

Quoted 2 lines
#140 lore raw

Re: [PATCH] raw/ifpga/base: fix compile error on ia32 icc compiler

Quoted 10 lines
Quoted 3 lines

From: "Zhang, Tianfei" <[email protected]>

fix compile error on ia32 icc compiler

This is also applicable for 64-bit icc compilation.

Quoted 3 lines
Fixes 56bb54ea1bdf ("raw/ifpga: add Intel FPGA bus rawdev driver")
Quoted 6 lines

No need to cc stable, as this is fixing code from this release.

Quoted 2 lines

Applied, thanks

author
#141 lore raw

PATCH 1/1 drivers/bus/ifpga/: fix Coverity issue

In reply to Rosen Xu

Fix Coverity issue: 279455, 279459 and 279454

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")

Coverity issue: 279455, 279459 and 279454
Cc: [email protected]

---
 drivers/bus/ifpga/ifpga_bus.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +9 -6
index 45597a1..b324872 100644
@@ -156,27 +156,30 @@ void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
 	if (rawdev->dev_ops &&
 		rawdev->dev_ops->dev_start &&
 		rawdev->dev_ops->dev_start(rawdev))
-		goto free_dev;
+		goto end;
 
 	strlcpy(afu_pr_conf.bs_path, path, sizeof(afu_pr_conf.bs_path));
-	if (rawdev->dev_ops->firmware_load &&
+	if (rawdev->dev_ops &&
+		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;
+		goto end;
 	}
 	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;
 
+	rte_kvargs_free(kvlist);
+	free(path);
 	return afu_dev;
 
-free_dev:
-	free(afu_dev);
 end:
 	if (kvlist)
 		rte_kvargs_free(kvlist);
 	if (path)
 		free(path);
+	if (afu_dev)
+		free(afu_dev);
 
 	return NULL;
 }
@@ -367,7 +370,7 @@ void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
 		return -EINVAL;
 
 	afu_dev = RTE_DEV_TO_AFU(dev);
-	if (!dev)
+	if (!afu_dev)
 		return -ENOENT;
 
 	devargs = dev->devargs;
Signature · 1 line
1.8.3.1
#142 lore raw

Re: [dpdk-stable] [PATCH] drivers/bus/ifpga/: fix Coverity issue

16/05/2018 15:48, Rosen Xu:

Quoted 7 lines

Fix Coverity issue: 279455, 279459 and 279454

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")

Coverity issue: 279455, 279459 and 279454
Cc: [email protected]

The commit message should explain what was the issue.

FYI, it should look like this:

"
bus/ifpga: fix <scope of the change>

<explanation of the issue>

Coverity issue: 279455, 279459, 279454

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")

"

author
#143 lore raw

v2 cover Fix bus/ifpga coverity issue: 279455, 279459 and 279454

In reply to Rosen Xu

This patch set fix bus/ifpga coverity issue: 279455, 279459 and 279454

v2 updates:
===========
- Add more description, devide to 3 patches

v1 updates:
===========
- Fix Coverity issue: 279455, 279459 and 279454

Rosen Xu (3):
bus/ifpga: fix error control flow issue
bus/ifpga: fix resource leaks issue
bus/ifpga: fix null pointer dereferences issue

 drivers/bus/ifpga/ifpga_bus.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
author
#144 lore raw

PATCH v2 1/3 bus/ifpga: fix error control flow issue

The control variable should be afu_dev not dev.

Coverity issue: 279455

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")
---
 drivers/bus/ifpga/ifpga_bus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bus/ifpga/ifpga_bus.c +1 -1
index 45597a1..675b9a3 100644
@@ -367,7 +367,7 @@ void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
 		return -EINVAL;
 
 	afu_dev = RTE_DEV_TO_AFU(dev);
-	if (!dev)
+	if (!afu_dev)
 		return -ENOENT;
 
 	devargs = dev->devargs;
Signature · 1 line
1.8.3.1
author
#145 lore raw

PATCH v2 2/3 bus/ifpga: fix resource leaks issue

In reply to Rosen Xu

There are some resource leaks in ifpga_scan_one.
This patch fixes it.

Coverity issue: 279459

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")
---
 drivers/bus/ifpga/ifpga_bus.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/bus/ifpga/ifpga_bus.c +6 -4
index 675b9a3..db16173 100644
@@ -156,27 +156,29 @@ void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
 	if (rawdev->dev_ops &&
 		rawdev->dev_ops->dev_start &&
 		rawdev->dev_ops->dev_start(rawdev))
-		goto free_dev;
+		goto end;
 
 	strlcpy(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;
+		goto end;
 	}
 	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;
 
+	rte_kvargs_free(kvlist);
+	free(path);
 	return afu_dev;
 
-free_dev:
-	free(afu_dev);
 end:
 	if (kvlist)
 		rte_kvargs_free(kvlist);
 	if (path)
 		free(path);
+	if (afu_dev)
+		free(afu_dev);
 
 	return NULL;
 }
Signature · 1 line
1.8.3.1
author
#146 lore raw

PATCH v2 3/3 bus/ifpga: fix null pointer dereferences issue

In reply to Rosen Xu

Fix ifpga_scan_one() null pointer dereferences issue.

Coverity issue: 279454

Fixes 05fa3d4a6539 ("bus/ifpga: add Intel FPGA bus library")
---
 drivers/bus/ifpga/ifpga_bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/bus/ifpga/ifpga_bus.c +2 -1
index db16173..b324872 100644
@@ -159,7 +159,8 @@ void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
 		goto end;
 
 	strlcpy(afu_pr_conf.bs_path, path, sizeof(afu_pr_conf.bs_path));
-	if (rawdev->dev_ops->firmware_load &&
+	if (rawdev->dev_ops &&
+		rawdev->dev_ops->firmware_load &&
 		rawdev->dev_ops->firmware_load(rawdev,
 				&afu_pr_conf)){
 		IFPGA_BUS_ERR("firmware load error %d\n", ret);
Signature · 1 line
1.8.3.1
#147 lore raw

Re: [PATCH v2 0/3] Fix bus/ifpga coverity issue: 279455, 279459 and 279454

In reply to Rosen Xu
Quoted 4 lines

Rosen Xu (3):
bus/ifpga: fix error control flow issue
bus/ifpga: fix resource leaks issue
bus/ifpga: fix null pointer dereferences issue

Applied, thanks

author
#148 lore raw

Re: [PATCH v2 0/3] Fix bus/ifpga coverity issue: 279455, 279459 and 279454

Thanks a lot Thomas.

Quoted 22 lines

-----Original Message-----
From: Thomas Monjalon [mailto:[email protected]]
Sent: Tuesday, May 22, 2018 23:16
To: Xu, Rosen <[email protected]>
Cc: [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 v2 0/3] Fix bus/ifpga coverity issue: 279455, 279459 and 279454

Quoted 4 lines

Rosen Xu (3):
bus/ifpga: fix error control flow issue
bus/ifpga: fix resource leaks issue
bus/ifpga: fix null pointer dereferences issue

Applied, thanks