Skip to contentSkip to conversation

raw/ifpga: add extra OPAE APIs

PATCH Superseded Wei Huang 2 participants 12 messages Jan 26, 2021 – Jan 29, 2021 Arm/Amlogic Meson SoC support

v12 of 16 Superseded Latest is v16 →

lore
Share & tools
lore

Wei Huang

author
#0 lore raw

v12 cover raw/ifpga: add extra OPAE APIs

Cyborg is part of OpenStack, it needs some OPAE APIs to manage devices with Intel FPGA. The first three patches implement extra APIs to meet Cyborg requirement. The last patch add an example to show how to use these APIs.

Main changes from v11:
- implement OPAE APIs in example instead of ifpga rawdev

Wei Huang (4):
raw/ifpga: add fpga rsu function
raw/ifpga: add fpga property get function
raw/ifpga: add fpga helper function
examples/ifpga: add example for ifpga opae API

 MAINTAINERS                                |    1 +
 doc/guides/sample_app_ug/ifpga.rst         |  433 +++++
 doc/guides/sample_app_ug/index.rst         |    1 +
 drivers/raw/ifpga/base/ifpga_api.c         |   34 +
 drivers/raw/ifpga/base/ifpga_defines.h     |    1 +
 drivers/raw/ifpga/base/ifpga_feature_dev.c |   21 +
 drivers/raw/ifpga/base/ifpga_feature_dev.h |    1 +
 drivers/raw/ifpga/base/ifpga_fme.c         |   36 +-
 drivers/raw/ifpga/base/ifpga_fme_rsu.c     |  435 +++++
 drivers/raw/ifpga/base/ifpga_hw.h          |    1 +
 drivers/raw/ifpga/base/ifpga_sec_mgr.c     |  639 +++++++
 drivers/raw/ifpga/base/ifpga_sec_mgr.h     |   89 +
 drivers/raw/ifpga/base/meson.build         |    2 +
 drivers/raw/ifpga/base/opae_hw_api.c       |   77 +
 drivers/raw/ifpga/base/opae_hw_api.h       |   13 +
 drivers/raw/ifpga/base/opae_ifpga_hw_api.h |    1 +
 drivers/raw/ifpga/base/opae_intel_max10.c  |   48 +
 drivers/raw/ifpga/base/opae_intel_max10.h  |   44 +
 drivers/raw/ifpga/ifpga_rawdev.c           |  352 ++++
 drivers/raw/ifpga/ifpga_rawdev.h           |   50 +-
 examples/ifpga/Makefile                    |   45 +
 examples/ifpga/commands.c                  | 1321 +++++++++++++++
 examples/ifpga/commands.h                  |   16 +
 examples/ifpga/main.c                      |   38 +
 examples/ifpga/meson.build                 |   20 +
 examples/ifpga/opae_api.c                  | 1788 ++++++++++++++++++++
 examples/ifpga/opae_api.h                  |  245 +++
 27 files changed, 5749 insertions(+), 3 deletions(-)
 create mode 100644 doc/guides/sample_app_ug/ifpga.rst
 create mode 100644 drivers/raw/ifpga/base/ifpga_fme_rsu.c
 create mode 100644 drivers/raw/ifpga/base/ifpga_sec_mgr.c
 create mode 100644 drivers/raw/ifpga/base/ifpga_sec_mgr.h
 create mode 100644 examples/ifpga/Makefile
 create mode 100644 examples/ifpga/commands.c
 create mode 100644 examples/ifpga/commands.h
 create mode 100644 examples/ifpga/main.c
 create mode 100644 examples/ifpga/meson.build
 create mode 100644 examples/ifpga/opae_api.c
 create mode 100644 examples/ifpga/opae_api.h
Signature · 1 line
2.29.2
author
#1 lore raw

PATCH v12 1/4 raw/ifpga: add fpga rsu function

RSU (Remote System Update) depends on secure manager which may be different on various implementations, so a new secure manager device is implemented for adapting such difference.
There are three major functions added:
1. ifpga_rawdev_update_flash() updates flash with specific image file.
2. ifpga_rawdev_stop_flash_update() aborts flash update process.
3. ifpga_rawdev_reload() reloads FPGA from updated flash.

---
v2: fix coding style issue in ifpga_fme_rsu.c and ifpga_sec_mgr.c
---
v3: fix compilation issues in ifpga_fme_rsu.c
---
v4: fix compilation issues in opae_intel_max10.c

---
 drivers/raw/ifpga/base/ifpga_api.c        |  26 +
 drivers/raw/ifpga/base/ifpga_fme.c        |   8 +
 drivers/raw/ifpga/base/ifpga_fme_rsu.c    | 435 +++++++++++++++
 drivers/raw/ifpga/base/ifpga_hw.h         |   1 +
 drivers/raw/ifpga/base/ifpga_sec_mgr.c    | 639 ++++++++++++++++++++++
 drivers/raw/ifpga/base/ifpga_sec_mgr.h    |  89 +++
 drivers/raw/ifpga/base/meson.build        |   2 +
 drivers/raw/ifpga/base/opae_hw_api.c      |  59 ++
 drivers/raw/ifpga/base/opae_hw_api.h      |  11 +
 drivers/raw/ifpga/base/opae_intel_max10.c |  48 ++
 drivers/raw/ifpga/base/opae_intel_max10.h |  44 ++
 drivers/raw/ifpga/ifpga_rawdev.c          |  55 ++
 drivers/raw/ifpga/ifpga_rawdev.h          |   7 +-
 13 files changed, 1423 insertions(+), 1 deletion(-)
 create mode 100644 drivers/raw/ifpga/base/ifpga_fme_rsu.c
 create mode 100644 drivers/raw/ifpga/base/ifpga_sec_mgr.c
 create mode 100644 drivers/raw/ifpga/base/ifpga_sec_mgr.h
drivers/raw/ifpga/base/ifpga_api.c +26 -0
index 1ff57fa18..1aedf150b 100644
@@ -5,6 +5,7 @@
 #include "ifpga_api.h"
 #include "ifpga_enumerate.h"
 #include "ifpga_feature_dev.h"
+#include "ifpga_sec_mgr.h"
 
 #include "opae_hw_api.h"
 
@@ -228,11 +229,36 @@ static int ifpga_mgr_get_board_info(struct opae_manager *mgr,
 	return 0;
 }
 
