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 1 of 3

lore
Share & tools
lore

Rosen Xu

author
#0 lore raw

cover Introduce Intel FPGA BUS

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

This patch set introduces Intel FPGA BUS support in DPDK.

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.

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.

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
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream

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.

Patch set Information
====================

This patch set includes 6 patches:
* 0 : Introduce the Intel FPGA BUS library and enable its compilation.
* 1 : Adds command parse code, for start-up application
with Intel FPGA BUS.
* 2 : Adds Driver Probe Code, for AFU Drivers should probed after PCI Drivers.
* 3 : Adds Intel FPGA BUS library code, for AFU Device scan and AFU Drivers probe.
* 4 : Adds a Intel FPGA rawdevice driver, for FPGA Device Management such as PR.
* 5 : Adds Intel OPAE(Open Programmable Acceleration Engine) Share Code, it's Intel FPGA Software Stack.

Rosen Xu (5):
Add Intel FPGA BUS Command Parse Code
Add Intel FPGA BUS Probe Code
Add Intel FPGA BUS Lib Code
Add Intel FPGA BUS Rawdev Code
Add Intel OPAE Share Code

 drivers/bus/ifpga/Makefile                         |   64 +
 drivers/bus/ifpga/ifpga_bus.c                      |  573 +++++++
 drivers/bus/ifpga/ifpga_common.c                   |  154 ++
 drivers/bus/ifpga/ifpga_common.h                   |   25 +
 drivers/bus/ifpga/ifpga_logs.h                     |   32 +
 drivers/bus/ifpga/rte_bus_ifpga.h                  |  141 ++
 drivers/bus/ifpga/rte_bus_ifpga_version.map        |    8 +
 drivers/raw/Makefile                               |    1 +
 drivers/raw/ifpga_rawdev/Makefile                  |   63 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  543 +++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   77 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1696 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  861 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  340 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  197 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  763 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  395 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  152 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  730 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  236 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  389 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  276 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  151 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  293 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  111 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            |  486 ++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |   38 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c    |   99 ++
 .../ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map  |    4 +
 lib/librte_eal/common/eal_common_bus.c             |   14 +-
 lib/librte_eal/common/eal_common_options.c         |    8 +-
 lib/librte_eal/common/eal_options.h                |    2 +
 42 files changed, 10944 insertions(+), 2 deletions(-)
 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/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/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
 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/ifpga_rawdev_example.c
 create mode 100644 drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/5 Add Intel FPGA BUS Command Parse Code

---
 lib/librte_eal/common/eal_common_options.c | 8 +++++++-
 lib/librte_eal/common/eal_options.h        | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_options.c +7 -1
index 9f2f8d2..4fe0875 100644
@@ -73,6 +73,7 @@
 	{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
 	{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
 	{OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
+	{OPT_IFPGA,             1, NULL, OPT_IFPGA_NUM            },
 	{0,                     0, NULL, 0                        }
 };
 
@@ -1160,7 +1161,12 @@ static int xdigit2val(unsigned char c)
 
 		core_parsed = LCORE_OPT_MAP;
 		break;
-
+	case OPT_IFPGA_NUM:
+		if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
+				optarg) < 0) {
+			return -1;
+		}
+		break;
 	/* don't know what to do, leave this to caller */
 	default:
 		return 1;
lib/librte_eal/common/eal_options.h +2 -0
index e86c711..bdbb2c4 100644
@@ -55,6 +55,8 @@ enum {
 	OPT_VFIO_INTR_NUM,
 #define OPT_VMWARE_TSC_MAP    "vmware-tsc-map"
 	OPT_VMWARE_TSC_MAP_NUM,
+#define OPT_IFPGA              "ifpga"
+	OPT_IFPGA_NUM,
 	OPT_LONG_MAX_NUM
 };
 
Signature · 1 line
1.8.3.1
author
#2 lore raw

PATCH 2/5 Add Intel FPGA BUS Probe Code

In reply to Rosen Xu
---
 lib/librte_eal/common/eal_common_bus.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_bus.c +13 -1
index 3e022d5..e3bcebe 100644
@@ -87,7 +87,7 @@ struct rte_bus_list rte_bus_list =
 rte_bus_probe(void)
 {
 	int ret;
-	struct rte_bus *bus, *vbus = NULL;
+	struct rte_bus *bus, *vbus = NULL, *ifpga_bus = NULL;
 
 	TAILQ_FOREACH(bus, &rte_bus_list, next) {
 		if (!strcmp(bus->name, "vdev")) {
@@ -95,6 +95,11 @@ struct rte_bus_list rte_bus_list =
 			continue;
 		}
 
+		if (!strcmp(bus->name, "ifpga")) {
+			ifpga_bus = bus;
+			continue;
+		}
+
 		ret = bus->probe();
 		if (ret)
 			RTE_LOG(ERR, EAL, "Bus (%s) probe failed.\n",
@@ -108,6 +113,13 @@ struct rte_bus_list rte_bus_list =
 				vbus->name);
 	}
 
+	if (ifpga_bus) {
+		ret = ifpga_bus->probe();
+		if (ret)
+			RTE_LOG(ERR, EAL, "Scan for (%s) bus failed.\n",
+				ifpga_bus->name);
+	}
+
 	return 0;
 }
 
Signature · 1 line
1.8.3.1
author
#3 lore raw

PATCH 3/5 Add Intel FPGA BUS Lib Code

In reply to Rosen Xu
---
 drivers/bus/ifpga/Makefile                  |  64 ++++
 drivers/bus/ifpga/ifpga_bus.c               | 573 ++++++++++++++++++++++++++++
 drivers/bus/ifpga/ifpga_common.c            | 154 ++++++++
 drivers/bus/ifpga/ifpga_common.h            |  25 ++
 drivers/bus/ifpga/ifpga_logs.h              |  32 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 141 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 7 files changed, 997 insertions(+)
 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/rte_bus_ifpga.h
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
drivers/bus/ifpga/Makefile new file +64 -0
new file mode 100644
index 0000000..c71f186
@@ -0,0 +1,64 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2017 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+LIBABIVER := 1
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+ifeq ($(CONFIG_RTE_LIBRTE_DPAA2_DEBUG_INIT),y)
+CFLAGS += -O0 -g
+CFLAGS += "-Wno-error"
+else
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+endif
+
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga
+CFLAGS += -I$(RTE_SDK)/drivers/bus/pci
+CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal
+CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common
+#CFLAGS += -I$(RTE_SDK)/lib/librte_rawdev
+#LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -lrte_rawdev
+LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
+#LDLIBS += -lrte_ethdev
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
+        ifpga_bus.c \
+        ifpga_common.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +573 -0

573 lines not on this page · raw message

drivers/bus/ifpga/ifpga_common.c new file +154 -0

154 lines not on this page · raw message

drivers/bus/ifpga/ifpga_common.h new file +25 -0
new file mode 100644
index 0000000..23b68d4
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation.
+ * Copyright 2013-2014 6WIND S.A.
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_pci_addr_cmp_1(const struct rte_pci_addr *pci_addr0,
+	const struct rte_pci_addr *pci_addr1);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +32 -0
new file mode 100644
index 0000000..36b9b3f
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation.
+ * Copyright 2013-2014 6WIND S.A.
+ */
+
+#ifndef _IFPGA_BUS_LOGS_H_
+#define _IFPGA_BUS_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/rte_bus_ifpga.h new file +141 -0

141 lines not on this page · raw message

drivers/bus/ifpga/rte_bus_ifpga_version.map new file +8 -0
new file mode 100644
index 0000000..e2aa7da
@@ -0,0 +1,8 @@
+DPDK_17.11 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;
+
+	local: *;
+};
Signature · 1 line
1.8.3.1
author
#4 lore raw

PATCH 4/5 Add Intel FPGA BUS Rawdev Code

In reply to Rosen Xu
---
 drivers/raw/Makefile                               |   1 +
 drivers/raw/ifpga_rawdev/Makefile                  |  63 +++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 486 +++++++++++++++++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  38 ++
 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c    |  99 +++++
 .../ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map  |   4 +
 6 files changed, 691 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c
 create mode 100644 drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map
drivers/raw/Makefile +1 -0
index da7c8b4..47cc567 100644
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 # DIRS-$(<configuration>) += <directory>
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev
+DIRS-y += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +63 -0

63 lines not on this page · raw message

drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +486 -0

486 lines not on this page · raw message

drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +38 -0
new file mode 100644
index 0000000..f346d1a
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2015 Intel Corporation.
+ * Copyright 2013-2014 6WIND S.A.
+ */
+
+#ifndef _IFPGA_RAWDEV_H_
+#define _IFPGA_RAWDEV_H_
+
+extern int ifpga_rawdev_logtype;
+
+#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \
+		__func__, ##args)
+
+#define IFPGA_RAWDEV_PMD_FUNC_TRACE() IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>")
+
+#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args)
+
+enum ifpga_rawdev_device_state {
+	IFPGA_IDLE,
+	IFPGA_READY,
+	IFPGA_ERROR
+};
+
+static inline struct opae_adapter *
+ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
+{
+	return rawdev->dev_private;
+}
+
+#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c new file +99 -0

99 lines not on this page · raw message

drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map new file +4 -0
new file mode 100644
index 0000000..179140f
@@ -0,0 +1,4 @@
+DPDK_18.02 {
+
+	local: *;
+};
Signature · 1 line
1.8.3.1
author
#5 lore raw

PATCH 5/5 Add Intel OPAE Share Code

In reply to Rosen Xu
---
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  543 +++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   77 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1696 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  861 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  340 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  197 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  763 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  395 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  152 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  730 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  236 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  389 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  276 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  151 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  293 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  111 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 26 files changed, 9234 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +54 -0
new file mode 100644
index 0000000..9c0d64b
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+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 += ifpga_fme_pr.c
+SRCS-y += opae_hw_api.c
+SRCS-y += opae_ifpga_hw_api.c
+SRCS-y += opae_debug.c
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +543 -0

543 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +77 -0

77 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +84 -0

84 lines not on this page · raw message

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

1,696 lines not on this page · raw message

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

546 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +38 -0
new file mode 100644
index 0000000..0df7b2f

Lines of this file are not shown. View the raw message.

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +340 -0

340 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +197 -0

197 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +763 -0

763 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +328 -0

328 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +430 -0

430 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +742 -0

742 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +395 -0

395 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +152 -0

152 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +730 -0

730 lines not on this page · raw message

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

236 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.c new file +126 -0

126 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.h new file +46 -0

46 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +389 -0

389 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +276 -0

276 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +151 -0

151 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +293 -0

293 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +111 -0

111 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +104 -0

104 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +72 -0

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

#6 lore raw
In reply to Rosen Xu

Hi Rosen,

Unless I'm mistaken, this is the v1? Did you mean to send the v2 instead and got mixed up or did I miss something?

I would have the same remarks regarding PCI parsing of devices etc.

Can you send the v2 as a response to this cover-letter? You have to take the Message-ID of the previous patch and use "--in-reply-to" option from git-send-email.

Quoted 149 lines · Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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.

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.

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
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream

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.

Patch set Information
====================

This patch set includes 6 patches:
* 0 : Introduce the Intel FPGA BUS library and enable its compilation.
* 1 : Adds command parse code, for start-up application
with Intel FPGA BUS.
* 2 : Adds Driver Probe Code, for AFU Drivers should probed after PCI Drivers.
* 3 : Adds Intel FPGA BUS library code, for AFU Device scan and AFU Drivers probe.
* 4 : Adds a Intel FPGA rawdevice driver, for FPGA Device Management such as PR.
* 5 : Adds Intel OPAE(Open Programmable Acceleration Engine) Share Code, it's Intel FPGA Software Stack.

Rosen Xu (5):
Add Intel FPGA BUS Command Parse Code
Add Intel FPGA BUS Probe Code
Add Intel FPGA BUS Lib Code
Add Intel FPGA BUS Rawdev Code
Add Intel OPAE Share Code

 drivers/bus/ifpga/Makefile                         |   64 +
 drivers/bus/ifpga/ifpga_bus.c                      |  573 +++++++
 drivers/bus/ifpga/ifpga_common.c                   |  154 ++
 drivers/bus/ifpga/ifpga_common.h                   |   25 +
 drivers/bus/ifpga/ifpga_logs.h                     |   32 +
 drivers/bus/ifpga/rte_bus_ifpga.h                  |  141 ++
 drivers/bus/ifpga/rte_bus_ifpga_version.map        |    8 +
 drivers/raw/Makefile                               |    1 +
 drivers/raw/ifpga_rawdev/Makefile                  |   63 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  543 +++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   77 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1696 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  861 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  340 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  197 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  763 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  395 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  152 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  730 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  236 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  389 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  276 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  151 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  293 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  111 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            |  486 ++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |   38 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c    |   99 ++
 .../ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map  |    4 +
 lib/librte_eal/common/eal_common_bus.c             |   14 +-
 lib/librte_eal/common/eal_common_options.c         |    8 +-
 lib/librte_eal/common/eal_options.h                |    2 +
 42 files changed, 10944 insertions(+), 2 deletions(-)
 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/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/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
 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/ifpga_rawdev_example.c
 create mode 100644 drivers/raw/ifpga_rawdev/rte_pmd_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
Signature · 2 lines
Gaëtan Rivet
6WIND
author
#7 lore raw

v3 cover Introduce Intel FPGA BUS

In reply to Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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 (6):
Add Intel FPGA BUS Command Parse Code config/common_base: Add Intel FPGA Build Configuration Macro mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App
Script
drivers/bus: Add Intel FPGA Bus Lib Code drivers/raw/ifpga_rawdev: Add Intel FPGA Rawdev Driver Code drivers/raw/ifpga_rawdev: Add Intel FPGA OPAE Share Code

 config/common_base                                 |    6 +
 drivers/bus/Makefile                               |    1 +
 drivers/bus/ifpga/Makefile                         |   33 +
 drivers/bus/ifpga/ifpga_bus.c                      |  562 +++++++
 drivers/bus/ifpga/ifpga_common.c                   |  141 ++
 drivers/bus/ifpga/ifpga_common.h                   |   22 +
 drivers/bus/ifpga/ifpga_logs.h                     |   31 +
 drivers/bus/ifpga/rte_bus_ifpga.h                  |  140 ++
 drivers/bus/ifpga/rte_bus_ifpga_version.map        |    8 +
 drivers/raw/Makefile                               |    1 +
 drivers/raw/ifpga_rawdev/Makefile                  |   35 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  543 +++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   77 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1696 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  861 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  340 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  197 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  763 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  395 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  154 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  735 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  236 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  389 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  276 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  173 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  306 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  111 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            |  492 ++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |   37 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c    |   98 ++
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |    4 +
 lib/librte_eal/common/eal_common_options.c         |    8 +-
 lib/librte_eal/common/eal_options.h                |    2 +
 mk/rte.app.mk                                      |    3 +
 44 files changed, 10899 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/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/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
 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/ifpga_rawdev_example.c
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
author
#8 lore raw

PATCH v3 1/6 Add Intel FPGA BUS Command Parse Code

---
 lib/librte_eal/common/eal_common_options.c | 8 +++++++-
 lib/librte_eal/common/eal_options.h        | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_options.c +7 -1
index 9f2f8d2..4fe0875 100644
@@ -73,6 +73,7 @@
 	{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
 	{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
 	{OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
+	{OPT_IFPGA,             1, NULL, OPT_IFPGA_NUM            },
 	{0,                     0, NULL, 0                        }
 };
 
@@ -1160,7 +1161,12 @@ static int xdigit2val(unsigned char c)
 
 		core_parsed = LCORE_OPT_MAP;
 		break;
-
+	case OPT_IFPGA_NUM:
+		if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
+				optarg) < 0) {
+			return -1;
+		}
+		break;
 	/* don't know what to do, leave this to caller */
 	default:
 		return 1;
lib/librte_eal/common/eal_options.h +2 -0
index e86c711..bdbb2c4 100644
@@ -55,6 +55,8 @@ enum {
 	OPT_VFIO_INTR_NUM,
 #define OPT_VMWARE_TSC_MAP    "vmware-tsc-map"
 	OPT_VMWARE_TSC_MAP_NUM,
+#define OPT_IFPGA              "ifpga"
+	OPT_IFPGA_NUM,
 	OPT_LONG_MAX_NUM
 };
 
Signature · 1 line
1.8.3.1
#9 lore raw

Re: [PATCH v3 1/6] Add Intel FPGA BUS Command Parse Code

Quoted 19 lines · Rosen Xu
---
 lib/librte_eal/common/eal_common_options.c | 8 +++++++-
 lib/librte_eal/common/eal_options.h        | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_options.c +1 -0
index 9f2f8d2..4fe0875 100644
@@ -73,6 +73,7 @@
 	{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
 	{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
 	{OPT_VMWARE_TSC_MAP,    0, NULL, OPT_VMWARE_TSC_MAP_NUM   },
+	{OPT_IFPGA,             1, NULL, OPT_IFPGA_NUM            },
 	{0,                     0, NULL, 0                        }
 };
 

lib/librte_eal/common/eal_common_options.c static int xdigit2val(unsigned char c) · line 1169

Quoted 10 lines
lib/librte_eal/common/eal_common_options.c +6 -1
@@ -1160,7 +1161,12 @@ static int xdigit2val(unsigned char c)
 
 		core_parsed = LCORE_OPT_MAP;
 		break;
-
+	case OPT_IFPGA_NUM:
+		if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
+				optarg) < 0) {
+			return -1;
+		}
+		break;

why do you need to add a new option if you only insert a virtual devargs?

Why wouldn't --vdev option work instead? and for that matter, I was expecting you to provide a PCI address. Can you give a command line showing how you create your device? The devtype is essentially ignored currently (at option stage, maybe there are still cruft left in PCI bus), instead the devargs parsing will detect the bus from the given optarg.

This part of EAL will change rather soon, I'd prefer not to deal with additional options unless necessary.

Quoted 19 lines
lib/librte_eal/common/eal_common_options.c +0 -0
 	/* don't know what to do, leave this to caller */
 	default:
 		return 1;
lib/librte_eal/common/eal_options.h +2 -0
index e86c711..bdbb2c4 100644
@@ -55,6 +55,8 @@ enum {
 	OPT_VFIO_INTR_NUM,
 #define OPT_VMWARE_TSC_MAP    "vmware-tsc-map"
 	OPT_VMWARE_TSC_MAP_NUM,
+#define OPT_IFPGA              "ifpga"
+	OPT_IFPGA_NUM,
 	OPT_LONG_MAX_NUM
 };
 
Signature · 1 line
1.8.3.1
Signature · 2 lines
Gaëtan Rivet
6WIND
author
#10 lore raw

Re: [PATCH v3 1/6] Add Intel FPGA BUS Command Parse Code

Quoted 46 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:26
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 1/6] Add Intel FPGA BUS Command Parse Code

Quoted 12 lines · Rosen Xu
---
 lib/librte_eal/common/eal_common_options.c | 8 +++++++-
 lib/librte_eal/common/eal_options.h        | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_options.c +0 -0
index 9f2f8d2..4fe0875 100644

lib/librte_eal/common/eal_common_options.c line 75

Quoted 3 lines
lib/librte_eal/common/eal_common_options.c +0 -0
@@ -73,6 +73,7 @@
 	{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
 	{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
 	{OPT_VMWARE_TSC_MAP,    0, NULL,

OPT_VMWARE_TSC_MAP_NUM },

Quoted 5 lines
lib/librte_eal/common/eal_common_options.c +1 -0
+	{OPT_IFPGA,             1, NULL, OPT_IFPGA_NUM            },
 	{0,                     0, NULL, 0                        }
 };
 

lib/librte_eal/common/eal_common_options.c static int xdigit2val(unsigned char c) · line 1169

Quoted 10 lines
lib/librte_eal/common/eal_common_options.c +6 -1
@@ -1160,7 +1161,12 @@ static int xdigit2val(unsigned char c)
 
 		core_parsed = LCORE_OPT_MAP;
 		break;
-
+	case OPT_IFPGA_NUM:
+		if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
+				optarg) < 0) {
+			return -1;
+		}
+		break;

why do you need to add a new option if you only insert a virtual devargs?

Quoted 8 lines

Why wouldn't --vdev option work instead? and for that matter, I was expecting you to provide a PCI address. Can you give a command line showing how you create your device? The devtype is essentially ignored currently (at option stage, maybe there are still cruft left in PCI bus), instead the devargs parsing will detect the bus from the given optarg.

This part of EAL will change rather soon, I'd prefer not to deal with additional options unless necessary.

For PATCH v4, I have removed all the modification from eal library. Create vdev to take IFPGA parameters configuration.

The command line for PATCH v4 is(just take 2 AFU for example):
testpmd -c 0x3 -n 4 --socket-mem 1024,0 --huge-dir=/mnt/huge \
--vdev 'net_ifpga_cfg0,bdf=5e:00.0,port=0,afu_bts=./xxx.gbs' \
--vdev 'net_ifpga_cfg1,bdf=be:00.0,port=0,afu_bts=./xxx.gbs' -- -i --no-numa
Note: the parameter of "port" is used by OPAE for download bitstream.

Quoted 24 lines
Quoted 18 lines
lib/librte_eal/common/eal_common_options.c +0 -0
 	/* don't know what to do, leave this to caller */
 	default:
 		return 1;
lib/librte_eal/common/eal_options.h +2 -1
index e86c711..bdbb2c4 100644
@@ -55,6 +55,8 @@ enum {
 	OPT_VFIO_INTR_NUM,
 #define OPT_VMWARE_TSC_MAP    "vmware-tsc-map"
 	OPT_VMWARE_TSC_MAP_NUM,
+#define OPT_IFPGA              "ifpga"
+	OPT_IFPGA_NUM,
 	OPT_LONG_MAX_NUM
 };
 
--
Quoted 2 lines

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#11 lore raw

Re: [PATCH v3 1/6] Add Intel FPGA BUS Command Parse Code

Hello Gaetan,

Are my answers ok?
If so, could you reply it?
Many thanks to you.

Quoted 98 lines

-----Original Message-----
From: Xu, Rosen
Sent: Sunday, April 01, 2018 0:26
To: [email protected]
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: RE: [PATCH v3 1/6] Add Intel FPGA BUS Command Parse Code

Quoted 45 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:26
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 1/6] Add Intel FPGA BUS Command Parse Code

Quoted 12 lines · Rosen Xu
---
 lib/librte_eal/common/eal_common_options.c | 8 +++++++-
 lib/librte_eal/common/eal_options.h        | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)
lib/librte_eal/common/eal_common_options.c +0 -0
index 9f2f8d2..4fe0875 100644

lib/librte_eal/common/eal_common_options.c line 75

Quoted 3 lines
lib/librte_eal/common/eal_common_options.c +0 -0
@@ -73,6 +73,7 @@
 	{OPT_VDEV,              1, NULL, OPT_VDEV_NUM             },
 	{OPT_VFIO_INTR,         1, NULL, OPT_VFIO_INTR_NUM        },
 	{OPT_VMWARE_TSC_MAP,    0, NULL,

OPT_VMWARE_TSC_MAP_NUM },

Quoted 5 lines
lib/librte_eal/common/eal_common_options.c +1 -0
+	{OPT_IFPGA,             1, NULL, OPT_IFPGA_NUM            },
 	{0,                     0, NULL, 0                        }
 };
 

lib/librte_eal/common/eal_common_options.c static int xdigit2val(unsigned char c) · line 1169

Quoted 10 lines
lib/librte_eal/common/eal_common_options.c +6 -1
@@ -1160,7 +1161,12 @@ static int xdigit2val(unsigned char c)
 
 		core_parsed = LCORE_OPT_MAP;
 		break;
-
+	case OPT_IFPGA_NUM:
+		if (eal_option_device_add(RTE_DEVTYPE_VIRTUAL,
+				optarg) < 0) {
+			return -1;
+		}
+		break;

why do you need to add a new option if you only insert a virtual devargs?

Quoted 8 lines

Why wouldn't --vdev option work instead? and for that matter, I was expecting you to provide a PCI address. Can you give a command line showing how you create your device? The devtype is essentially ignored currently (at option stage, maybe there are still cruft left in PCI bus), instead the devargs parsing will detect the bus from the given optarg.

This part of EAL will change rather soon, I'd prefer not to deal with additional options unless necessary.

For PATCH v4, I have removed all the modification from eal library. Create vdev to take IFPGA parameters configuration.

The command line for PATCH v4 is(just take 2 AFU for example):
testpmd -c 0x3 -n 4 --socket-mem 1024,0 --huge-dir=/mnt/huge \ --vdev 'net_ifpga_cfg0,bdf=5e:00.0,port=0,afu_bts=./xxx.gbs' \ --vdev 'net_ifpga_cfg1,bdf=be:00.0,port=0,afu_bts=./xxx.gbs' -- -i --no-numa
Note: the parameter of "port" is used by OPAE for download bitstream.

Quoted 24 lines
Quoted 18 lines
lib/librte_eal/common/eal_common_options.c +0 -0
 	/* don't know what to do, leave this to caller */
 	default:
 		return 1;
lib/librte_eal/common/eal_options.h +2 -1
index e86c711..bdbb2c4 100644
@@ -55,6 +55,8 @@ enum {
 	OPT_VFIO_INTR_NUM,
 #define OPT_VMWARE_TSC_MAP    "vmware-tsc-map"
 	OPT_VMWARE_TSC_MAP_NUM,
+#define OPT_IFPGA              "ifpga"
+	OPT_IFPGA_NUM,
 	OPT_LONG_MAX_NUM
 };
 
--
Quoted 2 lines

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#12 lore raw

PATCH v3 2/6 config/common_base: Add Intel FPGA Build Configuration Macro

In reply to Rosen Xu
---
 config/common_base | 6 ++++++
 1 file changed, 6 insertions(+)
config/common_base +6 -0
index ad03cf4..08b7cce 100644
@@ -134,6 +134,12 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
 CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
 #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
+
+#
 # Compile ARK PMD
 #
 CONFIG_RTE_LIBRTE_ARK_PMD=y
Signature · 1 line
1.8.3.1
#13 lore raw

Re: [PATCH v3 2/6] config/common_base: Add Intel FPGA Build Configuration Macro

Quoted 10 lines · Rosen Xu
---
 config/common_base | 6 ++++++
 1 file changed, 6 insertions(+)
config/common_base +0 -0
index ad03cf4..08b7cce 100644

config/common_base CONFIG_RTE_LIBRTE_PCI_BUS=y · line 142

Quoted 9 lines
config/common_base +6 -0
@@ -134,6 +134,12 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
 CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
 #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
+
+#

Please squash this patch with their relevant counterparts. As it is, this won't trigger an error but the patch is meaningless.

Quoted 6 lines
config/common_base +0 -0
 # Compile ARK PMD
 #
 CONFIG_RTE_LIBRTE_ARK_PMD=y
Signature · 1 line
1.8.3.1
Signature · 2 lines
Gaëtan Rivet
6WIND
author
#14 lore raw

Re: [PATCH v3 2/6] config/common_base: Add Intel FPGA Build Configuration Macro

Quoted 25 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:27
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 2/6] config/common_base: Add Intel FPGA Build Configuration Macro

Quoted 12 lines · Rosen Xu
---
 config/common_base | 6 ++++++
 1 file changed, 6 insertions(+)
config/common_base index renamed from config/common_base +0 -0

ad03cf4..08b7cce 100644

config/common_base +0 -0
@@ -134,6 +134,12 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y

CONFIG_RTE_LIBRTE_VDEV_BUS=y

Quoted 10 lines

config/common_base CONFIG_RTE_LIBRTE_PCI_BUS=y · line 142

Quoted 7 lines

#

config/common_base +6 -0
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
+
+#

Please squash this patch with their relevant counterparts. As it is, this won't trigger an error but the patch is meaningless.

It's done by PATCH v4.

Quoted 10 lines
Quoted 6 lines

# Compile ARK PMD
#
CONFIG_RTE_LIBRTE_ARK_PMD=y
--
1.8.3.1

--
Gaëtan Rivet
6WIND

author
#15 lore raw

Re: [PATCH v3 2/6] config/common_base: Add Intel FPGA Build Configuration Macro

In reply to Gaëtan Rivet

Hi Gaetan,

I have squash this patch with their relevant counterparts.
For PATCH v4 and later version CONFIG_RTE_LIBRTE_IFPGA_BUS is squashed with ifpga_bus driver, And CONFIG_RTE_LIBRTE_IFPGA_RAWDEV is squashed with ifpga_rawdev driver.
Is it ok?

Quoted 44 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:27
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 2/6] config/common_base: Add Intel FPGA Build Configuration Macro

Quoted 13 lines · Rosen Xu
---
 config/common_base | 6 ++++++
 1 file changed, 6 insertions(+)
config/common_base index renamed from config/common_base +0 -0

ad03cf4..08b7cce 100644

config/common_base +0 -0
@@ -134,6 +134,12 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y

CONFIG_RTE_LIBRTE_VDEV_BUS=y

#

config/common_base CONFIG_RTE_LIBRTE_PCI_BUS=y · line 142

Quoted 6 lines
config/common_base +6 -0
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
+
+#

Please squash this patch with their relevant counterparts. As it is, this won't trigger an error but the patch is meaningless.

Quoted 6 lines

# Compile ARK PMD
#
CONFIG_RTE_LIBRTE_ARK_PMD=y
--
1.8.3.1

--
Gaëtan Rivet
6WIND

author
#16 lore raw

PATCH v3 3/6 mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App Script

In reply to Rosen Xu
---
 mk/rte.app.mk | 3 +++
 1 file changed, 3 insertions(+)
mk/rte.app.mk +3 -0
index 3eb41d1..958b6b5 100644
@@ -107,6 +107,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV)   += -lrte_ifpga_rawdev
+
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
Signature · 1 line
1.8.3.1
#17 lore raw

Re: [PATCH v3 3/6] mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App Script

Quoted 10 lines · Rosen Xu
---
 mk/rte.app.mk | 3 +++
 1 file changed, 3 insertions(+)
mk/rte.app.mk +0 -0
index 3eb41d1..958b6b5 100644

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline · line 112

Quoted 6 lines
mk/rte.app.mk +3 -0
@@ -107,6 +107,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV)   += -lrte_ifpga_rawdev
+

This however, should trigger a link error given that the relevant libraries are not yet available. Same as before, please squash with the patch introducing the libraries.

Quoted 6 lines
mk/rte.app.mk +0 -0
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
Signature · 1 line
1.8.3.1
Signature · 2 lines
Gaëtan Rivet
6WIND
author
#18 lore raw

Re: [PATCH v3 3/6] mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App Script

Quoted 27 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:29
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 3/6] mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App Script

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -

Quoted 10 lines · Rosen Xu
---
 mk/rte.app.mk | 3 +++
 1 file changed, 3 insertions(+)
mk/rte.app.mk index 3eb41d1..958b6b5 renamed from mk/rte.app.mk +0 -0

100644

mk/rte.app.mk +0 -0
@@ -107,6 +107,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -

lrte_cmdline

Quoted 3 lines
mk/rte.app.mk +0 -0
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
Quoted 8 lines

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += - · line 111

Quoted 2 lines
mk/rte.app.mk +2 -0
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV)   += -

lrte_ifpga_rawdev

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline · line 112

Quoted 1 line
mk/rte.app.mk +1 -0
+

This however, should trigger a link error given that the relevant libraries are not yet available. Same as before, please squash with the patch introducing the libraries.

It's done by PATCH v4.

Quoted 10 lines
Quoted 6 lines
mk/rte.app.mk +0 -1
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
--

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#19 lore raw

Re: [PATCH v3 3/6] mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App Script

In reply to Gaëtan Rivet

Hi Gaetan,

Quoted 25 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:29
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 3/6] mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App Script

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -

Quoted 10 lines · Rosen Xu
---
 mk/rte.app.mk | 3 +++
 1 file changed, 3 insertions(+)
mk/rte.app.mk index 3eb41d1..958b6b5 renamed from mk/rte.app.mk +0 -0

100644

mk/rte.app.mk +0 -0
@@ -107,6 +107,9 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -

lrte_cmdline

Quoted 3 lines
mk/rte.app.mk +0 -0
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
Quoted 8 lines

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += - · line 111

Quoted 2 lines
mk/rte.app.mk +2 -0
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV)   += -

lrte_ifpga_rawdev

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE) += -lrte_cmdline · line 112

Quoted 1 line
mk/rte.app.mk +1 -0
+

This however, should trigger a link error given that the relevant libraries are not yet available. Same as before, please squash with the patch introducing the libraries.

I have fixed the link error comment in my PATCH v5. For squash comment I have fixed it in my PATCH v4. Are they ok?

Quoted 10 lines
Quoted 6 lines
mk/rte.app.mk +0 -1
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
--

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#20 lore raw

PATCH v3 4/6 drivers/bus: Add Intel FPGA Bus Lib Code

In reply to Rosen Xu
---
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 562 ++++++++++++++++++++++++++++
 drivers/bus/ifpga/ifpga_common.c            | 141 +++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 140 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 8 files changed, 938 insertions(+)
 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/rte_bus_ifpga.h
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
drivers/bus/Makefile +1 -0
index 7ef2593..55d2dfe 100644
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +33 -0
new file mode 100644
index 0000000..e611950
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017 Intel Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_bus_ifpga.h
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +562 -0

562 lines not on this page · raw message

drivers/bus/ifpga/ifpga_common.c new file +141 -0

141 lines not on this page · raw message

drivers/bus/ifpga/ifpga_common.h new file +22 -0
new file mode 100644
index 0000000..48a5012
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
new file mode 100644
index 0000000..e3f4849
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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/rte_bus_ifpga.h new file +140 -0

140 lines not on this page · raw message

drivers/bus/ifpga/rte_bus_ifpga_version.map new file +8 -0
new file mode 100644
index 0000000..4edc9c0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;
+
+	local: *;
+};
Signature · 1 line
1.8.3.1
#21 lore raw

Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 36 lines · Rosen Xu
---
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 562 ++++++++++++++++++++++++++++
 drivers/bus/ifpga/ifpga_common.c            | 141 +++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 140 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 8 files changed, 938 insertions(+)
 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/rte_bus_ifpga.h
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
drivers/bus/Makefile +1 -0
index 7ef2593..55d2dfe 100644
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +0 -0
new file mode 100644
index 0000000..e611950

drivers/bus/ifpga/Makefile line 2

Quoted 2 lines
drivers/bus/ifpga/Makefile new file +2 -0
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017 Intel Corporation

Copyrigth 2018 (same comment for most SPDX tags, I think I saw 2017 or a variation of it everywhere I think).

Quoted 14 lines
drivers/bus/ifpga/Makefile new file +14 -0
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+

drivers/bus/ifpga/Makefile line 26

Quoted 10 lines
drivers/bus/ifpga/Makefile new file +10 -0
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal

you should probably load librte_pci.
You use afterward functions (at least address comparison).
I haven't tested the SHARED build, but my guess is that it would break.

On that note, you haven't acted on my previous remarks to use the common PCI utilities provided.

Quoted 96 lines
drivers/bus/ifpga/Makefile new file +7 -0
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_bus_ifpga.h
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +83 -0
new file mode 100644
index 0000000..092be65
@@ -0,0 +1,562 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.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;
+
+/* register a ifpga bus based driver */
+void rte_ifpga_driver_register(struct rte_afu_driver *driver)
+{
+	RTE_VERIFY(driver);
+
+	TAILQ_INSERT_TAIL(&rte_ifpga_bus.driver_list, driver, next);
+}
+
+/* un-register a fpga bus based driver */
+void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
+{
+	TAILQ_REMOVE(&rte_ifpga_bus.driver_list, driver, next);
+}
+
+static struct rte_ifpga_device *
+ifpga_find_ifpga_dev(const struct rte_pci_addr *pci_addr)
+{
+	struct rte_ifpga_device *ifpga_dev = NULL;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		if (!rte_pci_addr_cmp(&ifpga_dev->pci_addr, pci_addr))
+			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_BDF          "bdf"
+	IFPGA_ARG_BDF,
+#define IFPGA_ARG_PORT         "port"
+	IFPGA_ARG_PORT,
+#define IFPGA_ARG_PATH         "path"
+	IFPGA_ARG_PATH,

drivers/bus/ifpga/ifpga_bus.c line 93

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+#define IFPGA_ARG_UUID_HIGH    "uuid_high"
+	IFPGA_ARG_UUID_HIGH,
+#define IFPGA_ARG_UUID_LOW     "uuid_low"
+	IFPGA_ARG_UUID_LOW,
+#define IFPGA_ARG_PR_ENABLE     "pr_enable"
+	IFPGA_ARG_PR_ENABLE,
+#define IFPGA_ARG_DEBUG         "debug"
+	IFPGA_ARG_DEBUG,
+	NULL
+};

So these parameters are parsed during scan afterward, taken from the PCI device that was probed.

Given the kerfuffle of the VIRTUAL devtype in the EAL option, I'm not sure how the PCI bus would react with your IFPGA PCI device being probed by its blacklist operation: the devargs would be null. Do you segfault during your scan? Have you tested this?

Why are those parameters parsed again here on this note? Shouldn't they be parsed by the PCI device being probed with a custome PCI driver that you would have added (and I think you provide it afterward), that would spawn the rawdev with the relevant metadata? Then you could scan this rawdev here and have all these parameters already parsed?

Is there a reason that you did all this in this order? (specific initialization step for example?)

Quoted 147 lines
drivers/bus/ifpga/ifpga_bus.c new file +147 -0
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,
+	struct rte_ifpga_device *ifpga_dev)
+{
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_bus *pci_bus = NULL;
+	struct rte_device *dev = 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;
+	int pr_enable = 1;
+	int debug = 0;
+
+	memset((char *)(&afu_pr_conf), 0, sizeof(struct rte_afu_pr_conf));
+
+	kvlist = rte_kvargs_parse(devargs->args, valid_args);
+	if (!kvlist) {
+		IFPGA_BUS_ERR("error when parsing param");
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_BDF) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+			&ifpga_get_bdf_arg, &afu_pr_conf.afu_id.pci_addr) < 0) {
+			IFPGA_BUS_ERR("error to parse %s", IFPGA_ARG_BDF);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PORT,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PATH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PATH,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PATH);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_HIGH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_HIGH,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_high) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_LOW) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_LOW,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_low) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_LOW);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PR_ENABLE) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PR_ENABLE,
+			&ifpga_get_integer32_arg, &pr_enable) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_DEBUG) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_DEBUG,
+				       &ifpga_get_integer32_arg, &debug) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (!debug) {
+		pci_bus = rte_bus_find_by_name("pci");
+		if (pci_bus == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI bus\n");
+			goto end;
+		}
+
+		dev = pci_bus->find_device(NULL,
+				ifpga_pci_addr_cmp,
+				&afu_pr_conf.afu_id.pci_addr);
+		if (dev == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI device\n");
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_DEBUG("pci_addr domain   : %x\n",
+				afu_pr_conf.afu_id.pci_addr.domain);
+		IFPGA_BUS_DEBUG("pci_addr bus      : %x\n",
+				afu_pr_conf.afu_id.pci_addr.bus);
+		IFPGA_BUS_DEBUG("pci_addr devid    : %x\n",
+				afu_pr_conf.afu_id.pci_addr.devid);
+		IFPGA_BUS_DEBUG("pci_addr function : %x\n",
+				afu_pr_conf.afu_id.pci_addr.function);
+		IFPGA_BUS_DEBUG("uuid_low          : %lx\n",
+				afu_pr_conf.afu_id.uuid_low);
+		IFPGA_BUS_DEBUG("uuid_high         : %lx\n",
+				afu_pr_conf.afu_id.uuid_high);
+		IFPGA_BUS_DEBUG("afu port          : %x\n",
+				afu_pr_conf.afu_id.port);
+	}
+
+	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)

drivers/bus/ifpga/ifpga_bus.c line 250

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		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.pci_addr.domain = afu_pr_conf.afu_id.pci_addr.domain;
+	afu_dev->id.pci_addr.bus = afu_pr_conf.afu_id.pci_addr.bus;
+	afu_dev->id.pci_addr.devid = afu_pr_conf.afu_id.pci_addr.devid;
+	afu_dev->id.pci_addr.function = afu_pr_conf.afu_id.pci_addr.function;

Can you add a function called rte_pci_addr_cpy in librte_pci and use it instead of doing this by hand here? Others would benefit from this.

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+	afu_dev->id.port      = afu_pr_conf.afu_id.port;
+	afu_dev->ifpga_dev    = ifpga_dev;

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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;
+	if (pr_enable) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy is dangerous here, please use strlcpy or snprintf. (And your use of strncpy is dangerous, you are limitting the write to the length of the source, not to the size of the destination.)

Quoted 69 lines
drivers/bus/ifpga/ifpga_bus.c new file +69 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+	}
+
+	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
+rte_ifpga_scan(void)
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_devargs *devargs;
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rawdev = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct rte_afu_device *afu_dev = NULL;
+
+	/* for FPGA devices we scan the devargs_list populated via cmdline */
+	TAILQ_FOREACH(devargs, &devargs_list, next) {
+		if (devargs->bus != &rte_ifpga_bus.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_BDF) == 1) {
+			if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+				&ifpga_get_bdf_arg, &pci_addr) < 0) {
+				IFPGA_BUS_ERR("error to parse %s",
+					IFPGA_ARG_BDF);
+				goto end;
+			}
+		} else {
+			IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+				IFPGA_ARG_PATH);
+			goto end;
+		}
+
+		memset(name, 0, sizeof(name));
+		snprintf(name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%x:%x:%x",
+		pci_addr.bus, pci_addr.devid, pci_addr.function);
+
+		rawdev = rte_rawdev_pmd_get_named_dev(name);
+		if (!rawdev)
+			goto end;
+
+		if (ifpga_find_ifpga_dev(&pci_addr))

drivers/bus/ifpga/ifpga_bus.c line 343

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			goto end;
+
+		ifpga_dev = calloc(1, sizeof(*ifpga_dev));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->pci_addr.domain   = pci_addr.domain;
+		ifpga_dev->pci_addr.bus      = pci_addr.bus;
+		ifpga_dev->pci_addr.devid    = pci_addr.devid;
+		ifpga_dev->pci_addr.function = pci_addr.function;

Again, PCI copy would be nice instead of doing it by hand.

Quoted 15 lines
drivers/bus/ifpga/ifpga_bus.c new file +15 -0
+		ifpga_dev->rdev = rawdev;
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&rte_ifpga_bus.ifpga_list, ifpga_dev, next);
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev, next);
+	}
+
+end:
+	if (kvlist)
+		rte_kvargs_free(kvlist);
+
+	return 0;
+}

drivers/bus/ifpga/ifpga_bus.c line 368

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+static int
+ifpga_probe_one_driver(struct rte_afu_driver *drv,
+			struct rte_afu_device *afu_dev)
+{
+	int ret;
+
+	if ((drv->id.pci_addr.bus == afu_dev->id.pci_addr.bus) &&
+		(drv->id.pci_addr.devid == afu_dev->id.pci_addr.devid) &&
+		(drv->id.pci_addr.function == afu_dev->id.pci_addr.function) &&

There is the rte_pci_addr_cmp function that should be used here instead. Additionally, you haven't responded to my comment about ignoring the Domain part of the address. Why? Is there a reason for this? Is the domain irrelevant? If so, it should be documented. If not, please use the relevant function instead.

Quoted 40 lines
drivers/bus/ifpga/ifpga_bus.c new file +40 -0
+		(drv->id.uuid_low == afu_dev->id.uuid_low) &&
+		(drv->id.uuid_high == afu_dev->id.uuid_high) &&
+		(drv->id.port == afu_dev->id.port)) {
+
+		afu_dev->driver = drv;
+
+		/* call the driver probe() function */
+		ret = drv->probe(afu_dev);
+		if (ret)
+			afu_dev->driver = NULL;
+		return ret;
+	}
+
+	/* return positive value if driver doesn't support this device */
+	return 1;
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
+{
+	const char *name;
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	name = rte_ifpga_device_name(afu_dev);
+	IFPGA_BUS_DEBUG("Search driver %s to probe device %s\n", name,
+		rte_ifpga_device_name(afu_dev));
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;

drivers/bus/ifpga/ifpga_bus.c line 418

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function for

One should read IFPGA bus here I guess.

Quoted 36 lines
drivers/bus/ifpga/ifpga_bus.c new file +36 -0
+ * all registered drivers that have a matching entry in its id_table
+ * for discovered devices.
+ */
+static int
+rte_ifpga_probe(void)
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_afu_device *afu_dev = NULL;
+	int ret = 0;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) {
+
+			if (afu_dev->device.driver)
+				continue;
+
+			ret = ifpga_probe_all_drivers(afu_dev);
+			if (ret < 0)
+				IFPGA_BUS_ERR("failed to initialize %s device\n",
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_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;

drivers/bus/ifpga/ifpga_bus.c line 464

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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 = container_of(afu_dev->device.driver,
+		const struct rte_afu_driver,
+		driver);

No RTE_DRV_TO_AFU_CONST? It would be easier to read.

Quoted 71 lines
drivers/bus/ifpga/ifpga_bus.c new file +71 -0
+	return driver->remove(afu_dev);
+}
+
+static int
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	if (ret)
+		return ret;
+
+	TAILQ_REMOVE(&ifpga_dev->afu_list, afu_dev, next);
+
+	TAILQ_REMOVE(&devargs_list, devargs, next);
+
+	free(devargs->args);
+	free(devargs);
+	free(afu_dev);
+	return 0;
+
+}
+
+static struct rte_device *
+rte_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, &rte_ifpga_bus.ifpga_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
+rte_ifpga_parse(const char *name, void *addr)
+{
+	struct rte_afu_driver **out = addr;
+	struct rte_afu_driver *driver = NULL;
+
+	TAILQ_FOREACH(driver, &rte_ifpga_bus.driver_list, next) {
+		if (strncmp(driver->driver.name, name,
+			    strlen(driver->driver.name)) == 0)
+			break;
+		if (driver->driver.alias &&
+		    strncmp(driver->driver.alias, name,
+			    strlen(driver->driver.alias)) == 0)
+			break;
+	}
+	if (driver != NULL &&

drivers/bus/ifpga/ifpga_bus.c line 545

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	    addr != NULL)
+		*out = driver;
+	return driver == NULL;
+}
+
+struct rte_ifpga_bus rte_ifpga_bus = {
+	 .bus = {
+		 .scan        = rte_ifpga_scan,
+		 .probe       = rte_ifpga_probe,
+		 .find_device = rte_ifpga_find_device,

Wrong indentation (2 tabs instead of one).

drivers/bus/ifpga/ifpga_bus.c line 551

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+	     .plug        = rte_ifpga_plug,
+	     .unplug      = rte_ifpga_unplug,
+	     .parse       = rte_ifpga_parse,
+	 },
+	.ifpga_list  = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.ifpga_list),
+	.driver_list = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.driver_list),

Why are those lists part of the bus definition? Can you do the same as the vdev bus and have them statically declared in your source file only?

Is there a reason you want them part of the bus, do you need to access it somewhere?

Quoted 87 lines
drivers/bus/ifpga/ifpga_bus.c new file +11 -0
+};
+
+RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus.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 +70 -0
new file mode 100644
index 0000000..03a8d48
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_kvargs.h>
+#include <rte_alarm.h>
+
+#include "rte_bus_ifpga.h"
+#include "ifpga_logs.h"
+#include "ifpga_common.h"
+
+int 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 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;

drivers/bus/ifpga/ifpga_common.c line 80

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+
+	errno = 0;
+
+	num = strtoul(str, &end, base);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0))
+		return -1;
+
+	return num;
+
+}

Missing newline here.

Quoted 28 lines
drivers/bus/ifpga/ifpga_common.c new file +28 -0
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args)
+{
+#define MAX_PATH_LEN 1024
+	struct rte_pci_addr *addr;
+	int num[4];
+	char str[MAX_PATH_LEN];
+	int i, j;
+
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	addr = (struct rte_pci_addr *)extra_args;
+	strcpy(str, value);
+	memset(num, 0, 4 * sizeof(num[0]));
+	i = strlen(str) - 1;
+	j = 3;
+	while (i > 0 && j >= 0) {
+		while ((str[i - 1] != ':' && str[i - 1] != '.') && i > 0)
+			i--;
+		num[j--] = ifpga_get_unsigned_long(&str[i], 16);
+		i--;
+		if (i >= 0)
+			str[i] = '\0';
+	}
+	addr->domain = num[0];
+	addr->bus = num[1];
+	addr->devid = num[2];

drivers/bus/ifpga/ifpga_common.c line 118

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+	addr->function = num[3];
+	printf("[%s]: bdf %04d:%02d:%02d.%02d\n",
+			__func__,
+			addr->domain,
+			addr->bus,
+			addr->devid,
+			addr->function);
+
+	return 0;
+}

Use rte_pci_addr_parse instead of rewriting it please.

Quoted 4 lines
drivers/bus/ifpga/ifpga_common.c new file +4 -0
+
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1)
+{

drivers/bus/ifpga/ifpga_common.c line 132

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+	if ((afu_id0->pci_addr.bus       == afu_id1->pci_addr.bus) &&
+		(afu_id0->pci_addr.devid     == afu_id1->pci_addr.devid) &&
+		(afu_id0->pci_addr.function  == afu_id1->pci_addr.function) &&
+		(afu_id0->uuid_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}

You used the exact same check in the ifpga_bus.c file, why not call this function instead?

drivers/bus/ifpga/ifpga_common.c line 140

Quoted 8 lines
drivers/bus/ifpga/ifpga_common.c new file +8 -0
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr)
+{
+	struct rte_pci_device *pdev;
+	const struct rte_pci_addr *paddr = _pci_addr;
+
+	pdev = RTE_DEV_TO_PCI(*(struct rte_device **)(void *)&dev);
+	return rte_eal_compare_pci_addr(&pdev->addr, paddr);

This function is deprecated (I should mark is as so to forbid its use). Use rte_pci_addr_cmp() instead.

Quoted 96 lines
drivers/bus/ifpga/ifpga_common.c new file +1 -0
+}
drivers/bus/ifpga/ifpga_common.h new file +22 -0
new file mode 100644
index 0000000..48a5012
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
new file mode 100644
index 0000000..e3f4849
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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/rte_bus_ifpga.h new file +24 -0
new file mode 100644
index 0000000..7290149
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _RTE_BUS_IFPGA_H_
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI 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 */

drivers/bus/ifpga/rte_bus_ifpga.h line 34

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+struct rte_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_afu_driver_list, rte_afu_driver);

Is there a reason for you to expose your lists publicly? These symbols should be made private to your bus unless necessary.

drivers/bus/ifpga/rte_bus_ifpga.h line 43

Quoted 9 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +9 -0
+
+#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
+
+/**
+ * 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_pci_addr pci_addr;

You use a symbol from librte_pci, without linking it.

Quoted 103 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +97 -0
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;
+	char		bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices */
+};
+
+/**
+ * A structure describing a AFU device.
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource */
+	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	struct rte_afu_driver *driver;          /**< Associated driver */
+	char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+} __attribute__ ((packed));
+
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_afu_device.
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI 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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	struct rte_afu_id id;	                /**< AFU id within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus
+ */
+struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA drivers */
+};
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+void rte_ifpga_driver_register(struct rte_afu_driver *driver);
+void rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
+
+
+#endif /* _RTE_BUS_IFPGA_H_ */
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +0 -0
new file mode 100644
index 0000000..4edc9c0

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Wrong indentation.
It should be one tabulation, not 4 spaces.

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -0
+
+	local: *;
+};
Signature · 1 line
1.8.3.1
Signature · 2 lines
Gaëtan Rivet
6WIND
author
#22 lore raw

Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 42 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:52
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 5 lines · Rosen Xu
---
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 562

++++++++++++++++++++++++++++

Quoted 24 lines
 drivers/bus/ifpga/ifpga_common.c            | 141 +++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 140 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 8 files changed, 938 insertions(+)
 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/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map

drivers/bus/Makefile index renamed from drivers/bus/Makefile +0 -0

7ef2593..55d2dfe 100644

drivers/bus/Makefile +1 -0
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
Quoted 11 lines

drivers/bus/ifpga/Makefile line 2

Quoted 8 lines
drivers/bus/Makefile +0 -0
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +2 -0
new file mode 100644 index 0000000..e611950
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel
+Corporation

Copyrigth 2018 (same comment for most SPDX tags, I think I saw 2017 or a variation of it everywhere I think).

It's done by PATCH v4.

Quoted 20 lines
Quoted 20 lines
drivers/bus/ifpga/Makefile new file +20 -0
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
Quoted 8 lines

drivers/bus/ifpga/Makefile line 26

Quoted 4 lines
drivers/bus/ifpga/Makefile new file +4 -0
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal

you should probably load librte_pci.
You use afterward functions (at least address comparison).
I haven't tested the SHARED build, but my guess is that it would break.

The FPGA BUS is based PCI(IFPGA is probed by PCI), do you think so users to add it?

Quoted 2 lines

On that note, you haven't acted on my previous remarks to use the common PCI utilities provided.

It's done in PATCH v4.

Quoted 109 lines
Quoted 90 lines
drivers/bus/ifpga/Makefile new file +7 -0
+
+#
+# Export include files
+#
+SYMLINK-y-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..092be65

drivers/bus/ifpga/ifpga_bus.c new file +77 -0
@@ -0,0 +1,562 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.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;
+
+/* register a ifpga bus based driver */ void
+rte_ifpga_driver_register(struct rte_afu_driver *driver) {
+	RTE_VERIFY(driver);
+
+	TAILQ_INSERT_TAIL(&rte_ifpga_bus.driver_list, driver, next); }
+
+/* un-register a fpga bus based driver */ void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver) {
+	TAILQ_REMOVE(&rte_ifpga_bus.driver_list, driver, next); }
+
+static struct rte_ifpga_device *
+ifpga_find_ifpga_dev(const struct rte_pci_addr *pci_addr) {
+	struct rte_ifpga_device *ifpga_dev = NULL;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		if (!rte_pci_addr_cmp(&ifpga_dev->pci_addr, pci_addr))
+			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_BDF          "bdf"
+	IFPGA_ARG_BDF,
+#define IFPGA_ARG_PORT         "port"
+	IFPGA_ARG_PORT,
+#define IFPGA_ARG_PATH         "path"
+	IFPGA_ARG_PATH,

drivers/bus/ifpga/ifpga_bus.c line 87

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+#define IFPGA_ARG_UUID_HIGH    "uuid_high"
+	IFPGA_ARG_UUID_HIGH,
+#define IFPGA_ARG_UUID_LOW     "uuid_low"
+	IFPGA_ARG_UUID_LOW,
+#define IFPGA_ARG_PR_ENABLE     "pr_enable"
+	IFPGA_ARG_PR_ENABLE,
+#define IFPGA_ARG_DEBUG         "debug"
+	IFPGA_ARG_DEBUG,
+	NULL
+};

So these parameters are parsed during scan afterward, taken from the PCI device that was probed.

Given the kerfuffle of the VIRTUAL devtype in the EAL option, I'm not sure how the PCI bus would react with your IFPGA PCI device being probed by its blacklist operation: the devargs would be null. Do you segfault during your scan? Have you tested this?

Quoted 8 lines

Why are those parameters parsed again here on this note? Shouldn't they be parsed by the PCI device being probed with a custome PCI driver that you would have added (and I think you provide it afterward), that would spawn the rawdev with the relevant metadata? Then you could scan this rawdev here and have all these parameters already parsed?

Is there a reason that you did all this in this order? (specific initialization step for example?)

Pls see PATCH v4 and my reply for your email of PATCH v3 1/6. The command line is in that email.

Quoted 906 lines
Quoted 21 lines
drivers/bus/ifpga/ifpga_bus.c new file +21 -0
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,
+	struct rte_ifpga_device *ifpga_dev)
+{
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_bus *pci_bus = NULL;
+	struct rte_device *dev = 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;
+	int pr_enable = 1;
+	int debug = 0;
+
+	memset((char *)(&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_BDF) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+			&ifpga_get_bdf_arg, &afu_pr_conf.afu_id.pci_addr)

< 0) {

drivers/bus/ifpga/ifpga_bus.c line 119

Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1 -0
+			IFPGA_BUS_ERR("error to parse %s",

IFPGA_ARG_BDF);

Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PORT,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PATH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PATH,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PATH);
+			goto end;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_HIGH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_HIGH,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_high)

< 0) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 13 lines
drivers/bus/ifpga/ifpga_bus.c new file +13 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_LOW) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_LOW,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_low) <

0) {

Quoted 66 lines
drivers/bus/ifpga/ifpga_bus.c new file +66 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_LOW);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PR_ENABLE) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PR_ENABLE,
+			&ifpga_get_integer32_arg, &pr_enable) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_DEBUG) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_DEBUG,
+				       &ifpga_get_integer32_arg, &debug) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (!debug) {
+		pci_bus = rte_bus_find_by_name("pci");
+		if (pci_bus == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI bus\n");
+			goto end;
+		}
+
+		dev = pci_bus->find_device(NULL,
+				ifpga_pci_addr_cmp,
+				&afu_pr_conf.afu_id.pci_addr);
+		if (dev == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI device\n");
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_DEBUG("pci_addr domain   : %x\n",
+				afu_pr_conf.afu_id.pci_addr.domain);
+		IFPGA_BUS_DEBUG("pci_addr bus      : %x\n",
+				afu_pr_conf.afu_id.pci_addr.bus);
+		IFPGA_BUS_DEBUG("pci_addr devid    : %x\n",
+				afu_pr_conf.afu_id.pci_addr.devid);
+		IFPGA_BUS_DEBUG("pci_addr function : %x\n",
+				afu_pr_conf.afu_id.pci_addr.function);
+		IFPGA_BUS_DEBUG("uuid_low          : %lx\n",
+				afu_pr_conf.afu_id.uuid_low);
+		IFPGA_BUS_DEBUG("uuid_high         : %lx\n",
+				afu_pr_conf.afu_id.uuid_high);
+		IFPGA_BUS_DEBUG("afu port          : %x\n",
+				afu_pr_conf.afu_id.port);
+	}
+
+	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;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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.pci_addr.domain = afu_pr_conf.afu_id.pci_addr.domain;
+	afu_dev->id.pci_addr.bus = afu_pr_conf.afu_id.pci_addr.bus;
+	afu_dev->id.pci_addr.devid = afu_pr_conf.afu_id.pci_addr.devid;
+	afu_dev->id.pci_addr.function =
+afu_pr_conf.afu_id.pci_addr.function;

Can you add a function called rte_pci_addr_cpy in librte_pci and use it instead of doing this by hand here? Others would benefit from this.

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+	afu_dev->id.port      = afu_pr_conf.afu_id.port;
+	afu_dev->ifpga_dev    = ifpga_dev;

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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;
+	if (pr_enable) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy is dangerous here, please use strlcpy or snprintf. (And your use of strncpy is dangerous, you are limitting the write to the length of the source, not to the size of the destination.)

Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+	}
+
+	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
+rte_ifpga_scan(void)

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_devargs *devargs;
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rawdev = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct rte_afu_device *afu_dev = NULL;
+
+	/* for FPGA devices we scan the devargs_list populated via cmdline

*/

Quoted 15 lines
drivers/bus/ifpga/ifpga_bus.c new file +15 -0
+	TAILQ_FOREACH(devargs, &devargs_list, next) {
+		if (devargs->bus != &rte_ifpga_bus.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_BDF) == 1) {
+			if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+				&ifpga_get_bdf_arg, &pci_addr) < 0) {
+				IFPGA_BUS_ERR("error to parse %s",
+					IFPGA_ARG_BDF);

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_PATH);
+			goto end;
+		}
+
+		memset(name, 0, sizeof(name));
+		snprintf(name, RTE_RAWDEV_NAME_MAX_LEN,

"IFPGA:%x:%x:%x",

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+		pci_addr.bus, pci_addr.devid, pci_addr.function);
+
+		rawdev = rte_rawdev_pmd_get_named_dev(name);
+		if (!rawdev)
+			goto end;
+
+		if (ifpga_find_ifpga_dev(&pci_addr))