+static int ifpga_mgr_update_flash(struct opae_manager *mgr, const char *image,
+	u64 *status)
+{
+	struct ifpga_fme_hw *fme = mgr->data;
+
+	return fpga_update_flash(fme, image, status);
+}
+
+static int ifpga_mgr_stop_flash_update(struct opae_manager *mgr, int force)
+{
+	struct ifpga_fme_hw *fme = mgr->data;
+
+	return fpga_stop_flash_update(fme, force);
+}
+
+static int ifpga_mgr_reload(struct opae_manager *mgr, int type, int page)
+{
+	struct ifpga_fme_hw *fme = mgr->data;
+
+	return fpga_reload(fme, type, page);
+}
+
 struct opae_manager_ops ifpga_mgr_ops = {
 	.flash = ifpga_mgr_flash,
 	.get_eth_group_region_info = ifpga_mgr_get_eth_group_region_info,
 	.get_sensor_value = ifpga_mgr_get_sensor_value,
 	.get_board_info = ifpga_mgr_get_board_info,
+	.update_flash = ifpga_mgr_update_flash,
+	.stop_flash_update = ifpga_mgr_stop_flash_update,
+	.reload = ifpga_mgr_reload,
 };
 
 static int ifpga_mgr_read_mac_rom(struct opae_manager *mgr, int offset,
drivers/raw/ifpga/base/ifpga_fme.c +8 -0
index f29ff3159..34fd9a818 100644
@@ -7,6 +7,7 @@
 #include "opae_intel_max10.h"
 #include "opae_i2c.h"
 #include "opae_at24_eeprom.h"
+#include "ifpga_sec_mgr.h"
 
 #define PWR_THRESHOLD_MAX       0x7F
 
@@ -1152,6 +1153,12 @@ static int fme_nios_spi_init(struct ifpga_feature *feature)
 	if (spi_self_checking(max10))
 		goto spi_fail;
 
+	ret = init_sec_mgr(fme);
+	if (ret) {
+		dev_err(fme, "security manager init fail\n");
+		goto spi_fail;
+	}
+
 	return ret;
 
 spi_fail:
@@ -1165,6 +1172,7 @@ static void fme_nios_spi_uinit(struct ifpga_feature *feature)
 {
 	struct ifpga_fme_hw *fme = (struct ifpga_fme_hw *)feature->parent;
 
+	release_sec_mgr(fme);
 	if (fme->max10_dev)
 		intel_max10_device_remove(fme->max10_dev);
 }
drivers/raw/ifpga/base/ifpga_fme_rsu.c new file +435 -0

435 lines not on this page · raw message

drivers/raw/ifpga/base/ifpga_hw.h +1 -0
index 7c3307fe7..ed5edc601 100644
@@ -91,6 +91,7 @@ struct ifpga_fme_hw {
 	struct opae_board_info board_info;
 	int nums_eth_dev;
 	unsigned int nums_acc_region;
+	void *sec_mgr;
 };
 
 enum ifpga_port_state {
drivers/raw/ifpga/base/ifpga_sec_mgr.c new file +639 -0

639 lines not on this page · raw message

drivers/raw/ifpga/base/ifpga_sec_mgr.h new file +89 -0

89 lines not on this page · raw message

drivers/raw/ifpga/base/meson.build +2 -0
index da2d6e33c..3549afafa 100644
@@ -12,6 +12,8 @@ sources = [
 	'ifpga_port.c',
 	'ifpga_port_error.c',
 	'ifpga_fme_pr.c',
+	'ifpga_fme_rsu.c',
+	'ifpga_sec_mgr.c',
 	'opae_hw_api.c',
 	'opae_ifpga_hw_api.c',
 	'opae_debug.c',
drivers/raw/ifpga/base/opae_hw_api.c +59 -0

68 lines not on this page · raw message

drivers/raw/ifpga/base/opae_hw_api.h +11 -0
index e99ee4564..c819dc3d2 100644
@@ -55,6 +55,10 @@ struct opae_manager_ops {
 			unsigned int *value);
 	int (*get_board_info)(struct opae_manager *mgr,
 			struct opae_board_info **info);
+	int (*update_flash)(struct opae_manager *mgr, const char *image,
+			u64 *status);
+	int (*stop_flash_update)(struct opae_manager *mgr, int force);
+	int (*reload)(struct opae_manager *mgr, int type, int page);
 };
 
 /* networking management ops in FME */
@@ -276,6 +280,8 @@ typedef struct {
 			pthread_mutex_t i2c_mutex;
 			u32 ref_cnt;    /* reference count of shared memory */
 			u32 dtb_size;   /* actual length of DTB data in byte */
+			u32 rsu_ctrl;   /* used to control rsu */
+			u32 rsu_stat;   /* used to report status for rsu */
 		};
 	};
 	u8 dtb[SHM_BLK_SIZE];   /* DTB data */
@@ -354,4 +360,9 @@ int opae_manager_eth_group_read_reg(struct opae_manager *mgr, u8 group_id,
 		u8 type, u8 index, u16 addr, u32 *data);
 int opae_mgr_get_board_info(struct opae_manager *mgr,
 		struct opae_board_info **info);
+int opae_mgr_update_flash(struct opae_manager *mgr, const char *image,
+		uint64_t *status);
+int opae_mgr_stop_flash_update(struct opae_manager *mgr, int force);
+int opae_mgr_reload(struct opae_manager *mgr, int type, int page);
+
 #endif /* _OPAE_HW_API_H_*/
drivers/raw/ifpga/base/opae_intel_max10.c +48 -0

66 lines not on this page · raw message

drivers/raw/ifpga/base/opae_intel_max10.h +44 -0

76 lines not on this page · raw message

drivers/raw/ifpga/ifpga_rawdev.c +55 -0

58 lines not on this page · raw message

drivers/raw/ifpga/ifpga_rawdev.h +6 -1
index 7754beb02..bf74a5eb3 100644
@@ -43,7 +43,7 @@ enum ifpga_rawdev_device_state {
 static inline struct opae_adapter *
 ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
 {
-	return rawdev->dev_private;
+	return (struct opae_adapter *)rawdev->dev_private;
 }
 
 #define IFPGA_RAWDEV_MSIX_IRQ_NUM 7
@@ -76,4 +76,9 @@ int
 ifpga_unregister_msix_irq(enum ifpga_irq_type type,
 		int vec_start, rte_intr_callback_fn handler, void *arg);
 
+int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
+	uint64_t *status);
+int ifpga_rawdev_stop_flash_update(struct rte_rawdev *dev, int force);
+int ifpga_rawdev_reload(struct rte_rawdev *dev, int type, int page);
+
 #endif /* _IFPGA_RAWDEV_H_ */
Signature · 1 line
2.29.2
#2 lore raw

Re: [dpdk-dev] [PATCH v12 1/4] raw/ifpga: add fpga rsu function

Quoted 18 lines · Wei Huang

RSU (Remote System Update) depends on secure manager which may be different on various implementations, so a new secure manager device is implemented for adapting such difference.
There are three major functions added:
1. ifpga_rawdev_update_flash() updates flash with specific image file.
2. ifpga_rawdev_stop_flash_update() aborts flash update process.
3. ifpga_rawdev_reload() reloads FPGA from updated flash.

---
v2: fix coding style issue in ifpga_fme_rsu.c and ifpga_sec_mgr.c
---
v3: fix compilation issues in ifpga_fme_rsu.c
---
v4: fix compilation issues in opae_intel_max10.c
---

<...>

Quoted 11 lines
drivers/raw/ifpga/ifpga_rawdev.h +1 -1
@@ -43,7 +43,7 @@ enum ifpga_rawdev_device_state {
  static inline struct opae_adapter *
  ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
  {
-	return rawdev->dev_private;
+	return (struct opae_adapter *)rawdev->dev_private;
  }
 
  #define IFPGA_RAWDEV_MSIX_IRQ_NUM 7

drivers/raw/ifpga/ifpga_rawdev.h int · line 84

Quoted 9 lines
drivers/raw/ifpga/ifpga_rawdev.h +5 -0
@@ -76,4 +76,9 @@ int
  ifpga_unregister_msix_irq(enum ifpga_irq_type type,
  		int vec_start, rte_intr_callback_fn handler, void *arg);
 
+int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
+	uint64_t *status);
+int ifpga_rawdev_stop_flash_update(struct rte_rawdev *dev, int force);
+int ifpga_rawdev_reload(struct rte_rawdev *dev, int type, int page);
+
  #endif /* _IFPGA_RAWDEV_H_ */

Hi Wei, Rosen,

This patch introduces three new PMD specific APIs, adding new API has some requirements.

1)
There must be a header file for user application to include, that has the definitions of the APIs.

This header file should be installed in meson via "headers = ..." syntax.

Indeed for rawdev a header always should be installed, because of the rawdev design, the user application should know about the some driver structures, to share those structures PMD should provide a header. This header seems missing.

You can start for providing the missing header, even before this patch.

Header file should be named as 'rte_pmd_.....', and since it is a public header now it should be fully documented via doxygen comments.

This header file should be added to 'doc/api/doxy-api-index.md' for API documentathion.

2)
All APIs should start with 'rte_pmd_' prefix.

3)
All APIs should be in the .map file

4)
Since these are new APIs, they should be marked as experimental. This is done both documenting this in the doxygen comments and marking the function decleration via '__rte_experimental' tag

5)
Please don't use "struct rte_rawdev *dev" as a argument in the APIs, since that structure is rawdev internal structures, applications (that will call your API) should not know or access to this struct. Instead you can you 'dev_id' (ethdev 'port_id' equivalent) in the API, as done in the rawdev APIs. Driver can easily get the rawdevice from 'dev_id'.

cc'ed Ray & Hemant in case I missed something related to rawdev and API/ABIs.

And for the ifpga implementation, it is hard for me to review it, I trust Rosen for it.

author
#3 lore raw

Re: [dpdk-dev] [PATCH v12 1/4] raw/ifpga: add fpga rsu function

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, January 28, 2021 21:25
To: Huang, Wei <[email protected]>; [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Ray Kinsella <[email protected]>; Hemant Agrawal <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v12 1/4] raw/ifpga: add fpga rsu function

Quoted 18 lines · Wei Huang

RSU (Remote System Update) depends on secure manager which may be different on various implementations, so a new secure manager device is implemented for adapting such difference.
There are three major functions added:
1. ifpga_rawdev_update_flash() updates flash with specific image file.
2. ifpga_rawdev_stop_flash_update() aborts flash update process.
3. ifpga_rawdev_reload() reloads FPGA from updated flash.

---
v2: fix coding style issue in ifpga_fme_rsu.c and ifpga_sec_mgr.c
---
v3: fix compilation issues in ifpga_fme_rsu.c
---
v4: fix compilation issues in opae_intel_max10.c
---

<...>

Quoted 11 lines
drivers/raw/ifpga/ifpga_rawdev.h +1 -1
@@ -43,7 +43,7 @@ enum ifpga_rawdev_device_state {
  static inline struct opae_adapter *
  ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
  {
-	return rawdev->dev_private;
+	return (struct opae_adapter *)rawdev->dev_private;
  }
 
  #define IFPGA_RAWDEV_MSIX_IRQ_NUM 7

drivers/raw/ifpga/ifpga_rawdev.h int · line 84

Quoted 10 lines
drivers/raw/ifpga/ifpga_rawdev.h +6 -0
@@ -76,4 +76,9 @@ int
  ifpga_unregister_msix_irq(enum ifpga_irq_type type,
  		int vec_start, rte_intr_callback_fn handler, void *arg);
 
+int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
+	uint64_t *status);
+int ifpga_rawdev_stop_flash_update(struct rte_rawdev *dev, int 
+force); int ifpga_rawdev_reload(struct rte_rawdev *dev, int type, int 
+page);
+
  #endif /* _IFPGA_RAWDEV_H_ */

Hi Wei, Rosen,

This patch introduces three new PMD specific APIs, adding new API has some requirements.

1)
There must be a header file for user application to include, that has the definitions of the APIs.

This header file should be installed in meson via "headers = ..." syntax.

Indeed for rawdev a header always should be installed, because of the rawdev design, the user application should know about the some driver structures, to share those structures PMD should provide a header. This header seems missing.

You can start for providing the missing header, even before this patch.

Header file should be named as 'rte_pmd_.....', and since it is a public header now it should be fully documented via doxygen comments.

This header file should be added to 'doc/api/doxy-api-index.md' for API documentathion.
OK, I will add rte_pmd_ifpga.h.
2)
All APIs should start with 'rte_pmd_' prefix.
OK, I will use 'rte_pmd_' prefix before driver APIs.
3)
All APIs should be in the .map file
OK, I will add them into .map file.
4)
Since these are new APIs, they should be marked as experimental. This is done both documenting this in the doxygen comments and marking the function decleration via '__rte_experimental' tag How to document it in doxygen comments ? Could you give an example ?
5)
Please don't use "struct rte_rawdev *dev" as a argument in the APIs, since that structure is rawdev internal structures, applications (that will call your API) should not know or access to this struct. Instead you can you 'dev_id' (ethdev 'port_id' equivalent) in the API, as done in the rawdev APIs. Driver can easily get the rawdevice from 'dev_id'.
OK, I will use dev_id in driver APIs' argument.
cc'ed Ray & Hemant in case I missed something related to rawdev and API/ABIs.

And for the ifpga implementation, it is hard for me to review it, I trust Rosen for it.

#4 lore raw

Re: [dpdk-dev] [PATCH v12 1/4] raw/ifpga: add fpga rsu function

Quoted 68 lines · Wei

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, January 28, 2021 21:25
To: Huang, Wei <[email protected]>; [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>; Ray Kinsella <[email protected]>; Hemant Agrawal <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v12 1/4] raw/ifpga: add fpga rsu function

Quoted 18 lines · Wei Huang

RSU (Remote System Update) depends on secure manager which may be different on various implementations, so a new secure manager device is implemented for adapting such difference.
There are three major functions added:
1. ifpga_rawdev_update_flash() updates flash with specific image file.
2. ifpga_rawdev_stop_flash_update() aborts flash update process.
3. ifpga_rawdev_reload() reloads FPGA from updated flash.

---
v2: fix coding style issue in ifpga_fme_rsu.c and ifpga_sec_mgr.c
---
v3: fix compilation issues in ifpga_fme_rsu.c
---
v4: fix compilation issues in opae_intel_max10.c
---

<...>

Quoted 11 lines
drivers/raw/ifpga/ifpga_rawdev.h +1 -1
@@ -43,7 +43,7 @@ enum ifpga_rawdev_device_state {
   static inline struct opae_adapter *
   ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
   {
-return rawdev->dev_private;
+return (struct opae_adapter *)rawdev->dev_private;
   }
 
   #define IFPGA_RAWDEV_MSIX_IRQ_NUM 7

drivers/raw/ifpga/ifpga_rawdev.h int · line 84

Quoted 10 lines
drivers/raw/ifpga/ifpga_rawdev.h +6 -0
@@ -76,4 +76,9 @@ int
   ifpga_unregister_msix_irq(enum ifpga_irq_type type,
   int vec_start, rte_intr_callback_fn handler, void *arg);
 
+int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
+uint64_t *status);
+int ifpga_rawdev_stop_flash_update(struct rte_rawdev *dev, int
+force); int ifpga_rawdev_reload(struct rte_rawdev *dev, int type, int
+page);
+
   #endif /* _IFPGA_RAWDEV_H_ */

Hi Wei, Rosen,

This patch introduces three new PMD specific APIs, adding new API has some requirements.

1)
There must be a header file for user application to include, that has the definitions of the APIs.

This header file should be installed in meson via "headers = ..." syntax.

Indeed for rawdev a header always should be installed, because of the rawdev design, the user application should know about the some driver structures, to share those structures PMD should provide a header. This header seems missing.

You can start for providing the missing header, even before this patch.

Header file should be named as 'rte_pmd_.....', and since it is a public header now it should be fully documented via doxygen comments.

Quoted 8 lines

This header file should be added to 'doc/api/doxy-api-index.md' for API documentathion. OK, I will add rte_pmd_ifpga.h.
2)
All APIs should start with 'rte_pmd_' prefix.
OK, I will use 'rte_pmd_' prefix before driver APIs.
3)
All APIs should be in the .map file
OK, I will add them into .map file.

Btw, in the .map, it needs a special block for the experimental APIs, and since all your APIs will be experimental at this stage, they will all go in that block, it is like:

EXPERIMENTAL {
global:

# added in <dpdk release version>
<list of APIs>
};

Quoted 3 lines

4)
Since these are new APIs, they should be marked as experimental. This is done both documenting this in the doxygen comments and marking the function decleration via '__rte_experimental' tag How to document it in doxygen comments ? Could you give an example ?

Sample:
https://git.dpdk.org/dpdk/tree/lib/librte_ethdev/rte_ethdev.h?h=v20.11#n2105

It is simply adding a note/warning that is saying API is experimental.

Quoted 9 lines

5)
Please don't use "struct rte_rawdev *dev" as a argument in the APIs, since that structure is rawdev internal structures, applications (that will call your API) should not know or access to this struct. Instead you can you 'dev_id' (ethdev 'port_id' equivalent) in the API, as done in the rawdev APIs. Driver can easily get the rawdevice from 'dev_id'.
OK, I will use dev_id in driver APIs' argument.
cc'ed Ray & Hemant in case I missed something related to rawdev and API/ABIs.

And for the ifpga implementation, it is hard for me to review it, I trust Rosen for it.

author
#5 lore raw

PATCH v12 2/4 raw/ifpga: add fpga property get function

In reply to Wei Huang