drivers/bus/ifpga/ifpga_bus.c line 343

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			goto end;
+
+		ifpga_dev = calloc(1, sizeof(*ifpga_dev));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->pci_addr.domain   = pci_addr.domain;
+		ifpga_dev->pci_addr.bus      = pci_addr.bus;
+		ifpga_dev->pci_addr.devid    = pci_addr.devid;
+		ifpga_dev->pci_addr.function = pci_addr.function;

Again, PCI copy would be nice instead of doing it by hand.

drivers/bus/ifpga/ifpga_bus.c

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+		ifpga_dev->rdev = rawdev;
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&rte_ifpga_bus.ifpga_list, ifpga_dev,

next);

drivers/bus/ifpga/ifpga_bus.c

Quoted 3 lines
drivers/bus/ifpga/ifpga_bus.c new file +3 -0
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,

next);

Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c new file +8 -0
+	}
+
+end:
+	if (kvlist)
+		rte_kvargs_free(kvlist);
+
+	return 0;
+}

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+static int
+ifpga_probe_one_driver(struct rte_afu_driver *drv,
+			struct rte_afu_device *afu_dev)
+{
+	int ret;
+
+	if ((drv->id.pci_addr.bus == afu_dev->id.pci_addr.bus) &&
+		(drv->id.pci_addr.devid == afu_dev->id.pci_addr.devid) &&
+		(drv->id.pci_addr.function == afu_dev->id.pci_addr.function)

&&

There is the rte_pci_addr_cmp function that should be used here instead. Additionally, you haven't responded to my comment about ignoring the Domain part of the address. Why? Is there a reason for this? Is the domain irrelevant? If so, it should be documented. If not, please use the relevant function instead.

Quoted 39 lines
drivers/bus/ifpga/ifpga_bus.c new file +39 -0
+		(drv->id.uuid_low == afu_dev->id.uuid_low) &&
+		(drv->id.uuid_high == afu_dev->id.uuid_high) &&
+		(drv->id.port == afu_dev->id.port)) {
+
+		afu_dev->driver = drv;
+
+		/* call the driver probe() function */
+		ret = drv->probe(afu_dev);
+		if (ret)
+			afu_dev->driver = NULL;
+		return ret;
+	}
+
+	/* return positive value if driver doesn't support this device */
+	return 1;
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) {
+	const char *name;
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	name = rte_ifpga_device_name(afu_dev);
+	IFPGA_BUS_DEBUG("Search driver %s to probe device %s\n", name,
+		rte_ifpga_device_name(afu_dev));
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;

drivers/bus/ifpga/ifpga_bus.c line 418

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function for

One should read IFPGA bus here I guess.

Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9 -0
+ * all registered drivers that have a matching entry in its id_table
+ * for discovered devices.
+ */
+static int
+rte_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, &rte_ifpga_bus.ifpga_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 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9 -0
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_ifpga_plug(struct rte_device *dev) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	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);

drivers/bus/ifpga/ifpga_bus.c line 464

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+		return 1;
+	}
+
+	driver = container_of(afu_dev->device.driver,
+		const struct rte_afu_driver,
+		driver);

No RTE_DRV_TO_AFU_CONST? It would be easier to read.

Quoted 68 lines
drivers/bus/ifpga/ifpga_bus.c new file +68 -0
+	return driver->remove(afu_dev);
+}
+
+static int
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	if (ret)
+		return ret;
+
+	TAILQ_REMOVE(&ifpga_dev->afu_list, afu_dev, next);
+
+	TAILQ_REMOVE(&devargs_list, devargs, next);
+
+	free(devargs->args);
+	free(devargs);
+	free(afu_dev);
+	return 0;
+
+}
+
+static struct rte_device *
+rte_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, &rte_ifpga_bus.ifpga_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
+rte_ifpga_parse(const char *name, void *addr) {
+	struct rte_afu_driver **out = addr;
+	struct rte_afu_driver *driver = NULL;
+
+	TAILQ_FOREACH(driver, &rte_ifpga_bus.driver_list, next) {
+		if (strncmp(driver->driver.name, name,
+			    strlen(driver->driver.name)) == 0)
+			break;
+		if (driver->driver.alias &&
+		    strncmp(driver->driver.alias, name,
+			    strlen(driver->driver.alias)) == 0)
+			break;
+	}
+	if (driver != NULL &&

drivers/bus/ifpga/ifpga_bus.c line 545

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	    addr != NULL)
+		*out = driver;
+	return driver == NULL;
+}
+
+struct rte_ifpga_bus rte_ifpga_bus = {
+	 .bus = {
+		 .scan        = rte_ifpga_scan,
+		 .probe       = rte_ifpga_probe,
+		 .find_device = rte_ifpga_find_device,

Wrong indentation (2 tabs instead of one).

drivers/bus/ifpga/ifpga_bus.c line 551

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+	     .plug        = rte_ifpga_plug,
+	     .unplug      = rte_ifpga_unplug,
+	     .parse       = rte_ifpga_parse,
+	 },
+	.ifpga_list  = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.ifpga_list),
+	.driver_list = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.driver_list),

Why are those lists part of the bus definition? Can you do the same as the vdev bus and have them statically declared in your source file only?

Is there a reason you want them part of the bus, do you need to access it somewhere?

Quoted 82 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+};
+
+RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus.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 +65 -0
new file mode 100644
index 0000000..03a8d48
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_kvargs.h>
+#include <rte_alarm.h>
+
+#include "rte_bus_ifpga.h"
+#include "ifpga_logs.h"
+#include "ifpga_common.h"
+
+int 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 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;

drivers/bus/ifpga/ifpga_common.c line 75

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+
+	errno = 0;
+
+	num = strtoul(str, &end, base);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0))
+		return -1;
+
+	return num;
+
+}

Missing newline here.

Quoted 26 lines
drivers/bus/ifpga/ifpga_common.c new file +26 -0
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args) { #define MAX_PATH_LEN 1024
+	struct rte_pci_addr *addr;
+	int num[4];
+	char str[MAX_PATH_LEN];
+	int i, j;
+
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	addr = (struct rte_pci_addr *)extra_args;
+	strcpy(str, value);
+	memset(num, 0, 4 * sizeof(num[0]));
+	i = strlen(str) - 1;
+	j = 3;
+	while (i > 0 && j >= 0) {
+		while ((str[i - 1] != ':' && str[i - 1] != '.') && i > 0)
+			i--;
+		num[j--] = ifpga_get_unsigned_long(&str[i], 16);
+		i--;
+		if (i >= 0)
+			str[i] = '\0';
+	}
+	addr->domain = num[0];
+	addr->bus = num[1];
+	addr->devid = num[2];

drivers/bus/ifpga/ifpga_common.c line 118

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+	addr->function = num[3];
+	printf("[%s]: bdf %04d:%02d:%02d.%02d\n",
+			__func__,
+			addr->domain,
+			addr->bus,
+			addr->devid,
+			addr->function);
+
+	return 0;
+}

Use rte_pci_addr_parse instead of rewriting it please.

drivers/bus/ifpga/ifpga_common.c

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1)
+{
+	if ((afu_id0->pci_addr.bus       == afu_id1->pci_addr.bus) &&
+		(afu_id0->pci_addr.devid     == afu_id1->pci_addr.devid) &&
+		(afu_id0->pci_addr.function  == afu_id1->pci_addr.function)

&&

drivers/bus/ifpga/ifpga_common.c line 132

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+		(afu_id0->uuid_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}

You used the exact same check in the ifpga_bus.c file, why not call this function instead?

drivers/bus/ifpga/ifpga_common.c line 140

Quoted 8 lines
drivers/bus/ifpga/ifpga_common.c new file +8 -0
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr)
+{
+	struct rte_pci_device *pdev;
+	const struct rte_pci_addr *paddr = _pci_addr;
+
+	pdev = RTE_DEV_TO_PCI(*(struct rte_device **)(void *)&dev);
+	return rte_eal_compare_pci_addr(&pdev->addr, paddr);

This function is deprecated (I should mark is as so to forbid its use). Use rte_pci_addr_cmp() instead.

Quoted 95 lines
drivers/bus/ifpga/ifpga_common.c new file +1 -0
+}
drivers/bus/ifpga/ifpga_common.h new file +21 -0
new file mode 100644
index 0000000..48a5012
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_unsigned_long(const char *str, int base); int
+ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int ifpga_afu_id_cmp(const
+struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
(quoted diff) +0 -0

b/drivers/bus/ifpga/ifpga_logs.h new file mode 100644 index 0000000..e3f4849

drivers/bus/ifpga/ifpga_logs.h new file +30 -0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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/rte_bus_ifpga.h new file +23 -0
new file mode 100644
index 0000000..7290149
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _RTE_BUS_IFPGA_H_
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI 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 */

drivers/bus/ifpga/rte_bus_ifpga.h line 33

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+struct rte_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_afu_driver_list, rte_afu_driver);

Is there a reason for you to expose your lists publicly? These symbols should be made private to your bus unless necessary.

drivers/bus/ifpga/rte_bus_ifpga.h line 43

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+
+#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
+
+/**
+ * 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_pci_addr pci_addr;

You use a symbol from librte_pci, without linking it.

Quoted 28 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +28 -0
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;
+	char		bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices */ };
+
+/**
+ * A structure describing a AFU device.

drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource

*/

Quoted 62 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +55 -0
+	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	struct rte_afu_driver *driver;          /**< Associated driver */
+	char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+} __attribute__ ((packed));
+
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_afu_device.
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI 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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	struct rte_afu_id id;	                /**< AFU id within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus  */ struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA drivers
+*/ };
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+void rte_ifpga_driver_register(struct rte_afu_driver *driver); void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
+
+
+#endif /* _RTE_BUS_IFPGA_H_ */
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +0 -0
new file mode 100644
index 0000000..4edc9c0

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Wrong indentation.
It should be one tabulation, not 4 spaces.

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -1
+
+	local: *;
+};
--

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#23 lore raw

Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 214 lines

-----Original Message-----
From: Xu, Rosen
Sent: Sunday, April 01, 2018 0:31
To: [email protected]
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: RE: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 41 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:52
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 5 lines · Rosen Xu
---
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 562

++++++++++++++++++++++++++++

Quoted 24 lines
 drivers/bus/ifpga/ifpga_common.c            | 141 +++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 140 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 8 files changed, 938 insertions(+)
 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/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map

drivers/bus/Makefile index renamed from drivers/bus/Makefile +0 -0

7ef2593..55d2dfe 100644

drivers/bus/Makefile +1 -0
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
Quoted 11 lines

drivers/bus/ifpga/Makefile line 2

Quoted 8 lines
drivers/bus/Makefile +0 -0
 include $(RTE_SDK)/mk/rte.subdir.mk diff --git

a/drivers/bus/ifpga/Makefile b/drivers/bus/ifpga/Makefile new file mode 100644 index 0000000..e611950

drivers/bus/ifpga/Makefile new file +2 -0
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel
+Corporation

Copyrigth 2018 (same comment for most SPDX tags, I think I saw 2017 or a variation of it everywhere I think).

It's done by PATCH v4.

Quoted 20 lines
Quoted 20 lines
drivers/bus/ifpga/Makefile new file +20 -0
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
Quoted 8 lines

drivers/bus/ifpga/Makefile line 26

Quoted 4 lines
drivers/bus/ifpga/Makefile new file +4 -0
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal

you should probably load librte_pci.
You use afterward functions (at least address comparison).
I haven't tested the SHARED build, but my guess is that it would break.

The FPGA BUS is based PCI(IFPGA is probed by PCI), do you think so users to add it?

Quoted 2 lines

On that note, you haven't acted on my previous remarks to use the common PCI utilities provided.

It's done in PATCH v4.

Quoted 109 lines
Quoted 90 lines
drivers/bus/ifpga/Makefile new file +7 -0
+
+#
+# Export include files
+#
+SYMLINK-y-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..092be65

drivers/bus/ifpga/ifpga_bus.c new file +77 -0
@@ -0,0 +1,562 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.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;
+
+/* register a ifpga bus based driver */ void
+rte_ifpga_driver_register(struct rte_afu_driver *driver) {
+	RTE_VERIFY(driver);
+
+	TAILQ_INSERT_TAIL(&rte_ifpga_bus.driver_list, driver, next); }
+
+/* un-register a fpga bus based driver */ void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver) {
+	TAILQ_REMOVE(&rte_ifpga_bus.driver_list, driver, next); }
+
+static struct rte_ifpga_device *
+ifpga_find_ifpga_dev(const struct rte_pci_addr *pci_addr) {
+	struct rte_ifpga_device *ifpga_dev = NULL;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		if (!rte_pci_addr_cmp(&ifpga_dev->pci_addr, pci_addr))
+			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_BDF          "bdf"
+	IFPGA_ARG_BDF,
+#define IFPGA_ARG_PORT         "port"
+	IFPGA_ARG_PORT,
+#define IFPGA_ARG_PATH         "path"
+	IFPGA_ARG_PATH,

drivers/bus/ifpga/ifpga_bus.c line 87

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+#define IFPGA_ARG_UUID_HIGH    "uuid_high"
+	IFPGA_ARG_UUID_HIGH,
+#define IFPGA_ARG_UUID_LOW     "uuid_low"
+	IFPGA_ARG_UUID_LOW,
+#define IFPGA_ARG_PR_ENABLE     "pr_enable"
+	IFPGA_ARG_PR_ENABLE,
+#define IFPGA_ARG_DEBUG         "debug"
+	IFPGA_ARG_DEBUG,
+	NULL
+};

So these parameters are parsed during scan afterward, taken from the PCI device that was probed.

Given the kerfuffle of the VIRTUAL devtype in the EAL option, I'm not sure how the PCI bus would react with your IFPGA PCI device being probed by its blacklist operation: the devargs would be null. Do you segfault during your scan? Have you tested this?

Quoted 10 lines
Quoted 5 lines

Why are those parameters parsed again here on this note? Shouldn't they be parsed by the PCI device being probed with a custome PCI driver that you would have added (and I think you provide it afterward), that would spawn the rawdev with the relevant metadata? Then you could scan this rawdev here and have all these parameters

already parsed?

Quoted 3 lines

Is there a reason that you did all this in this order? (specific initialization step for example?)

Pls see PATCH v4 and my reply for your email of PATCH v3 1/6. The command line is in that email.

For PATCH v4 I have removed all modification from eal library. I use vdev driver to take parameter configuration, and this vdev driver call rte_eal_hotplug_add() to add afu device and trigger scan/probe.

Quoted 910 lines
Quoted 714 lines
Quoted 20 lines
drivers/bus/ifpga/ifpga_bus.c new file +20 -0
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,
+	struct rte_ifpga_device *ifpga_dev) {
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_bus *pci_bus = NULL;
+	struct rte_device *dev = 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;
+	int pr_enable = 1;
+	int debug = 0;
+
+	memset((char *)(&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_BDF) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+			&ifpga_get_bdf_arg, &afu_pr_conf.afu_id.pci_addr)

< 0) {

drivers/bus/ifpga/ifpga_bus.c line 118

Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1 -0
+			IFPGA_BUS_ERR("error to parse %s",

IFPGA_ARG_BDF);

Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PORT,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PATH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PATH,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PATH);
+			goto end;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_HIGH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_HIGH,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_high)

< 0) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 13 lines
drivers/bus/ifpga/ifpga_bus.c new file +13 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_LOW) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_LOW,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_low) <

0) {

Quoted 66 lines
drivers/bus/ifpga/ifpga_bus.c new file +66 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_LOW);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PR_ENABLE) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PR_ENABLE,
+			&ifpga_get_integer32_arg, &pr_enable) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_DEBUG) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_DEBUG,
+				       &ifpga_get_integer32_arg, &debug) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (!debug) {
+		pci_bus = rte_bus_find_by_name("pci");
+		if (pci_bus == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI bus\n");
+			goto end;
+		}
+
+		dev = pci_bus->find_device(NULL,
+				ifpga_pci_addr_cmp,
+				&afu_pr_conf.afu_id.pci_addr);
+		if (dev == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI device\n");
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_DEBUG("pci_addr domain   : %x\n",
+				afu_pr_conf.afu_id.pci_addr.domain);
+		IFPGA_BUS_DEBUG("pci_addr bus      : %x\n",
+				afu_pr_conf.afu_id.pci_addr.bus);
+		IFPGA_BUS_DEBUG("pci_addr devid    : %x\n",
+				afu_pr_conf.afu_id.pci_addr.devid);
+		IFPGA_BUS_DEBUG("pci_addr function : %x\n",
+				afu_pr_conf.afu_id.pci_addr.function);
+		IFPGA_BUS_DEBUG("uuid_low          : %lx\n",
+				afu_pr_conf.afu_id.uuid_low);
+		IFPGA_BUS_DEBUG("uuid_high         : %lx\n",
+				afu_pr_conf.afu_id.uuid_high);
+		IFPGA_BUS_DEBUG("afu port          : %x\n",
+				afu_pr_conf.afu_id.port);
+	}
+
+	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;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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.pci_addr.domain = afu_pr_conf.afu_id.pci_addr.domain;
+	afu_dev->id.pci_addr.bus = afu_pr_conf.afu_id.pci_addr.bus;
+	afu_dev->id.pci_addr.devid = afu_pr_conf.afu_id.pci_addr.devid;
+	afu_dev->id.pci_addr.function =
+afu_pr_conf.afu_id.pci_addr.function;

Can you add a function called rte_pci_addr_cpy in librte_pci and use it instead of doing this by hand here? Others would benefit from this.

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+	afu_dev->id.port      = afu_pr_conf.afu_id.port;
+	afu_dev->ifpga_dev    = ifpga_dev;

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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;
+	if (pr_enable) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy is dangerous here, please use strlcpy or snprintf. (And your use of strncpy is dangerous, you are limitting the write to the length of the source, not to the size of the destination.)

Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+	}
+
+	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
+rte_ifpga_scan(void)

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_devargs *devargs;
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rawdev = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct rte_afu_device *afu_dev = NULL;
+
+	/* for FPGA devices we scan the devargs_list populated via cmdline

*/

Quoted 15 lines
drivers/bus/ifpga/ifpga_bus.c new file +15 -0
+	TAILQ_FOREACH(devargs, &devargs_list, next) {
+		if (devargs->bus != &rte_ifpga_bus.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_BDF) == 1) {
+			if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+				&ifpga_get_bdf_arg, &pci_addr) < 0) {
+				IFPGA_BUS_ERR("error to parse %s",
+					IFPGA_ARG_BDF);

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_PATH);
+			goto end;
+		}
+
+		memset(name, 0, sizeof(name));
+		snprintf(name, RTE_RAWDEV_NAME_MAX_LEN,

"IFPGA:%x:%x:%x",

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+		pci_addr.bus, pci_addr.devid, pci_addr.function);
+
+		rawdev = rte_rawdev_pmd_get_named_dev(name);
+		if (!rawdev)
+			goto end;
+
+		if (ifpga_find_ifpga_dev(&pci_addr))

drivers/bus/ifpga/ifpga_bus.c line 343

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			goto end;
+
+		ifpga_dev = calloc(1, sizeof(*ifpga_dev));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->pci_addr.domain   = pci_addr.domain;
+		ifpga_dev->pci_addr.bus      = pci_addr.bus;
+		ifpga_dev->pci_addr.devid    = pci_addr.devid;
+		ifpga_dev->pci_addr.function = pci_addr.function;

Again, PCI copy would be nice instead of doing it by hand.

drivers/bus/ifpga/ifpga_bus.c

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+		ifpga_dev->rdev = rawdev;
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&rte_ifpga_bus.ifpga_list, ifpga_dev,

next);

drivers/bus/ifpga/ifpga_bus.c

Quoted 3 lines
drivers/bus/ifpga/ifpga_bus.c new file +3 -0
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,

next);

Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c new file +8 -0
+	}
+
+end:
+	if (kvlist)
+		rte_kvargs_free(kvlist);
+
+	return 0;
+}

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+static int
+ifpga_probe_one_driver(struct rte_afu_driver *drv,
+			struct rte_afu_device *afu_dev)
+{
+	int ret;
+
+	if ((drv->id.pci_addr.bus == afu_dev->id.pci_addr.bus) &&
+		(drv->id.pci_addr.devid == afu_dev->id.pci_addr.devid) &&
+		(drv->id.pci_addr.function == afu_dev->id.pci_addr.function)

&&

There is the rte_pci_addr_cmp function that should be used here instead. Additionally, you haven't responded to my comment about ignoring the Domain part of the address. Why? Is there a reason for this? Is the domain irrelevant? If so, it should be documented. If not, please use the relevant function instead.

Quoted 40 lines
drivers/bus/ifpga/ifpga_bus.c new file +40 -0
+		(drv->id.uuid_low == afu_dev->id.uuid_low) &&
+		(drv->id.uuid_high == afu_dev->id.uuid_high) &&
+		(drv->id.port == afu_dev->id.port)) {
+
+		afu_dev->driver = drv;
+
+		/* call the driver probe() function */
+		ret = drv->probe(afu_dev);
+		if (ret)
+			afu_dev->driver = NULL;
+		return ret;
+	}
+
+	/* return positive value if driver doesn't support this device */
+	return 1;
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) {
+	const char *name;
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	name = rte_ifpga_device_name(afu_dev);
+	IFPGA_BUS_DEBUG("Search driver %s to probe device %s\n", name,
+		rte_ifpga_device_name(afu_dev));
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;
+		if (rc > 0)

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function
+for

One should read IFPGA bus here I guess.

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+ * all registered drivers that have a matching entry in its
+id_table
+ * for discovered devices.
+ */
+static int
+rte_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, &rte_ifpga_bus.ifpga_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 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9 -0
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_ifpga_plug(struct rte_device *dev) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	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);

drivers/bus/ifpga/ifpga_bus.c line 464

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+		return 1;
+	}
+
+	driver = container_of(afu_dev->device.driver,
+		const struct rte_afu_driver,
+		driver);

No RTE_DRV_TO_AFU_CONST? It would be easier to read.

Quoted 68 lines
drivers/bus/ifpga/ifpga_bus.c new file +68 -0
+	return driver->remove(afu_dev);
+}
+
+static int
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	if (ret)
+		return ret;
+
+	TAILQ_REMOVE(&ifpga_dev->afu_list, afu_dev, next);
+
+	TAILQ_REMOVE(&devargs_list, devargs, next);
+
+	free(devargs->args);
+	free(devargs);
+	free(afu_dev);
+	return 0;
+
+}
+
+static struct rte_device *
+rte_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, &rte_ifpga_bus.ifpga_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
+rte_ifpga_parse(const char *name, void *addr) {
+	struct rte_afu_driver **out = addr;
+	struct rte_afu_driver *driver = NULL;
+
+	TAILQ_FOREACH(driver, &rte_ifpga_bus.driver_list, next) {
+		if (strncmp(driver->driver.name, name,
+			    strlen(driver->driver.name)) == 0)
+			break;
+		if (driver->driver.alias &&
+		    strncmp(driver->driver.alias, name,
+			    strlen(driver->driver.alias)) == 0)
+			break;
+	}
+	if (driver != NULL &&

drivers/bus/ifpga/ifpga_bus.c line 545

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	    addr != NULL)
+		*out = driver;
+	return driver == NULL;
+}
+
+struct rte_ifpga_bus rte_ifpga_bus = {
+	 .bus = {
+		 .scan        = rte_ifpga_scan,
+		 .probe       = rte_ifpga_probe,
+		 .find_device = rte_ifpga_find_device,

Wrong indentation (2 tabs instead of one).

drivers/bus/ifpga/ifpga_bus.c line 551

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+	     .plug        = rte_ifpga_plug,
+	     .unplug      = rte_ifpga_unplug,
+	     .parse       = rte_ifpga_parse,
+	 },
+	.ifpga_list  = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.ifpga_list),
+	.driver_list = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.driver_list),

Why are those lists part of the bus definition? Can you do the same as the vdev bus and have them statically declared in your source file only?

Is there a reason you want them part of the bus, do you need to access it somewhere?

Quoted 82 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+};
+
+RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus.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 +65 -0
new file mode 100644
index 0000000..03a8d48
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_kvargs.h>
+#include <rte_alarm.h>
+
+#include "rte_bus_ifpga.h"
+#include "ifpga_logs.h"
+#include "ifpga_common.h"
+
+int 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 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;

drivers/bus/ifpga/ifpga_common.c line 75

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+
+	errno = 0;
+
+	num = strtoul(str, &end, base);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0))
+		return -1;
+
+	return num;
+
+}

Missing newline here.

Quoted 26 lines
drivers/bus/ifpga/ifpga_common.c new file +26 -0
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args) { #define MAX_PATH_LEN 1024
+	struct rte_pci_addr *addr;
+	int num[4];
+	char str[MAX_PATH_LEN];
+	int i, j;
+
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	addr = (struct rte_pci_addr *)extra_args;
+	strcpy(str, value);
+	memset(num, 0, 4 * sizeof(num[0]));
+	i = strlen(str) - 1;
+	j = 3;
+	while (i > 0 && j >= 0) {
+		while ((str[i - 1] != ':' && str[i - 1] != '.') && i > 0)
+			i--;
+		num[j--] = ifpga_get_unsigned_long(&str[i], 16);
+		i--;
+		if (i >= 0)
+			str[i] = '\0';
+	}
+	addr->domain = num[0];
+	addr->bus = num[1];
+	addr->devid = num[2];

drivers/bus/ifpga/ifpga_common.c line 118

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+	addr->function = num[3];
+	printf("[%s]: bdf %04d:%02d:%02d.%02d\n",
+			__func__,
+			addr->domain,
+			addr->bus,
+			addr->devid,
+			addr->function);
+
+	return 0;
+}

Use rte_pci_addr_parse instead of rewriting it please.

drivers/bus/ifpga/ifpga_common.c

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1)
+{
+	if ((afu_id0->pci_addr.bus       == afu_id1->pci_addr.bus) &&
+		(afu_id0->pci_addr.devid     == afu_id1->pci_addr.devid) &&
+		(afu_id0->pci_addr.function  == afu_id1->pci_addr.function)

&&

drivers/bus/ifpga/ifpga_common.c line 132

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+		(afu_id0->uuid_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}

You used the exact same check in the ifpga_bus.c file, why not call this function instead?

drivers/bus/ifpga/ifpga_common.c line 140

Quoted 8 lines
drivers/bus/ifpga/ifpga_common.c new file +8 -0
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr)
+{
+	struct rte_pci_device *pdev;
+	const struct rte_pci_addr *paddr = _pci_addr;
+
+	pdev = RTE_DEV_TO_PCI(*(struct rte_device **)(void *)&dev);
+	return rte_eal_compare_pci_addr(&pdev->addr, paddr);

This function is deprecated (I should mark is as so to forbid its use). Use rte_pci_addr_cmp() instead.

Quoted 49 lines
drivers/bus/ifpga/ifpga_common.c new file +1 -0
+}
drivers/bus/ifpga/ifpga_common.h new file +21 -0
new file mode 100644
index 0000000..48a5012
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_unsigned_long(const char *str, int base); int
+ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int ifpga_afu_id_cmp(const
+struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1); int ifpga_pci_addr_cmp(const
+struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
(quoted diff) +0 -0

b/drivers/bus/ifpga/ifpga_logs.h new file mode 100644 index 0000000..e3f4849

drivers/bus/ifpga/ifpga_logs.h new file +14 -0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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)
+
Quoted 8 lines

drivers/bus/ifpga/ifpga_logs.h

Quoted 8 lines
drivers/bus/ifpga/ifpga_logs.h new file +8 -0
+#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,

Quoted 105 lines
Quoted 38 lines
drivers/bus/ifpga/ifpga_logs.h new file +8 -0
+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/rte_bus_ifpga.h new file +23 -0
new file mode 100644
index 0000000..7290149
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _RTE_BUS_IFPGA_H_
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI 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 */

drivers/bus/ifpga/rte_bus_ifpga.h line 33

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+struct rte_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_afu_driver_list, rte_afu_driver);

Is there a reason for you to expose your lists publicly? These symbols should be made private to your bus unless necessary.

drivers/bus/ifpga/rte_bus_ifpga.h line 43

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+
+#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
+
+/**
+ * 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_pci_addr pci_addr;

You use a symbol from librte_pci, without linking it.

Quoted 29 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +29 -0
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;
+	char		bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices */
+};
+
+/**
+ * A structure describing a AFU device.

drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource

*/

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 73 lines
Quoted 54 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +47 -0
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI 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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	struct rte_afu_id id;	                /**< AFU id within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus  */ struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA drivers
+*/ };
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+void rte_ifpga_driver_register(struct rte_afu_driver *driver); void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
+
+
+#endif /* _RTE_BUS_IFPGA_H_ */
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +0 -0
new file mode 100644
index 0000000..4edc9c0

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Wrong indentation.
It should be one tabulation, not 4 spaces.

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -1
+
+	local: *;
+};
--

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#24 lore raw

Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

In reply to Xu, Rosen
Quoted 237 lines

-----Original Message-----
From: Xu, Rosen
Sent: Monday, April 02, 2018 12:26
To: '[email protected]' <[email protected]>
Cc: '[email protected]' <[email protected]>; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; '[email protected]' <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: RE: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 212 lines

-----Original Message-----
From: Xu, Rosen
Sent: Sunday, April 01, 2018 0:31
To: [email protected]
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: RE: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 41 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:52
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 5 lines · Rosen Xu
---
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 562

++++++++++++++++++++++++++++

Quoted 24 lines
 drivers/bus/ifpga/ifpga_common.c            | 141 +++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 140 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 8 files changed, 938 insertions(+)  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/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map

drivers/bus/Makefile index renamed from drivers/bus/Makefile +0 -0

7ef2593..55d2dfe 100644

drivers/bus/Makefile +1 -0
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
Quoted 11 lines

drivers/bus/ifpga/Makefile line 2

Quoted 8 lines
drivers/bus/Makefile +0 -0
 include $(RTE_SDK)/mk/rte.subdir.mk diff --git

a/drivers/bus/ifpga/Makefile b/drivers/bus/ifpga/Makefile new file mode 100644 index 0000000..e611950

drivers/bus/ifpga/Makefile new file +2 -0
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel
+Corporation

Copyrigth 2018 (same comment for most SPDX tags, I think I saw 2017 or a variation of it everywhere I think).

It's done by PATCH v4.

Quoted 20 lines
Quoted 20 lines
drivers/bus/ifpga/Makefile new file +20 -0
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
Quoted 8 lines

drivers/bus/ifpga/Makefile line 26

Quoted 4 lines
drivers/bus/ifpga/Makefile new file +4 -0
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal

you should probably load librte_pci.
You use afterward functions (at least address comparison).
I haven't tested the SHARED build, but my guess is that it would break.

The FPGA BUS is based PCI(IFPGA is probed by PCI), do you think so users to add it?

Quoted 2 lines

On that note, you haven't acted on my previous remarks to use the common PCI utilities provided.

It's done in PATCH v4.

Quoted 108 lines
Quoted 89 lines
drivers/bus/ifpga/Makefile new file +7 -0
+
+#
+# Export include files
+#
+SYMLINK-y-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..092be65

drivers/bus/ifpga/ifpga_bus.c new file +76 -0
@@ -0,0 +1,562 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.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;
+
+/* register a ifpga bus based driver */ void
+rte_ifpga_driver_register(struct rte_afu_driver *driver) {
+	RTE_VERIFY(driver);
+
+	TAILQ_INSERT_TAIL(&rte_ifpga_bus.driver_list, driver, next); }
+
+/* un-register a fpga bus based driver */ void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver) {
+	TAILQ_REMOVE(&rte_ifpga_bus.driver_list, driver, next); }
+
+static struct rte_ifpga_device *
+ifpga_find_ifpga_dev(const struct rte_pci_addr *pci_addr) {
+	struct rte_ifpga_device *ifpga_dev = NULL;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		if (!rte_pci_addr_cmp(&ifpga_dev->pci_addr, pci_addr))
+			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_BDF          "bdf"
+	IFPGA_ARG_BDF,
+#define IFPGA_ARG_PORT         "port"
+	IFPGA_ARG_PORT,
+#define IFPGA_ARG_PATH         "path"
+	IFPGA_ARG_PATH,

drivers/bus/ifpga/ifpga_bus.c line 86

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+#define IFPGA_ARG_UUID_HIGH    "uuid_high"
+	IFPGA_ARG_UUID_HIGH,
+#define IFPGA_ARG_UUID_LOW     "uuid_low"
+	IFPGA_ARG_UUID_LOW,
+#define IFPGA_ARG_PR_ENABLE     "pr_enable"
+	IFPGA_ARG_PR_ENABLE,
+#define IFPGA_ARG_DEBUG         "debug"
+	IFPGA_ARG_DEBUG,
+	NULL
+};

So these parameters are parsed during scan afterward, taken from the PCI device that was probed.

Given the kerfuffle of the VIRTUAL devtype in the EAL option, I'm not sure how the PCI bus would react with your IFPGA PCI device being probed by its blacklist operation: the devargs would be null. Do you segfault during your scan? Have you tested this?

Quoted 10 lines
Quoted 5 lines

Why are those parameters parsed again here on this note? Shouldn't they be parsed by the PCI device being probed with a custome PCI driver that you would have added (and I think you provide it afterward), that would spawn the rawdev with the relevant metadata? Then you could scan this rawdev here and have all these parameters

already parsed?

Quoted 3 lines

Is there a reason that you did all this in this order? (specific initialization step for example?)

Quoted 6 lines

Pls see PATCH v4 and my reply for your email of PATCH v3 1/6. The command line is in that email.

For PATCH v4 I have removed all modification from eal library.
I use vdev driver to take parameter configuration, and this vdev driver call rte_eal_hotplug_add() to add afu device and trigger scan/probe.

This is the run command example(take 2 afu device for example):
testpmd -c 0x3 -n 4 --socket-mem 1024,0 --huge-dir=/mnt/huge \
--vdev 'net_ifpga_cfg0,bdf=5e:00.0,port=0,afu_bts=./afu_1.gbs' \
--vdev 'net_ifpga_cfg1,bdf=be:00.0,port=0,afu_bts=./afu_2.gbs' -- -i --no-numa

Quoted 913 lines
Quoted 913 lines
Quoted 717 lines
Quoted 22 lines
drivers/bus/ifpga/ifpga_bus.c new file +22 -0
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the
+devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,
+	struct rte_ifpga_device *ifpga_dev) {
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_bus *pci_bus = NULL;
+	struct rte_device *dev = 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;
+	int pr_enable = 1;
+	int debug = 0;
+
+	memset((char *)(&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_BDF) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+			&ifpga_get_bdf_arg, &afu_pr_conf.afu_id.pci_addr)

< 0) {

drivers/bus/ifpga/ifpga_bus.c line 119

Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1 -0
+			IFPGA_BUS_ERR("error to parse %s",

IFPGA_ARG_BDF);

Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PORT,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PATH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PATH,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PATH);
+			goto end;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_HIGH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_HIGH,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_high)

< 0) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 13 lines
drivers/bus/ifpga/ifpga_bus.c new file +13 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_LOW) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_LOW,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_low) <

0) {

Quoted 66 lines
drivers/bus/ifpga/ifpga_bus.c new file +66 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_LOW);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PR_ENABLE) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PR_ENABLE,
+			&ifpga_get_integer32_arg, &pr_enable) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_DEBUG) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_DEBUG,
+				       &ifpga_get_integer32_arg, &debug) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (!debug) {
+		pci_bus = rte_bus_find_by_name("pci");
+		if (pci_bus == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI bus\n");
+			goto end;
+		}
+
+		dev = pci_bus->find_device(NULL,
+				ifpga_pci_addr_cmp,
+				&afu_pr_conf.afu_id.pci_addr);
+		if (dev == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI device\n");
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_DEBUG("pci_addr domain   : %x\n",
+				afu_pr_conf.afu_id.pci_addr.domain);
+		IFPGA_BUS_DEBUG("pci_addr bus      : %x\n",
+				afu_pr_conf.afu_id.pci_addr.bus);
+		IFPGA_BUS_DEBUG("pci_addr devid    : %x\n",
+				afu_pr_conf.afu_id.pci_addr.devid);
+		IFPGA_BUS_DEBUG("pci_addr function : %x\n",
+				afu_pr_conf.afu_id.pci_addr.function);
+		IFPGA_BUS_DEBUG("uuid_low          : %lx\n",
+				afu_pr_conf.afu_id.uuid_low);
+		IFPGA_BUS_DEBUG("uuid_high         : %lx\n",
+				afu_pr_conf.afu_id.uuid_high);
+		IFPGA_BUS_DEBUG("afu port          : %x\n",
+				afu_pr_conf.afu_id.port);
+	}
+
+	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;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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.pci_addr.domain = afu_pr_conf.afu_id.pci_addr.domain;
+	afu_dev->id.pci_addr.bus = afu_pr_conf.afu_id.pci_addr.bus;
+	afu_dev->id.pci_addr.devid = afu_pr_conf.afu_id.pci_addr.devid;
+	afu_dev->id.pci_addr.function =
+afu_pr_conf.afu_id.pci_addr.function;

Can you add a function called rte_pci_addr_cpy in librte_pci and use it instead of doing this by hand here? Others would benefit from this.

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+	afu_dev->id.port      = afu_pr_conf.afu_id.port;
+	afu_dev->ifpga_dev    = ifpga_dev;

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+	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;
+	if (pr_enable) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy is dangerous here, please use strlcpy or snprintf. (And your use of strncpy is dangerous, you are limitting the write to the length of the source, not to the size of the destination.)

Quoted 29 lines
drivers/bus/ifpga/ifpga_bus.c new file +29 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+	}
+
+	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
+rte_ifpga_scan(void)
+{

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_devargs *devargs;
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rawdev = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct rte_afu_device *afu_dev = NULL;
+
+	/* for FPGA devices we scan the devargs_list populated via
+cmdline

*/

Quoted 15 lines
drivers/bus/ifpga/ifpga_bus.c new file +15 -0
+	TAILQ_FOREACH(devargs, &devargs_list, next) {
+		if (devargs->bus != &rte_ifpga_bus.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_BDF) == 1) {
+			if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+				&ifpga_get_bdf_arg, &pci_addr) < 0) {
+				IFPGA_BUS_ERR("error to parse %s",
+					IFPGA_ARG_BDF);

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_PATH);
+			goto end;
+		}
+
+		memset(name, 0, sizeof(name));
+		snprintf(name, RTE_RAWDEV_NAME_MAX_LEN,

"IFPGA:%x:%x:%x",

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+		pci_addr.bus, pci_addr.devid, pci_addr.function);
+
+		rawdev = rte_rawdev_pmd_get_named_dev(name);
+		if (!rawdev)
+			goto end;
+
+		if (ifpga_find_ifpga_dev(&pci_addr))

drivers/bus/ifpga/ifpga_bus.c line 343

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			goto end;
+
+		ifpga_dev = calloc(1, sizeof(*ifpga_dev));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->pci_addr.domain   = pci_addr.domain;
+		ifpga_dev->pci_addr.bus      = pci_addr.bus;
+		ifpga_dev->pci_addr.devid    = pci_addr.devid;
+		ifpga_dev->pci_addr.function = pci_addr.function;

Again, PCI copy would be nice instead of doing it by hand.

drivers/bus/ifpga/ifpga_bus.c

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+		ifpga_dev->rdev = rawdev;
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&rte_ifpga_bus.ifpga_list, ifpga_dev,

next);

drivers/bus/ifpga/ifpga_bus.c

Quoted 3 lines
drivers/bus/ifpga/ifpga_bus.c new file +3 -0
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,

next);

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+	}
+
+end:
+	if (kvlist)
+		rte_kvargs_free(kvlist);
+
+	return 0;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+}
+
+static int
+ifpga_probe_one_driver(struct rte_afu_driver *drv,
+			struct rte_afu_device *afu_dev) {
+	int ret;
+
+	if ((drv->id.pci_addr.bus == afu_dev->id.pci_addr.bus) &&
+		(drv->id.pci_addr.devid == afu_dev->id.pci_addr.devid) &&
+		(drv->id.pci_addr.function == afu_dev->id.pci_addr.function)

&&

There is the rte_pci_addr_cmp function that should be used here instead. Additionally, you haven't responded to my comment about ignoring the Domain part of the address. Why? Is there a reason for this? Is the domain irrelevant? If so, it should be documented. If not, please use the relevant function instead.

Quoted 40 lines
drivers/bus/ifpga/ifpga_bus.c new file +40 -0
+		(drv->id.uuid_low == afu_dev->id.uuid_low) &&
+		(drv->id.uuid_high == afu_dev->id.uuid_high) &&
+		(drv->id.port == afu_dev->id.port)) {
+
+		afu_dev->driver = drv;
+
+		/* call the driver probe() function */
+		ret = drv->probe(afu_dev);
+		if (ret)
+			afu_dev->driver = NULL;
+		return ret;
+	}
+
+	/* return positive value if driver doesn't support this device */
+	return 1;
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) {
+	const char *name;
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	name = rte_ifpga_device_name(afu_dev);
+	IFPGA_BUS_DEBUG("Search driver %s to probe device %s\n", name,
+		rte_ifpga_device_name(afu_dev));
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;
+		if (rc > 0)

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function
+for

One should read IFPGA bus here I guess.

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+ * all registered drivers that have a matching entry in its
+id_table
+ * for discovered devices.
+ */
+static int
+rte_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, &rte_ifpga_bus.ifpga_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 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9 -0
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_ifpga_plug(struct rte_device *dev) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	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);

drivers/bus/ifpga/ifpga_bus.c line 464

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+		return 1;
+	}
+
+	driver = container_of(afu_dev->device.driver,
+		const struct rte_afu_driver,
+		driver);

No RTE_DRV_TO_AFU_CONST? It would be easier to read.

Quoted 68 lines
drivers/bus/ifpga/ifpga_bus.c new file +68 -0
+	return driver->remove(afu_dev);
+}
+
+static int
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	if (ret)
+		return ret;
+
+	TAILQ_REMOVE(&ifpga_dev->afu_list, afu_dev, next);
+
+	TAILQ_REMOVE(&devargs_list, devargs, next);
+
+	free(devargs->args);
+	free(devargs);
+	free(afu_dev);
+	return 0;
+
+}
+
+static struct rte_device *
+rte_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, &rte_ifpga_bus.ifpga_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
+rte_ifpga_parse(const char *name, void *addr) {
+	struct rte_afu_driver **out = addr;
+	struct rte_afu_driver *driver = NULL;
+
+	TAILQ_FOREACH(driver, &rte_ifpga_bus.driver_list, next) {
+		if (strncmp(driver->driver.name, name,
+			    strlen(driver->driver.name)) == 0)
+			break;
+		if (driver->driver.alias &&
+		    strncmp(driver->driver.alias, name,
+			    strlen(driver->driver.alias)) == 0)
+			break;
+	}
+	if (driver != NULL &&

drivers/bus/ifpga/ifpga_bus.c line 545

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	    addr != NULL)
+		*out = driver;
+	return driver == NULL;
+}
+
+struct rte_ifpga_bus rte_ifpga_bus = {
+	 .bus = {
+		 .scan        = rte_ifpga_scan,
+		 .probe       = rte_ifpga_probe,
+		 .find_device = rte_ifpga_find_device,

Wrong indentation (2 tabs instead of one).

drivers/bus/ifpga/ifpga_bus.c

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+	     .plug        = rte_ifpga_plug,
+	     .unplug      = rte_ifpga_unplug,
+	     .parse       = rte_ifpga_parse,
+	 },
+	.ifpga_list  = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.ifpga_list),
+	.driver_list =
+TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.driver_list),

Why are those lists part of the bus definition? Can you do the same as the vdev bus and have them statically declared in your source file only?

Is there a reason you want them part of the bus, do you need to access it somewhere?

Quoted 82 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+};
+
+RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus.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 +65 -0
new file mode 100644
index 0000000..03a8d48
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_kvargs.h>
+#include <rte_alarm.h>
+
+#include "rte_bus_ifpga.h"
+#include "ifpga_logs.h"
+#include "ifpga_common.h"
+
+int 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 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;

drivers/bus/ifpga/ifpga_common.c line 75

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+
+	errno = 0;
+
+	num = strtoul(str, &end, base);
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0))
+		return -1;
+
+	return num;
+
+}

Missing newline here.

Quoted 26 lines
drivers/bus/ifpga/ifpga_common.c new file +26 -0
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args) { #define MAX_PATH_LEN 1024
+	struct rte_pci_addr *addr;
+	int num[4];
+	char str[MAX_PATH_LEN];
+	int i, j;
+
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	addr = (struct rte_pci_addr *)extra_args;
+	strcpy(str, value);
+	memset(num, 0, 4 * sizeof(num[0]));
+	i = strlen(str) - 1;
+	j = 3;
+	while (i > 0 && j >= 0) {
+		while ((str[i - 1] != ':' && str[i - 1] != '.') && i > 0)
+			i--;
+		num[j--] = ifpga_get_unsigned_long(&str[i], 16);
+		i--;
+		if (i >= 0)
+			str[i] = '\0';
+	}
+	addr->domain = num[0];
+	addr->bus = num[1];
+	addr->devid = num[2];

drivers/bus/ifpga/ifpga_common.c line 118

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +10 -0
+	addr->function = num[3];
+	printf("[%s]: bdf %04d:%02d:%02d.%02d\n",
+			__func__,
+			addr->domain,
+			addr->bus,
+			addr->devid,
+			addr->function);
+
+	return 0;
+}

Use rte_pci_addr_parse instead of rewriting it please.

drivers/bus/ifpga/ifpga_common.c

Quoted 6 lines
drivers/bus/ifpga/ifpga_common.c new file +6 -0
+
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1) {
+	if ((afu_id0->pci_addr.bus       == afu_id1->pci_addr.bus) &&
+		(afu_id0->pci_addr.devid     == afu_id1->pci_addr.devid) &&
+		(afu_id0->pci_addr.function  == afu_id1->pci_addr.function)

&&

drivers/bus/ifpga/ifpga_common.c line 132

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+		(afu_id0->uuid_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}

You used the exact same check in the ifpga_bus.c file, why not call this function instead?

drivers/bus/ifpga/ifpga_common.c line 140

Quoted 8 lines
drivers/bus/ifpga/ifpga_common.c new file +8 -0
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr)
+{
+	struct rte_pci_device *pdev;
+	const struct rte_pci_addr *paddr = _pci_addr;
+
+	pdev = RTE_DEV_TO_PCI(*(struct rte_device **)(void *)&dev);
+	return rte_eal_compare_pci_addr(&pdev->addr, paddr);

This function is deprecated (I should mark is as so to forbid its use). Use rte_pci_addr_cmp() instead.

Quoted 49 lines
drivers/bus/ifpga/ifpga_common.c new file +1 -0
+}
drivers/bus/ifpga/ifpga_common.h new file +21 -0
new file mode 100644
index 0000000..48a5012
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_unsigned_long(const char *str, int base); int
+ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int ifpga_afu_id_cmp(const
+struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1); int ifpga_pci_addr_cmp(const
+struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
(quoted diff) +0 -0

b/drivers/bus/ifpga/ifpga_logs.h new file mode 100644 index 0000000..e3f4849

drivers/bus/ifpga/ifpga_logs.h new file +14 -0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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)
+
Quoted 8 lines

drivers/bus/ifpga/ifpga_logs.h

Quoted 8 lines
drivers/bus/ifpga/ifpga_logs.h new file +8 -0
+#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,

Quoted 105 lines
Quoted 38 lines
drivers/bus/ifpga/ifpga_logs.h new file +8 -0
+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/rte_bus_ifpga.h new file +23 -0
new file mode 100644
index 0000000..7290149
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _RTE_BUS_IFPGA_H_
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI 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 */

drivers/bus/ifpga/rte_bus_ifpga.h line 33

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+struct rte_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_afu_driver_list, rte_afu_driver);

Is there a reason for you to expose your lists publicly? These symbols should be made private to your bus unless necessary.

drivers/bus/ifpga/rte_bus_ifpga.h line 43

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+
+#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
+
+/**
+ * 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_pci_addr pci_addr;

You use a symbol from librte_pci, without linking it.

Quoted 29 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +29 -0
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;
+	char		bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices
+*/ };
+
+/**
+ * A structure describing a AFU device.

drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource

*/

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 73 lines
Quoted 54 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +47 -0
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI 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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	struct rte_afu_id id;	                /**< AFU id within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus  */ struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA
+drivers */ };
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+void rte_ifpga_driver_register(struct rte_afu_driver *driver);
+void rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
+
+
+#endif /* _RTE_BUS_IFPGA_H_ */
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +0 -0
new file mode 100644
index 0000000..4edc9c0

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Wrong indentation.
It should be one tabulation, not 4 spaces.

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -1
+
+	local: *;
+};
--

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#25 lore raw

Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

In reply to Gaëtan Rivet

Hi Gaetan,

Quoted 40 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:52
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 4/6] drivers/bus: Add Intel FPGA Bus Lib Code

Quoted 5 lines · Rosen Xu
---
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 562

++++++++++++++++++++++++++++

Quoted 24 lines
 drivers/bus/ifpga/ifpga_common.c            | 141 +++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 140 +++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 8 files changed, 938 insertions(+)
 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/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map

drivers/bus/Makefile index renamed from drivers/bus/Makefile +0 -0

7ef2593..55d2dfe 100644

drivers/bus/Makefile +1 -0
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
Quoted 11 lines

drivers/bus/ifpga/Makefile line 2

Quoted 8 lines
drivers/bus/Makefile +0 -0
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +2 -0
new file mode 100644 index 0000000..e611950
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel
+Corporation

Copyrigth 2018 (same comment for most SPDX tags, I think I saw 2017 or a variation of it everywhere I think).

For PATCH v4 and later patches, I have change all the Copyright 2017 to Copyright 2018.

Quoted 20 lines
Quoted 20 lines
drivers/bus/ifpga/Makefile new file +20 -0
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_bus_ifpga.a
+
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
Quoted 8 lines

drivers/bus/ifpga/Makefile line 26

Quoted 4 lines
drivers/bus/ifpga/Makefile new file +4 -0
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal

you should probably load librte_pci.
You use afterward functions (at least address comparison).
I haven't tested the SHARED build, but my guess is that it would break.

Yes, I have fixed it and test with SHARED build in PATCH v5.

Quoted 2 lines

On that note, you haven't acted on my previous remarks to use the common PCI utilities provided.

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have removed all pci_addr and pci common function in PATCH v5.

Quoted 109 lines
Quoted 90 lines
drivers/bus/ifpga/Makefile new file +7 -0
+
+#
+# Export include files
+#
+SYMLINK-y-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..092be65

drivers/bus/ifpga/ifpga_bus.c new file +77 -0
@@ -0,0 +1,562 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.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;
+
+/* register a ifpga bus based driver */ void
+rte_ifpga_driver_register(struct rte_afu_driver *driver) {
+	RTE_VERIFY(driver);
+
+	TAILQ_INSERT_TAIL(&rte_ifpga_bus.driver_list, driver, next); }
+
+/* un-register a fpga bus based driver */ void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver) {
+	TAILQ_REMOVE(&rte_ifpga_bus.driver_list, driver, next); }
+
+static struct rte_ifpga_device *
+ifpga_find_ifpga_dev(const struct rte_pci_addr *pci_addr) {
+	struct rte_ifpga_device *ifpga_dev = NULL;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		if (!rte_pci_addr_cmp(&ifpga_dev->pci_addr, pci_addr))
+			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_BDF          "bdf"
+	IFPGA_ARG_BDF,
+#define IFPGA_ARG_PORT         "port"
+	IFPGA_ARG_PORT,
+#define IFPGA_ARG_PATH         "path"
+	IFPGA_ARG_PATH,

drivers/bus/ifpga/ifpga_bus.c line 87

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+#define IFPGA_ARG_UUID_HIGH    "uuid_high"
+	IFPGA_ARG_UUID_HIGH,
+#define IFPGA_ARG_UUID_LOW     "uuid_low"
+	IFPGA_ARG_UUID_LOW,
+#define IFPGA_ARG_PR_ENABLE     "pr_enable"
+	IFPGA_ARG_PR_ENABLE,
+#define IFPGA_ARG_DEBUG         "debug"
+	IFPGA_ARG_DEBUG,
+	NULL
+};

So these parameters are parsed during scan afterward, taken from the PCI device that was probed.

Given the kerfuffle of the VIRTUAL devtype in the EAL option, I'm not sure how the PCI bus would react with your IFPGA PCI device being probed by its blacklist operation: the devargs would be null. Do you segfault during your scan? Have you tested this?

Quoted 8 lines

Why are those parameters parsed again here on this note? Shouldn't they be parsed by the PCI device being probed with a custome PCI driver that you would have added (and I think you provide it afterward), that would spawn the rawdev with the relevant metadata? Then you could scan this rawdev here and have all these parameters already parsed?

Is there a reason that you did all this in this order? (specific initialization step for example?)

For PATCH v4 and later patches, I have remove all the modifications from eal library, is it ok?

Quoted 157 lines
Quoted 21 lines
drivers/bus/ifpga/ifpga_bus.c new file +21 -0
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,
+	struct rte_ifpga_device *ifpga_dev)
+{
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_bus *pci_bus = NULL;
+	struct rte_device *dev = 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;
+	int pr_enable = 1;
+	int debug = 0;
+
+	memset((char *)(&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_BDF) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+			&ifpga_get_bdf_arg, &afu_pr_conf.afu_id.pci_addr)

< 0) {

drivers/bus/ifpga/ifpga_bus.c line 119

Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1 -0
+			IFPGA_BUS_ERR("error to parse %s",

IFPGA_ARG_BDF);

Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PORT) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PORT,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PATH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PATH,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PATH);
+			goto end;

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_HIGH) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_HIGH,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_high)

< 0) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 13 lines
drivers/bus/ifpga/ifpga_bus.c new file +13 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_UUID_LOW) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_UUID_LOW,
+		&ifpga_get_integer64_arg, &afu_pr_conf.afu_id.uuid_low) <

0) {

Quoted 71 lines
drivers/bus/ifpga/ifpga_bus.c new file +71 -0
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_LOW);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PATH);
+		goto end;
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_PR_ENABLE) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_PR_ENABLE,
+			&ifpga_get_integer32_arg, &pr_enable) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_ARG_DEBUG) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_ARG_DEBUG,
+				       &ifpga_get_integer32_arg, &debug) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_UUID_HIGH);
+			goto end;
+		}
+	}
+
+	if (!debug) {
+		pci_bus = rte_bus_find_by_name("pci");
+		if (pci_bus == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI bus\n");
+			goto end;
+		}
+
+		dev = pci_bus->find_device(NULL,
+				ifpga_pci_addr_cmp,
+				&afu_pr_conf.afu_id.pci_addr);
+		if (dev == NULL) {
+			IFPGA_BUS_ERR("unable to find PCI device\n");
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_DEBUG("pci_addr domain   : %x\n",
+				afu_pr_conf.afu_id.pci_addr.domain);
+		IFPGA_BUS_DEBUG("pci_addr bus      : %x\n",
+				afu_pr_conf.afu_id.pci_addr.bus);
+		IFPGA_BUS_DEBUG("pci_addr devid    : %x\n",
+				afu_pr_conf.afu_id.pci_addr.devid);
+		IFPGA_BUS_DEBUG("pci_addr function : %x\n",
+				afu_pr_conf.afu_id.pci_addr.function);
+		IFPGA_BUS_DEBUG("uuid_low          : %lx\n",
+				afu_pr_conf.afu_id.uuid_low);
+		IFPGA_BUS_DEBUG("uuid_high         : %lx\n",
+				afu_pr_conf.afu_id.uuid_high);
+		IFPGA_BUS_DEBUG("afu port          : %x\n",
+				afu_pr_conf.afu_id.port);
+	}
+
+	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;
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c

Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5 -0
+	afu_dev->id.pci_addr.domain = afu_pr_conf.afu_id.pci_addr.domain;
+	afu_dev->id.pci_addr.bus = afu_pr_conf.afu_id.pci_addr.bus;
+	afu_dev->id.pci_addr.devid = afu_pr_conf.afu_id.pci_addr.devid;
+	afu_dev->id.pci_addr.function =
+afu_pr_conf.afu_id.pci_addr.function;

Can you add a function called rte_pci_addr_cpy in librte_pci and use it instead of doing this by hand here? Others would benefit from this.

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have remove all pci_addr and pci common function in PATCH v5.
So these copy may no need.

Quoted 10 lines
Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+	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 &&
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+		rawdev->dev_ops->dev_start(rawdev))
+		goto free_dev;
+	if (pr_enable) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy is dangerous here, please use strlcpy or snprintf. (And your use of strncpy is dangerous, you are limitting the write to the length of the source, not to the size of the destination.)

Fixed in PATCH v5.

Quoted 113 lines
Quoted 27 lines
drivers/bus/ifpga/ifpga_bus.c new file +27 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+	}
+
+	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
+rte_ifpga_scan(void)

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_devargs *devargs;
+	struct rte_kvargs *kvlist = NULL;
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rawdev = NULL;
+	char name[RTE_RAWDEV_NAME_MAX_LEN];
+	struct rte_afu_device *afu_dev = NULL;
+
+	/* for FPGA devices we scan the devargs_list populated via cmdline

*/

Quoted 15 lines
drivers/bus/ifpga/ifpga_bus.c new file +15 -0
+	TAILQ_FOREACH(devargs, &devargs_list, next) {
+		if (devargs->bus != &rte_ifpga_bus.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_BDF) == 1) {
+			if (rte_kvargs_process(kvlist, IFPGA_ARG_BDF,
+				&ifpga_get_bdf_arg, &pci_addr) < 0) {
+				IFPGA_BUS_ERR("error to parse %s",
+					IFPGA_ARG_BDF);

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_PATH);
+			goto end;
+		}
+
+		memset(name, 0, sizeof(name));
+		snprintf(name, RTE_RAWDEV_NAME_MAX_LEN,

"IFPGA:%x:%x:%x",

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+		pci_addr.bus, pci_addr.devid, pci_addr.function);
+
+		rawdev = rte_rawdev_pmd_get_named_dev(name);
+		if (!rawdev)
+			goto end;
+
+		if (ifpga_find_ifpga_dev(&pci_addr))

drivers/bus/ifpga/ifpga_bus.c line 343

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+			goto end;
+
+		ifpga_dev = calloc(1, sizeof(*ifpga_dev));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->pci_addr.domain   = pci_addr.domain;
+		ifpga_dev->pci_addr.bus      = pci_addr.bus;
+		ifpga_dev->pci_addr.devid    = pci_addr.devid;
+		ifpga_dev->pci_addr.function = pci_addr.function;

Again, PCI copy would be nice instead of doing it by hand.

drivers/bus/ifpga/ifpga_bus.c

Quoted 4 lines
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
+		ifpga_dev->rdev = rawdev;
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&rte_ifpga_bus.ifpga_list, ifpga_dev,

next);

drivers/bus/ifpga/ifpga_bus.c

Quoted 3 lines
drivers/bus/ifpga/ifpga_bus.c new file +3 -0
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev,

next);

Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c new file +8 -0
+	}
+
+end:
+	if (kvlist)
+		rte_kvargs_free(kvlist);
+
+	return 0;
+}

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+static int
+ifpga_probe_one_driver(struct rte_afu_driver *drv,
+			struct rte_afu_device *afu_dev)
+{
+	int ret;
+
+	if ((drv->id.pci_addr.bus == afu_dev->id.pci_addr.bus) &&
+		(drv->id.pci_addr.devid == afu_dev->id.pci_addr.devid) &&
+		(drv->id.pci_addr.function == afu_dev->id.pci_addr.function)

&&

Quoted 5 lines

There is the rte_pci_addr_cmp function that should be used here instead. Additionally, you haven't responded to my comment about ignoring the Domain part of the address. Why? Is there a reason for this? Is the domain irrelevant? If so, it should be documented. If not, please use the relevant function instead.

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have removed all pci_addr and pci common function in PATCH v5.

Quoted 43 lines
Quoted 43 lines
drivers/bus/ifpga/ifpga_bus.c new file +43 -0
+		(drv->id.uuid_low == afu_dev->id.uuid_low) &&
+		(drv->id.uuid_high == afu_dev->id.uuid_high) &&
+		(drv->id.port == afu_dev->id.port)) {
+
+		afu_dev->driver = drv;
+
+		/* call the driver probe() function */
+		ret = drv->probe(afu_dev);
+		if (ret)
+			afu_dev->driver = NULL;
+		return ret;
+	}
+
+	/* return positive value if driver doesn't support this device */
+	return 1;
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) {
+	const char *name;
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	name = rte_ifpga_device_name(afu_dev);
+	IFPGA_BUS_DEBUG("Search driver %s to probe device %s\n", name,
+		rte_ifpga_device_name(afu_dev));
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 418

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+	}
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function for