There are three types of property can be got from FPGA, they are implemented in below functions:
1. ifpga_rawdev_get_fme_property() get property of FME (FPGA Management Engine).
2. ifpga_rawdev_get_port_property() get property of FPGA port.
3. ifpga_rawdev_get_bmc_property() get property of BMC (Board Management Controller).

---
 drivers/raw/ifpga/base/ifpga_api.c         |   8 ++
 drivers/raw/ifpga/base/ifpga_defines.h     |   1 +
 drivers/raw/ifpga/base/ifpga_feature_dev.c |  21 +++
 drivers/raw/ifpga/base/ifpga_feature_dev.h |   1 +
 drivers/raw/ifpga/base/ifpga_fme.c         |  28 +++-
 drivers/raw/ifpga/base/opae_hw_api.c       |  18 +++
 drivers/raw/ifpga/base/opae_hw_api.h       |   2 +
 drivers/raw/ifpga/base/opae_ifpga_hw_api.h |   1 +
 drivers/raw/ifpga/ifpga_rawdev.c           | 157 +++++++++++++++++++++
 drivers/raw/ifpga/ifpga_rawdev.h           |  28 ++++
 10 files changed, 263 insertions(+), 2 deletions(-)
drivers/raw/ifpga/base/ifpga_api.c +8 -0
index 1aedf150b..4610ef101 100644
@@ -229,6 +229,13 @@ static int ifpga_mgr_get_board_info(struct opae_manager *mgr,
 	return 0;
 }
 
+static int ifpga_mgr_get_uuid(struct opae_manager *mgr, struct uuid *uuid)
+{
+	struct ifpga_fme_hw *fme = mgr->data;
+
+	return fpga_get_pr_uuid(fme, uuid);
+}
+
 static int ifpga_mgr_update_flash(struct opae_manager *mgr, const char *image,
 	u64 *status)
 {
@@ -256,6 +263,7 @@ struct opae_manager_ops ifpga_mgr_ops = {
 	.get_eth_group_region_info = ifpga_mgr_get_eth_group_region_info,
 	.get_sensor_value = ifpga_mgr_get_sensor_value,
 	.get_board_info = ifpga_mgr_get_board_info,
+	.get_uuid = ifpga_mgr_get_uuid,
 	.update_flash = ifpga_mgr_update_flash,
 	.stop_flash_update = ifpga_mgr_stop_flash_update,
 	.reload = ifpga_mgr_reload,
drivers/raw/ifpga/base/ifpga_defines.h +1 -0
index 9f0147d1e..dca1518a8 100644
@@ -1727,6 +1727,7 @@ struct opae_board_info {
 	u8 seu;
 	u8 ptp;
 
+	u32 boot_page;
 	u32 max10_version;
 	u32 nios_fw_version;
 	u32 nums_of_retimer;
drivers/raw/ifpga/base/ifpga_feature_dev.c +21 -0
index 0f852a75a..08135137a 100644
@@ -87,6 +87,27 @@ int fpga_get_afu_uuid(struct ifpga_port_hw *port, struct uuid *uuid)
 	return 0;
 }
 
+int fpga_get_pr_uuid(struct ifpga_fme_hw *fme, struct uuid *uuid)
+{
+	struct feature_fme_pr *fme_pr;
+	u64 guidl, guidh;
+
+	if (!fme || !uuid)
+		return -EINVAL;
+
+	fme_pr = get_fme_feature_ioaddr_by_index(fme, FME_FEATURE_ID_PR_MGMT);
+
+	spinlock_lock(&fme->lock);
+	guidl = readq(&fme_pr->fme_pr_intfc_id_l);
+	guidh = readq(&fme_pr->fme_pr_intfc_id_h);
+	spinlock_unlock(&fme->lock);
+
+	opae_memcpy(uuid->b, &guidl, sizeof(u64));
+	opae_memcpy(uuid->b + 8, &guidh, sizeof(u64));
+
+	return 0;
+}
+
 /* Mask / Unmask Port Errors by the Error Mask register. */
 void port_err_mask(struct ifpga_port_hw *port, bool mask)
 {
drivers/raw/ifpga/base/ifpga_feature_dev.h +1 -0
index 2b1309b44..b355d22b0 100644
@@ -103,6 +103,7 @@ is_port_feature_present(struct ifpga_port_hw *port, int index)
 }
 
 int fpga_get_afu_uuid(struct ifpga_port_hw *port, struct uuid *uuid);
+int fpga_get_pr_uuid(struct ifpga_fme_hw *fme, struct uuid *uuid);
 
 int __fpga_port_disable(struct ifpga_port_hw *port);
 void __fpga_port_enable(struct ifpga_port_hw *port);
drivers/raw/ifpga/base/ifpga_fme.c +26 -2
index 34fd9a818..43c7b9c3d 100644
@@ -101,6 +101,24 @@ static int fme_hdr_get_ports_num(struct ifpga_fme_hw *fme, u64 *ports_num)
 	return 0;
 }
 
+static int fme_hdr_get_port_type(struct ifpga_fme_hw *fme, u64 *port_type)
+{
+	struct feature_fme_header *fme_hdr
+		= get_fme_feature_ioaddr_by_index(fme, FME_FEATURE_ID_HEADER);
+	struct feature_fme_port pt;
+	u32 port = (u32)((*port_type >> 32) & 0xffffffff);
+
+	pt.csr = readq(&fme_hdr->port[port]);
+	if (!pt.port_implemented)
+		return -ENODEV;
+	if (pt.afu_access_control)
+		*port_type |= 0x1;
+	else
+		*port_type &= ~0x1;
+
+	return 0;
+}
+
 static int fme_hdr_get_cache_size(struct ifpga_fme_hw *fme, u64 *cache_size)
 {
 	struct feature_fme_header *fme_hdr
@@ -179,6 +197,8 @@ fme_hdr_get_prop(struct ifpga_feature *feature, struct feature_prop *prop)
 		return fme_hdr_get_bitstream_id(fme, &prop->data);
 	case FME_HDR_PROP_BITSTREAM_METADATA:
 		return fme_hdr_get_bitstream_metadata(fme, &prop->data);
+	case FME_HDR_PROP_PORT_TYPE:
+		return fme_hdr_get_port_type(fme, &prop->data);
 	}
 
 	return -ENOENT;
@@ -891,13 +911,17 @@ static int fme_get_board_interface(struct ifpga_fme_hw *fme)
 			fme->board_info.nums_of_fvl,
 			fme->board_info.ports_per_fvl);
 
+	if (max10_sys_read(fme->max10_dev, FPGA_PAGE_INFO, &val))
+		return -EINVAL;
+	fme->board_info.boot_page = val & 0x7;
+
 	if (max10_sys_read(fme->max10_dev, MAX10_BUILD_VER, &val))
 		return -EINVAL;
-	fme->board_info.max10_version = val & 0xffffff;
+	fme->board_info.max10_version = val;
 
 	if (max10_sys_read(fme->max10_dev, NIOS2_FW_VERSION, &val))
 		return -EINVAL;