One should read IFPGA bus here I guess.

I have fixed it in PATCH v5.

Quoted 40 lines
Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9 -0
+ * all registered drivers that have a matching entry in its id_table
+ * for discovered devices.
+ */
+static int
+rte_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, &rte_ifpga_bus.ifpga_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 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +9 -0
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_ifpga_plug(struct rte_device *dev) {

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	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);

Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 464

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+		return 1;
+	}
+
+	driver = container_of(afu_dev->device.driver,
+		const struct rte_afu_driver,
+		driver);

No RTE_DRV_TO_AFU_CONST? It would be easier to read.

I have add RTE_DRV_TO_AFU_CONST macro in PATCH v5.

Quoted 72 lines
Quoted 72 lines
drivers/bus/ifpga/ifpga_bus.c new file +72 -0
+	return driver->remove(afu_dev);
+}
+
+static int
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	if (ret)
+		return ret;
+
+	TAILQ_REMOVE(&ifpga_dev->afu_list, afu_dev, next);
+
+	TAILQ_REMOVE(&devargs_list, devargs, next);
+
+	free(devargs->args);
+	free(devargs);
+	free(afu_dev);
+	return 0;
+
+}
+
+static struct rte_device *
+rte_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, &rte_ifpga_bus.ifpga_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
+rte_ifpga_parse(const char *name, void *addr) {
+	struct rte_afu_driver **out = addr;
+	struct rte_afu_driver *driver = NULL;
+
+	TAILQ_FOREACH(driver, &rte_ifpga_bus.driver_list, next) {
+		if (strncmp(driver->driver.name, name,
+			    strlen(driver->driver.name)) == 0)
+			break;
+		if (driver->driver.alias &&
+		    strncmp(driver->driver.alias, name,
+			    strlen(driver->driver.alias)) == 0)
+			break;
+	}
+	if (driver != NULL &&
+	    addr != NULL)
+		*out = driver;
+	return driver == NULL;
+}
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 545

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+
+struct rte_ifpga_bus rte_ifpga_bus = {
+	 .bus = {
+		 .scan        = rte_ifpga_scan,
+		 .probe       = rte_ifpga_probe,
+		 .find_device = rte_ifpga_find_device,

Wrong indentation (2 tabs instead of one).

Yes, I have fixed it in PATCH v5.

Quoted 10 lines

drivers/bus/ifpga/ifpga_bus.c line 551

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+	     .plug        = rte_ifpga_plug,
+	     .unplug      = rte_ifpga_unplug,
+	     .parse       = rte_ifpga_parse,
+	 },
+	.ifpga_list  = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.ifpga_list),
+	.driver_list = TAILQ_HEAD_INITIALIZER(rte_ifpga_bus.driver_list),

Why are those lists part of the bus definition? Can you do the same as the vdev bus and have them statically declared in your source file only?

Quoted 2 lines

Is there a reason you want them part of the bus, do you need to access it somewhere?

I have fixed it and do the same as the vdev bus in PATCH v5.

Quoted 86 lines
Quoted 86 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+};
+
+RTE_REGISTER_BUS(IFPGA_BUS_NAME, rte_ifpga_bus.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 +69 -0
new file mode 100644
index 0000000..03a8d48
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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_pci.h>
+#include <rte_bus_pci.h>
+#include <rte_kvargs.h>
+#include <rte_alarm.h>
+
+#include "rte_bus_ifpga.h"
+#include "ifpga_logs.h"
+#include "ifpga_common.h"
+
+int 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 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);
Quoted 8 lines

drivers/bus/ifpga/ifpga_common.c line 80

Quoted 6 lines
drivers/bus/ifpga/ifpga_common.c new file +6 -0
+	if ((str[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0))
+		return -1;
+
+	return num;
+
+}

Missing newline here.

Fixe in PATCH v5.

Quoted 30 lines
Quoted 30 lines
drivers/bus/ifpga/ifpga_common.c new file +30 -0
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args) { #define MAX_PATH_LEN 1024
+	struct rte_pci_addr *addr;
+	int num[4];
+	char str[MAX_PATH_LEN];
+	int i, j;
+
+	if (!value || !extra_args)
+		return -EINVAL;
+
+	addr = (struct rte_pci_addr *)extra_args;
+	strcpy(str, value);
+	memset(num, 0, 4 * sizeof(num[0]));
+	i = strlen(str) - 1;
+	j = 3;
+	while (i > 0 && j >= 0) {
+		while ((str[i - 1] != ':' && str[i - 1] != '.') && i > 0)
+			i--;
+		num[j--] = ifpga_get_unsigned_long(&str[i], 16);
+		i--;
+		if (i >= 0)
+			str[i] = '\0';
+	}
+	addr->domain = num[0];
+	addr->bus = num[1];
+	addr->devid = num[2];
+	addr->function = num[3];
+	printf("[%s]: bdf %04d:%02d:%02d.%02d\n",
+			__func__,
+			addr->domain,
Quoted 8 lines

drivers/bus/ifpga/ifpga_common.c line 118

Quoted 6 lines
drivers/bus/ifpga/ifpga_common.c new file +6 -0
+			addr->bus,
+			addr->devid,
+			addr->function);
+
+	return 0;
+}

Use rte_pci_addr_parse instead of rewriting it please.

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have remove All pci_addr and pci common function such as ifpga_get_bdf_arg in PATCH v5.

Quoted 8 lines

drivers/bus/ifpga/ifpga_common.c

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1)
+{
+	if ((afu_id0->pci_addr.bus       == afu_id1->pci_addr.bus) &&
+		(afu_id0->pci_addr.devid     == afu_id1->pci_addr.devid) &&
+		(afu_id0->pci_addr.function  == afu_id1->pci_addr.function)

&&

Quoted 10 lines

drivers/bus/ifpga/ifpga_common.c line 132

Quoted 7 lines
drivers/bus/ifpga/ifpga_common.c new file +7 -0
+		(afu_id0->uuid_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}

You used the exact same check in the ifpga_bus.c file, why not call this function instead?

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have remove All pci_addr and pci common function such ifpga_pci_addr_cmp in PATCH v5.

Quoted 11 lines

drivers/bus/ifpga/ifpga_common.c line 140

Quoted 8 lines
drivers/bus/ifpga/ifpga_common.c new file +8 -0
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr)
+{
+	struct rte_pci_device *pdev;
+	const struct rte_pci_addr *paddr = _pci_addr;
+
+	pdev = RTE_DEV_TO_PCI(*(struct rte_device **)(void *)&dev);
+	return rte_eal_compare_pci_addr(&pdev->addr, paddr);

This function is deprecated (I should mark is as so to forbid its use). Use rte_pci_addr_cmp() instead.

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have remove All pci_addr and pci common function such ifpga_pci_addr_cmp in PATCH v5.

Quoted 100 lines
Quoted 100 lines
drivers/bus/ifpga/ifpga_common.c new file +1 -0
+}
drivers/bus/ifpga/ifpga_common.h new file +21 -0
new file mode 100644
index 0000000..48a5012
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int
+ifpga_get_unsigned_long(const char *str, int base); int
+ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args); int ifpga_afu_id_cmp(const
+struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr);
+
+#endif /* _IFPGA_COMMON_H_ */
(quoted diff) +0 -0

b/drivers/bus/ifpga/ifpga_logs.h new file mode 100644 index 0000000..e3f4849

drivers/bus/ifpga/ifpga_logs.h new file +30 -0
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 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/rte_bus_ifpga.h new file +28 -0
new file mode 100644
index 0000000..7290149
@@ -0,0 +1,140 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation  */
+
+#ifndef _RTE_BUS_IFPGA_H_
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI 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_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 34

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5 -0
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_afu_driver_list, rte_afu_driver);

Is there a reason for you to expose your lists publicly? These symbols should be made private to your bus unless necessary.

Yes, it should be private, and I have fix3e it in PATCH v5.

Quoted 4 lines
Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +4 -0
+
+#define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
+
+/**
Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 43

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +6 -0
+ * 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_pci_addr pci_addr;

You use a symbol from librte_pci, without linking it.

To be honest, FPGA BUS only need IFPGA_Rawdev name not pci_addr, so I have remove All pci_addr and pci common function in PATCH v5.

Quoted 101 lines
Quoted 28 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +28 -0
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;
+	char		bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices */ };
+
+/**
+ * A structure describing a AFU device.

drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource

*/

Quoted 62 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +55 -0
+	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	struct rte_afu_driver *driver;          /**< Associated driver */
+	char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+} __attribute__ ((packed));
+
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_afu_device.
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI 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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	struct rte_afu_id id;	                /**< AFU id within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus  */ struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA drivers
+*/ };
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+void rte_ifpga_driver_register(struct rte_afu_driver *driver); void
+rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
+
+
+#endif /* _RTE_BUS_IFPGA_H_ */
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +0 -0
new file mode 100644
index 0000000..4edc9c0
@@ -0,0 +1,8 @@
Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Wrong indentation.
It should be one tabulation, not 4 spaces.

Fixed in PATCH v5.

Quoted 10 lines
Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -1
+
+	local: *;
+};
--

1.8.3.1

--
Gaëtan Rivet
6WIND

author
#26 lore raw

PATCH v3 5/6 drivers/raw/ifpga_rawdev: Add Intel FPGA Rawdev Driver Code

In reply to Rosen Xu
---
 drivers/raw/Makefile                               |   1 +
 drivers/raw/ifpga_rawdev/Makefile                  |  35 ++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 492 +++++++++++++++++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c    |  98 ++++
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
 6 files changed, 667 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
drivers/raw/Makefile +1 -0
index da7c8b4..6fc8f2f 100644
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 # DIRS-$(<configuration>) += <directory>
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +35 -0
new file mode 100644
index 0000000..b3d1bdb
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2017 Intel Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga
+CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev_example.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +492 -0

492 lines not on this page · raw message

drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
new file mode 100644
index 0000000..f262180
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2017 Intel Corporation
+ */
+
+#ifndef _IFPGA_RAWDEV_H_
+#define _IFPGA_RAWDEV_H_
+
+extern int ifpga_rawdev_logtype;
+
+#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \
+		__func__, ##args)
+
+#define IFPGA_RAWDEV_PMD_FUNC_TRACE() IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>")
+
+#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args)
+
+enum ifpga_rawdev_device_state {
+	IFPGA_IDLE,
+	IFPGA_READY,
+	IFPGA_ERROR
+};
+
+static inline struct opae_adapter *
+ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
+{
+	return rawdev->dev_private;
+}
+
+#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/ifpga_rawdev_example.c new file +98 -0

98 lines not on this page · raw message

drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4 -0
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
Signature · 1 line
1.8.3.1
author
#27 lore raw

PATCH v3 6/6 drivers/raw/ifpga_rawdev: Add Intel FPGA OPAE Share Code

In reply to Rosen Xu
---
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  543 +++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   77 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1696 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  861 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  340 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  197 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  763 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  395 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  154 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  735 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  236 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  389 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  276 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  173 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  306 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  111 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 26 files changed, 9276 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +54 -0
new file mode 100644
index 0000000..9c0d64b
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+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 += ifpga_fme_pr.c
+SRCS-y += opae_hw_api.c
+SRCS-y += opae_ifpga_hw_api.c
+SRCS-y += opae_debug.c
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +543 -0

543 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +77 -0

77 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +84 -0

84 lines not on this page · raw message

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

1,696 lines not on this page · raw message

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

546 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +38 -0
new file mode 100644
index 0000000..0df7b2f

Lines of this file are not shown. View the raw message.

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +340 -0

340 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +197 -0

197 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +763 -0

763 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +328 -0

328 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +430 -0

430 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +742 -0

742 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +395 -0

395 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +154 -0

154 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +735 -0

735 lines not on this page · raw message

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

236 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.c new file +126 -0

126 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.h new file +46 -0

46 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +389 -0

389 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +276 -0

276 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +173 -0

173 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +306 -0

306 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +111 -0

111 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +104 -0

104 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +72 -0

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

#28 lore raw
In reply to Rosen Xu
Quoted 69 lines · Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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 (6):
Add Intel FPGA BUS Command Parse Code config/common_base: Add Intel FPGA Build Configuration Macro mk/rte.app.mk: Add Intel FPGA Bus Build Configuration Macro To App
Script
drivers/bus: Add Intel FPGA Bus Lib Code drivers/raw/ifpga_rawdev: Add Intel FPGA Rawdev Driver Code drivers/raw/ifpga_rawdev: Add Intel FPGA OPAE Share Code

Quoted 2 lines
 config/common_base                                 |    6 +
 drivers/bus/Makefile                               |    1 +

Forgot to mention this on previous versions, but please also include changes to add this to the meson build too.

/Bruce

#29 lore raw
In reply to Rosen Xu

Hi Rosen,

Quoted 53 lines · Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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.

Quoted 6 lines

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.

Which compiler did you use and in which version? With GCC 6.3 I got these errors:

== Build drivers/raw/ifpga_rawdev
CC skeleton_rawdev.o
CC skeleton_rawdev_test.o
CC ifpga_api.o
CC ifpga_enumerate.o
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c: In function ‘parse_feature_afus’:
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c:334:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
if (feature_is_UAFU(binfo))
^~
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c:336:4: note: ...this statement, but the latter is misleadinglyindented as if it is guarded by the ‘if’

    if (ret)
    ^~

CC ifpga_feature_dev.o
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c: In function ‘port_hw_init’:
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c:272:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
if (feature->ops && feature->ops->init)
^~
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c:274:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’

    if (ret) {
    ^~

cc1: all warnings being treated as errors

Signature · 2 lines
Gaëtan Rivet
6WIND
#30 lore raw
Quoted 75 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 6:18 AM
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 0/6] Introduce Intel FPGA BUS

Hi Rosen,

Quoted 21 lines · Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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.

Quoted 7 lines

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.

Quoted 25 lines

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.

Quoted 6 lines

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.

Quoted 2 lines

Which compiler did you use and in which version? With GCC 6.3 I got these errors:

We build it on Ubuntu 16.04 and RHEL 7.4, the compiler is : GCC 5.4 and GCC 4.8.5. We will check the GCC 6.3 later.

Quoted 38 lines

== Build drivers/raw/ifpga_rawdev
CC skeleton_rawdev.o
CC skeleton_rawdev_test.o
CC ifpga_api.o
CC ifpga_enumerate.o
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumerat e.c: In function ‘parse_feature_afus’:
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumerat e.c:334:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
if (feature_is_UAFU(binfo))
^~
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumerat e.c:336:4: note: ...this statement, but the latter is misleadinglyindented as if it is guarded by the ‘if’

    if (ret)
    ^~

CC ifpga_feature_dev.o
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_d ev.c: In function ‘port_hw_init’:
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_d ev.c:272:3: error: this ‘if’ clause does not guard... [-Werror=misleading-indentation]
if (feature->ops && feature->ops->init)
^~
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_d ev.c:274:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’

    if (ret) {
    ^~

cc1: all warnings being treated as errors

--
Gaëtan Rivet
6WIND

author
#31 lore raw
In reply to Gaëtan Rivet

Hi Gaetan,

Quoted 104 lines

-----Original Message-----
From: Gaëtan Rivet [mailto:[email protected]]
Sent: Wednesday, March 28, 2018 21:18
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>
Subject: Re: [PATCH v3 0/6] Introduce Intel FPGA BUS

Hi Rosen,

Quoted 21 lines · Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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.

Quoted 7 lines

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.

Quoted 25 lines

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.

Quoted 6 lines

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.

Which compiler did you use and in which version? With GCC 6.3 I got these errors:

== Build drivers/raw/ifpga_rawdev
CC skeleton_rawdev.o
CC skeleton_rawdev_test.o
CC ifpga_api.o
CC ifpga_enumerate.o
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumera te.c: In function ‘parse_feature_afus’:
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumera te.c:334:3: error: this ‘if’ clause does not guard... [-Werror=misleading- indentation]
if (feature_is_UAFU(binfo))
^~
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_enumera te.c:336:4: note: ...this statement, but the latter is misleadinglyindented as if it is guarded by the ‘if’

    if (ret)
    ^~

CC ifpga_feature_dev.o
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_ dev.c: In function ‘port_hw_init’:
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_ dev.c:272:3: error: this ‘if’ clause does not guard... [-Werror=misleading- indentation]
if (feature->ops && feature->ops->init)
^~
/home/rivet/dev/dpdk.org/drivers/raw/ifpga_rawdev/base/ifpga_feature_ dev.c:274:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’

Quoted 3 lines
    if (ret) {
    ^~

cc1: all warnings being treated as errors

For PATCH v4, we have fixed it, and try it by GCC 6.4, is it ok in your server?

Quoted 3 lines

--
Gaëtan Rivet
6WIND

author
#32 lore raw

v4 cover Introduce Intel FPGA BUS

In reply to Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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 (3):
Add Intel FPGA BUS Lib Code
Add Intel FPGA BUS Rawdev Driver
Add Intel FPGA OPAE Share Code

 config/common_base                                 |    6 +
 drivers/bus/Makefile                               |    1 +
 drivers/bus/ifpga/Makefile                         |   33 +
 drivers/bus/ifpga/ifpga_bus.c                      |  517 ++++++
 drivers/bus/ifpga/ifpga_common.c                   |  141 ++
 drivers/bus/ifpga/ifpga_common.h                   |   22 +
 drivers/bus/ifpga/ifpga_logs.h                     |   31 +
 drivers/bus/ifpga/rte_bus_ifpga.h                  |  175 ++
 drivers/bus/ifpga/rte_bus_ifpga_version.map        |    8 +
 drivers/raw/Makefile                               |    1 +
 drivers/raw/ifpga_rawdev/Makefile                  |   34 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  529 ++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   73 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1688 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  851 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  341 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  191 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  761 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  399 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  154 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  435 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  192 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  408 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  280 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  172 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  306 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  115 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            |  594 +++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |   37 +
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |    4 +
 mk/rte.app.mk                                      |    3 +
 41 files changed, 10526 insertions(+)
 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/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/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
author
#33 lore raw

PATCH v4 1/3 Add Intel FPGA BUS Lib Code

---
 config/common_base                          |   5 +
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  33 ++
 drivers/bus/ifpga/ifpga_bus.c               | 517 ++++++++++++++++++++++++++++
 drivers/bus/ifpga/ifpga_common.c            | 141 ++++++++
 drivers/bus/ifpga/ifpga_common.h            |  22 ++
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 175 ++++++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
 mk/rte.app.mk                               |   2 +
 10 files changed, 935 insertions(+)
 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/rte_bus_ifpga.h
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
config/common_base +5 -0
index ad03cf4..49f6b09 100644
@@ -134,6 +134,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
 CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
 #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
 # Compile ARK PMD
 #
 CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
index 7ef2593..55d2dfe 100644
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +33 -0
new file mode 100644
index 0000000..1b569af
@@ -0,0 +1,33 @@
+# 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 += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_bus_ifpga.h
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +517 -0

517 lines not on this page · raw message

drivers/bus/ifpga/ifpga_common.c new file +141 -0

141 lines not on this page · raw message

drivers/bus/ifpga/ifpga_common.h new file +22 -0
new file mode 100644
index 0000000..1c85bd3
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+int ifpga_pci_addr_cmp(const struct rte_device *dev,
+	const void *_pci_addr);
+
+#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/rte_bus_ifpga.h new file +175 -0

175 lines not on this page · raw message

drivers/bus/ifpga/rte_bus_ifpga_version.map new file +8 -0
new file mode 100644
index 0000000..4edc9c0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;
+
+	local: *;
+};
mk/rte.app.mk +2 -0
index 3eb41d1..929c3d8 100644
@@ -107,6 +107,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
Signature · 1 line
1.8.3.1
#34 lore raw

Re: [PATCH v4 1/3] Add Intel FPGA BUS Lib Code

Hello Rosen,

Quoted 42 lines · Rosen Xu
---
  config/common_base                          |   5 +
  drivers/bus/Makefile                        |   1 +
  drivers/bus/ifpga/Makefile                  |  33 ++
  drivers/bus/ifpga/ifpga_bus.c               | 517 ++++++++++++++++++++++++++++
  drivers/bus/ifpga/ifpga_common.c            | 141 ++++++++
  drivers/bus/ifpga/ifpga_common.h            |  22 ++
  drivers/bus/ifpga/ifpga_logs.h              |  31 ++
  drivers/bus/ifpga/rte_bus_ifpga.h           | 175 ++++++++++
  drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
  mk/rte.app.mk                               |   2 +
  10 files changed, 935 insertions(+)

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/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map

config/common_base +5 -0
index ad03cf4..49f6b09 100644
@@ -134,6 +134,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
  CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
  #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
  # Compile ARK PMD
  #
  CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +0 -0
index 7ef2593..55d2dfe 100644

drivers/bus/Makefile DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa · line 10

Quoted 4 lines
drivers/bus/Makefile +1 -0
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
  DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
  DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
  DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga

When I attempted to compile the above using SHARED_LIB=y, this is what I got:

--->8---
LD librte_bus_ifpga.so.1.1
ifpga_bus.o: In function `rte_ifpga_parse':
ifpga_bus.c:(.text+0x2eb): undefined reference to `rte_rawdevs'
ifpga_bus.o: In function `rte_ifpga_scan':
ifpga_bus.c:(.text+0x53e): undefined reference to rte_kvargs_parse' ifpga_bus.c:(.text+0x55e): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x580): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x5e0): undefined reference to rte_rawdevs' ifpga_bus.c:(.text+0x746): undefined reference to rte_kvargs_free' ifpga_bus.c:(.text+0x7b8): undefined reference to rte_pci_addr_cmp' ifpga_bus.c:(.text+0x858): undefined reference to rte_kvargs_parse' ifpga_bus.c:(.text+0x878): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x89c): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x8b8): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x8dc): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x8f8): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x91c): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x981): undefined reference to rte_kvargs_free'
ifpga_common.o: In function `ifpga_pci_addr_cmp':
ifpga_common.c:(.text+0x2c5): undefined reference to `rte_eal_compare_pci_addr'
collect2: error: ld returned 1 exit status /home/shreyansh/build/DPDK/00_dpdk/mk/rte.lib.mk:98: recipe for target 'librte_bus_ifpga.so.1.1' failed make[6]: *** [librte_bus_ifpga.so.1.1] Error 1 /home/shreyansh/build/DPDK/00_dpdk/mk/rte.subdir.mk:35: recipe for target 'ifpga' failed make[5]: *** [ifpga] Error 2
--->8---

Essentially, you are dependent on librte_kvargs but you have not declared that in your Makefile. Same for lib_rawdev.

Quoted 51 lines
drivers/bus/Makefile +0 -0
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +33 -0
new file mode 100644
index 0000000..1b569af
@@ -0,0 +1,33 @@
+# 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 += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal
+
+#
+# Export include files
+#
+SYMLINK-y-include += rte_bus_ifpga.h
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/bus/ifpga/ifpga_bus.c new file +4 -0
new file mode 100644
index 0000000..eba2615
@@ -0,0 +1,517 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+

[...]

drivers/bus/ifpga/ifpga_bus.c line 181

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+
+	if (rawdev->dev_ops &&
+		rawdev->dev_ops->dev_start &&
+		rawdev->dev_ops->dev_start(rawdev))
+		goto free_dev;
+	if (path) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy with demarcation based on source is not right. strlen(path) can be larger than afu_pr_conf.bs_path

I saw some comment from Gaetan in previous version, if I recall correctly.

Quoted 30 lines
drivers/bus/ifpga/ifpga_bus.c new file +30 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+		afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+		afu_dev->id.uuid_high = afu_pr_conf.afu_id.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
+rte_ifpga_scan(void)
+{

[...]

Quoted 19 lines
drivers/bus/ifpga/ifpga_bus.c new file +19 -0
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
+{
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;

drivers/bus/ifpga/ifpga_bus.c line 354

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function for

I think you are not moving on PCI bus elements. You are looping on rte_ifpga_bus.

Quoted 26 lines

+ * all registered drivers that have a matching entry in its id_table
+ * for discovered devices.
+ */

drivers/bus/ifpga/ifpga_bus.c new file +23 -0
+static int
+rte_ifpga_probe(void)
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_afu_device *afu_dev = NULL;
+	int ret = 0;
+
+	TAILQ_FOREACH(ifpga_dev, &rte_ifpga_bus.ifpga_list, next) {
+		TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) {
+
+			if (afu_dev->device.driver)
+				continue;
+
+			ret = ifpga_probe_all_drivers(afu_dev);
+			if (ret < 0)
+				IFPGA_BUS_ERR("failed to initialize %s device\n",
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+

[...]

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +4 -0
new file mode 100644
index 0000000..124ffd2
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+

[...]

drivers/bus/ifpga/ifpga_common.c line 84

Quoted 6 lines
drivers/bus/ifpga/ifpga_common.c new file +6 -0
+
+}
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args)
+{
+#define MAX_PATH_LEN 1024

Is this max len of a file path or a max len of the value string (BDF). Can you rename this?

Just a trivial comment, though.

[...]

Quoted 10 lines
drivers/bus/ifpga/ifpga_logs.h new file +4 -0
new file mode 100644
index 0000000..873e0a4
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+

drivers/bus/ifpga/ifpga_logs.h line 14

Quoted 10 lines
drivers/bus/ifpga/ifpga_logs.h new file +10 -0
+#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)

I don't see macro above being used. Would you be using this in later patches? (But, i think they might have their own logging definitions).

Quoted 24 lines
drivers/bus/ifpga/ifpga_logs.h new file +17 -0
+
+#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/rte_bus_ifpga.h new file +1 -0
new file mode 100644
index 0000000..e22ab4e
@@ -0,0 +1,175 @@
+/* SPDX-License-Identifier: BSD-3-Clause

drivers/bus/ifpga/rte_bus_ifpga.h line 11

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _RTE_BUS_IFPGA_H_
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI Bus Interface

This is not a "RTE PCI Bus Interface" - It should be AFU/IFPA Bus interface file

There are some comments which were given in early versions. Like this one. Please do respond to those individually if you are not fixing them. (Also, it is nice to get acknowledgment of those which are being fixed).

Quoted 42 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +42 -0
+ */
+
+#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_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_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_pci_addr pci_addr;
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;

drivers/bus/ifpga/rte_bus_ifpga.h line 63

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+} __attribute__ ((packed));
+
+/**
+ * A structure pr 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];
            ^^^^^^^^^^^

Some stray indentation issue, it seems

Quoted 30 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +30 -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. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices */
+};
+
+/**
+ * A structure describing a AFU device.
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource */
+	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	struct rte_afu_driver *driver;          /**< Associated driver */
+	char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+} __attribute__ ((packed));

drivers/bus/ifpga/rte_bus_ifpga.h line 103

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_afu_device.
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.

PCI Probing would have already been done through the PCI bus. I think this is probing of the AFU devices (based on the PCI already probed).

drivers/bus/ifpga/rte_bus_ifpga.h line 113

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI device.
                              ^^^^

Structure describing an AFU device.

Quoted 68 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +62 -0
+ */
+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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	const struct rte_afu_uuid *id_table;    /**< AFU uuid within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus
+ */
+struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA drivers */
+};
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+/**
+ * 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 +0 -0
new file mode 100644
index 0000000..4edc9c0

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Should be tab indented

drivers/bus/ifpga/rte_bus_ifpga_version.map line 8

Quoted 3 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -0
+
+	local: *;
+};

[...]

One suggestion:

I think a lot of comments were provided by Gaetan in the previous version. I see some that some of them are still not fixed in this version.

I suggest you individually reply to his comments if you are not going to fix, with reason. He put quite an effort to go through your patches.

That would help you track comments as well as not discount a reviewers effort.

-
Shreyansh

author
#35 lore raw

Re: [PATCH v4 1/3] Add Intel FPGA BUS Lib Code

Hello Shreyansh,

Quoted 87 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Tuesday, April 03, 2018 17:25
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v4 1/3] Add Intel FPGA BUS Lib Code

Hello Rosen,

Quoted 6 lines · Rosen Xu
---
  config/common_base                          |   5 +
  drivers/bus/Makefile                        |   1 +
  drivers/bus/ifpga/Makefile                  |  33 ++
  drivers/bus/ifpga/ifpga_bus.c               | 517

++++++++++++++++++++++++++++

Quoted 36 lines
  drivers/bus/ifpga/ifpga_common.c            | 141 ++++++++
  drivers/bus/ifpga/ifpga_common.h            |  22 ++
  drivers/bus/ifpga/ifpga_logs.h              |  31 ++
  drivers/bus/ifpga/rte_bus_ifpga.h           | 175 ++++++++++
  drivers/bus/ifpga/rte_bus_ifpga_version.map |   8 +
  mk/rte.app.mk                               |   2 +
  10 files changed, 935 insertions(+)

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/rte_bus_ifpga.h create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map

config/common_base index renamed from config/common_base +0 -0

ad03cf4..49f6b09 100644

config/common_base +5 -0
@@ -134,6 +134,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
  CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
  #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
  # Compile ARK PMD
  #
  CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile index renamed from drivers/bus/Makefile +0 -0

7ef2593..55d2dfe 100644

drivers/bus/Makefile DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa · line 10

Quoted 4 lines
drivers/bus/Makefile +1 -0
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
  DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
  DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
  DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga

When I attempted to compile the above using SHARED_LIB=y, this is what I got:

--->8---
LD librte_bus_ifpga.so.1.1
ifpga_bus.o: In function `rte_ifpga_parse':
ifpga_bus.c:(.text+0x2eb): undefined reference to rte_rawdevs' ifpga_bus.o: In function rte_ifpga_scan':
ifpga_bus.c:(.text+0x53e): undefined reference to rte_kvargs_parse' ifpga_bus.c:(.text+0x55e): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x580): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x5e0): undefined reference to rte_rawdevs' ifpga_bus.c:(.text+0x746): undefined reference to rte_kvargs_free' ifpga_bus.c:(.text+0x7b8): undefined reference to rte_pci_addr_cmp' ifpga_bus.c:(.text+0x858): undefined reference to rte_kvargs_parse' ifpga_bus.c:(.text+0x878): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x89c): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x8b8): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x8dc): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x8f8): undefined reference to rte_kvargs_count' ifpga_bus.c:(.text+0x91c): undefined reference to rte_kvargs_process' ifpga_bus.c:(.text+0x981): undefined reference to rte_kvargs_free' ifpga_common.o: In function `ifpga_pci_addr_cmp':
ifpga_common.c:(.text+0x2c5): undefined reference to `rte_eal_compare_pci_addr'

Quoted 8 lines

collect2: error: ld returned 1 exit status /home/shreyansh/build/DPDK/00_dpdk/mk/rte.lib.mk:98: recipe for target 'librte_bus_ifpga.so.1.1' failed
make[6]: *** [librte_bus_ifpga.so.1.1] Error 1 /home/shreyansh/build/DPDK/00_dpdk/mk/rte.subdir.mk:35: recipe for target 'ifpga' failed
make[5]: *** [ifpga] Error 2
--->8---

I have fixed it to modify Makefile in my PATCH v5.

Quoted 2 lines

Essentially, you are dependent on librte_kvargs but you have not declared that in your Makefile. Same for lib_rawdev.

I have declared it in my PATCH v5.

Quoted 52 lines
Quoted 49 lines
drivers/bus/Makefile +0 -0
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +33 -0
new file mode 100644 index 0000000..1b569af
@@ -0,0 +1,33 @@
+# 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 += -O3
+CFLAGS += $(WERROR_FLAGS)
+
+# versioning export map
+EXPORT_MAP := rte_bus_ifpga_version.map
+
+# library version
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+SRCS-y += \
+        ifpga_bus.c \
+        ifpga_common.c
+
+LDLIBS += -lrte_eal
+
+#
+# Export include files
+#
+SYMLINK-y-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..eba2615

drivers/bus/ifpga/ifpga_bus.c new file +3 -0
@@ -0,0 +1,517 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation  */
+

[...]

Quoted 10 lines

drivers/bus/ifpga/ifpga_bus.c line 181

Quoted 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+
+	if (rawdev->dev_ops &&
+		rawdev->dev_ops->dev_start &&
+		rawdev->dev_ops->dev_start(rawdev))
+		goto free_dev;
+	if (path) {
+		strncpy(afu_pr_conf.bs_path, path, strlen(path));

strncpy with demarcation based on source is not right. strlen(path) can be larger than afu_pr_conf.bs_path

I have changed to destination string in PATCH v5.

Quoted 58 lines

I saw some comment from Gaetan in previous version, if I recall correctly.

Quoted 30 lines
drivers/bus/ifpga/ifpga_bus.c new file +30 -0
+		if (rawdev->dev_ops->firmware_load &&
+			rawdev->dev_ops->firmware_load(rawdev,
+					&afu_pr_conf)){
+			printf("firmware load error %d\n", ret);
+			goto free_dev;
+		}
+		afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+		afu_dev->id.uuid_high = afu_pr_conf.afu_id.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
+rte_ifpga_scan(void)
+{

[...]

Quoted 23 lines
drivers/bus/ifpga/ifpga_bus.c new file +23 -0
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev) {
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	if (afu_dev == NULL)
+		return -1;
+
+	/* Check if a driver is already loaded */
+	if (afu_dev->driver != NULL)
+		return 0;
+
+	TAILQ_FOREACH(drv, &rte_ifpga_bus.driver_list, next) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 354

Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5 -0
+	return 1;
+}
+
+/*
+ * Scan the content of the PCI bus, and call the probe() function for

I think you are not moving on PCI bus elements. You are looping on rte_ifpga_bus.

I have modified all PCI bus elements to FPGA BUS in my PATCH v5.

Quoted 43 lines
Quoted 9 lines

+ * all registered drivers that have a matching entry in its id_table
+ * for discovered devices.
+ */

drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+static int
+rte_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, &rte_ifpga_bus.ifpga_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 7 lines
drivers/bus/ifpga/ifpga_bus.c new file +7 -0
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+

[...]

Quoted 10 lines
drivers/bus/ifpga/ifpga_common.c new file +3 -0
new file mode 100644
index 0000000..124ffd2
@@ -0,0 +1,141 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation  */
+

[...]

Quoted 7 lines

drivers/bus/ifpga/ifpga_common.c

Quoted 4 lines
drivers/bus/ifpga/ifpga_common.c new file +4 -0
+
+}
+int ifpga_get_bdf_arg(const char *key __rte_unused,
+	const char *value, void *extra_args) { #define MAX_PATH_LEN 1024

Is this max len of a file path or a max len of the value string (BDF). Can you rename this?

I will rename it to IFPGA_MAX_BDF_LEN in my PATCH v5.

Quoted 18 lines

Just a trivial comment, though.

[...]

Quoted 14 lines
(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 +8 -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>
+
Quoted 8 lines

drivers/bus/ifpga/ifpga_logs.h line 14

Quoted 5 lines
drivers/bus/ifpga/ifpga_logs.h new file +5 -0
+extern int ifpga_bus_logtype;
+
+#define IFPGA_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, ifpga_bus_logtype, "%s(): " fmt "\n", \
+		__func__, ##args)

I don't see macro above being used. Would you be using this in later patches? (But, i think they might have their own logging definitions).

Yes, they will be used in later patches.
For FPGA BUS is a common module, so we need to provide all macros will be used.

Quoted 28 lines
Quoted 28 lines
drivers/bus/ifpga/ifpga_logs.h new file +17 -0
+
+#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/rte_bus_ifpga.h new file +4 -0
new file mode 100644
index 0000000..e22ab4e
@@ -0,0 +1,175 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation  */
+
+#ifndef _RTE_BUS_IFPGA_H_
Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 11

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +6 -0
+#define _RTE_BUS_IFPGA_H_
+
+/**
+ * @file
+ *
+ * RTE PCI Bus Interface

This is not a "RTE PCI Bus Interface" - It should be AFU/IFPA Bus interface file

I will modify it in PATCH v5.

Quoted 3 lines

There are some comments which were given in early versions. Like this one. Please do respond to those individually if you are not fixing them. (Also, it is nice to get acknowledgment of those which are being fixed).

I have fix those comments and I also will reply it to those individually.

Quoted 54 lines
Quoted 43 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +43 -0
+ */
+
+#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_ifpga_device;
+struct rte_afu_device;
+struct rte_afu_driver;
+
+/** List of Intel FPGA devices */
+TAILQ_HEAD(rte_ifpga_device_list, rte_ifpga_device);
+/** List of Intel AFU devices */
+TAILQ_HEAD(rte_afu_device_list, rte_afu_device);
+/** List of AFU drivers */
+TAILQ_HEAD(rte_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_pci_addr pci_addr;
+	uint64_t uuid_low;
+	uint64_t uuid_high;
+	int      port;

drivers/bus/ifpga/rte_bus_ifpga.h line 63

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+} __attribute__ ((packed));
+
+/**
+ * A structure pr 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 1 line

Some stray indentation issue, it seems

Do you means to change it to:
char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];?
If so I have fixed it in my PATCH v5.

Quoted 35 lines
Quoted 15 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +15 -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. */
+	struct rte_pci_addr pci_addr;
+	struct rte_rawdev *rdev;
+	struct rte_afu_device_list afu_list;  /**< List of AFU devices */ };
+
+/**
+ * A structure describing a AFU device.

drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< PCI Memory Resource

*/

Quoted 9 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +9 -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 8 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 103

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5 -0
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+/**
+ * Initialisation function for the driver called during PCI probing.

PCI Probing would have already been done through the PCI bus. I think this is probing of the AFU devices (based on the PCI already probed).

rte_ifpga_plug()/rte_ifpga_unplug() will use this macro.

Quoted 11 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 113

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+typedef int (afu_remove_t)(struct rte_afu_device *);
+
+/**
+ * A structure describing a PCI device.
                               ^^^^
Quoted 1 line

Structure describing an AFU device.

Yes, it should be AFU device, and I have fixed it in my PATCH v5.

Quoted 63 lines
Quoted 63 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +57 -0
+ */
+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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */
+	const struct rte_afu_uuid *id_table;    /**< AFU uuid within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus  */ struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+	struct rte_ifpga_device_list ifpga_list;  /**< List of FPGA devices */
+	struct rte_afu_driver_list driver_list;  /**< List of FPGA drivers
+*/ };
+
+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;
+}
+
+extern struct rte_ifpga_bus rte_ifpga_bus;
+
+/**
+ * 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 +0 -0
new file mode 100644
index 0000000..4edc9c0
Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,8 @@
+DPDK_18.05 {
+	global:
+
+    rte_ifpga_driver_register;
+    rte_ifpga_driver_unregister;

Should be tab indented

Yes, I will fix them.

Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga_version.map line 8

Quoted 3 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +3 -0
+
+	local: *;
+};

[...]

One suggestion:

Quoted 8 lines

I think a lot of comments were provided by Gaetan in the previous version. I see some that some of them are still not fixed in this version.

I suggest you individually reply to his comments if you are not going to fix, with reason. He put quite an effort to go through your patches.

That would help you track comments as well as not discount a reviewers effort.

OK, I will individually reply to Gaetan's comments.

Quoted 2 lines

-
Shreyansh

author
#36 lore raw

PATCH v4 2/3 Add Intel FPGA BUS Rawdev Driver

In reply to Rosen Xu
---
 config/common_base                                 |   1 +
 drivers/raw/Makefile                               |   1 +
 drivers/raw/ifpga_rawdev/Makefile                  |  34 ++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 594 +++++++++++++++++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
 mk/rte.app.mk                                      |   1 +
 7 files changed, 672 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
config/common_base +1 -0
index 49f6b09..08b7cce 100644
@@ -137,6 +137,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y
 # Compile the Intel FPGA bus
 #
 CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
 
 #
 # Compile ARK PMD
drivers/raw/Makefile +1 -0
index da7c8b4..6fc8f2f 100644
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 # DIRS-$(<configuration>) += <directory>
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +34 -0
new file mode 100644
index 0000000..118c729
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga
+CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +594 -0

594 lines not on this page · raw message

drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
new file mode 100644
index 0000000..169dc1d
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_RAWDEV_H_
+#define _IFPGA_RAWDEV_H_
+
+extern int ifpga_rawdev_logtype;
+
+#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \
+		__func__, ##args)
+
+#define IFPGA_RAWDEV_PMD_FUNC_TRACE() IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>")
+
+#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args)
+
+enum ifpga_rawdev_device_state {
+	IFPGA_IDLE,
+	IFPGA_READY,
+	IFPGA_ERROR
+};
+
+static inline struct opae_adapter *
+ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
+{
+	return rawdev->dev_private;
+}
+
+#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4 -0
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
mk/rte.app.mk +1 -0
index 929c3d8..958b6b5 100644
@@ -108,6 +108,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV)   += -lrte_ifpga_rawdev
 
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
Signature · 1 line
1.8.3.1
#37 lore raw

Re: [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Quoted 69 lines · Rosen Xu
---
  config/common_base                                 |   1 +
  drivers/raw/Makefile                               |   1 +
  drivers/raw/ifpga_rawdev/Makefile                  |  34 ++
  drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 594 +++++++++++++++++++++
  drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
  .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
  mk/rte.app.mk                                      |   1 +
  7 files changed, 672 insertions(+)

create mode 100644 drivers/raw/ifpga_rawdev/Makefile
create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map

config/common_base +1 -0
index 49f6b09..08b7cce 100644
@@ -137,6 +137,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y
  # Compile the Intel FPGA bus
  #
  CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
 
  #
  # Compile ARK PMD
drivers/raw/Makefile +1 -0
index da7c8b4..6fc8f2f 100644
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
  # DIRS-$(<configuration>) += <directory>
  DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev
 
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +24 -0
new file mode 100644
index 0000000..118c729
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga
+CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+

drivers/raw/ifpga_rawdev/Makefile line 34

Quoted 10 lines
drivers/raw/ifpga_rawdev/Makefile new file +10 -0
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk

[...]
Your patch doesn't compile at this point: (Static build; Shared is still stuck on patch [1/3]).

--->8---
== Build drivers/raw/ifpga_rawdev
/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/Makefile:27: /home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/Makefile: No such file or directory make[6]: *** No rule to make target '/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/Makefile'.
Stop.
/home/shreyansh/build/DPDK/00_dpdk/mk/rte.subdir.mk:35: recipe for target 'ifpga_rawdev' failed
make[5]: *** [ifpga_rawdev] Error 2
make[5]: *** Waiting for unfinished jobs....
--->8---

Which is because your patch [3/3] contains various definitions which are being used in this patch.

Am I missing something?

-
Shreyansh

author
#38 lore raw

Re: [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Quoted 120 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Tuesday, April 03, 2018 17:35
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Quoted 7 lines · Rosen Xu
---
  config/common_base                                 |   1 +
  drivers/raw/Makefile                               |   1 +
  drivers/raw/ifpga_rawdev/Makefile                  |  34 ++
  drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 594

+++++++++++++++++++++

Quoted 27 lines
  drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
  .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
  mk/rte.app.mk                                      |   1 +
  7 files changed, 672 insertions(+)

create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map

config/common_base index renamed from config/common_base +0 -0

49f6b09..08b7cce 100644

config/common_base +1 -0
@@ -137,6 +137,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y
  # Compile the Intel FPGA bus
  #
  CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
 
  #
  # Compile ARK PMD
drivers/raw/Makefile index renamed from drivers/raw/Makefile +0 -0

da7c8b4..6fc8f2f 100644

drivers/raw/Makefile include $(RTE_SDK)/mk/rte.vars.mk · line 7

Quoted 3 lines
drivers/raw/Makefile +0 -0
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
  # DIRS-$(<configuration>) += <directory>
  DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) +=

skeleton_rawdev

Quoted 34 lines
drivers/raw/Makefile +1 -0
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev
 
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +24 -0
new file mode 100644
index 0000000..118c729
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel
+Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga CFLAGS +=
+-I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+

drivers/raw/ifpga_rawdev/Makefile line 34

Quoted 10 lines
drivers/raw/ifpga_rawdev/Makefile new file +10 -0
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk

[...]
Your patch doesn't compile at this point: (Static build; Shared is still stuck on patch [1/3]).

--->8---
== Build drivers/raw/ifpga_rawdev /home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/Makefil e:27:
/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/M akefile:
No such file or directory
make[6]: *** No rule to make target '/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/M akefile'.
Stop.
/home/shreyansh/build/DPDK/00_dpdk/mk/rte.subdir.mk:35: recipe for target 'ifpga_rawdev' failed
make[5]: *** [ifpga_rawdev] Error 2
make[5]: *** Waiting for unfinished jobs....
--->8---

Quoted 4 lines

Which is because your patch [3/3] contains various definitions which are being used in this patch.

Am I missing something?

I have fixed it and try to build it after CONFIG_RTE_BUILD_SHARED_LIB = y, And it build and link well.
Is this answer to your comments?

Quoted 2 lines

-
Shreyansh

#39 lore raw

Re: [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Hello Rosen,

Quoted 138 lines

-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 7:20 AM
To: Shreyansh Jain <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Quoted 6 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Tuesday, April 03, 2018 17:35
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>;

[email protected];

Quoted 2 lines

Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei

<[email protected]>;

Quoted 3 lines

Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v4 2/3] Add Intel FPGA BUS Rawdev

Driver

Quoted 80 lines · Rosen Xu
Quoted 7 lines
---
  config/common_base                                 |   1 +
  drivers/raw/Makefile                               |   1 +
  drivers/raw/ifpga_rawdev/Makefile                  |  34 ++
  drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 594

+++++++++++++++++++++

Quoted 27 lines
  drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
  .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
  mk/rte.app.mk                                      |   1 +
  7 files changed, 672 insertions(+)

create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map

config/common_base index renamed from config/common_base +0 -0

49f6b09..08b7cce 100644

config/common_base +1 -0
@@ -137,6 +137,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y
  # Compile the Intel FPGA bus
  #
  CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
 
  #
  # Compile ARK PMD
drivers/raw/Makefile index renamed from drivers/raw/Makefile +0 -0

da7c8b4..6fc8f2f 100644

drivers/raw/Makefile include $(RTE_SDK)/mk/rte.vars.mk · line 7

Quoted 3 lines
drivers/raw/Makefile +0 -0
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
  # DIRS-$(<configuration>) += <directory>
  DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) +=

skeleton_rawdev

Quoted 39 lines
drivers/raw/Makefile +1 -0
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev
 
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +29 -0
new file mode 100644
index 0000000..118c729
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel
+Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga CFLAGS +=
+-I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
+#
Quoted 8 lines

drivers/raw/ifpga_rawdev/Makefile line 34

Quoted 5 lines
drivers/raw/ifpga_rawdev/Makefile new file +5 -0
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk

[...]
Your patch doesn't compile at this point: (Static build; Shared is

still stuck on

Quoted 19 lines

patch [1/3]).

--->8---
== Build drivers/raw/ifpga_rawdev /home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/Makefil e:27:
/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/M akefile:
No such file or directory
make[6]: *** No rule to make target '/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/M akefile'.
Stop.
/home/shreyansh/build/DPDK/00_dpdk/mk/rte.subdir.mk:35: recipe for target 'ifpga_rawdev' failed
make[5]: *** [ifpga_rawdev] Error 2
make[5]: *** Waiting for unfinished jobs....
--->8---

Quoted 1 line

Which is because your patch [3/3] contains various definitions which

are

Quoted 8 lines
Quoted 3 lines

being used in this patch.

Am I missing something?

I have fixed it and try to build it after CONFIG_RTE_BUILD_SHARED_LIB = y,
And it build and link well.
Is this answer to your comments?

Yes, and no.
I get that there was an issue with shared compilation so, yes, your response has fixed that.
But, I still see the issue of patch being dependent. I think you compiled everything together (all patches combined) - so, no, that is not the expectation.

All patches should be compliable separately, shared or static.

Quoted 3 lines
Quoted 3 lines

-
Shreyansh

author
#40 lore raw

Re: [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Hi Shreyansh,

Quoted 161 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, April 04, 2018 19:31
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Hello Rosen,

Quoted 114 lines

-----Original Message-----
From: Xu, Rosen [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 7:20 AM
To: Shreyansh Jain <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v4 2/3] Add Intel FPGA BUS Rawdev Driver

Quoted 6 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Tuesday, April 03, 2018 17:35
To: Xu, Rosen <[email protected]>
Cc: [email protected]; Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>;

[email protected];

Quoted 2 lines

Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei

<[email protected]>;

Quoted 3 lines

Wu, Hao <[email protected]>; [email protected]; Wu, Yanglong <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v4 2/3] Add Intel FPGA BUS Rawdev

Driver

Quoted 77 lines · Rosen Xu
Quoted 7 lines
---
  config/common_base                                 |   1 +
  drivers/raw/Makefile                               |   1 +
  drivers/raw/ifpga_rawdev/Makefile                  |  34 ++
  drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 594

+++++++++++++++++++++

Quoted 27 lines
  drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
  .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
  mk/rte.app.mk                                      |   1 +
  7 files changed, 672 insertions(+)

create mode 100644 drivers/raw/ifpga_rawdev/Makefile create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h create mode 100644
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map

config/common_base index renamed from config/common_base +0 -0

49f6b09..08b7cce 100644

config/common_base +1 -0
@@ -137,6 +137,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y
  # Compile the Intel FPGA bus
  #
  CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
 
  #
  # Compile ARK PMD
drivers/raw/Makefile index renamed from drivers/raw/Makefile +0 -0

da7c8b4..6fc8f2f 100644

drivers/raw/Makefile include $(RTE_SDK)/mk/rte.vars.mk · line 7

Quoted 3 lines
drivers/raw/Makefile +0 -0
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
  # DIRS-$(<configuration>) += <directory>
  DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) +=

skeleton_rawdev

Quoted 36 lines
drivers/raw/Makefile +1 -0
+DIRS-$(CONFIG_RTE_LIBRTE_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..118c729

drivers/raw/ifpga_rawdev/Makefile new file +26 -0
@@ -0,0 +1,34 @@
+# SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2018 Intel
+Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS +=
+$(WERROR_FLAGS) CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga CFLAGS
++= -I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
Quoted 8 lines

drivers/raw/ifpga_rawdev/Makefile line 34

Quoted 5 lines
drivers/raw/ifpga_rawdev/Makefile new file +5 -0
+#
+# all source are stored in SRCS-y #
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk

[...]
Your patch doesn't compile at this point: (Static build; Shared is

Quoted 6 lines

still stuck on

Quoted 5 lines

patch [1/3]).

--->8---
== Build drivers/raw/ifpga_rawdev

/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/Makefil

Quoted 2 lines
Quoted 2 lines

e:27:

/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/M

Quoted 4 lines
Quoted 4 lines

akefile:
No such file or directory
make[6]: *** No rule to make target

'/home/shreyansh/build/DPDK/00_dpdk/drivers/raw/ifpga_rawdev/base/M

Quoted 9 lines
Quoted 9 lines

akefile'.
Stop.
/home/shreyansh/build/DPDK/00_dpdk/mk/rte.subdir.mk:35: recipe for target 'ifpga_rawdev' failed
make[5]: *** [ifpga_rawdev] Error 2
make[5]: *** Waiting for unfinished jobs....
--->8---

Which is because your patch [3/3] contains various definitions which

Quoted 8 lines

are

Quoted 3 lines

being used in this patch.

Am I missing something?

I have fixed it and try to build it after CONFIG_RTE_BUILD_SHARED_LIB = y, And it build and link well.
Is this answer to your comments?

Quoted 8 lines

Yes, and no.
I get that there was an issue with shared compilation so, yes, your response has fixed that.
But, I still see the issue of patch being dependent. I think you compiled everything together (all patches combined) - so, no, that is not the expectation.

All patches should be compliable separately, shared or static.

It's fixed, pls see my PATCH v6.

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

-
Shreyansh

author
#41 lore raw

PATCH v4 3/3 Add Intel FPGA OPAE Share Code

In reply to Rosen Xu
---
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  529 ++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   73 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1688 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  851 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  341 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  191 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  761 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  399 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  154 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  435 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  192 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  408 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  280 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  172 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  306 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  115 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 26 files changed, 8919 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +54 -0
new file mode 100644
index 0000000..9c0d64b
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+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 += ifpga_fme_pr.c
+SRCS-y += opae_hw_api.c
+SRCS-y += opae_ifpga_hw_api.c
+SRCS-y += opae_debug.c
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +529 -0

529 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +73 -0

73 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +84 -0

84 lines not on this page · raw message

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

1,688 lines not on this page · raw message

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

572 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +38 -0
new file mode 100644
index 0000000..0df7b2f

Lines of this file are not shown. View the raw message.

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +341 -0

341 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +191 -0

191 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +761 -0

761 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +328 -0

328 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +430 -0

430 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +742 -0

742 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +399 -0

399 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +154 -0

154 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +435 -0

435 lines not on this page · raw message

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

192 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.c new file +126 -0

126 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.h new file +46 -0

46 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +408 -0

408 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +280 -0

280 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +172 -0

172 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +306 -0

306 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +115 -0

115 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +104 -0

104 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +72 -0

72 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
#42 lore raw

v5 cover Introduce Intel FPGA BUS

In reply to Rosen Xu

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

This patch set introduces Intel FPGA BUS support in DPDK.

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 (3):
Add Intel FPGA BUS Library
Add Intel FPGA BUS Rawdev Driver
Add Intel FPGA OPAE Share Code

 config/common_base                                 |    6 +
 drivers/bus/Makefile                               |    1 +
 drivers/bus/ifpga/Makefile                         |   32 +
 drivers/bus/ifpga/ifpga_bus.c                      |  504 ++++++
 drivers/bus/ifpga/ifpga_common.c                   |   88 +
 drivers/bus/ifpga/ifpga_common.h                   |   18 +
 drivers/bus/ifpga/ifpga_logs.h                     |   31 +
 drivers/bus/ifpga/rte_bus_ifpga.h                  |  168 ++
 drivers/bus/ifpga/rte_bus_ifpga_version.map        |   10 +
 drivers/raw/Makefile                               |    1 +
 drivers/raw/ifpga_rawdev/Makefile                  |   36 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  529 ++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   73 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1688 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  851 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  341 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  191 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  761 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  399 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  154 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  435 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  192 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  408 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  280 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  172 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  306 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  115 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            |  592 +++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |   37 +
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |    4 +
 mk/rte.app.mk                                      |    3 +
 41 files changed, 10450 insertions(+)
 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/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/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
Signature · 1 line
1.8.3.1
author
#43 lore raw

PATCH v5 1/3 Add Intel FPGA BUS Library

---
 config/common_base                          |   5 +
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  32 ++
 drivers/bus/ifpga/ifpga_bus.c               | 504 ++++++++++++++++++++++++++++
 drivers/bus/ifpga/ifpga_common.c            |  88 +++++
 drivers/bus/ifpga/ifpga_common.h            |  18 +
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
 mk/rte.app.mk                               |   2 +
 10 files changed, 859 insertions(+)
 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/rte_bus_ifpga.h
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
config/common_base +5 -0
index ad03cf4..49f6b09 100644
@@ -134,6 +134,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
 CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
 #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
 # Compile ARK PMD
 #
 CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
index 7ef2593..55d2dfe 100644
@@ -7,5 +7,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_DPAA_BUS) += dpaa
 DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
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 +504 -0

504 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..b6662c8
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
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/rte_bus_ifpga.h new file +168 -0

168 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..7e46261
@@ -0,0 +1,10 @@
+DPDK_18.05 {
+	global:
+
+	rte_ifpga_driver_register;
+	rte_ifpga_driver_unregister;
+	ifpga_get_string_arg;
+	ifpga_get_integer32_arg;
+
+	local: *;
+};
mk/rte.app.mk +2 -0
index 3eb41d1..929c3d8 100644
@@ -107,6 +107,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
Signature · 1 line
1.8.3.1
#44 lore raw

Re: [PATCH v5 1/3] Add Intel FPGA BUS Library

Quoted 1 line · Rosen Xu

Please include a description of this patch in the commit message. The cover letter is not going to be part of the commit history, after all. Therefore, move or copy relevant parts of the cover letter to the commit message here, so that someone viewing the git log gets a good overview of this work.

Quoted 11 lines
---
 config/common_base                          |   5 +
 drivers/bus/Makefile                        |   1 +
 drivers/bus/ifpga/Makefile                  |  32 ++
 drivers/bus/ifpga/ifpga_bus.c               | 504 ++++++++++++++++++++++++++++
 drivers/bus/ifpga/ifpga_common.c            |  88 +++++
 drivers/bus/ifpga/ifpga_common.h            |  18 +
 drivers/bus/ifpga/ifpga_logs.h              |  31 ++
 drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
 mk/rte.app.mk                               |   2 +

Need to add this to the meson build too. If you are unfamiliar with building DPDK with meson see "doc/build-sdk-meson.txt".

/Bruce

author
#45 lore raw

PATCH v5 2/3 Add Intel FPGA BUS Rawdev Driver

In reply to Rosen Xu
---
 config/common_base                                 |   1 +
 drivers/raw/Makefile                               |   1 +
 drivers/raw/ifpga_rawdev/Makefile                  |  36 ++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            | 592 +++++++++++++++++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |  37 ++
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |   4 +
 mk/rte.app.mk                                      |   1 +
 7 files changed, 672 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
config/common_base +1 -0
index 49f6b09..08b7cce 100644
@@ -137,6 +137,7 @@ CONFIG_RTE_LIBRTE_VDEV_BUS=y
 # Compile the Intel FPGA bus
 #
 CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+CONFIG_RTE_LIBRTE_IFPGA_RAWDEV=y
 
 #
 # Compile ARK PMD
drivers/raw/Makefile +1 -0
index da7c8b4..6fc8f2f 100644
@@ -5,5 +5,6 @@ include $(RTE_SDK)/mk/rte.vars.mk
 
 # DIRS-$(<configuration>) += <directory>
 DIRS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += skeleton_rawdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/raw/ifpga_rawdev/Makefile new file +36 -0
new file mode 100644
index 0000000..66e2e34
@@ -0,0 +1,36 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2018 Intel Corporation
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+#
+# library name
+#
+LIB = librte_ifpga_rawdev.a
+
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -O3
+CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/bus/ifpga
+CFLAGS += -I$(RTE_SDK)/drivers/raw/ifpga_rawdev
+LDLIBS += -lrte_eal
+LDLIBS += -lrte_rawdev
+LDLIBS += -lrte_bus_vdev
+LDLIBS += -lrte_kvargs
+LDLIBS += -lrte_bus_pci
+LDLIBS += -lrte_bus_ifpga
+
+EXPORT_MAP := rte_ifpga_rawdev_version.map
+
+LIBABIVER := 1
+
+VPATH += $(SRCDIR)/base
+
+include $(RTE_SDK)/drivers/raw/ifpga_rawdev/base/Makefile
+
+#
+# all source are stored in SRCS-y
+#
+SRCS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV) += ifpga_rawdev.c
+
+include $(RTE_SDK)/mk/rte.lib.mk
drivers/raw/ifpga_rawdev/ifpga_rawdev.c new file +592 -0

592 lines not on this page · raw message

drivers/raw/ifpga_rawdev/ifpga_rawdev.h new file +37 -0
new file mode 100644
index 0000000..169dc1d
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_RAWDEV_H_
+#define _IFPGA_RAWDEV_H_
+
+extern int ifpga_rawdev_logtype;
+
+#define IFPGA_RAWDEV_PMD_LOG(level, fmt, args...) \
+	rte_log(RTE_LOG_ ## level, ifpga_rawdev_logtype, "%s(): " fmt "\n", \
+		__func__, ##args)
+
+#define IFPGA_RAWDEV_PMD_FUNC_TRACE() IFPGA_RAWDEV_PMD_LOG(DEBUG, ">>")
+
+#define IFPGA_RAWDEV_PMD_DEBUG(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(DEBUG, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_INFO(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(INFO, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_ERR(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(ERR, fmt, ## args)
+#define IFPGA_RAWDEV_PMD_WARN(fmt, args...) \
+	IFPGA_RAWDEV_PMD_LOG(WARNING, fmt, ## args)
+
+enum ifpga_rawdev_device_state {
+	IFPGA_IDLE,
+	IFPGA_READY,
+	IFPGA_ERROR
+};
+
+static inline struct opae_adapter *
+ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
+{
+	return rawdev->dev_private;
+}
+
+#endif /* _IFPGA_RAWDEV_H_ */
drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map new file +4 -0
new file mode 100644
index 0000000..9b9ab1a
@@ -0,0 +1,4 @@
+DPDK_18.05 {
+
+	local: *;
+};
mk/rte.app.mk +1 -0
index 929c3d8..d4c014a 100644
@@ -232,6 +232,7 @@ endif # CONFIG_RTE_LIBRTE_EVENTDEV
 
 ifeq ($(CONFIG_RTE_LIBRTE_RAWDEV),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_SKELETON_RAWDEV) += -lrte_pmd_skeleton_rawdev
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_RAWDEV)   += -lrte_ifpga_rawdev
 endif # CONFIG_RTE_LIBRTE_RAWDEV
 
 ifeq ($(CONFIG_RTE_LIBRTE_DPAA2_PMD),y)