-	fme->board_info.nios_fw_version = val & 0xffffff;
+	fme->board_info.nios_fw_version = val;
 
 	dev_info(fme, "max10 version 0x%x, nios fw version 0x%x\n",
 		fme->board_info.max10_version,
drivers/raw/ifpga/base/opae_hw_api.c +18 -0
index 86ad88f72..11c9887c7 100644
@@ -967,6 +967,24 @@ opae_mgr_get_board_info(struct opae_manager *mgr,
 	return -ENOENT;
 }
 
+/**
+ * opae_mgr_get_uuid -  get manager's UUID.
+ * @mgr: targeted manager
+ * @uuid: a pointer to UUID
+ *
+ * Return: 0 on success, otherwise error code.
+ */
+int opae_mgr_get_uuid(struct opae_manager *mgr, struct uuid *uuid)
+{
+	if (!mgr || !uuid)
+		return -EINVAL;
+
+	if (mgr->ops && mgr->ops->get_uuid)
+		return mgr->ops->get_uuid(mgr, uuid);
+
+	return -ENOENT;
+}
+
 /**
  * opae_mgr_update_flash -  update image in flash.
  * @mgr: targeted manager
drivers/raw/ifpga/base/opae_hw_api.h +2 -0
index c819dc3d2..fcf7d2f6d 100644
@@ -55,6 +55,7 @@ struct opae_manager_ops {
 			unsigned int *value);
 	int (*get_board_info)(struct opae_manager *mgr,
 			struct opae_board_info **info);
+	int (*get_uuid)(struct opae_manager *mgr, struct uuid *uuid);
 	int (*update_flash)(struct opae_manager *mgr, const char *image,
 			u64 *status);
 	int (*stop_flash_update)(struct opae_manager *mgr, int force);
@@ -360,6 +361,7 @@ int opae_manager_eth_group_read_reg(struct opae_manager *mgr, u8 group_id,
 		u8 type, u8 index, u16 addr, u32 *data);
 int opae_mgr_get_board_info(struct opae_manager *mgr,
 		struct opae_board_info **info);
+int opae_mgr_get_uuid(struct opae_manager *mgr, struct uuid *uuid);
 int opae_mgr_update_flash(struct opae_manager *mgr, const char *image,
 		uint64_t *status);
 int opae_mgr_stop_flash_update(struct opae_manager *mgr, int force);
drivers/raw/ifpga/base/opae_ifpga_hw_api.h +1 -0
index bab33862e..ffdbebf70 100644
@@ -61,6 +61,7 @@ struct feature_prop {
 #define FME_HDR_PROP_SOCKET_ID		0x5	/* RDONLY */
 #define FME_HDR_PROP_BITSTREAM_ID		0x6	/* RDONLY */
 #define FME_HDR_PROP_BITSTREAM_METADATA	0x7	/* RDONLY */
+#define FME_HDR_PROP_PORT_TYPE		0x8	/* RDWR */
 
 /* FME error reporting feature's properties */
 /* FME error reporting properties format */
drivers/raw/ifpga/ifpga_rawdev.c +157 -0

163 lines not on this page · raw message

drivers/raw/ifpga/ifpga_rawdev.h +28 -0
index bf74a5eb3..d4be7913d 100644
@@ -67,6 +67,28 @@ enum ifpga_irq_type {
 	IFPGA_AFU_IRQ = 1,
 };
 
+typedef struct {
+	uint8_t b[16];
+} ifpga_uuid;
+
+typedef struct {
+	uint32_t boot_page;
+	uint32_t num_ports;
+	uint64_t bitstream_id;
+	uint64_t bitstream_metadata;
+	ifpga_uuid pr_id;
+} ifpga_fme_property;
+
+typedef struct {
+	ifpga_uuid afu_id;
+	uint32_t type;   /* AFU memory access control type */
+} ifpga_port_property;
+
+typedef struct {
+	uint32_t bmc_version;
+	uint32_t fw_version;
+} ifpga_bmc_property;
+
 int
 ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 		enum ifpga_irq_type type, int vec_start, int count,
@@ -76,6 +98,12 @@ int
 ifpga_unregister_msix_irq(enum ifpga_irq_type type,
 		int vec_start, rte_intr_callback_fn handler, void *arg);
 
+int ifpga_rawdev_get_fme_property(struct rte_rawdev *dev,
+	ifpga_fme_property *prop);
+int ifpga_rawdev_get_port_property(struct rte_rawdev *dev, uint32_t port,
+	ifpga_port_property *prop);
+int ifpga_rawdev_get_bmc_property(struct rte_rawdev *dev,
+	ifpga_bmc_property *prop);
 int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
 	uint64_t *status);
 int ifpga_rawdev_stop_flash_update(struct rte_rawdev *dev, int force);
Signature · 1 line
2.29.2
author
#6 lore raw

PATCH v12 3/4 raw/ifpga: add fpga helper function

In reply to Wei Huang

Below helper functions are used to implement OPAE application.
1. ifpga_rawdev_lock() and ifpga_rawdev_unlock() protect FPGA access in multiproces.
2. ifpga_rawdev_get_rsu_stat() and ifpga_rawdev_set_rsu_stat() record current RSU status and progress.
3. ifpga_rawdev_get_phy_info() get information of connected retimer.
4. ifpga_rawdev_partial_reconfigure() do partial reconfiguration.
5. ifpga_rawdev_cleanup() free software resources allocated for driver.

---
 drivers/raw/ifpga/ifpga_rawdev.c | 152 +++++++++++++++++++++++++++++--
 drivers/raw/ifpga/ifpga_rawdev.h |  15 +++
 2 files changed, 161 insertions(+), 6 deletions(-)
drivers/raw/ifpga/ifpga_rawdev.c +146 -6
index 8dd566e44..64ed9903e 100644
@@ -1738,6 +1738,79 @@ RTE_PMD_REGISTER_PARAM_STRING(ifpga_rawdev_cfg,
 	"port=<int> "
 	"afu_bts=<path>");
 