Signature · 1 line
1.8.3.1
author
#46 lore raw

PATCH v5 3/3 Add Intel FPGA OPAE Share Code

In reply to Rosen Xu
---
 drivers/raw/ifpga_rawdev/base/Makefile             |   54 +
 drivers/raw/ifpga_rawdev/base/ifpga_api.c          |  529 ++++++
 drivers/raw/ifpga_rawdev/base/ifpga_api.h          |   73 +
 drivers/raw/ifpga_rawdev/base/ifpga_compat.h       |   84 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1688 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  851 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   38 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  341 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  191 +++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  761 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  328 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  430 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  742 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  399 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  154 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  435 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  192 +++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |  126 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   46 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  408 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  280 ++++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  172 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  306 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |  115 ++
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |  104 ++
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   72 +
 26 files changed, 8919 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +54 -0
new file mode 100644
index 0000000..9c0d64b
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+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 += ifpga_fme_pr.c
+SRCS-y += opae_hw_api.c
+SRCS-y += opae_ifpga_hw_api.c
+SRCS-y += opae_debug.c
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/ifpga_api.c new file +529 -0

529 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_api.h new file +73 -0

73 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_compat.h new file +84 -0

84 lines not on this page · raw message

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

1,688 lines not on this page · raw message

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

572 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h new file +38 -0
new file mode 100644
index 0000000..0df7b2f

Lines of this file are not shown. View the raw message.

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c new file +341 -0

341 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +191 -0

191 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +761 -0

761 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +328 -0

328 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +430 -0

430 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +742 -0

742 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +399 -0

399 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +154 -0

154 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +435 -0

435 lines not on this page · raw message

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

192 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.c new file +126 -0

126 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.h new file +46 -0

46 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.c new file +408 -0

408 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_hw_api.h new file +280 -0

280 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c new file +172 -0

172 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h new file +306 -0

306 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_osdep.h new file +115 -0

115 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h new file +104 -0

104 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h new file +72 -0

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

#47 lore raw

Re: [PATCH v5 3/3] Add Intel FPGA OPAE Share Code

Hi Rosen/Bruce,

Quoted 22 lines · Rosen Xu

+++ b/drivers/raw/ifpga_rawdev/base/Makefile

drivers/raw/ifpga_rawdev/base/Makefile new file +20 -0
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS

drivers/raw/ifpga_rawdev/base/Makefile line 30

Quoted 10 lines
drivers/raw/ifpga_rawdev/base/Makefile new file +10 -0
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

These files are adding the full license boiler plate. What is your plan to change it to SPDX?

Bruce, may be your script can help Rosen to do it faster.

Regards,
Hemant

author
#48 lore raw

Re: [PATCH v5 3/3] Add Intel FPGA OPAE Share Code

Hi Hemant,

Quoted 57 lines

-----Original Message-----
From: Hemant Agrawal [mailto:[email protected]]
Sent: Wednesday, April 04, 2018 20:00
To: Xu, Rosen <[email protected]>; [email protected]; Richardson, Bruce <[email protected]>
Cc: Doherty, Declan <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]; Xu, Yilun <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v5 3/3] Add Intel FPGA OPAE Share Code

Hi Rosen/Bruce,

Quoted 12 lines · Rosen Xu

+++ b/drivers/raw/ifpga_rawdev/base/Makefile

drivers/raw/ifpga_rawdev/base/Makefile new file +10 -0
@@ -0,0 +1,54 @@
+#   BSD LICENSE
+#
+#   Copyright(c) 2017-2018 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright

drivers/raw/ifpga_rawdev/base/Makefile line 20

Quoted 10 lines
drivers/raw/ifpga_rawdev/base/Makefile new file +10 -0
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND

CONTRIBUTORS

Review line 21

Quoted 1 line
(quoted diff) +1 -0
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT

NOT

Review line 22

Quoted 1 line
(quoted diff) +1 -0
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND

FITNESS FOR

Review line 23

Quoted 1 line
(quoted diff) +1 -0
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE

COPYRIGHT

Review line 24

Quoted 1 line
(quoted diff) +1 -0
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,

INCIDENTAL,

Review line 25

Quoted 1 line
(quoted diff) +1 -0
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,

BUT NOT

Review line 26

Quoted 1 line
(quoted diff) +1 -0
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;

LOSS OF USE,

Review line 27

Quoted 1 line
(quoted diff) +1 -0
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED

AND ON ANY

Review line 28

Quoted 1 line
(quoted diff) +1 -0
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR

TORT

Review line 29

Quoted 1 line
(quoted diff) +1 -0
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT

OF THE USE

Quoted 8 lines

Review line 30

Quoted 1 line
(quoted diff) +1 -0
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH

DAMAGE.

These files are adding the full license boiler plate. What is your plan to change it to SPDX?

Bruce, may be your script can help Rosen to do it faster.

It's fixed in PATCH v6.

Quoted 2 lines

Regards,
Hemant

#49 lore raw
In reply to Rosen Xu

Hello Rosen,

Quoted 13 lines

-----Original Message-----
From: Rosen Xu [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 12:21 PM
To: [email protected]
Cc: [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v5 0/3] Introduce Intel FPGA BUS

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

Quoted 9 lines

This patch set introduces Intel FPGA BUS support in DPDK.

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

[...]

Primary problems I see with your patches:
1. They are not split enough. Still the patch 2/3 is dependent on 3/3. That mean, it would break the compilation. There is no simpler way to solve this except breaking the patch into multiple patches and slowly introducing each function/feature. (One obvious way would be to have 3/3 as 2/3 and vice-versa - Not sure what that blocks).

2. Documentation - there is none right now. Being a special use case for PCI, I think a lot of people would benefit if you can explain the comments about why iFPGA bus is required through documentation.

3. Meson as requested by Bruce. Problem you will face is that rawdev doesn't yet have meson enabled. I will work on that. If you can still rework your patches for (1)+(2), I think meson enable over rawdev would be trivial.

Other issues being license plate in opae code not being SPDX. But, I will leave that you and maintainers to decice.

#50 lore raw
Quoted 48 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 11:14 AM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [PATCH v5 0/3] Introduce Intel FPGA BUS

Hello Rosen,

Quoted 13 lines

-----Original Message-----
From: Rosen Xu [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 12:21 PM
To: [email protected]
Cc: [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v5 0/3] Introduce Intel FPGA BUS

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

Quoted 9 lines

This patch set introduces Intel FPGA BUS support in DPDK.

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

[...]

Primary problems I see with your patches:
1. They are not split enough. Still the patch 2/3 is dependent on 3/3. That mean, it would break the compilation. There is no simpler way to solve this except breaking the patch into multiple patches and slowly introducing each function/feature.
(One obvious way would be to have 3/3 as 2/3 and vice-versa - Not sure
what that blocks).

Quoted 8 lines

2. Documentation - there is none right now. Being a special use case for PCI, I think a lot of people would benefit if you can explain the comments about why iFPGA bus is required through documentation.

3. Meson as requested by Bruce. Problem you will face is that rawdev doesn't yet have meson enabled. I will work on that. If you can still rework your patches for (1)+(2), I think meson enable over rawdev would be trivial.

I just spotted this and I've sent a patch for rawdev. It was pretty trivial. :-) Please review and ack if you have the chance. The skeleton rawdev however, I haven't done, so feel free to patch in that.

/Bruce

#51 lore raw
Quoted 70 lines

-----Original Message-----
From: Richardson, Bruce [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 4:08 PM
To: Shreyansh Jain <[email protected]>; Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [PATCH v5 0/3] Introduce Intel FPGA BUS

Quoted 36 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 11:14 AM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: RE: [PATCH v5 0/3] Introduce Intel FPGA BUS

Hello Rosen,

Quoted 13 lines

-----Original Message-----
From: Rosen Xu [mailto:[email protected]]
Sent: Wednesday, April 4, 2018 12:21 PM
To: [email protected]
Cc: [email protected]; [email protected]; Shreyansh Jain <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [PATCH v5 0/3] Introduce Intel FPGA BUS

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

Quoted 9 lines

This patch set introduces Intel FPGA BUS support in DPDK.

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

Quoted 8 lines

[...]

Primary problems I see with your patches:
1. They are not split enough. Still the patch 2/3 is dependent on 3/3. That mean, it would break the compilation. There is no simpler way to solve this except breaking the patch into multiple patches and slowly introducing each function/feature.
(One obvious way would be to have 3/3 as 2/3 and vice-versa - Not

sure

Quoted 3 lines

what that blocks).

2. Documentation - there is none right now. Being a special use case

for

Quoted 1 line

PCI, I think a lot of people would benefit if you can explain the

comments

Quoted 5 lines

about why iFPGA bus is required through documentation.

3. Meson as requested by Bruce. Problem you will face is that rawdev doesn't yet have meson enabled. I will work on that. If you can still rework your patches for (1)+(2), I think meson enable over rawdev

Quoted 8 lines

would be

Quoted 1 line

trivial.

I just spotted this and I've sent a patch for rawdev. It was pretty trivial. :-)
Please review and ack if you have the chance. The skeleton rawdev however, I haven't
done, so feel free to patch in that.

:) Thanks. I'll review.
I will push a dependent patch for skeleton_rawdev.

Quoted 2 lines

/Bruce

author
#52 lore raw

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

v6 updates:
===========
- Add documentation
- Add meson build script
- Split new patch for OPAE share code

v5 updates:
===========
- Fixed SHARED LIB Build issue
- Changed command name to IFPGA Rawdev name,
so remove pci library datastruct and function.
- Fixed PATCH v2/v3/v4 comments

v4 updates:
===========
- Remove all modifications from eal
- Create vdev to take IFPGA parameters configuration
- AFU Device Driver bind to AFU Device by uuid
- Take more test in scenario of Multi-FPGA System

v3 updates:
===========
- Remove all modifications of bus scan and probe
- FPGA BUS Scan is trigged by hotplug of Rawdev
- Took Modifications of comments
- Move AFU Device to IFPGA
- FPGA BUS Scan depend on it¡¯s IFPGA Rawdev
- Add Build Macros for FPGA BUS and IFPGA Rawdev

Questions
=========
Why not PCI Bus?
All of the AFUs of one FPGA may share same PCI BDF. Why not vdev Bus?
Because AFUs depend on Rawdev, and it's hardware specpic.

Motivation
==========
FPGA is used more and more widely in Cloud and NFV, one primary reason is that FPGA not only provide ASIC performance but also it's more flexible than ASIC. FPGA use Partial Reconfigure(PR) Parts of Bitstream to achieve its flexibility. Another reason is that one FPGA can be shared by different Users, and each User can use some of AFUs of One FPGA.

That means One FPGA Device Bitstream is divided into many Parts of Bitstream(each Part of Bitstream is defined as AFU-Accelerated Function Unit), and each AFU is a Hardware Acceleration Unit and it can dynamically Reload respectively.

Proposed Solution
=================
- Involve Rawdev to take FPGA Partial Configuration(Download/PR)
- Defined FPGA-BUS for Acceleration Drivers of AFUs
- FPGA PCI Scan(1st Scan) follows DPDK UIO/VFIO PCI Scan Process, probe Intel FPGA Rawdev Driver. FPGA-BUS scan is called, but AFU depend on Rawdev, so this scan doesn't trig AFU device create.
- AFU Scan(2nd Scan) bind DPDK Driver to FPGA Partial-Bitstream. This scan is trigged by hotplug of IFPGA Rawdev probe, in this scan the AFUs will be created and their dirves are also probed.

Scope
=====
The Intel FPGA BUS implementation is target towards various FPGA Devices use PR to provide many Acceleration Function. Specific PMDs may also bind to its AFU. And Applications don't care they are using ASIC Acceleration or FPGA AFU Acceleration.

Status
=====
With integrating Intel PSG FPGA Software Stack OPAE(Open Programmable Acceleration Engine) Share Code, Intel FPGA BUS runs well in Intel PSG FPGA Cards.

Figo Zhang (2):
iFPGA: add meson build
iFPGA: add document for iFPGA driver

Rosen Xu (3):
iFPGA: Add Intel FPGA BUS Library
iFPGA: Add Intel FPGA OPAE Share Code
iFPGA: Add Intel FPGA BUS Rawdev Driver

 config/common_base                                 |    6 +
 doc/guides/index.rst                               |    1 +
 doc/guides/rawdevs/ifpga_rawdev.rst                |  112 ++
 doc/guides/rawdevs/index.rst                       |   11 +
 doc/guides/rel_notes/release_18_05.rst             |   13 +
 drivers/bus/Makefile                               |    1 +
 drivers/bus/ifpga/Makefile                         |   32 +
 drivers/bus/ifpga/ifpga_bus.c                      |  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                      |    6 +
 drivers/bus/ifpga/rte_bus_ifpga.h                  |  168 ++
 drivers/bus/ifpga/rte_bus_ifpga_version.map        |   10 +
 drivers/bus/meson.build                            |    2 +-
 drivers/meson.build                                |    3 +-
 drivers/raw/Makefile                               |    1 +
 drivers/raw/ifpga_rawdev/Makefile                  |   36 +
 drivers/raw/ifpga_rawdev/base/Makefile             |   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       |   57 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1661 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  824 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   11 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  314 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  164 ++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  734 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  301 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  403 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  715 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  372 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  127 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  408 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  165 ++
 drivers/raw/ifpga_rawdev/base/meson.build          |   34 +
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |   99 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   19 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  381 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  253 +++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  145 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  279 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |   81 +
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |   75 +
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   45 +
 drivers/raw/ifpga_rawdev/ifpga_rawdev.c            |  597 +++++++
 drivers/raw/ifpga_rawdev/ifpga_rawdev.h            |   37 +
 drivers/raw/ifpga_rawdev/meson.build               |   13 +
 .../raw/ifpga_rawdev/rte_ifpga_rawdev_version.map  |    4 +
 drivers/raw/meson.build                            |    6 +
 mk/rte.app.mk                                      |    3 +
 52 files changed, 9746 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/rawdevs/ifpga_rawdev.rst
 create mode 100644 doc/guides/rawdevs/index.rst
 create mode 100644 drivers/bus/ifpga/Makefile
 create mode 100644 drivers/bus/ifpga/ifpga_bus.c
 create mode 100644 drivers/bus/ifpga/ifpga_common.c
 create mode 100644 drivers/bus/ifpga/ifpga_common.h
 create mode 100644 drivers/bus/ifpga/ifpga_logs.h
 create mode 100644 drivers/bus/ifpga/meson.build
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga.h
 create mode 100644 drivers/bus/ifpga/rte_bus_ifpga_version.map
 create mode 100644 drivers/raw/ifpga_rawdev/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/README
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/meson.build
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.c
 create mode 100644 drivers/raw/ifpga_rawdev/ifpga_rawdev.h
 create mode 100644 drivers/raw/ifpga_rawdev/meson.build
 create mode 100644 drivers/raw/ifpga_rawdev/rte_ifpga_rawdev_version.map
 create mode 100644 drivers/raw/meson.build
Signature · 1 line
1.8.3.1
author
#53 lore raw

PATCH v6 1/5 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.
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.

---
 config/common_base                          |   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               |   6 +
 drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
 drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
 drivers/bus/meson.build                     |   2 +-
 mk/rte.app.mk                               |   2 +
 12 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
config/common_base +5 -0
index 7e45412..b59f1de 100644
@@ -148,6 +148,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
 CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
 #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
 # Compile ARK PMD
 #
 CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
index c251b65..cff3567 100644
@@ -9,5 +9,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
 endif
 DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
 DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
 include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
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..b6662c8
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
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 +6 -0
new file mode 100644
index 0000000..4ea31f1
@@ -0,0 +1,6 @@
+# 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')
drivers/bus/ifpga/rte_bus_ifpga.h new file +168 -0

168 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..1304caf
@@ -0,0 +1,10 @@
+DPDK_18.05 {
+	global:
+
+	ifpga_get_integer32_arg;
+	ifpga_get_string_arg;
+	rte_ifpga_driver_register;
+	rte_ifpga_driver_unregister;
+
+	local: *;
+};
drivers/bus/meson.build +1 -1
index 58dfbe2..170df25 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017 Intel Corporation
 
-drivers = ['dpaa', 'fslmc', 'pci', 'vdev']
+drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga']
 std_deps = ['eal']
 config_flag_fmt = 'RTE_LIBRTE_@0@_BUS'
 driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +2 -0
index a145791..9de2edb 100644
@@ -107,6 +107,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
 _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
 _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+
 ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
 _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
 endif
Signature · 1 line
1.8.3.1
#54 lore raw

Re: [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

Quoted 25 lines · Rosen

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

---
  config/common_base                          |   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               |   6 +
  drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
  drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
  drivers/bus/meson.build                     |   2 +-
  mk/rte.app.mk                               |   2 +
  12 files changed, 865 insertions(+), 1 deletion(-)
Quoted 9 lines

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

Hello Rosen,

While compiling this series with meson, I found following warnings:

--->8---
3d/1& [shreyansh:~/build/DPDK/00_dpdk/ifpga-build]↥ master(6)+* ± ninja
[335/949] Compiling C object 'drivers/tmp_rte_bus_ifpga@sta/bus_ifpga_ifpga_bus.c.o'.
../drivers/bus/ifpga/ifpga_bus.c: In function ‘rte_ifpga_scan’:
../drivers/bus/ifpga/ifpga_bus.c:217:2: warning: ‘rte_devargs_next’ is deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]
RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/bus/ifpga/ifpga_bus.c:24:0:
../lib/librte_eal/common/include/rte_devargs.h:262:1: note: declared here
rte_devargs_next(const char *busname, const struct rte_devargs *start);
^~~~~~~~~~~~~~~~
../drivers/bus/ifpga/ifpga_bus.c:217:2: warning: ‘rte_devargs_next’ is deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]
RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
^~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/bus/ifpga/ifpga_bus.c:24:0:
../lib/librte_eal/common/include/rte_devargs.h:262:1: note: declared here
rte_devargs_next(const char *busname, const struct rte_devargs *start);
^~~~~~~~~~~~~~~~
../drivers/bus/ifpga/ifpga_bus.c: In function ‘rte_ifpga_unplug’:
../drivers/bus/ifpga/ifpga_bus.c:419:2: warning: ‘rte_devargs_remove’ is deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]
rte_devargs_remove(devargs->bus->name, devargs->name);
^~~~~~~~~~~~~~~~~~
In file included from ../drivers/bus/ifpga/ifpga_bus.c:24:0:
../lib/librte_eal/common/include/rte_devargs.h:195:5: note: declared here
int rte_devargs_remove(const char *busname,

     ^~~~~~~~~~~~~~~~~~

../drivers/bus/ifpga/ifpga_bus.c: At top level:
cc1: warning: unrecognized command line option ‘-W --->8---

My meson configuration is:

--->8---
3d/1& [shreyansh:~/build/DPDK/00_dpdk]↥ master(6)+* 130 ± ~/.local/bin/meson ifpga-build The Meson build system
Version: 0.44.0
Source dir: /home/shreyansh/build/DPDK/00_dpdk
Build dir: /home/shreyansh/build/DPDK/00_dpdk/ifpga-build
Build type: native build
Project name: DPDK
Native C compiler: ccache cc (gcc 7.2.0)
Build machine cpu family: x86_64
Build machine cpu: x86_64
Library numa found: YES
Has header "numaif.h": YES
...
--->8---

Can you please look into this?

-
Shreyansh

#55 lore raw

Re: [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

Quoted 105 lines

-----Original Message-----
From: Shreyansh Jain [mailto:[email protected]]
Sent: Wednesday, May 2, 2018 9:14 PM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

Quoted 9 lines · Rosen

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

Quoted 7 lines
---
  config/common_base                          |   5 +
  drivers/bus/Makefile                        |   1 +
  drivers/bus/ifpga/Makefile                  |  32 ++
  drivers/bus/ifpga/ifpga_bus.c               | 503

++++++++++++++++++++++++++++

Quoted 9 lines
  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               |   6 +
  drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
  drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
  drivers/bus/meson.build                     |   2 +-
  mk/rte.app.mk                               |   2 +
  12 files changed, 865 insertions(+), 1 deletion(-)
Quoted 9 lines

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

Hello Rosen,

While compiling this series with meson, I found following warnings:

--->8---
3d/1& [shreyansh:~/build/DPDK/00_dpdk/ifpga-build]↥ master(6)+* ± ninja [335/949] Compiling C object 'drivers/tmp_rte_bus_ifpga@sta/bus_ifpga_ifpga_bus.c.o'. ../drivers/bus/ifpga/ifpga_bus.c: In function ‘rte_ifpga_scan’:
../drivers/bus/ifpga/ifpga_bus.c:217:2: warning: ‘rte_devargs_next’ is
deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]

   RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
   ^~~~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/bus/ifpga/ifpga_bus.c:24:0:
../lib/librte_eal/common/include/rte_devargs.h:262:1: note: declared here
rte_devargs_next(const char *busname, const struct rte_devargs *start); ^~~~~~~~~~~~~~~~
../drivers/bus/ifpga/ifpga_bus.c:217:2: warning: ‘rte_devargs_next’ is
deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]

   RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
   ^~~~~~~~~~~~~~~~~~~~~~~

In file included from ../drivers/bus/ifpga/ifpga_bus.c:24:0:
../lib/librte_eal/common/include/rte_devargs.h:262:1: note: declared here
rte_devargs_next(const char *busname, const struct rte_devargs *start); ^~~~~~~~~~~~~~~~
../drivers/bus/ifpga/ifpga_bus.c: In function ‘rte_ifpga_unplug’:
../drivers/bus/ifpga/ifpga_bus.c:419:2: warning: ‘rte_devargs_remove’ is
deprecated: Symbol is not yet part of stable ABI [-Wdeprecated-declarations]

   rte_devargs_remove(devargs->bus->name, devargs->name);
   ^~~~~~~~~~~~~~~~~~
In file included from ../drivers/bus/ifpga/ifpga_bus.c:24:0:
../lib/librte_eal/common/include/rte_devargs.h:195:5: note: declared here
  int rte_devargs_remove(const char *busname,
      ^~~~~~~~~~~~~~~~~~

../drivers/bus/ifpga/ifpga_bus.c: At top level:
cc1: warning: unrecognized command line option ‘-W --->8---

My meson configuration is:

--->8---
3d/1& [shreyansh:~/build/DPDK/00_dpdk]↥ master(6)+* 130 ± ~/.local/bin/meson ifpga-build The Meson build system
Version: 0.44.0
Source dir: /home/shreyansh/build/DPDK/00_dpdk
Build dir: /home/shreyansh/build/DPDK/00_dpdk/ifpga-build Build type: native build
Project name: DPDK
Native C compiler: ccache cc (gcc 7.2.0) Build machine cpu family: x86_64 Build machine cpu: x86_64 Library numa found: YES Has header "numaif.h":
YES ...
--->8---

Quoted 1 line

Can you please look into this?

We will fix it and send v7 patches soon.
I try it add " allow_experimental_apis = true " in meson.build can remove those warrings.

Quoted 3 lines

-
Shreyansh

#56 lore raw

Re: [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

In reply to Xu, Rosen

For title prefix, use "bus/ifpga" instead.

Quoted 5 lines · Rosen

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.

As I understand, this part is not covered in this patch. You might want to add a note that "it will be covered in following patches".

Quoted 3 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 is not only responsible for scan, but also other bus ops. So in your commit log, you might want to clarify this, like we introduce rte_afu_device.

I have a question, hope you can clarify it a little bit. As I understand, this FPGA bus are used for AFU device enumeration, and each device on this bus needs a AFU driver to drive. But now we register AFU drivers, but enumerate rte_ifpga_device. Why? The reason I can think of, we need to maintain the relationship of fpga devices and afu devices. But I think similar problem would exist in dpaa and fslmc bus too. It is interesting to know the best practice on this.

Besides, I see you are using a devargs for scanning, would you like to provide an example here?

Quoted 123 lines
---
  config/common_base                          |   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               |   6 +
  drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
  drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
  drivers/bus/meson.build                     |   2 +-
  mk/rte.app.mk                               |   2 +
  12 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

config/common_base +5 -0
index 7e45412..b59f1de 100644
@@ -148,6 +148,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
  CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
  #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
  # Compile ARK PMD
  #
  CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
index c251b65..cff3567 100644
@@ -9,5 +9,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
  endif
  DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
  DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
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 +26 -0
new file mode 100644
index 0000000..67c24ae
@@ -0,0 +1,503 @@
+/* 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>

drivers/bus/ifpga/ifpga_bus.c line 36

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+
+#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 declare to access Intel FPGA bus name */

s/declare/declaration, actually, does "Intel FPGA bus on which iFPGA devices are connected" sound better?

drivers/bus/ifpga/ifpga_bus.c line 44

Quoted 8 lines
drivers/bus/ifpga/ifpga_bus.c new file +8 -0
+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);
+struct afu_driver_list afu_driver_list =

Why not keep this list as static?

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

drivers/bus/ifpga/ifpga_bus.c line 104

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	IFPGA_AFU_BTS,
+	NULL
+};
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,

For internal functions, we'd better not use the prefix "rte".

drivers/bus/ifpga/ifpga_bus.c line 114

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	struct rte_ifpga_device *ifpga_dev)
+{
+	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((char *)(&afu_pr_conf), 0, sizeof(struct rte_afu_pr_conf));

For "void *", no need to add explicit type cast.

Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +14 -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,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}

drivers/bus/ifpga/ifpga_bus.c line 138

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	} 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,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",

s/error/failed

Quoted 45 lines
drivers/bus/ifpga/ifpga_bus.c new file +45 -0
+				     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_low = 0;
+	afu_pr_conf.afu_id.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_low  = 0;
+	afu_dev->id.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;
+	}

drivers/bus/ifpga/ifpga_bus.c line 193

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+
+
+	return afu_dev;
+
+free_dev:
+	free(afu_dev);
+end:
+	if (kvlist)

You can remove above if statement for simplicity.

drivers/bus/ifpga/ifpga_bus.c line 195

Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2 -0
+		rte_kvargs_free(kvlist);
+	if (path)

Ditto.

Quoted 36 lines
drivers/bus/ifpga/ifpga_bus.c new file +36 -0
+		free(path);
+
+	return NULL;
+}
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static int
+rte_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;
+	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 */
+	RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
+		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,
+				       &ifpga_get_string_arg, &name) < 0) {
+				IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_NAME);

drivers/bus/ifpga/ifpga_bus.c line 241

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", name);

Change to use strlcpy instead.

Quoted 13 lines
drivers/bus/ifpga/ifpga_bus.c new file +13 -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));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->rdev = rawdev;

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&ifpga_device_list, ifpga_dev, next);
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev, next);
+	}
+
+end:
+	if (kvlist)

Ditto.

drivers/bus/ifpga/ifpga_bus.c line 266

Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2 -0
+		rte_kvargs_free(kvlist);
+	if (name)

Ditto.

Quoted 40 lines
drivers/bus/ifpga/ifpga_bus.c new file +40 -0
+		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_low) ||
+				(id_table->uuid_high != afu_dev->id.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;

drivers/bus/ifpga/ifpga_bus.c line 316

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	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 positive value if driver doesn't support this device */

This comment seems wrong; you already exclude the case that this driver does not support this device (>0); here, we only have the cases that, probe succeeds (=0), and probe fails (<0).

drivers/bus/ifpga/ifpga_bus.c line 317

Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1 -0
+	return 0;

return ret instead of 0?

Quoted 124 lines
drivers/bus/ifpga/ifpga_bus.c new file +124 -0
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
+{
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	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) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * 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
+rte_ifpga_probe(void)
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_afu_device *afu_dev = NULL;
+	int ret = 0;
+
+	TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) {
+		TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) {
+
+			if (afu_dev->device.driver)
+				continue;
+
+			ret = ifpga_probe_all_drivers(afu_dev);
+			if (ret < 0)
+				IFPGA_BUS_ERR("failed to initialize %s device\n",
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_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
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	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 *
+rte_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;
+		}
+	}

drivers/bus/ifpga/ifpga_bus.c line 451

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	return NULL;
+}
+static int
+rte_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;

Duplicated spaces after "int".

Quoted 257 lines
drivers/bus/ifpga/ifpga_bus.c new file +52 -0
+	char str_port[8];
+	int str_port_len = 0;
+	int ret;
+
+	memset(str_port, 0, 8);
+	c1 = strchr(name, '|');
+	if (c1 != NULL) {
+		str_port_len = c1-name;
+		c2 = c1+1;
+	}
+
+	if (str_port_len < 8 &&
+		str_port_len > 0) {
+		memcpy(str_port, name, str_port_len);
+		ret = sscanf(str_port, "%d", &port);
+		if (ret == -1)
+			return 0;
+	}
+
+	memset(rawdev_name, 0, sizeof(rawdev_name));
+	snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s", c2);
+	rawdev = rte_rawdev_pmd_get_named_dev(rawdev_name);
+
+	if ((port < IFPGA_BUS_DEV_PORT_MAX) &&
+		rawdev &&
+		(addr != NULL))
+		*out = port;
+
+	if ((port < IFPGA_BUS_DEV_PORT_MAX) &&
+		rawdev)
+		return 0;
+	else
+		return 1;
+}
+
+static struct rte_bus rte_ifpga_bus = {
+	.scan        = rte_ifpga_scan,
+	.probe       = rte_ifpga_probe,
+	.find_device = rte_ifpga_find_device,
+	.plug        = rte_ifpga_plug,
+	.unplug      = rte_ifpga_unplug,
+	.parse       = rte_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 +88 -0
new file mode 100644
index 0000000..26fee27
@@ -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 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 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_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}
drivers/bus/ifpga/ifpga_common.h new file +18 -0
new file mode 100644
index 0000000..b6662c8
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
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 +6 -0
new file mode 100644
index 0000000..4ea31f1
@@ -0,0 +1,6 @@
+# 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')
drivers/bus/ifpga/rte_bus_ifpga.h new file +32 -0
new file mode 100644
index 0000000..53e7183
@@ -0,0 +1,168 @@
+/* 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

drivers/bus/ifpga/rte_bus_ifpga.h line 42

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+
+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

It seems that this struct is for describing the AFU device, instead of AFU driver, no?

drivers/bus/ifpga/rte_bus_ifpga.h line 47

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5 -0
+ * table of these IDs for each device that it supports.
+ */
+struct rte_afu_id {
+	uint64_t uuid_low;
+	uint64_t uuid_high;

Why not reuse struct rte_afu_uuid for above two fields?

drivers/bus/ifpga/rte_bus_ifpga.h line 48

Quoted 1 line
drivers/bus/ifpga/rte_bus_ifpga.h new file +1 -0
+	int      port;

Can you add a note on what *port* means?

drivers/bus/ifpga/rte_bus_ifpga.h line 52

Quoted 4 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +4 -0
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.

What does pr mean? Mind to add a full name for it?

Quoted 64 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +64 -0
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;
+	char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list. */
+	struct rte_rawdev *rdev;
+	struct afu_device_list afu_list;  /**< List of AFU devices */
+};
+
+/**
+ * A structure describing a AFU device.
+ */
+struct rte_afu_device {
+	TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< AFU Memory Resource */
+	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	struct rte_afu_driver *driver;          /**< Associated driver */
+	char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+} __attribute__ ((packed));
+
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_afu_device.
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+#define RTE_DRV_TO_AFU_CONST(ptr) \
+	container_of(ptr, const struct rte_afu_driver, driver)
+
+/**
+ * Initialisation function for the driver called during FPGA BUS probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.
+ */
+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. */
+	afu_remove_t *remove;                   /**< Device Remove function. */

drivers/bus/ifpga/rte_bus_ifpga.h line 126

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+	const struct rte_afu_uuid *id_table;    /**< AFU uuid within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device. */
+};
+
+/**
+ * Structure describing the Intel FPGA bus
+ */
+struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+};

Where is this struct used?

Quoted 30 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +30 -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;\

drivers/bus/ifpga/rte_bus_ifpga.h line 166

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+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)

Do we really need alias for new bus? Originally, alias is a way for compatibility, but it seems that it's not necessary for new bus.

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 13 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +2 -0
+
+#endif /* _RTE_BUS_IFPGA_H_ */
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
new file mode 100644
index 0000000..1304caf
@@ -0,0 +1,10 @@
+DPDK_18.05 {
+	global:
+
+	ifpga_get_integer32_arg;
+	ifpga_get_string_arg;

Above two functions shall be not exposed as APIs.

Quoted 31 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
+	rte_ifpga_driver_register;
+	rte_ifpga_driver_unregister;
+
+	local: *;
+};
drivers/bus/meson.build +1 -1
index 58dfbe2..170df25 100644
@@ -1,7 +1,7 @@
  # SPDX-License-Identifier: BSD-3-Clause
  # Copyright(c) 2017 Intel Corporation
 
-drivers = ['dpaa', 'fslmc', 'pci', 'vdev']
+drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga']
  std_deps = ['eal']
  config_flag_fmt = 'RTE_LIBRTE_@0@_BUS'
  driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +2 -0
index a145791..9de2edb 100644
@@ -107,6 +107,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)        += -lrte_cmdline
  _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
  _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
 
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+
  ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
  _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
  endif
#57 lore raw

Re: [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

Quoted 1 line · Jianfeng

I have a question, hope you can clarify it a little bit. As I understand, this FPGA bus are used for AFU device enumeration, and each device on this bus needs a AFU driver to drive. But now we register AFU drivers, but enumerate rte_ifpga_device. Why? The reason I can think of, we need to maintain the relationship of fpga devices and afu devices. But I think similar problem would exist in dpaa and fslmc bus too. It is interesting to know the best practice on this.

After offline discussion with Tianfei, I got that current implementation is to add a bus for afu devices and afu drivers. As for the bus name, ifpga bus or afu bus, I'm OK to both; only if you clarify the purpose of this bus is to manage afu devices and afu drivers.

Thanks,
Jianfeng

#58 lore raw

Re: [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

In reply to Tan, Jianfeng
Quoted 12 lines

-----Original Message-----
From: Tan, Jianfeng
Sent: Thursday, May 3, 2018 11:58 AM
To: Xu, Rosen <[email protected]>; [email protected]
Cc: Doherty, Declan <[email protected]>; Richardson, Bruce <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>; Ananyev, Konstantin <[email protected]>; Zhang, Tianfei <[email protected]>; Wu, Hao <[email protected]>; [email protected]
Subject: Re: [dpdk-dev] [PATCH v6 1/5] iFPGA: Add Intel FPGA BUS Library

Quoted 1 line

For title prefix, use "bus/ifpga" instead.

Will fix in next version.

Quoted 11 lines · Rosen
Quoted 5 lines

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.

As I understand, this part is not covered in this patch. You might want to add a note that "it will be covered in following patches".

Yes, this scan in Intel FPGA raw device driver. Will fix this comment in next version.

Quoted 8 lines
Quoted 4 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 is not only responsible for scan, but also other bus ops. So in your commit log, you might want to clarify this, like we introduce rte_afu_device.

Quoted 7 lines

I have a question, hope you can clarify it a little bit. As I understand, this FPGA bus are used for AFU device enumeration, and each device on this bus needs a AFU driver to drive. But now we register AFU drivers, but enumerate rte_ifpga_device. Why? The reason I can think of, we need to maintain the relationship of fpga devices and afu devices.
But I think similar problem would exist in dpaa and fslmc bus too. It is interesting to know the best practice on this.

Suppose we will have multiple FPGA chips in one system, and each FPGA chip will has multiple AFUs, So the rte_ifpga_device will describe the FPGA chip.

Quoted 3 lines

Besides, I see you are using a devargs for scanning, would you like to provide an example here?

This is an example run ethernet functionality on AFU 0 of FPGA (pci addr = 5e:00.0)

#./x86_64-native-linuxapp-gcc/app/testpmd -c 0x3 -n 4 --socket-mem 1024,0 --huge-dir=/mnt/huge --vdev 'net_ifpga_cfg0,ifpga=5e:00.0,port=0,afu_bts=./ether.gbs' -- -i --no-numa

Quoted 131 lines
Quoted 10 lines
---
  config/common_base                          |   5 +
  drivers/bus/Makefile                        |   1 +
  drivers/bus/ifpga/Makefile                  |  32 ++
  drivers/bus/ifpga/ifpga_bus.c               | 503

++++++++++++++++++++++++++++

Quoted 120 lines
  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               |   6 +
  drivers/bus/ifpga/rte_bus_ifpga.h           | 168 ++++++++++
  drivers/bus/ifpga/rte_bus_ifpga_version.map |  10 +
  drivers/bus/meson.build                     |   2 +-
  mk/rte.app.mk                               |   2 +
  12 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

config/common_base +5 -0
index 7e45412..b59f1de 100644
@@ -148,6 +148,11 @@ CONFIG_RTE_LIBRTE_PCI_BUS=y
  CONFIG_RTE_LIBRTE_VDEV_BUS=y
 
  #
+# Compile the Intel FPGA bus
+#
+CONFIG_RTE_LIBRTE_IFPGA_BUS=y
+
+#
  # Compile ARK PMD
  #
  CONFIG_RTE_LIBRTE_ARK_PMD=y
drivers/bus/Makefile +1 -0
index c251b65..cff3567 100644
@@ -9,5 +9,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_FSLMC_BUS) += fslmc
  endif
  DIRS-$(CONFIG_RTE_LIBRTE_PCI_BUS) += pci
  DIRS-$(CONFIG_RTE_LIBRTE_VDEV_BUS) += vdev
+DIRS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS) += ifpga
 
  include $(RTE_SDK)/mk/rte.subdir.mk
drivers/bus/ifpga/Makefile new file +32 -0
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 +31 -0
new file mode 100644
index 0000000..67c24ae
@@ -0,0 +1,503 @@
+/* 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"
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 36

Quoted 5 lines
drivers/bus/ifpga/ifpga_bus.c new file +5 -0
+#include "ifpga_common.h"
+
+int ifpga_bus_logtype;
+
+/* Forward declare to access Intel FPGA bus name */

s/declare/declaration, actually, does "Intel FPGA bus on which iFPGA devices are connected" sound better?

Yes, sounds good.

Quoted 11 lines

drivers/bus/ifpga/ifpga_bus.c line 44

Quoted 9 lines
drivers/bus/ifpga/ifpga_bus.c new file +8 -0
+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);
+struct afu_driver_list afu_driver_list =

Why not keep this list as static?

Will fix it in next version.

Quoted 55 lines
Quoted 55 lines
drivers/bus/ifpga/ifpga_bus.c new file +54 -0
+	TAILQ_HEAD_INITIALIZER(afu_driver_list);
+
+
+/* register a ifpga bus based driver */
+void rte_ifpga_driver_register(struct rte_afu_driver *driver)
+{
+	RTE_VERIFY(driver);
+
+	TAILQ_INSERT_TAIL(&afu_driver_list, driver, next);
+}
+
+/* un-register a fpga bus based driver */
+void rte_ifpga_driver_unregister(struct rte_afu_driver *driver)
+{
+	TAILQ_REMOVE(&afu_driver_list, driver, next);
+}
+
+static struct rte_ifpga_device *
+ifpga_find_ifpga_dev(const struct rte_rawdev *rdev)
+{
+	struct rte_ifpga_device *ifpga_dev = NULL;
+
+	TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) {
+		if (rdev &&
+			ifpga_dev->rdev &&
+			ifpga_dev->rdev == rdev)
+			return ifpga_dev;
+	}
+	return NULL;
+}
+
+static struct rte_afu_device *
+ifpga_find_afu_dev(const struct rte_ifpga_device *ifpga_dev,
+	const struct rte_afu_id *afu_id)
+{
+	struct rte_afu_device *afu_dev = NULL;
+
+	TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) {
+		if (!ifpga_afu_id_cmp(&afu_dev->id, afu_id))
+			return afu_dev;
+	}
+	return NULL;
+}
+
+static const char * const valid_args[] = {
+#define IFPGA_ARG_NAME         "ifpga"
+	IFPGA_ARG_NAME,
+#define IFPGA_ARG_PORT         "port"
+	IFPGA_ARG_PORT,
+#define IFPGA_AFU_BTS          "afu_bts"
+	IFPGA_AFU_BTS,
+	NULL
+};
+
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 104

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static struct rte_afu_device *
+rte_ifpga_scan_one(struct rte_devargs *devargs,

For internal functions, we'd better not use the prefix "rte".

Will fix in next version.

Quoted 13 lines

drivers/bus/ifpga/ifpga_bus.c line 114

Quoted 11 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	struct rte_ifpga_device *ifpga_dev)
+{
+	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((char *)(&afu_pr_conf), 0, sizeof(struct rte_afu_pr_conf));

For "void *", no need to add explicit type cast.

Will fix in next version.

Quoted 19 lines
Quoted 19 lines
drivers/bus/ifpga/ifpga_bus.c new file +18 -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,
+		&ifpga_get_integer32_arg, &afu_pr_conf.afu_id.port) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",
+				     IFPGA_ARG_PORT);
+			goto end;
+		}
+	} else {
+		IFPGA_BUS_ERR("arg %s is mandatory for ifpga bus",
+			  IFPGA_ARG_PORT);
+		goto end;
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 138

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+	}
+
+	if (rte_kvargs_count(kvlist, IFPGA_AFU_BTS) == 1) {
+		if (rte_kvargs_process(kvlist, IFPGA_AFU_BTS,
+				       &ifpga_get_string_arg, &path) < 0) {
+			IFPGA_BUS_ERR("error to parse %s",

s/error/failed

I think error and failed is ok.

Quoted 112 lines
Quoted 46 lines
drivers/bus/ifpga/ifpga_bus.c new file +45 -0
+				     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_low = 0;
+	afu_pr_conf.afu_id.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_low  = 0;
+	afu_dev->id.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;
+	}

drivers/bus/ifpga/ifpga_bus.c line 193

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	afu_dev->id.uuid_low  = afu_pr_conf.afu_id.uuid_low;
+	afu_dev->id.uuid_high = afu_pr_conf.afu_id.uuid_high;
+
+
+	return afu_dev;
+
+free_dev:
+	free(afu_dev);
+end:
+	if (kvlist)

You can remove above if statement for simplicity.

drivers/bus/ifpga/ifpga_bus.c line 195

Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2 -0
+		rte_kvargs_free(kvlist);
+	if (path)

Ditto.

Quoted 36 lines
drivers/bus/ifpga/ifpga_bus.c new file +36 -0
+		free(path);
+
+	return NULL;
+}
+
+/*
+ * Scan the content of the FPGA bus, and the devices in the devices
+ * list
+ */
+static int
+rte_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;
+	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 */
+	RTE_EAL_DEVARGS_FOREACH("ifpga", devargs) {
+		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,
+				       &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",

name);

Quoted 1 line

Change to use strlcpy instead.

Got it, I agree, will fix in next version.

Quoted 87 lines
Quoted 14 lines
drivers/bus/ifpga/ifpga_bus.c new file +13 -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));
+		if (!ifpga_dev)
+			goto end;
+
+		ifpga_dev->rdev = rawdev;

drivers/bus/ifpga/ifpga_bus.c line 264

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+		TAILQ_INIT(&ifpga_dev->afu_list);
+
+		TAILQ_INSERT_TAIL(&ifpga_device_list, ifpga_dev, next);
+		afu_dev = rte_ifpga_scan_one(devargs, ifpga_dev);
+		if (afu_dev != NULL)
+			TAILQ_INSERT_TAIL(&ifpga_dev->afu_list, afu_dev, next);
+	}
+
+end:
+	if (kvlist)

Ditto.

drivers/bus/ifpga/ifpga_bus.c line 266

Quoted 2 lines
drivers/bus/ifpga/ifpga_bus.c new file +2 -0
+		rte_kvargs_free(kvlist);
+	if (name)

Ditto.

Quoted 40 lines
drivers/bus/ifpga/ifpga_bus.c new file +40 -0
+		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_low) ||
+				(id_table->uuid_high != afu_dev->id.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;

drivers/bus/ifpga/ifpga_bus.c line 316

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	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 positive value if driver doesn't support this device */

This comment seems wrong; you already exclude the case that this driver does not support this device (>0); here, we only have the cases that, probe succeeds (=0), and probe fails (<0).

Quoted 3 lines

drivers/bus/ifpga/ifpga_bus.c line 317

Quoted 1 line
drivers/bus/ifpga/ifpga_bus.c new file +1 -0
+	return 0;

return ret instead of 0?

I agree, this return ret is better.

Quoted 129 lines
Quoted 129 lines
drivers/bus/ifpga/ifpga_bus.c new file +128 -0
+}
+
+static int
+ifpga_probe_all_drivers(struct rte_afu_device *afu_dev)
+{
+	struct rte_afu_driver *drv = NULL;
+	int rc;
+
+	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) {
+		rc = ifpga_probe_one_driver(drv, afu_dev);
+		if (rc < 0)
+			/* negative value is an error */
+			return -1;
+		if (rc > 0)
+			/* positive value means driver doesn't support it */
+			continue;
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * 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
+rte_ifpga_probe(void)
+{
+	struct rte_ifpga_device *ifpga_dev;
+	struct rte_afu_device *afu_dev = NULL;
+	int ret = 0;
+
+	TAILQ_FOREACH(ifpga_dev, &ifpga_device_list, next) {
+		TAILQ_FOREACH(afu_dev, &ifpga_dev->afu_list, next) {
+
+			if (afu_dev->device.driver)
+				continue;
+
+			ret = ifpga_probe_all_drivers(afu_dev);
+			if (ret < 0)
+				IFPGA_BUS_ERR("failed to initialize %s device\n",
+					rte_ifpga_device_name(afu_dev));
+		}
+	}
+
+	return 0;
+}
+
+static int
+rte_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
+rte_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;
+
+	ifpga_dev = afu_dev->ifpga_dev;
+	devargs = dev->devargs;
+
+	ret = ifpga_remove_driver(afu_dev);
+	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 *
+rte_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
+rte_ifpga_parse(const char *name, void *addr)
Quoted 8 lines

drivers/bus/ifpga/ifpga_bus.c line 451

Quoted 6 lines
drivers/bus/ifpga/ifpga_bus.c new file +6 -0
+{
+	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;

Duplicated spaces after "int".

Will fix it in next version.

Quoted 267 lines
Quoted 12 lines
drivers/bus/ifpga/ifpga_bus.c new file +11 -0
+	char str_port[8];
+	int str_port_len = 0;
+	int ret;
+
+	memset(str_port, 0, 8);
+	c1 = strchr(name, '|');
+	if (c1 != NULL) {
+		str_port_len = c1-name;
+		c2 = c1+1;
+	}
+

drivers/bus/ifpga/ifpga_bus.c

Quoted 10 lines
drivers/bus/ifpga/ifpga_bus.c new file +10 -0
+	if (str_port_len < 8 &&
+		str_port_len > 0) {
+		memcpy(str_port, name, str_port_len);
+		ret = sscanf(str_port, "%d", &port);
+		if (ret == -1)
+			return 0;
+	}
+
+	memset(rawdev_name, 0, sizeof(rawdev_name));
+	snprintf(rawdev_name, RTE_RAWDEV_NAME_MAX_LEN, "IFPGA:%s",

c2);

Review

Quoted 32 lines
drivers/bus/ifpga/ifpga_bus.c new file +31 -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        = rte_ifpga_scan,
+	.probe       = rte_ifpga_probe,
+	.find_device = rte_ifpga_find_device,
+	.plug        = rte_ifpga_plug,
+	.unplug      = rte_ifpga_unplug,
+	.parse       = rte_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);
+}
(quoted diff) +0 -0

b/drivers/bus/ifpga/ifpga_common.c

Review

Quoted 94 lines

new file mode 100644
index 0000000..26fee27

drivers/bus/ifpga/ifpga_common.c new file +88 -0
@@ -0,0 +1,88 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#include <string.h>
+#include <inttypes.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/queue.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <rte_errno.h>
+#include <rte_bus.h>
+#include <rte_per_lcore.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_eal.h>
+#include <rte_common.h>
+
+#include <rte_devargs.h>
+#include <rte_kvargs.h>
+#include <rte_alarm.h>
+
+#include "rte_bus_ifpga.h"
+#include "ifpga_logs.h"
+#include "ifpga_common.h"
+
+int 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 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_low           == afu_id1->uuid_low) &&
+		(afu_id0->uuid_high          == afu_id1->uuid_high) &&
+		(afu_id0->port               == afu_id1->port)) {
+		return 0;
+	} else
+		return 1;
+}
(quoted diff) +0 -0

b/drivers/bus/ifpga/ifpga_common.h

Review

Quoted 73 lines

new file mode 100644
index 0000000..b6662c8

drivers/bus/ifpga/ifpga_common.h new file +18 -0
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2010-2018 Intel Corporation
+ */
+
+#ifndef _IFPGA_COMMON_H_
+#define _IFPGA_COMMON_H_
+
+int ifpga_get_string_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer32_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_integer64_arg(const char *key __rte_unused,
+	const char *value, void *extra_args);
+int ifpga_get_unsigned_long(const char *str, int base);
+int ifpga_afu_id_cmp(const struct rte_afu_id *afu_id0,
+	const struct rte_afu_id *afu_id1);
+
+#endif /* _IFPGA_COMMON_H_ */
drivers/bus/ifpga/ifpga_logs.h new file +31 -0
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 +6 -0
new file mode 100644
index 0000000..4ea31f1
@@ -0,0 +1,6 @@
+# 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')
(quoted diff) +0 -0

b/drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 42 lines

new file mode 100644
index 0000000..53e7183

drivers/bus/ifpga/rte_bus_ifpga.h new file +37 -0
@@ -0,0 +1,168 @@
+/* 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));
Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 42

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5 -0
+
+#define IFPGA_BUS_DEV_PORT_MAX 4
+
+/**
+ * A structure describing an ID for a AFU driver. Each driver provides a

It seems that this struct is for describing the AFU device, instead of AFU driver, no?

This struct is describing the AFU device's attribute like UUID which is match AFU driver for AFU device, and port number.

Quoted 8 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 47

Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5 -0
+ * table of these IDs for each device that it supports.
+ */
+struct rte_afu_id {
+	uint64_t uuid_low;
+	uint64_t uuid_high;

Why not reuse struct rte_afu_uuid for above two fields?

Yes, we can reuse the struct rte_afu_uuid.

Quoted 4 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 48

Quoted 2 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +1 -0
+	int      port;

Can you add a note on what *port* means?

This is port number, suppose that one FPGA chip may has multiple AFUs, one AFU has one dedicate port. It is like bridge function.

Quoted 7 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 52

Quoted 5 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +4 -0
+} __attribute__ ((packed));
+
+/**
+ * A structure pr configuration AFU driver.

What does pr mean? Mind to add a full name for it?

PR means partial reconfiguration.

Quoted 71 lines
Quoted 6 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +5 -0
+ */
+
+struct rte_afu_pr_conf {
+	struct rte_afu_id afu_id;
+	int pr_enable;

drivers/bus/ifpga/rte_bus_ifpga.h

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+	char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+};
+
+#define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
+
+/**
+ * A structure describing a fpga device.
+ */
+struct rte_ifpga_device {
+	TAILQ_ENTRY(rte_ifpga_device) next;       /**< Next in device list.

*/

Quoted 38 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +38 -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. */
+	struct rte_device device;               /**< Inherit core device */
+	struct rte_rawdev *rawdev;    /**< Point Rawdev */
+	struct rte_ifpga_device *ifpga_dev;    /**< Point ifpga device */
+	struct rte_afu_id id;                   /**< AFU id within FPGA. */
+	uint32_t num_region;   /**< number of regions found */
+	struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
+						/**< AFU Memory Resource */
+	struct rte_intr_handle intr_handle;     /**< Interrupt handle */
+	struct rte_afu_driver *driver;          /**< Associated driver */
+	char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
+} __attribute__ ((packed));
+
+/**
+ * @internal
+ * Helper macro for drivers that need to convert to struct rte_afu_device.
+ */
+#define RTE_DEV_TO_AFU(ptr) \
+	container_of(ptr, struct rte_afu_device, device)
+
+#define RTE_DRV_TO_AFU_CONST(ptr) \
+	container_of(ptr, const struct rte_afu_driver, driver)
+
+/**
+ * Initialisation function for the driver called during FPGA BUS probing.
+ */
+typedef int (afu_probe_t)(struct rte_afu_device *);
+
+/**
+ * Uninitialisation function for the driver called during hotplugging.

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. */

drivers/bus/ifpga/rte_bus_ifpga.h line 116

Quoted 1 line
drivers/bus/ifpga/rte_bus_ifpga.h new file +1 -0
+	afu_remove_t *remove;                   /**< Device Remove

function. */

drivers/bus/ifpga/rte_bus_ifpga.h line 118

Quoted 2 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +2 -0
+	const struct rte_afu_uuid *id_table;    /**< AFU uuid within FPGA. */
+	uint32_t drv_flags;         /**< Flags contolling handling of device.

*/

Quoted 10 lines

drivers/bus/ifpga/rte_bus_ifpga.h line 126

Quoted 8 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +8 -0
+};
+
+/**
+ * Structure describing the Intel FPGA bus
+ */
+struct rte_ifpga_bus {
+	struct rte_bus bus;               /**< Inherit the generic class */
+};

Where is this struct used?

This struct no need, will remove in next version.

Quoted 49 lines
Quoted 31 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +30 -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;\

drivers/bus/ifpga/rte_bus_ifpga.h line 166

Quoted 10 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +10 -0
+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)

Do we really need alias for new bus? Originally, alias is a way for compatibility, but it seems that it's not necessary for new bus.

Review

Quoted 3 lines
drivers/bus/ifpga/rte_bus_ifpga.h new file +2 -0
+
+#endif /* _RTE_BUS_IFPGA_H_ */
(quoted diff) +0 -0

b/drivers/bus/ifpga/rte_bus_ifpga_version.map

Quoted 12 lines

drivers/bus/ifpga/rte_bus_ifpga_version.map line 5

Quoted 10 lines

new file mode 100644
index 0000000..1304caf

drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
@@ -0,0 +1,10 @@
+DPDK_18.05 {
+	global:
+
+	ifpga_get_integer32_arg;
+	ifpga_get_string_arg;

Above two functions shall be not exposed as APIs.

Those APIs used in ifpga raw device driver.

Quoted 33 lines

mk/rte.app.mk _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)

Quoted 24 lines
drivers/bus/ifpga/rte_bus_ifpga_version.map new file +5 -0
+	rte_ifpga_driver_register;
+	rte_ifpga_driver_unregister;
+
+	local: *;
+};
drivers/bus/meson.build +1 -1
index 58dfbe2..170df25 100644
@@ -1,7 +1,7 @@
  # SPDX-License-Identifier: BSD-3-Clause
  # Copyright(c) 2017 Intel Corporation
 
-drivers = ['dpaa', 'fslmc', 'pci', 'vdev']
+drivers = ['dpaa', 'fslmc', 'pci', 'vdev', 'ifpga']
  std_deps = ['eal']
  config_flag_fmt = 'RTE_LIBRTE_@0@_BUS'
  driver_name_fmt = 'rte_bus_@0@'
mk/rte.app.mk +0 -0
index a145791..9de2edb 100644
@@ -107,6 +107,8 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CMDLINE)
+= -lrte_cmdline
>   _LDLIBS-$(CONFIG_RTE_LIBRTE_REORDER)        += -lrte_reorder
>   _LDLIBS-$(CONFIG_RTE_LIBRTE_SCHED)          += -lrte_sched
Quoted 6 lines
mk/rte.app.mk +2 -0
+_LDLIBS-$(CONFIG_RTE_LIBRTE_IFPGA_BUS)      += -lrte_bus_ifpga
+
  ifeq ($(CONFIG_RTE_EXEC_ENV_LINUXAPP),y)
  _LDLIBS-$(CONFIG_RTE_LIBRTE_KNI)            += -lrte_kni
  endif
author
#59 lore raw

PATCH v6 2/5 iFPGA: Add Intel FPGA OPAE Share Code

In reply to Xu, Rosen

From: Rosen Xu <[email protected]>

This patch adds Intel FPGA Open Programmable Acceleration Engine (OPAE)[1] base driver code, in order to support Intel FPGA devices under DPDK. The base code currently supports Intel FPGA solutions including integrated solution (Intel(R) Xeon(R) CPU with FPGAs) and discrete solution (Intel(R) Programmable Acceleration Card with Intel(R) Arria(R) 10 FPGA) and it could be extended to support more FPGA devices in the future. Please refer to [1][2] for more introduction on OPAE and Intel FPGAs.

[1] https://01.org/OPAE
[2] https://www.altera.com/solutions/acceleration-hub/overview.html

---
 drivers/raw/ifpga_rawdev/base/Makefile             |   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       |   57 +
 drivers/raw/ifpga_rawdev/base/ifpga_defines.h      | 1661 ++++++++++++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c    |  824 ++++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h    |   11 +
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c  |  314 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h  |  164 ++
 drivers/raw/ifpga_rawdev/base/ifpga_fme.c          |  734 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c    |  301 ++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c    |  403 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c    |  715 +++++++++
 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c       |  372 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_hw.h           |  127 ++
 drivers/raw/ifpga_rawdev/base/ifpga_port.c         |  408 +++++
 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c   |  165 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.c         |   99 ++
 drivers/raw/ifpga_rawdev/base/opae_debug.h         |   19 +
 drivers/raw/ifpga_rawdev/base/opae_hw_api.c        |  381 +++++
 drivers/raw/ifpga_rawdev/base/opae_hw_api.h        |  253 +++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c  |  145 ++
 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h  |  279 ++++
 drivers/raw/ifpga_rawdev/base/opae_osdep.h         |   81 +
 .../ifpga_rawdev/base/osdep_raw/osdep_generic.h    |   75 +
 .../ifpga_rawdev/base/osdep_rte/osdep_generic.h    |   45 +
 27 files changed, 8012 insertions(+)
 create mode 100644 drivers/raw/ifpga_rawdev/base/Makefile
 create mode 100644 drivers/raw/ifpga_rawdev/base/README
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_compat.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_defines.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_enumerate.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_hw.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/ifpga_port_error.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_debug.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.c
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_ifpga_hw_api.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/opae_osdep.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_raw/osdep_generic.h
 create mode 100644 drivers/raw/ifpga_rawdev/base/osdep_rte/osdep_generic.h
drivers/raw/ifpga_rawdev/base/Makefile new file +26 -0
new file mode 100644
index 0000000..64c8472
@@ -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 += ifpga_fme_pr.c
+SRCS-y += opae_hw_api.c
+SRCS-y += opae_ifpga_hw_api.c
+SRCS-y += opae_debug.c
+
+SRCS-y += $(wildcard $(SRCDIR)/base/$(OSDEP)/*.c)
drivers/raw/ifpga_rawdev/base/README new file +31 -0
new file mode 100644
index 0000000..3636ac7
@@ -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

68 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_feature_dev.h new file +164 -0

164 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme.c new file +734 -0

734 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_dperf.c new file +301 -0

301 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_error.c new file +403 -0

403 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_iperf.c new file +715 -0

715 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_fme_pr.c new file +372 -0

372 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_hw.h new file +127 -0

127 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/ifpga_port.c new file +408 -0

408 lines not on this page · raw message

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

165 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.c new file +99 -0

99 lines not on this page · raw message

drivers/raw/ifpga_rawdev/base/opae_debug.h new file +19 -0
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.