+struct rte_pci_bus *ifpga_get_pci_bus(void)
+{
+	return rte_ifpga_rawdev_pmd.bus;
+}
+
+int ifpga_rawdev_lock(struct rte_rawdev *dev)
+{
+	if (!dev) {
+		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+		return -EINVAL;
+	}
+	return opae_adapter_lock(ifpga_rawdev_get_priv(dev), -1);
+}
+
+int ifpga_rawdev_unlock(struct rte_rawdev *dev)
+{
+	if (!dev) {
+		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+		return -EINVAL;
+	}
+	return opae_adapter_unlock(ifpga_rawdev_get_priv(dev));
+}
+
+uint32_t ifpga_rawdev_get_rsu_stat(struct rte_rawdev *dev)
+{
+	struct opae_adapter *adapter = NULL;
+	opae_share_data *sd = NULL;
+
+	if (!dev) {
+		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+		return 0;
+	}
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter) {
+		IFPGA_RAWDEV_PMD_ERR("adapter is invalid");
+		return 0;
+	}
+
+	sd = (opae_share_data *)adapter->shm.ptr;
+	if (!sd) {
+		IFPGA_RAWDEV_PMD_ERR("shared memory is invalid");
+		return 0;
+	}
+
+	return sd->rsu_stat;
+}
+
+void ifpga_rawdev_set_rsu_stat(struct rte_rawdev *dev, uint32_t value)
+{
+	struct opae_adapter *adapter = NULL;
+	opae_share_data *sd = NULL;
+
+	if (!dev) {
+		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+		return;
+	}
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter) {
+		IFPGA_RAWDEV_PMD_ERR("adapter is invalid");
+		return;
+	}
+
+	sd = (opae_share_data *)adapter->shm.ptr;
+	if (!sd) {
+		IFPGA_RAWDEV_PMD_ERR("shared memory is invalid");
+		return;
+	}
+
+	sd->rsu_stat = value;
+}
+
 int ifpga_rawdev_get_fme_property(struct rte_rawdev *dev,
 	ifpga_fme_property *prop)
 {
@@ -1748,8 +1821,8 @@ int ifpga_rawdev_get_fme_property(struct rte_rawdev *dev,
 	struct uuid pr_id;
 	int ret = 0;
 
-	if (!dev) {
-		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+	if (!dev || !prop) {
+		IFPGA_RAWDEV_PMD_ERR("Input parameter is invalid");
 		return -EINVAL;
 	}
 
@@ -1820,8 +1893,8 @@ int ifpga_rawdev_get_port_property(struct rte_rawdev *dev, uint32_t port,
 	struct uuid afu_id;
 	int ret = 0;
 
-	if (!dev) {
-		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+	if (!dev || !prop) {
+		IFPGA_RAWDEV_PMD_ERR("Input parameter is invalid");
 		return -EINVAL;
 	}
 
@@ -1867,8 +1940,8 @@ int ifpga_rawdev_get_bmc_property(struct rte_rawdev *dev,
 	struct opae_board_info *info = NULL;
 	int ret = 0;
 
-	if (!dev) {
-		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+	if (!dev || !prop) {
+		IFPGA_RAWDEV_PMD_ERR("Input parameter is invalid");
 		return -EINVAL;
 	}
 
@@ -1895,6 +1968,48 @@ int ifpga_rawdev_get_bmc_property(struct rte_rawdev *dev,
 	return 0;
 }
 
+int ifpga_rawdev_get_phy_info(struct rte_rawdev *dev, ifpga_phy_info *info)
+{
+	struct opae_adapter *adapter = NULL;
+	struct opae_retimer_info rtm_info;
+	struct opae_retimer_status rtm_status;
+	int ret = 0;
+
+	if (!dev || !info) {
+		IFPGA_RAWDEV_PMD_ERR("Input parameter is invalid");
+		return -EINVAL;
+	}
+
+	adapter = ifpga_rawdev_get_priv(dev);
+	if (!adapter) {
+		IFPGA_RAWDEV_PMD_ERR("adapter is invalid");
+		return -ENODEV;
+	}
+
+	if (!adapter->mgr) {
+		IFPGA_RAWDEV_PMD_ERR("manager is invalid");
+		return -ENODEV;
+	}
+
+	ret = opae_manager_get_retimer_info(adapter->mgr, &rtm_info);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("Failed to get retimer info");
+		return ret;
+	}
+
+	ret = opae_manager_get_retimer_status(adapter->mgr, &rtm_status);
+	if (ret) {
+		IFPGA_RAWDEV_PMD_ERR("Failed to get retimer status");
+		return ret;
+	}
+
+	info->num_retimers = rtm_info.nums_retimer;
+	info->link_speed = rtm_status.speed;
+	info->link_status = rtm_status.line_link_bitmap;
+
+	return 0;
+}
+
 int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
 	uint64_t *status)
 {
@@ -1949,3 +2064,28 @@ int ifpga_rawdev_reload(struct rte_rawdev *dev, int type, int page)
 
 	return opae_mgr_reload(adapter->mgr, type, page);
 }
+
+int ifpga_rawdev_partial_reconfigure(struct rte_rawdev *dev, int port,
+	const char *file)
+{
+	if (!dev) {
+		IFPGA_RAWDEV_PMD_ERR("rawdev is invalid");
+		return -EINVAL;
+	}
+
+	return rte_fpga_do_pr(dev, port, file);
+}
+
+void ifpga_rawdev_cleanup(void)
+{
+	struct ifpga_rawdev *dev;
+	unsigned int i;
+
+	for (i = 0; i < IFPGA_RAWDEV_NUM; i++) {
+		dev = &ifpga_rawdevices[i];
+		if (dev->rawdev) {
+			rte_rawdev_pmd_release(dev->rawdev);
+			dev->rawdev = NULL;
+		}
+	}
+}
drivers/raw/ifpga/ifpga_rawdev.h +15 -0
index d4be7913d..185e79071 100644
@@ -89,6 +89,12 @@ typedef struct {
 	uint32_t fw_version;
 } ifpga_bmc_property;
 
+typedef struct {
+	uint32_t num_retimers;
+	uint32_t link_speed;
+	uint32_t link_status;
+} ifpga_phy_info;
+
 int
 ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 		enum ifpga_irq_type type, int vec_start, int count,
@@ -98,15 +104,24 @@ int
 ifpga_unregister_msix_irq(enum ifpga_irq_type type,
 		int vec_start, rte_intr_callback_fn handler, void *arg);
 
+struct rte_pci_bus *ifpga_get_pci_bus(void);
+int ifpga_rawdev_lock(struct rte_rawdev *dev);
+int ifpga_rawdev_unlock(struct rte_rawdev *dev);
+uint32_t ifpga_rawdev_get_rsu_stat(struct rte_rawdev *dev);
+void ifpga_rawdev_set_rsu_stat(struct rte_rawdev *dev, uint32_t value);
 int ifpga_rawdev_get_fme_property(struct rte_rawdev *dev,
 	ifpga_fme_property *prop);
 int ifpga_rawdev_get_port_property(struct rte_rawdev *dev, uint32_t port,
 	ifpga_port_property *prop);
 int ifpga_rawdev_get_bmc_property(struct rte_rawdev *dev,
 	ifpga_bmc_property *prop);
+int ifpga_rawdev_get_phy_info(struct rte_rawdev *dev, ifpga_phy_info *info);
 int ifpga_rawdev_update_flash(struct rte_rawdev *dev, const char *image,
 	uint64_t *status);
 int ifpga_rawdev_stop_flash_update(struct rte_rawdev *dev, int force);
 int ifpga_rawdev_reload(struct rte_rawdev *dev, int type, int page);
+int ifpga_rawdev_partial_reconfigure(struct rte_rawdev *dev, int port,
+	const char *file);
+void ifpga_rawdev_cleanup(void);
 
 #endif /* _IFPGA_RAWDEV_H_ */
Signature · 1 line
2.29.2
#7 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v12 3/4] raw/ifpga: add fpga helper function

Quoted 3 lines · Wei Huang

Below helper functions are used to implement OPAE application.
1. ifpga_rawdev_lock() and ifpga_rawdev_unlock() protect FPGA access in multiproces.

Why driver needs to expose the lock APIs to the application?

Can't application use its own locking mechanism for multiprocess, and driver can use its own locking for its needs. Driver exposing locking internals to applications doesn't look right, but I don't know the full usecase.

Quoted 9 lines

2. ifpga_rawdev_get_rsu_stat() and ifpga_rawdev_set_rsu_stat() record current RSU status and progress.
3. ifpga_rawdev_get_phy_info() get information of connected retimer.
4. ifpga_rawdev_partial_reconfigure() do partial reconfiguration.
5. ifpga_rawdev_cleanup() free software resources allocated for driver.

<...>

author
#8 lore raw

Re: [dpdk-dev] [dpdk-stable] [PATCH v12 3/4] raw/ifpga: add fpga helper function

Hi,

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, January 28, 2021 21:30
To: Huang, Wei <[email protected]>; [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>
Subject: Re: [dpdk-stable] [PATCH v12 3/4] raw/ifpga: add fpga helper function

Quoted 3 lines · Wei Huang

Below helper functions are used to implement OPAE application.
1. ifpga_rawdev_lock() and ifpga_rawdev_unlock() protect FPGA access in multiproces.

Why driver needs to expose the lock APIs to the application?

Can't application use its own locking mechanism for multiprocess, and driver can use its own locking for its needs. Driver exposing locking internals to applications doesn't look right, but I don't know the full usecase. I agree, these two lock APIs will be used only in rte_pmd_ifpga.c in next patch, application cannot see them.

Quoted 9 lines

2. ifpga_rawdev_get_rsu_stat() and ifpga_rawdev_set_rsu_stat() record current RSU status and progress.
3. ifpga_rawdev_get_phy_info() get information of connected retimer.
4. ifpga_rawdev_partial_reconfigure() do partial reconfiguration.
5. ifpga_rawdev_cleanup() free software resources allocated for driver.

<...>

author
#9 lore raw

PATCH v12 4/4 examples/ifpga: add example for ifpga opae API

In reply to Wei Huang

Below major OPAE APIs are added in this example.
1. opae_init_eal() set up EAL environment.
2. opae_cleanup_eal() clean up EAL environment.
3. opae_enumerate() searches PAC with specific FPGA.
4. opae_get_property() gets properties of FPGA.
5. opae_partial_reconfigure() perform partial configuration on FPGA.
6. opae_get_image_info() gets information of image file.
7. opae_update_flash() updates FPGA flash with specific image file.
8. opae_cancel_flash_update() cancel process of FPGA flash update.
9. opae_probe_device() manually probe specific FPGA with ifpga driver.
10. opae_remove_device() manually remove specific FPGA from ifpga driver.
11. opae_bind_driver() binds specific FPGA with specified kernel driver.
12. opae_unbind_driver() unbinds specific FPGA from kernel driver.
13. opae_reboot_device() reboots specific FPGA.

An example application shows how to call above OPAE APIs. You can test each API by running corresponding command. A guide is also added to show how to run the example.

---
v2: fix coding style issue in commands.c
---
v3: add guide for running example
---
v4: fix compilation issue of ifpga.rst
---
v5: add ifpga.rst into sample_app_ug/index.rst
---
v6: implement OPAE APIs in example instead of ifpga rawdev

---
 MAINTAINERS                        |    1 +
 doc/guides/sample_app_ug/ifpga.rst |  433 +++++++
 doc/guides/sample_app_ug/index.rst |    1 +
 examples/ifpga/Makefile            |   45 +
 examples/ifpga/commands.c          | 1321 ++++++++++++++++++++
 examples/ifpga/commands.h          |   16 +
 examples/ifpga/main.c              |   38 +
 examples/ifpga/meson.build         |   20 +
 examples/ifpga/opae_api.c          | 1788 ++++++++++++++++++++++++++++
 examples/ifpga/opae_api.h          |  245 ++++
 10 files changed, 3908 insertions(+)
 create mode 100644 doc/guides/sample_app_ug/ifpga.rst
 create mode 100644 examples/ifpga/Makefile
 create mode 100644 examples/ifpga/commands.c
 create mode 100644 examples/ifpga/commands.h
 create mode 100644 examples/ifpga/main.c
 create mode 100644 examples/ifpga/meson.build
 create mode 100644 examples/ifpga/opae_api.c
 create mode 100644 examples/ifpga/opae_api.h
MAINTAINERS +1 -0
index eafe9f8c4..04a8fdebb 100644
@@ -1237,6 +1237,7 @@ M: Tianfei zhang <[email protected]>
 T: git://dpdk.org/next/dpdk-next-net-intel
 F: drivers/raw/ifpga/
 F: doc/guides/rawdevs/ifpga.rst
+F: doc/guides/sample_app_ug/ifpga.rst
 
 IOAT Rawdev
 M: Bruce Richardson <[email protected]>
doc/guides/sample_app_ug/ifpga.rst new file +433 -0

433 lines not on this page · raw message

doc/guides/sample_app_ug/index.rst +1 -0
index e8db83d3a..beb94ff3e 100644
@@ -23,6 +23,7 @@ Sample Applications User Guides
     kernel_nic_interface
     keep_alive
     ioat
+    ifpga
     l2_forward_crypto
     l2_forward_job_stats
     l2_forward_real_virtual
examples/ifpga/Makefile new file +45 -0

45 lines not on this page · raw message

examples/ifpga/commands.c new file +1321 -0

1,321 lines not on this page · raw message

examples/ifpga/commands.h new file +16 -0
new file mode 100644
index 000000000..06fe9a68b
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020-2021 Intel Corporation
+ */
+
+#ifndef _COMMANDS_H_
+#define _COMMANDS_H_
+
+#include "opae_api.h"
+
+extern cmdline_parse_ctx_t main_ctx[];
+
+typedef struct {
+	char s[38];
+} uuid_str;
+
+#endif /* _COMMANDS_H_ */
examples/ifpga/main.c new file +38 -0
new file mode 100644
index 000000000..e9380d581
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020-2021 Intel Corporation
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <errno.h>
+#include <sys/queue.h>
+
+#include <cmdline_rdline.h>
+#include <cmdline_parse.h>
+#include <cmdline_socket.h>
+#include <cmdline.h>
+
+#include <rte_memory.h>
+#include <rte_eal.h>
+#include <rte_debug.h>
+
+#include "commands.h"
+
+
+int main(int argc, char **argv)
+{
+	struct cmdline *cl;
+	int ret;
+
+	ret = opae_init_eal(argc, argv);
+	if (ret < 0)
+		rte_panic("Cannot init EAL\n");
+	cl = cmdline_stdin_new(main_ctx, "opae> ");
+	if (cl == NULL)
+		rte_panic("Cannot create cmdline instance\n");
+	cmdline_interact(cl);
+	opae_cleanup_eal();
+	cmdline_stdin_exit(cl);
+	return 0;
+}
examples/ifpga/meson.build new file +20 -0
new file mode 100644
index 000000000..b88a37a7a
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: BSD-3-Clause
+# Copyright(c) 2020-2021 Intel Corporation
+
+# meson file, for building this example as part of a main DPDK build.
+#
+# To build this example as a standalone application with an already-installed
+# DPDK instance, use 'make'
+
+# require the raw_ifpga library
+build = dpdk_conf.has('RTE_RAW_IFPGA')
+if not build
+	subdir_done()
+endif
+
+deps += 'raw_ifpga'
+allow_experimental_apis = true
+sources = files(
+	'main.c', 'commands.c', 'opae_api.c'
+)
+cflags += '-fPIC'
examples/ifpga/opae_api.c new file +1788 -0

1,113 lines not on this page · raw message

examples/ifpga/opae_api.h new file +245 -0

245 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.29.2

Part of the diff is not shown here. View the raw message.

#10 lore raw

Re: [dpdk-dev] [PATCH v12 4/4] examples/ifpga: add example for ifpga opae API

Quoted 58 lines · Wei Huang

Below major OPAE APIs are added in this example.
1. opae_init_eal() set up EAL environment.
2. opae_cleanup_eal() clean up EAL environment.
3. opae_enumerate() searches PAC with specific FPGA.
4. opae_get_property() gets properties of FPGA.
5. opae_partial_reconfigure() perform partial configuration on FPGA.
6. opae_get_image_info() gets information of image file.
7. opae_update_flash() updates FPGA flash with specific image file.
8. opae_cancel_flash_update() cancel process of FPGA flash update.
9. opae_probe_device() manually probe specific FPGA with ifpga driver.
10. opae_remove_device() manually remove specific FPGA from ifpga driver.
11. opae_bind_driver() binds specific FPGA with specified kernel driver.
12. opae_unbind_driver() unbinds specific FPGA from kernel driver.
13. opae_reboot_device() reboots specific FPGA.

An example application shows how to call above OPAE APIs. You can test each API by running corresponding command. A guide is also added to show how to run the example.

---
v2: fix coding style issue in commands.c
---
v3: add guide for running example
---
v4: fix compilation issue of ifpga.rst
---
v5: add ifpga.rst into sample_app_ug/index.rst
---
v6: implement OPAE APIs in example instead of ifpga rawdev

---
  MAINTAINERS                        |    1 +
  doc/guides/sample_app_ug/ifpga.rst |  433 +++++++
  doc/guides/sample_app_ug/index.rst |    1 +
  examples/ifpga/Makefile            |   45 +
  examples/ifpga/commands.c          | 1321 ++++++++++++++++++++
  examples/ifpga/commands.h          |   16 +
  examples/ifpga/main.c              |   38 +
  examples/ifpga/meson.build         |   20 +
  examples/ifpga/opae_api.c          | 1788 ++++++++++++++++++++++++++++
  examples/ifpga/opae_api.h          |  245 ++++
  10 files changed, 3908 insertions(+)

create mode 100644 doc/guides/sample_app_ug/ifpga.rst create mode 100644 examples/ifpga/Makefile create mode 100644 examples/ifpga/commands.c create mode 100644 examples/ifpga/commands.h create mode 100644 examples/ifpga/main.c create mode 100644 examples/ifpga/meson.build create mode 100644 examples/ifpga/opae_api.c create mode 100644 examples/ifpga/opae_api.h

MAINTAINERS +0 -0
index eafe9f8c4..04a8fdebb 100644

MAINTAINERS M: Tianfei zhang <[email protected]> · line 1240

Quoted 4 lines
MAINTAINERS +1 -0
@@ -1237,6 +1237,7 @@ M: Tianfei zhang <[email protected]>
  T: git://dpdk.org/next/dpdk-next-net-intel
  F: drivers/raw/ifpga/
  F: doc/guides/rawdevs/ifpga.rst
+F: doc/guides/sample_app_ug/ifpga.rst

The new example also needs to be added to the maintainers file.

Quoted 9 lines
MAINTAINERS +0 -0
  IOAT Rawdev
  M: Bruce Richardson <[email protected]>
doc/guides/sample_app_ug/ifpga.rst new file +0 -0
new file mode 100644
index 000000000..adcac3bdf

doc/guides/sample_app_ug/ifpga.rst line 9

Quoted 9 lines
doc/guides/sample_app_ug/ifpga.rst new file +9 -0
@@ -0,0 +1,433 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2020-2021 Intel Corporation.
+
+Intel FPGA Sample Application
+=============================
+
+The Intel FPGA sample application is an example of how to use OPAE API to manage
+Intel FPGA.
+

Can you please explain more what is "OPAE API" in documentation, provide links if possible.

Quoted 36 lines
doc/guides/sample_app_ug/ifpga.rst new file +36 -0
+Overview
+--------
+
+The Intel FPGA sample application is a simple application that demonstrates
+the use of the OPAE API provided by ifpga driver in the DPDK.
+This application is a readline-like interface that can be used to manage
+Intel FPGA, in a Linux* application environment.
+
+Compiling the Application
+-------------------------
+
+To compile the sample application see :doc:`compiling`
+
+The application is located in the ``ifpga`` sub-directory.
+
+Running the Application
+-----------------------
+
+To run the application in linux environment, issue the following command:
+
+.. code-block:: console
+
+    $ ./<build_dir>/examples/dpdk-ifpga --proc-type=auto
+
+Refer to the *DPDK Getting Started Guide* for general information on running
+applications and the Environment Abstraction Layer (EAL) options.
+
+Explanation
+-----------
+
+The following sections provide some explanation of the code.
+
+EAL Initialization and cmdline Start
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The first task is the initialization of the Environment Abstraction Layer (EAL).

doc/guides/sample_app_ug/ifpga.rst line 55

Quoted 10 lines
doc/guides/sample_app_ug/ifpga.rst new file +10 -0
+This is achieved as follows:
+
+.. code-block:: c
+
+    int main(int argc, char **argv)
+    {
+        ret = opae_init_eal(argc, argv);
+        if (ret < 0)
+            rte_panic("Cannot init EAL\n");
+

Adding code to the documentation will be heachache to maintain, and it will be wrong by time as people update the code but not documentation.

I highly suggest removing code snippets from the documentation.

author
#11 lore raw

Re: [dpdk-dev] [PATCH v12 4/4] examples/ifpga: add example for ifpga opae API

Hi,

-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Thursday, January 28, 2021 21:35
To: Huang, Wei <[email protected]>; [email protected]; Xu, Rosen <[email protected]>; Zhang, Qi Z <[email protected]>
Cc: [email protected]; Zhang, Tianfei <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v12 4/4] examples/ifpga: add example for ifpga opae API

Quoted 58 lines · Wei Huang

Below major OPAE APIs are added in this example.
1. opae_init_eal() set up EAL environment.
2. opae_cleanup_eal() clean up EAL environment.
3. opae_enumerate() searches PAC with specific FPGA.
4. opae_get_property() gets properties of FPGA.
5. opae_partial_reconfigure() perform partial configuration on FPGA.
6. opae_get_image_info() gets information of image file.
7. opae_update_flash() updates FPGA flash with specific image file.
8. opae_cancel_flash_update() cancel process of FPGA flash update.
9. opae_probe_device() manually probe specific FPGA with ifpga driver.
10. opae_remove_device() manually remove specific FPGA from ifpga driver.
11. opae_bind_driver() binds specific FPGA with specified kernel driver.
12. opae_unbind_driver() unbinds specific FPGA from kernel driver.
13. opae_reboot_device() reboots specific FPGA.

An example application shows how to call above OPAE APIs. You can test each API by running corresponding command. A guide is also added to show how to run the example.

---
v2: fix coding style issue in commands.c
---
v3: add guide for running example
---
v4: fix compilation issue of ifpga.rst
---
v5: add ifpga.rst into sample_app_ug/index.rst
---
v6: implement OPAE APIs in example instead of ifpga rawdev

---
  MAINTAINERS                        |    1 +
  doc/guides/sample_app_ug/ifpga.rst |  433 +++++++
  doc/guides/sample_app_ug/index.rst |    1 +
  examples/ifpga/Makefile            |   45 +
  examples/ifpga/commands.c          | 1321 ++++++++++++++++++++
  examples/ifpga/commands.h          |   16 +
  examples/ifpga/main.c              |   38 +
  examples/ifpga/meson.build         |   20 +
  examples/ifpga/opae_api.c          | 1788 ++++++++++++++++++++++++++++
  examples/ifpga/opae_api.h          |  245 ++++
  10 files changed, 3908 insertions(+)

create mode 100644 doc/guides/sample_app_ug/ifpga.rst create mode 100644 examples/ifpga/Makefile create mode 100644 examples/ifpga/commands.c create mode 100644 examples/ifpga/commands.h create mode 100644 examples/ifpga/main.c create mode 100644 examples/ifpga/meson.build create mode 100644 examples/ifpga/opae_api.c create mode 100644 examples/ifpga/opae_api.h

MAINTAINERS index eafe9f8c4..04a8fdebb renamed from MAINTAINERS +0 -0

100644

MAINTAINERS M: Tianfei zhang <[email protected]> · line 1240

Quoted 4 lines
MAINTAINERS +1 -0
@@ -1237,6 +1237,7 @@ M: Tianfei zhang <[email protected]>
  T: git://dpdk.org/next/dpdk-next-net-intel
  F: drivers/raw/ifpga/
  F: doc/guides/rawdevs/ifpga.rst
+F: doc/guides/sample_app_ug/ifpga.rst

The new example also needs to be added to the maintainers file. OK, I will add it maintainers file.

Quoted 10 lines
MAINTAINERS +0 -0
  IOAT Rawdev
  M: Bruce Richardson <[email protected]> diff --git 

a/doc/guides/sample_app_ug/ifpga.rst
b/doc/guides/sample_app_ug/ifpga.rst
new file mode 100644
index 000000000..adcac3bdf

doc/guides/sample_app_ug/ifpga.rst line 9

Quoted 9 lines
doc/guides/sample_app_ug/ifpga.rst new file +9 -0
@@ -0,0 +1,433 @@
+..  SPDX-License-Identifier: BSD-3-Clause
+    Copyright(c) 2020-2021 Intel Corporation.
+
+Intel FPGA Sample Application
+=============================
+
+The Intel FPGA sample application is an example of how to use OPAE 
+API to manage Intel FPGA.
+

Can you please explain more what is "OPAE API" in documentation, provide links if possible. OK, I will add "OPAE" description and link in documentation.

Quoted 36 lines
doc/guides/sample_app_ug/ifpga.rst new file +36 -0
+Overview
+--------
+
+The Intel FPGA sample application is a simple application that 
+demonstrates the use of the OPAE API provided by ifpga driver in the DPDK.
+This application is a readline-like interface that can be used to 
+manage Intel FPGA, in a Linux* application environment.
+
+Compiling the Application
+-------------------------
+
+To compile the sample application see :doc:`compiling`
+
+The application is located in the ``ifpga`` sub-directory.
+
+Running the Application
+-----------------------
+
+To run the application in linux environment, issue the following command:
+
+.. code-block:: console
+
+    $ ./<build_dir>/examples/dpdk-ifpga --proc-type=auto
+
+Refer to the *DPDK Getting Started Guide* for general information on 
+running applications and the Environment Abstraction Layer (EAL) options.
+
+Explanation
+-----------
+
+The following sections provide some explanation of the code.
+
+EAL Initialization and cmdline Start
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The first task is the initialization of the Environment Abstraction Layer (EAL).

doc/guides/sample_app_ug/ifpga.rst line 55

Quoted 10 lines
doc/guides/sample_app_ug/ifpga.rst new file +10 -0
+This is achieved as follows:
+
+.. code-block:: c
+
+    int main(int argc, char **argv)
+    {
+        ret = opae_init_eal(argc, argv);
+        if (ret < 0)
+            rte_panic("Cannot init EAL\n");
+

Adding code to the documentation will be heachache to maintain, and it will be wrong by time as people update the code but not documentation. OK, I will remove them from documentation.

I highly suggest removing code snippets from the documentation.