Skip to contentSkip to conversation

add Intel DCF PMD support

PATCH Superseded Haiyue Wang 10 participants 94 messages Mar 9, 2020 – Mar 31, 2020 Page 1 of 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

And it needs the coming iavf common lib update to compile, the modified ice flow function to work.

Haiyue Wang (4):
net/iavf: stop the PCI probe in DCF mode
net/ice: export the DDP definition symbols
net/ice: add the DCF framework
doc: add release notes for Intel ice PMD

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  41 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 319 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 348 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/4 net/iavf: stop the PCI probe in DCF mode

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
 drivers/net/iavf/iavf_ethdev.c | 41 ++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
drivers/net/iavf/iavf_ethdev.c +41 -0
index 34913f9c4..8ff26c0e7 100644
@@ -1416,9 +1416,49 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);
+
+	rte_kvargs_free(kvlist);
+
+	return enable;
+}
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (check_cap_dcf_enable(pci_dev->device.devargs))
+		return 1; /* continue to probe */
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1479,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
Signature · 1 line
2.25.1
#2 lore raw

Re: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 41 lines · Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
drivers/net/iavf/iavf_ethdev.c | 41 ++++++++++++++++++++++++++++++++++

1 file changed, 41 insertions(+)
drivers/net/iavf/iavf_ethdev.c +21 -0
index 34913f9c4..8ff26c0e7 100644
@@ -1416,9 +1416,49 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;

drivers/net/iavf/iavf_ethdev.c iavf_dev_uninit(struct rte_eth_dev *dev) · line 1449

Quoted 10 lines
drivers/net/iavf/iavf_ethdev.c +10 -0
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);

Need error handling for failure case.

drivers/net/iavf/iavf_ethdev.c iavf_dev_uninit(struct rte_eth_dev *dev) · line 1460

Quoted 11 lines
drivers/net/iavf/iavf_ethdev.c +8 -0
+
+	rte_kvargs_free(kvlist);
+
+	return enable;
+}
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (check_cap_dcf_enable(pci_dev->device.devargs))
+		return 1; /* continue to probe */

This comment is confusing...

Quoted 15 lines
drivers/net/iavf/iavf_ethdev.c +2 -0
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1479,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
Signature · 1 line
2.25.1
#3 lore raw

Re: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 54 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Monday, March 9, 2020 23:38
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 45 lines · Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
drivers/net/iavf/iavf_ethdev.c | 41 ++++++++++++++++++++++++++++++++++

1 file changed, 41 insertions(+)
drivers/net/iavf/iavf_ethdev.c +25 -0
index 34913f9c4..8ff26c0e7 100644
@@ -1416,9 +1416,49 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
Quoted 9 lines

drivers/net/iavf/iavf_ethdev.c iavf_dev_uninit(struct rte_eth_dev *dev) · line 1449

Quoted 6 lines
drivers/net/iavf/iavf_ethdev.c +6 -0
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);

Need error handling for failure case.

We just need the 'cap=dcf' to check whether it is true, by default 'enable=false' can handle all the cases. ;-)

Quoted 5 lines
Quoted 5 lines
drivers/net/iavf/iavf_ethdev.c +5 -0
+
+	rte_kvargs_free(kvlist);
+
+	return enable;
+}
Quoted 8 lines

drivers/net/iavf/iavf_ethdev.c iavf_dev_uninit(struct rte_eth_dev *dev) · line 1460

Quoted 6 lines
drivers/net/iavf/iavf_ethdev.c +3 -0
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (check_cap_dcf_enable(pci_dev->device.devargs))
+		return 1; /* continue to probe */

This comment is confusing...

Yes, it should be like 'stop this driver probe to scan the next one'.

Quoted 16 lines
Quoted 16 lines
drivers/net/iavf/iavf_ethdev.c +2 -1
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1479,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
--

2.25.1

#4 lore raw

Re: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 64 lines · Haiyue
Quoted 54 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Monday, March 9, 2020 23:38
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 45 lines · Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
drivers/net/iavf/iavf_ethdev.c | 41 ++++++++++++++++++++++++++++++++++

1 file changed, 41 insertions(+)
drivers/net/iavf/iavf_ethdev.c +25 -0
index 34913f9c4..8ff26c0e7 100644
@@ -1416,9 +1416,49 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
Quoted 9 lines

drivers/net/iavf/iavf_ethdev.c iavf_dev_uninit(struct rte_eth_dev *dev) · line 1449

Quoted 6 lines
drivers/net/iavf/iavf_ethdev.c +6 -0
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);

Need error handling for failure case.

Quoted 3 lines

We just need the 'cap=dcf' to check whether it is true, by default 'enable=false' can handle all the cases. ;-)

Yes, from function point of view, this could work. But it is still good practice to check the return value of the function.

Thanks,
Xiaolong

#5 lore raw

Re: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 73 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Tuesday, March 10, 2020 11:38
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 64 lines · Haiyue
Quoted 63 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Monday, March 9, 2020 23:38
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 41 lines · Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
drivers/net/iavf/iavf_ethdev.c | 41 ++++++++++++++++++++++++++++++++++

1 file changed, 41 insertions(+)
drivers/net/iavf/iavf_ethdev.c +21 -0
index 34913f9c4..8ff26c0e7 100644
@@ -1416,9 +1416,49 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;

drivers/net/iavf/iavf_ethdev.c iavf_dev_uninit(struct rte_eth_dev *dev) · line 1449

Quoted 10 lines
drivers/net/iavf/iavf_ethdev.c +10 -0
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);

Need error handling for failure case.

Quoted 7 lines
Quoted 3 lines

We just need the 'cap=dcf' to check whether it is true, by default 'enable=false' can handle all the cases. ;-)

Yes, from function point of view, this could work. But it is still good practice to check the return value of the function.

Make sense, will handle it in v2.

Quoted 2 lines

Thanks,
Xiaolong

#6 lore raw

Re: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

In reply to Haiyue Wang

+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+ __rte_unused void *arg)
__rte_unused is not needed here.

+{
+ bool *dcf = arg;
+
+ if (arg == NULL || value == NULL)
+ return -EINVAL;
+
+ if (strcmp(value, "dcf") == 0)
+ *dcf = true;
+ else
+ *dcf = false;
+
+ return 0;
+}
+

#7 lore raw

Re: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

Quoted 11 lines

-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Monday, March 23, 2020 09:51
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v1 1/4] net/iavf: stop the PCI probe in DCF mode

drivers/net/iavf/iavf_ethdev.c +3 -0
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
Quoted 1 line

__rte_unused is not needed here.

Yes, has been rewritten and fixed in v3. ;-)

Quoted 15 lines
drivers/net/iavf/iavf_ethdev.c +14 -0
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
#8 lore raw

PATCH 2/4 net/ice: export the DDP definition symbols

In reply to Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

The DCF (Device Config Function) feature shares the core functions of the ICE PMD, like it needs to export the DDP definition symbols for the new DCF PMD use.

---
 drivers/net/ice/ice_ethdev.c | 9 +--------
 drivers/net/ice/ice_ethdev.h | 8 ++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ice/ice_ethdev.c +1 -8
index b42deb0bc..8b9d211b0 100644
@@ -67,15 +67,8 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 
 #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100
 
-/* DDP package search path */
-#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
-#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
-
 #define ICE_OS_DEFAULT_PKG_NAME		"ICE OS Default Package"
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
-#define ICE_MAX_PKG_FILENAME_SIZE   256
 #define ICE_MAX_RES_DESC_NUM        1024
 
 int ice_logtype_init;
@@ -1833,7 +1826,7 @@ ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file)
 	return 0;
 }
 
-static enum ice_pkg_type
+enum ice_pkg_type
 ice_load_pkg_type(struct ice_hw *hw)
 {
 	enum ice_pkg_type package_type;
drivers/net/ice/ice_ethdev.h +8 -0
index da557a254..7b94a3c3e 100644
@@ -42,6 +42,13 @@
 
 #define ICE_MAX_PKT_TYPE  1024
 
+/* DDP package search path */
+#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
+#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
+#define ICE_MAX_PKG_FILENAME_SIZE   256
+
 /**
  * vlan_id is a 12 bit number.
  * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
@@ -457,6 +464,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+enum ice_pkg_type ice_load_pkg_type(struct ice_hw *hw);
 struct ice_vsi *
 ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type);
 int
Signature · 1 line
2.25.1
Acked-by on v1 2/4
#9 lore raw

Re: [dpdk-dev] [PATCH v1 2/4] net/ice: export the DDP definition symbols

Quoted 66 lines · Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

The DCF (Device Config Function) feature shares the core functions of the ICE PMD, like it needs to export the DDP definition symbols for the new DCF PMD use.

---
drivers/net/ice/ice_ethdev.c | 9 +--------
drivers/net/ice/ice_ethdev.h | 8 ++++++++

2 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ice/ice_ethdev.c +1 -8
index b42deb0bc..8b9d211b0 100644
@@ -67,15 +67,8 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 
 #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100
 
-/* DDP package search path */
-#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
-#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
-
 #define ICE_OS_DEFAULT_PKG_NAME		"ICE OS Default Package"
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
-#define ICE_MAX_PKG_FILENAME_SIZE   256
 #define ICE_MAX_RES_DESC_NUM        1024
 
 int ice_logtype_init;
@@ -1833,7 +1826,7 @@ ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file)
 	return 0;
 }
 
-static enum ice_pkg_type
+enum ice_pkg_type
 ice_load_pkg_type(struct ice_hw *hw)
 {
 	enum ice_pkg_type package_type;
drivers/net/ice/ice_ethdev.h +8 -0
index da557a254..7b94a3c3e 100644
@@ -42,6 +42,13 @@
 
 #define ICE_MAX_PKT_TYPE  1024
 
+/* DDP package search path */
+#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
+#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
+#define ICE_MAX_PKG_FILENAME_SIZE   256
+
 /**
 * vlan_id is a 12 bit number.
 * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
@@ -457,6 +464,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+enum ice_pkg_type ice_load_pkg_type(struct ice_hw *hw);
Quoted 6 lines

struct ice_vsi *
ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type); int

Signature · 1 line
2.25.1
#10 lore raw

PATCH 3/4 net/ice: add the DCF framework

In reply to Haiyue Wang

The DCF (Device Config Function) feature works as a standalone PMD, its hardware entity is the trusted VF with ID 0, and the software function is to control the flow setting of other VFs by the mailbox with PF.

It doesn't handle packet Rx/Tx related things. This PMD needs the iAVF virtchnl to send the ICE PF's AdminQ command.

Also for security, it needs to acquire the DCF capability from PF. The flow related things will be added later, it shares most of the ICE flow function. This mainly handles hardware initialization etc.

                               .-------------.
                             .-|             |
                           .-| |             |
                           | | |  iAVF PMD   |
                           | | |             |
                           | | |             |
                           | | '-------------'
                           | '-------------'
                           '-------------'
                          ^   Other VFs
                         /
                        / Flow Distribution
  .------------------. /
  |                  |/  DCF cap req   .-------------.
  |      CVL         .  <----------    |             |
  |     Kernel       |  ---------->    |             |
  .                  .   DCF cap rsp   |   DCF PMD   |
  |                  |                 |             |
  '------------------'  <-----------   |             |
                          rte_flow     '-------------'
                                             VF0
---
 doc/guides/nics/ice.rst          |  47 +++
 doc/guides/nics/img/ice_dcf.png  | Bin 0 -> 39168 bytes
 drivers/common/Makefile          |   1 +
 drivers/net/ice/Makefile         |   6 +
 drivers/net/ice/ice_dcf.c        | 651 +++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h        |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c | 319 +++++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h |  33 ++
 drivers/net/ice/ice_dcf_parent.c | 348 +++++++++++++++++
 drivers/net/ice/meson.build      |   8 +-
 mk/rte.app.mk                    |   1 +
 11 files changed, 1473 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
doc/guides/nics/ice.rst +47 -0
index 8af32dabf..2639ae239 100644
@@ -240,6 +240,53 @@ report a MDD event and drop the packets.
 
 The APPs based on DPDK should avoid providing such packets.
 
+Device Config Function (DCF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This section demonstrates ICE DCF PMD, which shares the core module with ICE
+PMD and iAVF PMD.
+
+A DCF (Device Config Function) PMD bounds to the device's trusted VF with ID 0,
+it can act as a sole controlling entity to exercise advance functionality (such
+as switch, ACL) for the rest VFs.
+
+The DCF PMD needs to advertise and acquire DCF capability which allows DCF to
+send AdminQ commands that it would like to execute over to the PF and receive
+responses for the same from PF.
+
+.. _figure_ice_dcf:
+
+.. figure:: img/ice_dcf.*
+
+   DCF Communication flow.
+
+#. Create the VFs::
+
+      echo 4 > /sys/bus/pci/devices/0000\:18\:00.0/sriov_numvfs
+
+#. Enable the VF0 trust on::
+
+      ip link set dev enp24s0f0 vf 0 trust on
+
+#. Bind the VF0,  and run testpmd with 'cap=dcf' devarg::
+
+      testpmd -l 22-25 -n 4 -w 18:01.0,cap=dcf -- -i
+
+#. Monitor the VF2 interface network traffic::
+
+      tcpdump -e -nn -i enp24s1f2
+
+#. Create one flow to redirect the traffic to VF2 by DCF::
+
+      flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.2 \
+      dst is 192.168.0.3 / end actions vf id 2 / end
+
+#. Send the packet, and it should be displayed on tcpdump::
+
+      sendp(Ether(src='3c:fd:fe:aa:bb:78', dst='00:00:00:01:02:03')/IP(src=' \
+      192.168.0.2', dst="192.168.0.3")/TCP(flags='S')/Raw(load='XXXXXXXXXX'), \
+      iface="enp24s0f0", count=10)
+
 Sample Application Notes
 ------------------------
 
doc/guides/nics/img/ice_dcf.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..540823c4a05e9ea9d558d233fea77016d1ae5df3
GIT binary patch
drivers/common/Makefile +1 -0
index 96bd7ac6e..df2e840cf 100644
@@ -31,6 +31,7 @@ DIRS-y += dpaax
 endif
 
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifneq (,$(findstring y,$(IAVF-y)))
 DIRS-y += iavf
 endif
drivers/net/ice/Makefile +6 -0
index e22c34287..643639a50 100644
@@ -11,9 +11,11 @@ LIB = librte_pmd_ice.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/common/iavf
 
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs
 LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash
+LDLIBS += -lrte_net -lrte_common_iavf
 
 EXPORT_MAP := rte_pmd_ice_version.map
 
@@ -84,6 +86,10 @@ ifeq ($(CC_AVX2_SUPPORT), 1)
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
 
drivers/net/ice/ice_dcf.c new file +651 -0

651 lines not on this page · raw message

drivers/net/ice/ice_dcf.h new file +61 -0

61 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.c new file +319 -0

319 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.h new file +33 -0
new file mode 100644
index 000000000..e95266599
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_ETHDEV_H_
+#define _ICE_DCF_ETHDEV_H_
+
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
+#include "ice_ethdev.h"
+#include "ice_dcf.h"
+
+#define ICE_DCF_MAX_RINGS  1
+
+struct ice_dcf_queue {
+	uint64_t dummy;
+};
+
+struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
+	struct ice_dcf_hw real_hw;
+	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
+	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
+};
+
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
+#endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +348 -0

348 lines not on this page · raw message

drivers/net/ice/meson.build +6 -2
index f9e897bbc..0df8ddc0f 100644
@@ -15,8 +15,8 @@ sources = files(
 	'ice_hash.c'
 	)
 
-deps += ['hash']
-includes += include_directories('base')
+deps += ['hash', 'net', 'common_iavf']
+includes += include_directories('base', '../../common/iavf')
 
 if arch_subdir == 'x86'
 	sources += files('ice_rxtx_vec_sse.c')
@@ -37,4 +37,8 @@ if arch_subdir == 'x86'
 	endif
 endif
 
+sources += files('ice_dcf.c',
+		 'ice_dcf_parent.c',
+		 'ice_dcf_ethdev.c')
+
 install_headers('rte_pmd_ice.h')
mk/rte.app.mk +1 -0
index d295ca0a5..f3798a09f 100644
@@ -185,6 +185,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IAVF_PMD)       += -lrte_pmd_iavf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ICE_PMD)        += -lrte_pmd_ice
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifeq ($(findstring y,$(IAVF-y)),y)
 _LDLIBS-y += -lrte_common_iavf
 endif
Signature · 1 line
2.25.1
#11 lore raw

Re: [dpdk-dev] [PATCH v1 3/4] net/ice: add the DCF framework

Quoted 24 lines · Haiyue Wang

The DCF (Device Config Function) feature works as a standalone PMD, its hardware entity is the trusted VF with ID 0, and the software function is to control the flow setting of other VFs by the mailbox with PF.

It doesn't handle packet Rx/Tx related things. This PMD needs the iAVF virtchnl to send the ICE PF's AdminQ command.

Also for security, it needs to acquire the DCF capability from PF. The flow related things will be added later, it shares most of the ICE flow function. This mainly handles hardware initialization etc.

                              .-------------.
                            .-|             |
                          .-| |             |
                          | | |  iAVF PMD   |
                          | | |             |
                          | | |             |
                          | | '-------------'
                          | '-------------'
                          '-------------'
                         ^   Other VFs
                        /
                       / Flow Distribution

.------------------. /

Quoted 8 lines
 |                  |/  DCF cap req   .-------------.
 |      CVL         .  <----------    |             |
 |     Kernel       |  ---------->    |             |
 .                  .   DCF cap rsp   |   DCF PMD   |
 |                  |                 |             |
 '------------------'  <-----------   |             |
                         rte_flow     '-------------'
                                            VF0

It'd be clearer if this diagram keeps DCF PMD and iAVF PMD at the same level and CVL Kernel at the bottom, what do you think?

Quoted 67 lines

---

doc/guides/nics/ice.rst          |  47 +++
doc/guides/nics/img/ice_dcf.png  | Bin 0 -> 39168 bytes
drivers/common/Makefile          |   1 +
drivers/net/ice/Makefile         |   6 +
drivers/net/ice/ice_dcf.c        | 651 +++++++++++++++++++++++++++++++
drivers/net/ice/ice_dcf.h        |  61 +++
drivers/net/ice/ice_dcf_ethdev.c | 319 +++++++++++++++
drivers/net/ice/ice_dcf_ethdev.h |  33 ++
drivers/net/ice/ice_dcf_parent.c | 348 +++++++++++++++++
drivers/net/ice/meson.build      |   8 +-
mk/rte.app.mk                    |   1 +
11 files changed, 1473 insertions(+), 2 deletions(-)

create mode 100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

drivers/common/Makefile +0 -0
index 96bd7ac6e..df2e840cf 100644
@@ -31,6 +31,7 @@ DIRS-y += dpaax

endif

IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
ifneq (,$(findstring y,$(IAVF-y)))
DIRS-y += iavf
endif

drivers/net/ice/Makefile +0 -0
index e22c34287..643639a50 100644
@@ -11,9 +11,11 @@ LIB = librte_pmd_ice.a

CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/common/iavf

LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash +LDLIBS += -lrte_net -lrte_common_iavf

EXPORT_MAP := rte_pmd_ice_version.map

drivers/net/ice/Makefile +0 -0
@@ -84,6 +86,10 @@ ifeq ($(CC_AVX2_SUPPORT), 1)

endif
SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c

drivers/net/ice/Makefile +4 -0
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+
# install this header file
SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
drivers/net/ice/ice_dcf.c new file +0 -0
new file mode 100644
index 000000000..669122331

drivers/net/ice/ice_dcf.c line 2

Quoted 2 lines
drivers/net/ice/ice_dcf.c new file +2 -0
@@ -0,0 +1,651 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation

Should be 2020?

Quoted 191 lines
drivers/net/ice/ice_dcf.c new file +191 -0
+ */
+
+#include <sys/queue.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+
+#include <rte_pci.h>
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_ethdev_driver.h>
+#include <rte_ethdev_pci.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "ice_dcf.h"
+
+#define ICE_DCF_AQ_LEN     32
+#define ICE_DCF_AQ_BUF_SZ  4096
+
+#define ICE_DCF_ARQ_MAX_RETRIES 200
+#define ICE_DCF_ARQ_CHECK_TIME  2   /* msecs */
+
+#define ICE_DCF_VF_RES_BUF_SZ	\
+	(sizeof(struct virtchnl_vf_resource) +	\
+		IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource))
+
+static __rte_always_inline int
+ice_dcf_send_cmd_req_no_irq(struct ice_dcf_hw *hw, enum virtchnl_ops op,
+			    uint8_t *req_msg, uint16_t req_msglen)
+{
+	return iavf_aq_send_msg_to_pf(&hw->avf, op, IAVF_SUCCESS,
+				      req_msg, req_msglen, NULL);
+}
+
+static int
+ice_dcf_recv_cmd_rsp_no_irq(struct ice_dcf_hw *hw, enum virtchnl_ops op,
+			    uint8_t *rsp_msgbuf, uint16_t rsp_buflen,
+			    uint16_t *rsp_msglen)
+{
+	struct iavf_arq_event_info event;
+	enum virtchnl_ops v_op;
+	int i = 0;
+	int err;
+
+	event.buf_len = rsp_buflen;
+	event.msg_buf = rsp_msgbuf;
+
+	do {
+		err = iavf_clean_arq_element(&hw->avf, &event, NULL);
+		if (err != IAVF_SUCCESS)
+			goto again;
+
+		v_op = rte_le_to_cpu_32(event.desc.cookie_high);
+		if (v_op != op)
+			goto again;
+
+		if (rsp_msglen != NULL)
+			*rsp_msglen = event.msg_len;
+		return rte_le_to_cpu_32(event.desc.cookie_low);
+
+again:
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	return -EIO;
+}
+
+static __rte_always_inline void
+ice_dcf_aq_cmd_clear(struct ice_dcf_hw *hw, struct dcf_virtchnl_cmd *cmd)
+{
+	rte_spinlock_lock(&hw->vc_cmd_queue_lock);
+
+	TAILQ_REMOVE(&hw->vc_cmd_queue, cmd, next);
+
+	rte_spinlock_unlock(&hw->vc_cmd_queue_lock);
+}
+
+static __rte_always_inline void
+ice_dcf_vc_cmd_set(struct ice_dcf_hw *hw, struct dcf_virtchnl_cmd *cmd)
+{
+	cmd->v_ret = IAVF_ERR_NOT_READY;
+	cmd->rsp_msglen = 0;
+	cmd->pending = 1;
+
+	rte_spinlock_lock(&hw->vc_cmd_queue_lock);
+
+	TAILQ_INSERT_TAIL(&hw->vc_cmd_queue, cmd, next);
+
+	rte_spinlock_unlock(&hw->vc_cmd_queue_lock);
+}
+
+static __rte_always_inline int
+ice_dcf_vc_cmd_send(struct ice_dcf_hw *hw, struct dcf_virtchnl_cmd *cmd)
+{
+	return iavf_aq_send_msg_to_pf(&hw->avf,
+				      cmd->v_op, IAVF_SUCCESS,
+				      cmd->req_msg, cmd->req_msglen, NULL);
+}
+
+static __rte_always_inline void
+ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
+{
+	struct dcf_virtchnl_cmd *cmd;
+	enum virtchnl_ops v_op;
+	enum iavf_status v_ret;
+	uint16_t aq_op;
+
+	aq_op = rte_le_to_cpu_16(info->desc.opcode);
+	if (unlikely(aq_op != iavf_aqc_opc_send_msg_to_vf)) {
+		PMD_DRV_LOG(ERR,
+			    "Request %u is not supported yet", aq_op);
+		return;
+	}
+
+	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
+	if (unlikely(v_op == VIRTCHNL_OP_EVENT)) {
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
+		return;
+	}
+
+	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
+
+	rte_spinlock_lock(&hw->vc_cmd_queue_lock);
+
+	TAILQ_FOREACH(cmd, &hw->vc_cmd_queue, next) {
+		if (cmd->v_op == v_op && cmd->pending) {
+			cmd->v_ret = v_ret;
+			cmd->rsp_msglen = RTE_MIN(info->msg_len,
+						  cmd->rsp_buflen);
+			if (likely(cmd->rsp_msglen != 0))
+				rte_memcpy(cmd->rsp_msgbuf, info->msg_buf,
+					   cmd->rsp_msglen);
+
+			/* prevent compiler reordering */
+			rte_compiler_barrier();
+			cmd->pending = 0;
+			break;
+		}
+	}
+
+	rte_spinlock_unlock(&hw->vc_cmd_queue_lock);
+}
+
+static void
+ice_dcf_handle_virtchnl_msg(struct ice_dcf_hw *hw)
+{
+	struct iavf_arq_event_info info;
+	uint16_t pending = 1;
+	int ret;
+
+	info.buf_len = ICE_DCF_AQ_BUF_SZ;
+	info.msg_buf = hw->arq_buf;
+
+	while (pending) {
+		ret = iavf_clean_arq_element(&hw->avf, &info, &pending);
+		if (ret != IAVF_SUCCESS)
+			break;
+
+		ice_dcf_aq_cmd_handle(hw, &info);
+	}
+}
+
+static int
+ice_dcf_init_check_api_version(struct ice_dcf_hw *hw)
+{
+#define ICE_CPF_VIRTCHNL_VERSION_MAJOR_START	1
+#define ICE_CPF_VIRTCHNL_VERSION_MINOR_START	1
+	struct virtchnl_version_info version, *pver;
+	int err;
+
+	version.major = VIRTCHNL_VERSION_MAJOR;
+	version.minor = VIRTCHNL_VERSION_MINOR;
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_VERSION,
+					  (uint8_t *)&version, sizeof(version));
+	if (err) {
+		PMD_INIT_LOG(ERR, "Fail to send OP_VERSION");
+		return err;
+	}
+

drivers/net/ice/ice_dcf.c line 203

Quoted 10 lines
drivers/net/ice/ice_dcf.c new file +10 -0
+	pver = &hw->virtchnl_version;
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_VERSION,
+					  (uint8_t *)pver, sizeof(*pver), NULL);
+	if (err) {
+		PMD_INIT_LOG(ERR, "Fail to get response of OP_VERSION");
+		return -1;
+	}
+
+	PMD_DRV_LOG(DEBUG,
+		    "Peer PF API version: %u.%u", pver->major, pver->minor);

PMD_INIT_LOG

Quoted 10 lines
drivers/net/ice/ice_dcf.c new file +10 -0
+
+	if (pver->major < ICE_CPF_VIRTCHNL_VERSION_MAJOR_START ||
+	    (pver->major == ICE_CPF_VIRTCHNL_VERSION_MAJOR_START &&
+	     pver->minor < ICE_CPF_VIRTCHNL_VERSION_MINOR_START)) {
+		PMD_INIT_LOG(ERR,
+			     "VIRTCHNL API version should not be lower than (%u.%u)",
+			     ICE_CPF_VIRTCHNL_VERSION_MAJOR_START,
+			     ICE_CPF_VIRTCHNL_VERSION_MAJOR_START);
+		return -1;
+	} else if (pver->major > VIRTCHNL_VERSION_MAJOR ||

drivers/net/ice/ice_dcf.c line 223

Quoted 10 lines
drivers/net/ice/ice_dcf.c new file +10 -0
+		   (pver->major == VIRTCHNL_VERSION_MAJOR &&
+		    pver->minor > VIRTCHNL_VERSION_MINOR)) {
+		PMD_INIT_LOG(ERR,
+			     "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
+			     pver->major, pver->minor,
+			     VIRTCHNL_VERSION_MAJOR, VIRTCHNL_VERSION_MINOR);
+		return -1;
+	}
+
+	PMD_DRV_LOG(DEBUG, "Peer is supported PF host");

PMD_INIT_LOG

Quoted 611 lines
drivers/net/ice/ice_dcf.c new file +428 -0
+
+	return 0;
+}
+
+static int
+ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
+{
+	uint32_t caps;
+	int err, i;
+
+	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
+	       VF_BASE_MODE_OFFLOADS;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
+					  (uint8_t *)&caps, sizeof(caps));
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_GET_VF_RESOURCE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
+					  (uint8_t *)hw->vf_res,
+					  ICE_DCF_VF_RES_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_GET_VF_RESOURCE");
+		return -1;
+	}
+
+	iavf_vf_parse_hw_config(&hw->avf, hw->vf_res);
+
+	hw->vsi_res = NULL;
+	for (i = 0; i < hw->vf_res->num_vsis; i++) {
+		if (hw->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
+			hw->vsi_res = &hw->vf_res->vsi_res[i];
+	}
+
+	if (!hw->vsi_res) {
+		PMD_DRV_LOG(ERR, "no LAN VSI found");
+		return -1;
+	}
+
+	hw->vsi_id = hw->vsi_res->vsi_id;
+	PMD_DRV_LOG(DEBUG, "VSI ID is %u", hw->vsi_id);
+
+	return 0;
+}
+
+static int
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	if (len < sizeof(*vsi_map) || !vsi_map->num_vfs ||
+	    len < sizeof(*vsi_map) +
+			(vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0])) {
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+	if (!hw->vf_vsi_map) {
+		hw->num_vfs = vsi_map->num_vfs;
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
+	}
+
+	if (!hw->vf_vsi_map) {
+		PMD_DRV_LOG(ERR, "Fail to alloc memory for VSI context");
+		return -ENOMEM;
+	}
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
+{
+#define ICE_DCF_RESET_WAIT_CNT       50
+	struct iavf_hw *avf = &hw->avf;
+	int i, reset;
+
+	for (i = 0; i < ICE_DCF_RESET_WAIT_CNT; i++) {
+		reset = IAVF_READ_REG(avf, IAVF_VFGEN_RSTAT) &
+					IAVF_VFGEN_RSTAT_VFR_STATE_MASK;
+		reset = reset >> IAVF_VFGEN_RSTAT_VFR_STATE_SHIFT;
+
+		if (reset == VIRTCHNL_VFR_VFACTIVE ||
+		    reset == VIRTCHNL_VFR_COMPLETED)
+			break;
+
+		rte_delay_ms(20);
+	}
+
+	if (i >= ICE_DCF_RESET_WAIT_CNT)
+		return -1;
+
+	return 0;
+}
+
+static inline void
+ice_dcf_enable_irq0(struct ice_dcf_hw *hw)
+{
+	struct iavf_hw *avf = &hw->avf;
+
+	/* Enable admin queue interrupt trigger */
+	IAVF_WRITE_REG(avf, IAVF_VFINT_ICR0_ENA1,
+		       IAVF_VFINT_ICR0_ENA1_ADMINQ_MASK);
+	IAVF_WRITE_REG(avf, IAVF_VFINT_DYN_CTL01,
+		       IAVF_VFINT_DYN_CTL01_INTENA_MASK |
+		       IAVF_VFINT_DYN_CTL01_CLEARPBA_MASK |
+		       IAVF_VFINT_DYN_CTL01_ITR_INDX_MASK);
+
+	IAVF_WRITE_FLUSH(avf);
+}
+
+static inline void
+ice_dcf_disable_irq0(struct ice_dcf_hw *hw)
+{
+	struct iavf_hw *avf = &hw->avf;
+
+	/* Disable all interrupt types */
+	IAVF_WRITE_REG(avf, IAVF_VFINT_ICR0_ENA1, 0);
+	IAVF_WRITE_REG(avf, IAVF_VFINT_DYN_CTL01,
+		       IAVF_VFINT_DYN_CTL01_ITR_INDX_MASK);
+
+	IAVF_WRITE_FLUSH(avf);
+}
+
+static void
+ice_dcf_dev_interrupt_handler(void *param)
+{
+	struct ice_dcf_hw *hw = param;
+
+	ice_dcf_disable_irq0(hw);
+
+	ice_dcf_handle_virtchnl_msg(hw);
+
+	ice_dcf_enable_irq0(hw);
+}
+
+int
+ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
+			     struct dcf_virtchnl_cmd *cmd)
+{
+	int i = 0;
+	int err;
+
+	if ((cmd->req_msg && !cmd->req_msglen) ||
+	    (!cmd->req_msg && cmd->req_msglen) ||
+	    (cmd->rsp_msgbuf && !cmd->rsp_buflen) ||
+	    (!cmd->rsp_msgbuf && cmd->rsp_buflen))
+		return -EINVAL;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, cmd);
+
+	err = ice_dcf_vc_cmd_send(hw, cmd);
+	if (err) {
+		PMD_DRV_LOG(ERR, "fail to send cmd %d", cmd->v_op);
+		goto ret;
+	}
+
+	do {
+		if (!cmd->pending)
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (cmd->v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (%d) for cmd %d",
+			    i, cmd->v_ret, cmd->v_op);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+	return err;
+}
+
+int
+ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+		    void *buf, uint16_t buf_size)
+{
+	struct dcf_virtchnl_cmd desc_cmd, buff_cmd;
+	struct ice_dcf_hw *hw = dcf_hw;
+	int err = 0;
+	int i = 0;
+
+	if ((buf && !buf_size) || (!buf && buf_size) ||
+	    buf_size > ICE_DCF_AQ_BUF_SZ)
+		return -EINVAL;
+
+	desc_cmd.v_op = VIRTCHNL_OP_DCF_CMD_DESC;
+	desc_cmd.req_msglen = sizeof(*desc);
+	desc_cmd.req_msg = (uint8_t *)desc;
+	desc_cmd.rsp_buflen = sizeof(*desc);
+	desc_cmd.rsp_msgbuf = (uint8_t *)desc;
+
+	if (buf == NULL)
+		return ice_dcf_execute_virtchnl_cmd(hw, &desc_cmd);
+
+	desc->flags |= rte_cpu_to_le_16(ICE_AQ_FLAG_BUF);
+
+	buff_cmd.v_op = VIRTCHNL_OP_DCF_CMD_BUFF;
+	buff_cmd.req_msglen = buf_size;
+	buff_cmd.req_msg = buf;
+	buff_cmd.rsp_buflen = buf_size;
+	buff_cmd.rsp_msgbuf = buf;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, &desc_cmd);
+	ice_dcf_vc_cmd_set(hw, &buff_cmd);
+
+	if (ice_dcf_vc_cmd_send(hw, &desc_cmd) ||
+	    ice_dcf_vc_cmd_send(hw, &buff_cmd)) {
+		err = -1;
+		PMD_DRV_LOG(ERR, "fail to send OP_DCF_CMD_DESC/BUFF");
+		goto ret;
+	}
+
+	do {
+		if ((!desc_cmd.pending && !buff_cmd.pending) ||
+		    (!desc_cmd.pending && desc_cmd.v_ret != IAVF_SUCCESS) ||
+		    (!buff_cmd.pending && buff_cmd.v_ret != IAVF_SUCCESS))
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (desc_cmd.v_ret != IAVF_SUCCESS || buff_cmd.v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (desc: %d / buff: %d)",
+			    i, desc_cmd.v_ret, buff_cmd.v_ret);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, &desc_cmd);
+	ice_dcf_aq_cmd_clear(hw, &buff_cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	ice_dcf_enable_irq0(hw);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
+int
+ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	int ret;
+
+	hw->avf.hw_addr = pci_dev->mem_resource[0].addr;
+	hw->avf.back = hw;
+
+	hw->avf.bus.bus_id = pci_dev->addr.bus;
+	hw->avf.bus.device = pci_dev->addr.devid;
+	hw->avf.bus.func = pci_dev->addr.function;
+
+	hw->avf.device_id = pci_dev->id.device_id;
+	hw->avf.vendor_id = pci_dev->id.vendor_id;
+	hw->avf.subsystem_device_id = pci_dev->id.subsystem_device_id;
+	hw->avf.subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	hw->avf.aq.num_arq_entries = ICE_DCF_AQ_LEN;
+	hw->avf.aq.num_asq_entries = ICE_DCF_AQ_LEN;
+	hw->avf.aq.arq_buf_size = ICE_DCF_AQ_BUF_SZ;
+	hw->avf.aq.asq_buf_size = ICE_DCF_AQ_BUF_SZ;
+
+	rte_spinlock_init(&hw->vc_cmd_send_lock);
+	rte_spinlock_init(&hw->vc_cmd_queue_lock);
+	TAILQ_INIT(&hw->vc_cmd_queue);
+
+	hw->arq_buf = rte_zmalloc("arq_buf", ICE_DCF_AQ_BUF_SZ, 0);
+	if (hw->arq_buf == NULL) {
+		PMD_INIT_LOG(ERR, "unable to allocate AdminQ buffer memory");
+		goto err;
+	}
+
+	ret = iavf_set_mac_type(&hw->avf);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "set_mac_type failed: %d", ret);
+		goto err;
+	}
+
+	ret = ice_dcf_check_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "VF is still resetting");
+		goto err;
+	}
+
+	ret = iavf_init_adminq(&hw->avf);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "init_adminq failed: %d", ret);
+		goto err;
+	}
+
+	if (ice_dcf_init_check_api_version(hw)) {
+		PMD_INIT_LOG(ERR, "check_api version failed");
+		goto err_api;
+	}
+
+	hw->vf_res = rte_zmalloc("vf_res", ICE_DCF_VF_RES_BUF_SZ, 0);
+	if (hw->vf_res == NULL) {
+		PMD_INIT_LOG(ERR, "unable to allocate vf_res memory");
+		goto err_api;
+	}
+
+	if (ice_dcf_get_vf_resource(hw)) {
+		PMD_INIT_LOG(ERR, "Failed to get VF resource");
+		goto err_alloc;
+	}
+
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
+	rte_intr_callback_register(&pci_dev->intr_handle,
+				   ice_dcf_dev_interrupt_handler, hw);
+	rte_intr_enable(&pci_dev->intr_handle);
+	ice_dcf_enable_irq0(hw);
+
+	return 0;
+
+err_alloc:
+	rte_free(hw->vf_res);
+err_api:
+	iavf_shutdown_adminq(&hw->avf);
+err:
+	rte_free(hw->arq_buf);
+
+	return -1;
+}
+
+void
+ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	ice_dcf_disable_irq0(hw);
+	rte_intr_disable(intr_handle);
+	rte_intr_callback_unregister(intr_handle,
+				     ice_dcf_dev_interrupt_handler, hw);
+
+	ice_dcf_mode_disable(hw);
+	iavf_shutdown_adminq(&hw->avf);
+
+	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
+	rte_free(hw->vf_res);
+}
drivers/net/ice/ice_dcf.h new file +61 -0
new file mode 100644
index 000000000..58647d87f
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_H_
+#define _ICE_DCF_H_
+
+#include <rte_ethdev_driver.h>
+
+#include <iavf_prototype.h>
+#include <iavf_adminq_cmd.h>
+#include <iavf_type.h>
+
+#include "base/ice_type.h"
+#include "ice_logs.h"
+
+struct dcf_virtchnl_cmd {
+	TAILQ_ENTRY(dcf_virtchnl_cmd) next;
+
+	enum virtchnl_ops v_op;
+	enum iavf_status v_ret;
+
+	uint16_t req_msglen;
+	uint8_t *req_msg;
+
+	uint16_t rsp_msglen;
+	uint16_t rsp_buflen;
+	uint8_t *rsp_msgbuf;
+
+	volatile int pending;
+};
+
+struct ice_dcf_hw {
+	struct iavf_hw avf;
+
+	rte_spinlock_t vc_cmd_send_lock;
+	rte_spinlock_t vc_cmd_queue_lock;
+	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
+	uint8_t *arq_buf;
+
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
+	struct virtchnl_version_info virtchnl_version;
+	struct virtchnl_vf_resource *vf_res; /* VF resource */
+	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
+	uint16_t vsi_id;
+};
+
+int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
+				 struct dcf_virtchnl_cmd *cmd);
+int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
+int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
+void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
+
+#endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c new file +110 -0
new file mode 100644
index 000000000..f65b962d4
@@ -0,0 +1,319 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include <rte_interrupts.h>
+#include <rte_debug.h>
+#include <rte_pci.h>
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_ethdev_pci.h>
+#include <rte_kvargs.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include <iavf_devids.h>
+
+#include "ice_generic_flow.h"
+#include "ice_dcf_ethdev.h"
+
+static uint16_t
+ice_dcf_recv_pkts(__rte_unused void *rx_queue,
+		  __rte_unused struct rte_mbuf **bufs,
+		  __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
+static uint16_t
+ice_dcf_xmit_pkts(__rte_unused void *tx_queue,
+		  __rte_unused struct rte_mbuf **bufs,
+		  __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_start(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_UP;
+
+	return 0;
+}
+
+static void
+ice_dcf_dev_stop(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+}
+
+static int
+ice_dcf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_info_get(struct rte_eth_dev *dev,
+		     struct rte_eth_dev_info *dev_info)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	dev_info->max_mac_addrs = 1;
+	dev_info->max_rx_pktlen = (uint32_t)-1;
+	dev_info->max_rx_queues = RTE_DIM(adapter->rxqs);
+	dev_info->max_tx_queues = RTE_DIM(adapter->txqs);
+
+	return 0;
+}
+
+static int
+ice_dcf_stats_get(__rte_unused struct rte_eth_dev *dev,
+		  __rte_unused struct rte_eth_stats *igb_stats)
+{
+	return 0;
+}
+
+static int
+ice_dcf_stats_reset(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_promiscuous_enable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_promiscuous_disable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_allmulticast_enable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_allmulticast_disable(__rte_unused struct rte_eth_dev *dev)

drivers/net/ice/ice_dcf_ethdev.c line 120

Quoted 10 lines
drivers/net/ice/ice_dcf_ethdev.c new file +10 -0
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_filter_ctrl(struct rte_eth_dev *dev,
+			enum rte_filter_type filter_type,
+			__rte_unused enum rte_filter_op filter_op,
+			__rte_unused void *arg)
+{

legacy filter API will be deprecated, I think we should avoid adding support in new PMD.

Quoted 100 lines
drivers/net/ice/ice_dcf_ethdev.c new file +100 -0
+	int ret = 0;
+
+	if (!dev)
+		return -EINVAL;
+
+	switch (filter_type) {
+	default:
+		PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+			    filter_type);
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static void
+ice_dcf_dev_close(struct rte_eth_dev *dev)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return;
+
+	dev->dev_ops = NULL;
+	dev->rx_pkt_burst = NULL;
+	dev->tx_pkt_burst = NULL;
+
+	ice_dcf_uninit_parent_adapter(dev);
+	ice_dcf_uninit_hw(dev, &adapter->real_hw);
+}
+
+static void
+ice_dcf_queue_release(__rte_unused void *q)
+{
+}
+
+static int
+ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev,
+		    __rte_unused int wait_to_complete)
+{
+	return 0;
+}
+
+static int
+ice_dcf_rx_queue_setup(struct rte_eth_dev *dev,
+		       uint16_t rx_queue_id,
+		       __rte_unused uint16_t nb_rx_desc,
+		       __rte_unused unsigned int socket_id,
+		       __rte_unused const struct rte_eth_rxconf *rx_conf,
+		       __rte_unused struct rte_mempool *mb_pool)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	dev->data->rx_queues[rx_queue_id] = &adapter->rxqs[rx_queue_id];
+
+	return 0;
+}
+
+static int
+ice_dcf_tx_queue_setup(struct rte_eth_dev *dev,
+		       uint16_t tx_queue_id,
+		       __rte_unused uint16_t nb_tx_desc,
+		       __rte_unused unsigned int socket_id,
+		       __rte_unused const struct rte_eth_txconf *tx_conf)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	dev->data->tx_queues[tx_queue_id] = &adapter->txqs[tx_queue_id];
+
+	return 0;
+}
+
+static const struct eth_dev_ops ice_dcf_eth_dev_ops = {
+	.dev_start               = ice_dcf_dev_start,
+	.dev_stop                = ice_dcf_dev_stop,
+	.dev_close               = ice_dcf_dev_close,
+	.dev_configure           = ice_dcf_dev_configure,
+	.dev_infos_get           = ice_dcf_dev_info_get,
+	.rx_queue_setup          = ice_dcf_rx_queue_setup,
+	.tx_queue_setup          = ice_dcf_tx_queue_setup,
+	.rx_queue_release        = ice_dcf_queue_release,
+	.tx_queue_release        = ice_dcf_queue_release,
+	.link_update             = ice_dcf_link_update,
+	.stats_get               = ice_dcf_stats_get,
+	.stats_reset             = ice_dcf_stats_reset,
+	.promiscuous_enable      = ice_dcf_dev_promiscuous_enable,
+	.promiscuous_disable     = ice_dcf_dev_promiscuous_disable,
+	.allmulticast_enable     = ice_dcf_dev_allmulticast_enable,
+	.allmulticast_disable    = ice_dcf_dev_allmulticast_disable,
+	.filter_ctrl             = ice_dcf_dev_filter_ctrl,
+};
+
+static int
+ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+
+	eth_dev->dev_ops = &ice_dcf_eth_dev_ops;
+	eth_dev->rx_pkt_burst = ice_dcf_recv_pkts;

drivers/net/ice/ice_dcf_ethdev.c line 230

Quoted 10 lines
drivers/net/ice/ice_dcf_ethdev.c new file +10 -0
+	eth_dev->tx_pkt_burst = ice_dcf_xmit_pkts;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
+	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to init DCF hardware");

Use PMD_INIT_LOG instead.

drivers/net/ice/ice_dcf_ethdev.c line 235

Quoted 5 lines
drivers/net/ice/ice_dcf_ethdev.c new file +5 -0
+		return -1;
+	}
+
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to init DCF parent adapter");

Use PMD_INIT_LOG instead.

Quoted 36 lines
drivers/net/ice/ice_dcf_ethdev.c new file +36 -0
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	ice_dcf_dev_close(eth_dev);
+
+	return 0;
+}
+
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;

drivers/net/ice/ice_dcf_ethdev.c line 281

Quoted 10 lines
drivers/net/ice/ice_dcf_ethdev.c new file +10 -0
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);

Need error handing for failure case.

drivers/net/ice/ice_dcf_ethdev.c line 292

Quoted 11 lines
drivers/net/ice/ice_dcf_ethdev.c new file +11 -0
+
+	rte_kvargs_free(kvlist);
+
+	return enable;
+}
+
+static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
+			     struct rte_pci_device *pci_dev)
+{
+	if (!check_cap_dcf_enable(pci_dev->device.devargs))
+		return 1; /* continue to probe */

I think the code is self explanatory, this straightforward comment is unnecessary.

Quoted 110 lines
drivers/net/ice/ice_dcf_ethdev.c new file +27 -0
+
+	return rte_eth_dev_pci_generic_probe(pci_dev,
+					     sizeof(struct ice_dcf_adapter),
+					     ice_dcf_dev_init);
+}
+
+static int eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_dev_uninit);
+}
+
+static const struct rte_pci_id pci_id_ice_dcf_map[] = {
+	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static struct rte_pci_driver rte_ice_dcf_pmd = {
+	.id_table = pci_id_ice_dcf_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = eth_ice_dcf_pci_probe,
+	.remove = eth_ice_dcf_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_ice_dcf, rte_ice_dcf_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_ice_dcf, pci_id_ice_dcf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ice_dcf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, "cap=dcf");
drivers/net/ice/ice_dcf_ethdev.h new file +33 -0
new file mode 100644
index 000000000..e95266599
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_ETHDEV_H_
+#define _ICE_DCF_ETHDEV_H_
+
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
+#include "ice_ethdev.h"
+#include "ice_dcf.h"
+
+#define ICE_DCF_MAX_RINGS  1
+
+struct ice_dcf_queue {
+	uint64_t dummy;
+};
+
+struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
+	struct ice_dcf_hw real_hw;
+	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
+	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
+};
+
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
+#endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +38 -0
new file mode 100644
index 000000000..bca9cd34a
@@ -0,0 +1,348 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <rte_alarm.h>
+
+#include "ice_dcf_ethdev.h"
+#include "ice_generic_flow.h"
+
+#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL	100000 /* us */
+
+static __rte_always_inline void
+ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
+		       uint16_t vsi_map)
+{
+	struct ice_vsi_ctx *vsi_ctx;
+
+	if (unlikely(vsi_handle >= ICE_MAX_VSI)) {
+		PMD_DRV_LOG(ERR, "Invalid vsi handle %u", vsi_handle);
+		return;
+	}
+
+	vsi_ctx = hw->vsi_ctx[vsi_handle];
+
+	if (vsi_map & VIRTCHNL_DCF_VF_VSI_VALID) {
+		if (!vsi_ctx)
+			vsi_ctx = ice_malloc(hw, sizeof(*vsi_ctx));
+
+		if (!vsi_ctx) {
+			PMD_DRV_LOG(ERR, "No memory for vsi context %u",
+				    vsi_handle);
+			return;
+		}
+
+		vsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>

drivers/net/ice/ice_dcf_parent.c line 48

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+					      VIRTCHNL_DCF_VF_VSI_ID_S;
+		hw->vsi_ctx[vsi_handle] = vsi_ctx;
+
+		PMD_DRV_LOG(DEBUG, "VF%u is assigned with vsi number %u",
+			    vsi_handle, vsi_ctx->vsi_num);
+	} else {
+		hw->vsi_ctx[vsi_handle] = NULL;
+
+		if (vsi_ctx)
+			ice_free(hw, vsi_ctx);

Doesn't need to check vsi_ctx is NUll or not, ice_free (rte_free) would do it inside.

Quoted 110 lines
drivers/net/ice/ice_dcf_parent.c new file +110 -0
+
+		PMD_DRV_LOG(NOTICE, "VF%u is disabled", vsi_handle);
+	}
+}
+
+static void
+ice_dcf_update_vf_vsi_map(struct ice_hw *hw, uint16_t num_vfs,
+			  uint16_t *vf_vsi_map)
+{
+	uint16_t vf_id;
+
+	for (vf_id = 0; vf_id < num_vfs; vf_id++)
+		ice_dcf_update_vsi_ctx(hw, vf_id, vf_vsi_map[vf_id]);
+}
+
+static void
+ice_dcf_vsi_update_service_handler(void *param)
+{
+	struct ice_dcf_hw *hw = param;
+
+	if (!ice_dcf_handle_vsi_update_event(hw)) {
+		struct ice_dcf_adapter *dcf_ad =
+			container_of(hw, struct ice_dcf_adapter, real_hw);
+
+		ice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw,
+					  hw->num_vfs, hw->vf_vsi_map);
+	}
+}
+
+void
+ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+			    uint8_t *msg, uint16_t msglen)
+{
+	struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;
+
+	if (msglen < sizeof(struct virtchnl_pf_event)) {
+		PMD_DRV_LOG(DEBUG, "Invalid event message length : %u", msglen);
+		return;
+	}
+
+	switch (pf_msg->event) {
+	case VIRTCHNL_EVENT_RESET_IMPENDING:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL * 2,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);
+		break;
+	case VIRTCHNL_EVENT_LINK_CHANGE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
+		break;
+	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
+		break;
+	case VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE event : VF%u with VSI num %u",
+			    pf_msg->event_data.vf_vsi_map.vf_id,
+			    pf_msg->event_data.vf_vsi_map.vsi_id);
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event);
+		break;
+	}
+}
+
+static int
+ice_dcf_init_parent_hw(struct ice_hw *hw)
+{
+	struct ice_aqc_get_phy_caps_data *pcaps;
+	enum ice_status status;
+
+	status = ice_aq_get_fw_ver(hw, NULL);
+	if (status)
+		return status;
+
+	status = ice_get_caps(hw);
+	if (status)
+		return status;
+
+	hw->port_info = (struct ice_port_info *)
+			ice_malloc(hw, sizeof(*hw->port_info));
+	if (!hw->port_info)
+		return ICE_ERR_NO_MEMORY;
+
+	/* set the back pointer to HW */
+	hw->port_info->hw = hw;
+
+	/* Initialize port_info struct with switch configuration data */
+	status = ice_get_initial_sw_cfg(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	pcaps = (struct ice_aqc_get_phy_caps_data *)
+		ice_malloc(hw, sizeof(*pcaps));
+	if (!pcaps) {
+		status = ICE_ERR_NO_MEMORY;
+		goto err_unroll_alloc;
+	}
+
+	/* Initialize port_info struct with PHY capabilities */
+	status = ice_aq_get_phy_caps(hw->port_info, false,
+				     ICE_AQC_REPORT_TOPO_CAP, pcaps, NULL);
+	ice_free(hw, pcaps);
+	if (status)
+		goto err_unroll_alloc;
+
+	/* Initialize port_info struct with link information */
+	status = ice_aq_get_link_info(hw->port_info, false, NULL, NULL);
+	if (status)
+		goto err_unroll_alloc;

drivers/net/ice/ice_dcf_parent.c line 168

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+
+	status = ice_init_fltr_mgmt_struct(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	status = ice_init_hw_tbls(hw);
+	if (status)
+		goto err_unroll_fltr_mgmt_struct;
+
+	PMD_DRV_LOG(INFO,

PMD_INIT_LOG

Quoted 15 lines
drivers/net/ice/ice_dcf_parent.c new file +15 -0
+		    "firmware %d.%d.%d api %d.%d.%d build 0x%08x",
+		    hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch,
+		    hw->api_maj_ver, hw->api_min_ver, hw->api_patch,
+		    hw->fw_build);
+
+	return ICE_SUCCESS;
+
+err_unroll_fltr_mgmt_struct:
+	ice_cleanup_fltr_mgmt_struct(hw);
+err_unroll_alloc:
+	ice_free(hw, hw->port_info);
+	hw->port_info = NULL;
+
+	return status;
+}

drivers/net/ice/ice_dcf_parent.c line 193

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+
+static void ice_dcf_uninit_parent_hw(struct ice_hw *hw)
+{
+	ice_cleanup_fltr_mgmt_struct(hw);
+
+	ice_free_seg(hw);
+	ice_free_hw_tbls(hw);
+
+	if (hw->port_info) {
+		ice_free(hw, hw->port_info);

Doesn't need to check whether hw->port_info is NULL or not, ice_free (rte_free) would do it inside.

Quoted 101 lines
drivers/net/ice/ice_dcf_parent.c new file +101 -0
+		hw->port_info = NULL;
+	}
+
+	ice_clear_all_vsi_ctx(hw);
+}
+
+static int
+ice_dcf_request_pkg_name(struct ice_hw *hw, char *pkg_name)
+{
+	struct ice_dcf_adapter *dcf_adapter =
+			container_of(hw, struct ice_dcf_adapter, parent.hw);
+
+	/* TODO: check with DSN firstly by iAVF */
+	PMD_DRV_LOG(DEBUG,
+		    "DCF VSI_ID = %u",
+		    dcf_adapter->real_hw.vsi_id);
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_UPDATES);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_DEFAULT);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	return -1;
+}
+
+static int
+ice_dcf_load_pkg(struct ice_hw *hw)
+{
+	char pkg_name[ICE_MAX_PKG_FILENAME_SIZE];
+	uint8_t *pkg_buf;
+	uint32_t buf_len;
+	struct stat st;
+	FILE *fp;
+	int err;
+
+	if (ice_dcf_request_pkg_name(hw, pkg_name)) {
+		PMD_INIT_LOG(ERR, "failed to locate the package file");
+		return -ENOENT;
+	}
+
+	PMD_INIT_LOG(DEBUG, "DDP package name: %s", pkg_name);
+
+	err = stat(pkg_name, &st);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to get file status");
+		return err;
+	}
+
+	buf_len = st.st_size;
+	pkg_buf = rte_malloc(NULL, buf_len, 0);
+	if (!pkg_buf) {
+		PMD_INIT_LOG(ERR, "failed to allocate buffer of size %u for package",
+			     buf_len);
+		return -1;
+	}
+
+	fp = fopen(pkg_name, "rb");
+	if (!fp)  {
+		PMD_INIT_LOG(ERR, "failed to open file: %s", pkg_name);
+		err = -1;
+		goto ret;
+	}
+
+	err = fread(pkg_buf, buf_len, 1, fp);
+	fclose(fp);
+	if (err != 1) {
+		PMD_INIT_LOG(ERR, "failed to read package data");
+		err = -1;
+		goto ret;
+	}
+
+	err = ice_copy_and_init_pkg(hw, pkg_buf, buf_len);
+	if (err)
+		PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d", err);
+
+ret:
+	rte_free(pkg_buf);
+	return err;
+}
+
+int
+ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+	struct ice_dcf_hw *hw = &adapter->real_hw;
+	const struct rte_ether_addr *mac;
+	int err;
+
+	parent_adapter->eth_dev = eth_dev;
+	parent_adapter->pf.adapter = parent_adapter;
+	parent_adapter->pf.dev_data = eth_dev->data;
+	parent_hw->back = parent_adapter;
+	parent_hw->mac_type = ICE_MAC_GENERIC;
+	parent_hw->vendor_id = ICE_INTEL_VENDOR_ID;

drivers/net/ice/ice_dcf_parent.c line 304

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+
+	ice_init_lock(&parent_hw->adminq.sq_lock);
+	ice_init_lock(&parent_hw->adminq.rq_lock);
+	parent_hw->aq_send_cmd_fn = ice_dcf_send_aq_cmd;
+	parent_hw->aq_send_cmd_param = &adapter->real_hw;
+	parent_hw->dcf_enabled = true;
+
+	err = ice_dcf_init_parent_hw(parent_hw);
+	if (err) {
+		PMD_DRV_LOG(ERR, "failed to init the DCF parent hardware with error %d",

PMD_INIT_LOG

drivers/net/ice/ice_dcf_parent.c line 311

Quoted 7 lines
drivers/net/ice/ice_dcf_parent.c new file +7 -0
+			    err);
+		return err;
+	}
+
+	err = ice_dcf_load_pkg(parent_hw);
+	if (err) {
+		PMD_DRV_LOG(ERR, "failed to load package with error %d",

PMD_INIT_LOG

Quoted 76 lines
drivers/net/ice/ice_dcf_parent.c new file +37 -0
+			    err);
+		goto uninit_hw;
+	}
+	parent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);
+
+	ice_dcf_update_vf_vsi_map(parent_hw,
+				  hw->num_vfs, hw->vf_vsi_map);
+
+	mac = (const struct rte_ether_addr *)hw->avf.mac.addr;
+	if (rte_is_valid_assigned_ether_addr(mac))
+		rte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);
+	else
+		rte_eth_random_addr(parent_adapter->pf.dev_addr.addr_bytes);
+
+	eth_dev->data->mac_addrs = &parent_adapter->pf.dev_addr;
+
+	return 0;
+
+uninit_hw:
+	ice_dcf_uninit_parent_hw(parent_hw);
+	return err;
+}
+
+void
+ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+
+	eth_dev->data->mac_addrs = NULL;
+
+	rte_eal_alarm_cancel(ice_dcf_vsi_update_service_handler,
+			     &adapter->real_hw);
+
+	ice_dcf_uninit_parent_hw(parent_hw);
+}
drivers/net/ice/meson.build +2 -2
index f9e897bbc..0df8ddc0f 100644
@@ -15,8 +15,8 @@ sources = files(
 	'ice_hash.c'
 	)
 
-deps += ['hash']
-includes += include_directories('base')
+deps += ['hash', 'net', 'common_iavf']
+includes += include_directories('base', '../../common/iavf')
 

if arch_subdir == 'x86'

	sources += files('ice_rxtx_vec_sse.c')
drivers/net/ice/meson.build +0 -0
@@ -37,4 +37,8 @@ if arch_subdir == 'x86'
 	endif

endif

drivers/net/ice/meson.build +4 -0
+sources += files('ice_dcf.c',
+		 'ice_dcf_parent.c',
+		 'ice_dcf_ethdev.c')
+

install_headers('rte_pmd_ice.h')

mk/rte.app.mk +0 -0
index d295ca0a5..f3798a09f 100644
@@ -185,6 +185,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e

_LDLIBS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) += -lrte_pmd_iavf
_LDLIBS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += -lrte_pmd_ice
IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
ifeq ($(findstring y,$(IAVF-y)),y)
_LDLIBS-y += -lrte_common_iavf
endif

Signature · 1 line
2.25.1
#12 lore raw

Re: [dpdk-dev] [PATCH v1 3/4] net/ice: add the DCF framework

Quoted 42 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Tuesday, March 10, 2020 12:17
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v1 3/4] net/ice: add the DCF framework

Quoted 24 lines · Haiyue Wang

The DCF (Device Config Function) feature works as a standalone PMD, its hardware entity is the trusted VF with ID 0, and the software function is to control the flow setting of other VFs by the mailbox with PF.

It doesn't handle packet Rx/Tx related things. This PMD needs the iAVF virtchnl to send the ICE PF's AdminQ command.

Also for security, it needs to acquire the DCF capability from PF. The flow related things will be added later, it shares most of the ICE flow function. This mainly handles hardware initialization etc.

                              .-------------.
                            .-|             |
                          .-| |             |
                          | | |  iAVF PMD   |
                          | | |             |
                          | | |             |
                          | | '-------------'
                          | '-------------'
                          '-------------'
                         ^   Other VFs
                        /
                       / Flow Distribution

.------------------. /

Quoted 8 lines
 |                  |/  DCF cap req   .-------------.
 |      CVL         .  <----------    |             |
 |     Kernel       |  ---------->    |             |
 .                  .   DCF cap rsp   |   DCF PMD   |
 |                  |                 |             |
 '------------------'  <-----------   |             |
                         rte_flow     '-------------'
                                            VF0
Quoted 3 lines

It'd be clearer if this diagram keeps DCF PMD and iAVF PMD at the same level and CVL Kernel at the bottom, what do you think?

Yes, and will remove this redundant message, since the ice guide has a image for this, it has rich information. ;-)

Quoted 61 lines
Quoted 61 lines

---

doc/guides/nics/ice.rst          |  47 +++
doc/guides/nics/img/ice_dcf.png  | Bin 0 -> 39168 bytes
drivers/common/Makefile          |   1 +
drivers/net/ice/Makefile         |   6 +
drivers/net/ice/ice_dcf.c        | 651 +++++++++++++++++++++++++++++++
drivers/net/ice/ice_dcf.h        |  61 +++
drivers/net/ice/ice_dcf_ethdev.c | 319 +++++++++++++++
drivers/net/ice/ice_dcf_ethdev.h |  33 ++
drivers/net/ice/ice_dcf_parent.c | 348 +++++++++++++++++
drivers/net/ice/meson.build      |   8 +-
mk/rte.app.mk                    |   1 +
11 files changed, 1473 insertions(+), 2 deletions(-)

create mode 100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

drivers/common/Makefile +0 -0
index 96bd7ac6e..df2e840cf 100644
@@ -31,6 +31,7 @@ DIRS-y += dpaax

endif

IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
ifneq (,$(findstring y,$(IAVF-y)))
DIRS-y += iavf
endif

drivers/net/ice/Makefile +0 -0
index e22c34287..643639a50 100644
@@ -11,9 +11,11 @@ LIB = librte_pmd_ice.a

CFLAGS += -O3
CFLAGS += $(WERROR_FLAGS)
CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/common/iavf

LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash +LDLIBS += -lrte_net -lrte_common_iavf

EXPORT_MAP := rte_pmd_ice_version.map

drivers/net/ice/Makefile +0 -0
@@ -84,6 +86,10 @@ ifeq ($(CC_AVX2_SUPPORT), 1)

endif
SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c

drivers/net/ice/Makefile +4 -0
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+
# install this header file
SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
Quoted 11 lines

drivers/net/ice/ice_dcf.c line 2

Quoted 8 lines
drivers/net/ice/ice_dcf.c new file +2 -0
new file mode 100644
index 000000000..669122331
@@ -0,0 +1,651 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation

Should be 2020?

Yes, forget to update.

Quoted 195 lines
Quoted 195 lines
drivers/net/ice/ice_dcf.c new file +195 -0
+ */
+
+#include <sys/queue.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <inttypes.h>
+#include <rte_byteorder.h>
+#include <rte_common.h>
+
+#include <rte_pci.h>
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_ethdev_driver.h>
+#include <rte_ethdev_pci.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include "ice_dcf.h"
+
+#define ICE_DCF_AQ_LEN     32
+#define ICE_DCF_AQ_BUF_SZ  4096
+
+#define ICE_DCF_ARQ_MAX_RETRIES 200
+#define ICE_DCF_ARQ_CHECK_TIME  2   /* msecs */
+
+#define ICE_DCF_VF_RES_BUF_SZ	\
+	(sizeof(struct virtchnl_vf_resource) +	\
+		IAVF_MAX_VF_VSI * sizeof(struct virtchnl_vsi_resource))
+
+static __rte_always_inline int
+ice_dcf_send_cmd_req_no_irq(struct ice_dcf_hw *hw, enum virtchnl_ops op,
+			    uint8_t *req_msg, uint16_t req_msglen)
+{
+	return iavf_aq_send_msg_to_pf(&hw->avf, op, IAVF_SUCCESS,
+				      req_msg, req_msglen, NULL);
+}
+
+static int
+ice_dcf_recv_cmd_rsp_no_irq(struct ice_dcf_hw *hw, enum virtchnl_ops op,
+			    uint8_t *rsp_msgbuf, uint16_t rsp_buflen,
+			    uint16_t *rsp_msglen)
+{
+	struct iavf_arq_event_info event;
+	enum virtchnl_ops v_op;
+	int i = 0;
+	int err;
+
+	event.buf_len = rsp_buflen;
+	event.msg_buf = rsp_msgbuf;
+
+	do {
+		err = iavf_clean_arq_element(&hw->avf, &event, NULL);
+		if (err != IAVF_SUCCESS)
+			goto again;
+
+		v_op = rte_le_to_cpu_32(event.desc.cookie_high);
+		if (v_op != op)
+			goto again;
+
+		if (rsp_msglen != NULL)
+			*rsp_msglen = event.msg_len;
+		return rte_le_to_cpu_32(event.desc.cookie_low);
+
+again:
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	return -EIO;
+}
+
+static __rte_always_inline void
+ice_dcf_aq_cmd_clear(struct ice_dcf_hw *hw, struct dcf_virtchnl_cmd *cmd)
+{
+	rte_spinlock_lock(&hw->vc_cmd_queue_lock);
+
+	TAILQ_REMOVE(&hw->vc_cmd_queue, cmd, next);
+
+	rte_spinlock_unlock(&hw->vc_cmd_queue_lock);
+}
+
+static __rte_always_inline void
+ice_dcf_vc_cmd_set(struct ice_dcf_hw *hw, struct dcf_virtchnl_cmd *cmd)
+{
+	cmd->v_ret = IAVF_ERR_NOT_READY;
+	cmd->rsp_msglen = 0;
+	cmd->pending = 1;
+
+	rte_spinlock_lock(&hw->vc_cmd_queue_lock);
+
+	TAILQ_INSERT_TAIL(&hw->vc_cmd_queue, cmd, next);
+
+	rte_spinlock_unlock(&hw->vc_cmd_queue_lock);
+}
+
+static __rte_always_inline int
+ice_dcf_vc_cmd_send(struct ice_dcf_hw *hw, struct dcf_virtchnl_cmd *cmd)
+{
+	return iavf_aq_send_msg_to_pf(&hw->avf,
+				      cmd->v_op, IAVF_SUCCESS,
+				      cmd->req_msg, cmd->req_msglen, NULL);
+}
+
+static __rte_always_inline void
+ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
+{
+	struct dcf_virtchnl_cmd *cmd;
+	enum virtchnl_ops v_op;
+	enum iavf_status v_ret;
+	uint16_t aq_op;
+
+	aq_op = rte_le_to_cpu_16(info->desc.opcode);
+	if (unlikely(aq_op != iavf_aqc_opc_send_msg_to_vf)) {
+		PMD_DRV_LOG(ERR,
+			    "Request %u is not supported yet", aq_op);
+		return;
+	}
+
+	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
+	if (unlikely(v_op == VIRTCHNL_OP_EVENT)) {
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
+		return;
+	}
+
+	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
+
+	rte_spinlock_lock(&hw->vc_cmd_queue_lock);
+
+	TAILQ_FOREACH(cmd, &hw->vc_cmd_queue, next) {
+		if (cmd->v_op == v_op && cmd->pending) {
+			cmd->v_ret = v_ret;
+			cmd->rsp_msglen = RTE_MIN(info->msg_len,
+						  cmd->rsp_buflen);
+			if (likely(cmd->rsp_msglen != 0))
+				rte_memcpy(cmd->rsp_msgbuf, info->msg_buf,
+					   cmd->rsp_msglen);
+
+			/* prevent compiler reordering */
+			rte_compiler_barrier();
+			cmd->pending = 0;
+			break;
+		}
+	}
+
+	rte_spinlock_unlock(&hw->vc_cmd_queue_lock);
+}
+
+static void
+ice_dcf_handle_virtchnl_msg(struct ice_dcf_hw *hw)
+{
+	struct iavf_arq_event_info info;
+	uint16_t pending = 1;
+	int ret;
+
+	info.buf_len = ICE_DCF_AQ_BUF_SZ;
+	info.msg_buf = hw->arq_buf;
+
+	while (pending) {
+		ret = iavf_clean_arq_element(&hw->avf, &info, &pending);
+		if (ret != IAVF_SUCCESS)
+			break;
+
+		ice_dcf_aq_cmd_handle(hw, &info);
+	}
+}
+
+static int
+ice_dcf_init_check_api_version(struct ice_dcf_hw *hw)
+{
+#define ICE_CPF_VIRTCHNL_VERSION_MAJOR_START	1
+#define ICE_CPF_VIRTCHNL_VERSION_MINOR_START	1
+	struct virtchnl_version_info version, *pver;
+	int err;
+
+	version.major = VIRTCHNL_VERSION_MAJOR;
+	version.minor = VIRTCHNL_VERSION_MINOR;
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_VERSION,
+					  (uint8_t *)&version, sizeof(version));
+	if (err) {
+		PMD_INIT_LOG(ERR, "Fail to send OP_VERSION");
+		return err;
+	}
+
+	pver = &hw->virtchnl_version;
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_VERSION,
+					  (uint8_t *)pver, sizeof(*pver), NULL);
+	if (err) {
Quoted 9 lines

drivers/net/ice/ice_dcf.c line 203

Quoted 6 lines
drivers/net/ice/ice_dcf.c new file +6 -0
+		PMD_INIT_LOG(ERR, "Fail to get response of OP_VERSION");
+		return -1;
+	}
+
+	PMD_DRV_LOG(DEBUG,
+		    "Peer PF API version: %u.%u", pver->major, pver->minor);

PMD_INIT_LOG

Fixed in v2

Quoted 14 lines
Quoted 14 lines
drivers/net/ice/ice_dcf.c new file +14 -0
+
+	if (pver->major < ICE_CPF_VIRTCHNL_VERSION_MAJOR_START ||
+	    (pver->major == ICE_CPF_VIRTCHNL_VERSION_MAJOR_START &&
+	     pver->minor < ICE_CPF_VIRTCHNL_VERSION_MINOR_START)) {
+		PMD_INIT_LOG(ERR,
+			     "VIRTCHNL API version should not be lower than (%u.%u)",
+			     ICE_CPF_VIRTCHNL_VERSION_MAJOR_START,
+			     ICE_CPF_VIRTCHNL_VERSION_MAJOR_START);
+		return -1;
+	} else if (pver->major > VIRTCHNL_VERSION_MAJOR ||
+		   (pver->major == VIRTCHNL_VERSION_MAJOR &&
+		    pver->minor > VIRTCHNL_VERSION_MINOR)) {
+		PMD_INIT_LOG(ERR,
+			     "PF/VF API version mismatch:(%u.%u)-(%u.%u)",
Quoted 9 lines

drivers/net/ice/ice_dcf.c line 223

Quoted 6 lines
drivers/net/ice/ice_dcf.c new file +6 -0
+			     pver->major, pver->minor,
+			     VIRTCHNL_VERSION_MAJOR, VIRTCHNL_VERSION_MINOR);
+		return -1;
+	}
+
+	PMD_DRV_LOG(DEBUG, "Peer is supported PF host");

PMD_INIT_LOG

Fixed in v2, as below

Quoted 616 lines
Quoted 616 lines
drivers/net/ice/ice_dcf.c new file +428 -0
+
+	return 0;
+}
+
+static int
+ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
+{
+	uint32_t caps;
+	int err, i;
+
+	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
+	       VF_BASE_MODE_OFFLOADS;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
+					  (uint8_t *)&caps, sizeof(caps));
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_GET_VF_RESOURCE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
+					  (uint8_t *)hw->vf_res,
+					  ICE_DCF_VF_RES_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_GET_VF_RESOURCE");
+		return -1;
+	}
+
+	iavf_vf_parse_hw_config(&hw->avf, hw->vf_res);
+
+	hw->vsi_res = NULL;
+	for (i = 0; i < hw->vf_res->num_vsis; i++) {
+		if (hw->vf_res->vsi_res[i].vsi_type == VIRTCHNL_VSI_SRIOV)
+			hw->vsi_res = &hw->vf_res->vsi_res[i];
+	}
+
+	if (!hw->vsi_res) {
+		PMD_DRV_LOG(ERR, "no LAN VSI found");
+		return -1;
+	}
+
+	hw->vsi_id = hw->vsi_res->vsi_id;
+	PMD_DRV_LOG(DEBUG, "VSI ID is %u", hw->vsi_id);
+
+	return 0;
+}
+
+static int
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	if (len < sizeof(*vsi_map) || !vsi_map->num_vfs ||
+	    len < sizeof(*vsi_map) +
+			(vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0])) {
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+	if (!hw->vf_vsi_map) {
+		hw->num_vfs = vsi_map->num_vfs;
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
+	}
+
+	if (!hw->vf_vsi_map) {
+		PMD_DRV_LOG(ERR, "Fail to alloc memory for VSI context");
+		return -ENOMEM;
+	}
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
+{
+#define ICE_DCF_RESET_WAIT_CNT       50
+	struct iavf_hw *avf = &hw->avf;
+	int i, reset;
+
+	for (i = 0; i < ICE_DCF_RESET_WAIT_CNT; i++) {
+		reset = IAVF_READ_REG(avf, IAVF_VFGEN_RSTAT) &
+					IAVF_VFGEN_RSTAT_VFR_STATE_MASK;
+		reset = reset >> IAVF_VFGEN_RSTAT_VFR_STATE_SHIFT;
+
+		if (reset == VIRTCHNL_VFR_VFACTIVE ||
+		    reset == VIRTCHNL_VFR_COMPLETED)
+			break;
+
+		rte_delay_ms(20);
+	}
+
+	if (i >= ICE_DCF_RESET_WAIT_CNT)
+		return -1;
+
+	return 0;
+}
+
+static inline void
+ice_dcf_enable_irq0(struct ice_dcf_hw *hw)
+{
+	struct iavf_hw *avf = &hw->avf;
+
+	/* Enable admin queue interrupt trigger */
+	IAVF_WRITE_REG(avf, IAVF_VFINT_ICR0_ENA1,
+		       IAVF_VFINT_ICR0_ENA1_ADMINQ_MASK);
+	IAVF_WRITE_REG(avf, IAVF_VFINT_DYN_CTL01,
+		       IAVF_VFINT_DYN_CTL01_INTENA_MASK |
+		       IAVF_VFINT_DYN_CTL01_CLEARPBA_MASK |
+		       IAVF_VFINT_DYN_CTL01_ITR_INDX_MASK);
+
+	IAVF_WRITE_FLUSH(avf);
+}
+
+static inline void
+ice_dcf_disable_irq0(struct ice_dcf_hw *hw)
+{
+	struct iavf_hw *avf = &hw->avf;
+
+	/* Disable all interrupt types */
+	IAVF_WRITE_REG(avf, IAVF_VFINT_ICR0_ENA1, 0);
+	IAVF_WRITE_REG(avf, IAVF_VFINT_DYN_CTL01,
+		       IAVF_VFINT_DYN_CTL01_ITR_INDX_MASK);
+
+	IAVF_WRITE_FLUSH(avf);
+}
+
+static void
+ice_dcf_dev_interrupt_handler(void *param)
+{
+	struct ice_dcf_hw *hw = param;
+
+	ice_dcf_disable_irq0(hw);
+
+	ice_dcf_handle_virtchnl_msg(hw);
+
+	ice_dcf_enable_irq0(hw);
+}
+
+int
+ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
+			     struct dcf_virtchnl_cmd *cmd)
+{
+	int i = 0;
+	int err;
+
+	if ((cmd->req_msg && !cmd->req_msglen) ||
+	    (!cmd->req_msg && cmd->req_msglen) ||
+	    (cmd->rsp_msgbuf && !cmd->rsp_buflen) ||
+	    (!cmd->rsp_msgbuf && cmd->rsp_buflen))
+		return -EINVAL;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, cmd);
+
+	err = ice_dcf_vc_cmd_send(hw, cmd);
+	if (err) {
+		PMD_DRV_LOG(ERR, "fail to send cmd %d", cmd->v_op);
+		goto ret;
+	}
+
+	do {
+		if (!cmd->pending)
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (cmd->v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (%d) for cmd %d",
+			    i, cmd->v_ret, cmd->v_op);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+	return err;
+}
+
+int
+ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+		    void *buf, uint16_t buf_size)
+{
+	struct dcf_virtchnl_cmd desc_cmd, buff_cmd;
+	struct ice_dcf_hw *hw = dcf_hw;
+	int err = 0;
+	int i = 0;
+
+	if ((buf && !buf_size) || (!buf && buf_size) ||
+	    buf_size > ICE_DCF_AQ_BUF_SZ)
+		return -EINVAL;
+
+	desc_cmd.v_op = VIRTCHNL_OP_DCF_CMD_DESC;
+	desc_cmd.req_msglen = sizeof(*desc);
+	desc_cmd.req_msg = (uint8_t *)desc;
+	desc_cmd.rsp_buflen = sizeof(*desc);
+	desc_cmd.rsp_msgbuf = (uint8_t *)desc;
+
+	if (buf == NULL)
+		return ice_dcf_execute_virtchnl_cmd(hw, &desc_cmd);
+
+	desc->flags |= rte_cpu_to_le_16(ICE_AQ_FLAG_BUF);
+
+	buff_cmd.v_op = VIRTCHNL_OP_DCF_CMD_BUFF;
+	buff_cmd.req_msglen = buf_size;
+	buff_cmd.req_msg = buf;
+	buff_cmd.rsp_buflen = buf_size;
+	buff_cmd.rsp_msgbuf = buf;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, &desc_cmd);
+	ice_dcf_vc_cmd_set(hw, &buff_cmd);
+
+	if (ice_dcf_vc_cmd_send(hw, &desc_cmd) ||
+	    ice_dcf_vc_cmd_send(hw, &buff_cmd)) {
+		err = -1;
+		PMD_DRV_LOG(ERR, "fail to send OP_DCF_CMD_DESC/BUFF");
+		goto ret;
+	}
+
+	do {
+		if ((!desc_cmd.pending && !buff_cmd.pending) ||
+		    (!desc_cmd.pending && desc_cmd.v_ret != IAVF_SUCCESS) ||
+		    (!buff_cmd.pending && buff_cmd.v_ret != IAVF_SUCCESS))
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (desc_cmd.v_ret != IAVF_SUCCESS || buff_cmd.v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (desc: %d / buff: %d)",
+			    i, desc_cmd.v_ret, buff_cmd.v_ret);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, &desc_cmd);
+	ice_dcf_aq_cmd_clear(hw, &buff_cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	ice_dcf_enable_irq0(hw);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
+int
+ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	int ret;
+
+	hw->avf.hw_addr = pci_dev->mem_resource[0].addr;
+	hw->avf.back = hw;
+
+	hw->avf.bus.bus_id = pci_dev->addr.bus;
+	hw->avf.bus.device = pci_dev->addr.devid;
+	hw->avf.bus.func = pci_dev->addr.function;
+
+	hw->avf.device_id = pci_dev->id.device_id;
+	hw->avf.vendor_id = pci_dev->id.vendor_id;
+	hw->avf.subsystem_device_id = pci_dev->id.subsystem_device_id;
+	hw->avf.subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+
+	hw->avf.aq.num_arq_entries = ICE_DCF_AQ_LEN;
+	hw->avf.aq.num_asq_entries = ICE_DCF_AQ_LEN;
+	hw->avf.aq.arq_buf_size = ICE_DCF_AQ_BUF_SZ;
+	hw->avf.aq.asq_buf_size = ICE_DCF_AQ_BUF_SZ;
+
+	rte_spinlock_init(&hw->vc_cmd_send_lock);
+	rte_spinlock_init(&hw->vc_cmd_queue_lock);
+	TAILQ_INIT(&hw->vc_cmd_queue);
+
+	hw->arq_buf = rte_zmalloc("arq_buf", ICE_DCF_AQ_BUF_SZ, 0);
+	if (hw->arq_buf == NULL) {
+		PMD_INIT_LOG(ERR, "unable to allocate AdminQ buffer memory");
+		goto err;
+	}
+
+	ret = iavf_set_mac_type(&hw->avf);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "set_mac_type failed: %d", ret);
+		goto err;
+	}
+
+	ret = ice_dcf_check_reset_done(hw);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "VF is still resetting");
+		goto err;
+	}
+
+	ret = iavf_init_adminq(&hw->avf);
+	if (ret) {
+		PMD_INIT_LOG(ERR, "init_adminq failed: %d", ret);
+		goto err;
+	}
+
+	if (ice_dcf_init_check_api_version(hw)) {
+		PMD_INIT_LOG(ERR, "check_api version failed");
+		goto err_api;
+	}
+
+	hw->vf_res = rte_zmalloc("vf_res", ICE_DCF_VF_RES_BUF_SZ, 0);
+	if (hw->vf_res == NULL) {
+		PMD_INIT_LOG(ERR, "unable to allocate vf_res memory");
+		goto err_api;
+	}
+
+	if (ice_dcf_get_vf_resource(hw)) {
+		PMD_INIT_LOG(ERR, "Failed to get VF resource");
+		goto err_alloc;
+	}
+
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
+	rte_intr_callback_register(&pci_dev->intr_handle,
+				   ice_dcf_dev_interrupt_handler, hw);
+	rte_intr_enable(&pci_dev->intr_handle);
+	ice_dcf_enable_irq0(hw);
+
+	return 0;
+
+err_alloc:
+	rte_free(hw->vf_res);
+err_api:
+	iavf_shutdown_adminq(&hw->avf);
+err:
+	rte_free(hw->arq_buf);
+
+	return -1;
+}
+
+void
+ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
+	struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
+
+	ice_dcf_disable_irq0(hw);
+	rte_intr_disable(intr_handle);
+	rte_intr_callback_unregister(intr_handle,
+				     ice_dcf_dev_interrupt_handler, hw);
+
+	ice_dcf_mode_disable(hw);
+	iavf_shutdown_adminq(&hw->avf);
+
+	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
+	rte_free(hw->vf_res);
+}
drivers/net/ice/ice_dcf.h new file +61 -0
new file mode 100644
index 000000000..58647d87f
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_H_
+#define _ICE_DCF_H_
+
+#include <rte_ethdev_driver.h>
+
+#include <iavf_prototype.h>
+#include <iavf_adminq_cmd.h>
+#include <iavf_type.h>
+
+#include "base/ice_type.h"
+#include "ice_logs.h"
+
+struct dcf_virtchnl_cmd {
+	TAILQ_ENTRY(dcf_virtchnl_cmd) next;
+
+	enum virtchnl_ops v_op;
+	enum iavf_status v_ret;
+
+	uint16_t req_msglen;
+	uint8_t *req_msg;
+
+	uint16_t rsp_msglen;
+	uint16_t rsp_buflen;
+	uint8_t *rsp_msgbuf;
+
+	volatile int pending;
+};
+
+struct ice_dcf_hw {
+	struct iavf_hw avf;
+
+	rte_spinlock_t vc_cmd_send_lock;
+	rte_spinlock_t vc_cmd_queue_lock;
+	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
+	uint8_t *arq_buf;
+
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
+	struct virtchnl_version_info virtchnl_version;
+	struct virtchnl_vf_resource *vf_res; /* VF resource */
+	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
+	uint16_t vsi_id;
+};
+
+int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
+				 struct dcf_virtchnl_cmd *cmd);
+int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
+int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
+void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
+
+#endif /* _ICE_DCF_H_ */
drivers/net/ice/ice_dcf_ethdev.c new file +115 -0
new file mode 100644
index 000000000..f65b962d4
@@ -0,0 +1,319 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#include <errno.h>
+#include <stdbool.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include <rte_interrupts.h>
+#include <rte_debug.h>
+#include <rte_pci.h>
+#include <rte_atomic.h>
+#include <rte_eal.h>
+#include <rte_ether.h>
+#include <rte_ethdev_pci.h>
+#include <rte_kvargs.h>
+#include <rte_malloc.h>
+#include <rte_memzone.h>
+#include <rte_dev.h>
+
+#include <iavf_devids.h>
+
+#include "ice_generic_flow.h"
+#include "ice_dcf_ethdev.h"
+
+static uint16_t
+ice_dcf_recv_pkts(__rte_unused void *rx_queue,
+		  __rte_unused struct rte_mbuf **bufs,
+		  __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
+static uint16_t
+ice_dcf_xmit_pkts(__rte_unused void *tx_queue,
+		  __rte_unused struct rte_mbuf **bufs,
+		  __rte_unused uint16_t nb_pkts)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_start(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_UP;
+
+	return 0;
+}
+
+static void
+ice_dcf_dev_stop(struct rte_eth_dev *dev)
+{
+	dev->data->dev_link.link_status = ETH_LINK_DOWN;
+}
+
+static int
+ice_dcf_dev_configure(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_info_get(struct rte_eth_dev *dev,
+		     struct rte_eth_dev_info *dev_info)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	dev_info->max_mac_addrs = 1;
+	dev_info->max_rx_pktlen = (uint32_t)-1;
+	dev_info->max_rx_queues = RTE_DIM(adapter->rxqs);
+	dev_info->max_tx_queues = RTE_DIM(adapter->txqs);
+
+	return 0;
+}
+
+static int
+ice_dcf_stats_get(__rte_unused struct rte_eth_dev *dev,
+		  __rte_unused struct rte_eth_stats *igb_stats)
+{
+	return 0;
+}
+
+static int
+ice_dcf_stats_reset(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_promiscuous_enable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_promiscuous_disable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_allmulticast_enable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
+ice_dcf_dev_allmulticast_disable(__rte_unused struct rte_eth_dev *dev)
+{
+	return 0;
+}
+
+static int
Quoted 8 lines

drivers/net/ice/ice_dcf_ethdev.c line 120

Quoted 5 lines
drivers/net/ice/ice_dcf_ethdev.c new file +5 -0
+ice_dcf_dev_filter_ctrl(struct rte_eth_dev *dev,
+			enum rte_filter_type filter_type,
+			__rte_unused enum rte_filter_op filter_op,
+			__rte_unused void *arg)
+{

legacy filter API will be deprecated, I think we should avoid adding support in new PMD.

This is the entry for new filter:

dev->dev_ops->filter_ctrl(dev,

						    RTE_ETH_FILTER_GENERIC,
						    RTE_ETH_FILTER_GET,
						    &ops)
Quoted 162 lines
Quoted 101 lines
drivers/net/ice/ice_dcf_ethdev.c new file +100 -0
+	int ret = 0;
+
+	if (!dev)
+		return -EINVAL;
+
+	switch (filter_type) {
+	default:
+		PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
+			    filter_type);
+		ret = -EINVAL;
+		break;
+	}
+
+	return ret;
+}
+
+static void
+ice_dcf_dev_close(struct rte_eth_dev *dev)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return;
+
+	dev->dev_ops = NULL;
+	dev->rx_pkt_burst = NULL;
+	dev->tx_pkt_burst = NULL;
+
+	ice_dcf_uninit_parent_adapter(dev);
+	ice_dcf_uninit_hw(dev, &adapter->real_hw);
+}
+
+static void
+ice_dcf_queue_release(__rte_unused void *q)
+{
+}
+
+static int
+ice_dcf_link_update(__rte_unused struct rte_eth_dev *dev,
+		    __rte_unused int wait_to_complete)
+{
+	return 0;
+}
+
+static int
+ice_dcf_rx_queue_setup(struct rte_eth_dev *dev,
+		       uint16_t rx_queue_id,
+		       __rte_unused uint16_t nb_rx_desc,
+		       __rte_unused unsigned int socket_id,
+		       __rte_unused const struct rte_eth_rxconf *rx_conf,
+		       __rte_unused struct rte_mempool *mb_pool)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	dev->data->rx_queues[rx_queue_id] = &adapter->rxqs[rx_queue_id];
+
+	return 0;
+}
+
+static int
+ice_dcf_tx_queue_setup(struct rte_eth_dev *dev,
+		       uint16_t tx_queue_id,
+		       __rte_unused uint16_t nb_tx_desc,
+		       __rte_unused unsigned int socket_id,
+		       __rte_unused const struct rte_eth_txconf *tx_conf)
+{
+	struct ice_dcf_adapter *adapter = dev->data->dev_private;
+
+	dev->data->tx_queues[tx_queue_id] = &adapter->txqs[tx_queue_id];
+
+	return 0;
+}
+
+static const struct eth_dev_ops ice_dcf_eth_dev_ops = {
+	.dev_start               = ice_dcf_dev_start,
+	.dev_stop                = ice_dcf_dev_stop,
+	.dev_close               = ice_dcf_dev_close,
+	.dev_configure           = ice_dcf_dev_configure,
+	.dev_infos_get           = ice_dcf_dev_info_get,
+	.rx_queue_setup          = ice_dcf_rx_queue_setup,
+	.tx_queue_setup          = ice_dcf_tx_queue_setup,
+	.rx_queue_release        = ice_dcf_queue_release,
+	.tx_queue_release        = ice_dcf_queue_release,
+	.link_update             = ice_dcf_link_update,
+	.stats_get               = ice_dcf_stats_get,
+	.stats_reset             = ice_dcf_stats_reset,
+	.promiscuous_enable      = ice_dcf_dev_promiscuous_enable,
+	.promiscuous_disable     = ice_dcf_dev_promiscuous_disable,
+	.allmulticast_enable     = ice_dcf_dev_allmulticast_enable,
+	.allmulticast_disable    = ice_dcf_dev_allmulticast_disable,
+	.filter_ctrl             = ice_dcf_dev_filter_ctrl,
+};
+
+static int
+ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+
+	eth_dev->dev_ops = &ice_dcf_eth_dev_ops;
+	eth_dev->rx_pkt_burst = ice_dcf_recv_pkts;

drivers/net/ice/ice_dcf_ethdev.c line 230

Quoted 10 lines
drivers/net/ice/ice_dcf_ethdev.c new file +10 -0
+	eth_dev->tx_pkt_burst = ice_dcf_xmit_pkts;
+
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return 0;
+
+	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
+	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to init DCF hardware");

Use PMD_INIT_LOG instead.

drivers/net/ice/ice_dcf_ethdev.c line 235

Quoted 5 lines
drivers/net/ice/ice_dcf_ethdev.c new file +5 -0
+		return -1;
+	}
+
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_DRV_LOG(ERR, "Failed to init DCF parent adapter");

Use PMD_INIT_LOG instead.

Quoted 40 lines
drivers/net/ice/ice_dcf_ethdev.c new file +40 -0
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
+
+	return 0;
+}
+
+static int
+ice_dcf_dev_uninit(struct rte_eth_dev *eth_dev)
+{
+	ice_dcf_dev_close(eth_dev);
+
+	return 0;
+}
+
+static int
+handle_dcf_arg(__rte_unused const char *key, const char *value,
+	       __rte_unused void *arg)
+{
+	bool *dcf = arg;
+
+	if (arg == NULL || value == NULL)
+		return -EINVAL;
+
+	if (strcmp(value, "dcf") == 0)
+		*dcf = true;
+	else
+		*dcf = false;
+
+	return 0;
+}
+
+static bool
+check_cap_dcf_enable(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	bool enable = false;
+
+	if (devargs == NULL)
+		return false;
Quoted 8 lines

drivers/net/ice/ice_dcf_ethdev.c line 281

Quoted 6 lines
drivers/net/ice/ice_dcf_ethdev.c new file +6 -0
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return false;
+
+	rte_kvargs_process(kvlist, "cap", handle_dcf_arg, &enable);

Need error handing for failure case.

Fixed in v2.

Quoted 5 lines
Quoted 5 lines
drivers/net/ice/ice_dcf_ethdev.c new file +5 -0
+
+	rte_kvargs_free(kvlist);
+
+	return enable;
+}
Quoted 8 lines

drivers/net/ice/ice_dcf_ethdev.c line 292

Quoted 6 lines
drivers/net/ice/ice_dcf_ethdev.c new file +6 -0
+
+static int eth_ice_dcf_pci_probe(__rte_unused struct rte_pci_driver *pci_drv,
+			     struct rte_pci_device *pci_dev)
+{
+	if (!check_cap_dcf_enable(pci_dev->device.devargs))
+		return 1; /* continue to probe */

I think the code is self explanatory, this straightforward comment is unnecessary.

Make sense, will remove it.

Quoted 475 lines
Quoted 111 lines
drivers/net/ice/ice_dcf_ethdev.c new file +27 -0
+
+	return rte_eth_dev_pci_generic_probe(pci_dev,
+					     sizeof(struct ice_dcf_adapter),
+					     ice_dcf_dev_init);
+}
+
+static int eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
+{
+	return rte_eth_dev_pci_generic_remove(pci_dev, ice_dcf_dev_uninit);
+}
+
+static const struct rte_pci_id pci_id_ice_dcf_map[] = {
+	{ RTE_PCI_DEVICE(IAVF_INTEL_VENDOR_ID, IAVF_DEV_ID_ADAPTIVE_VF) },
+	{ .vendor_id = 0, /* sentinel */ },
+};
+
+static struct rte_pci_driver rte_ice_dcf_pmd = {
+	.id_table = pci_id_ice_dcf_map,
+	.drv_flags = RTE_PCI_DRV_NEED_MAPPING,
+	.probe = eth_ice_dcf_pci_probe,
+	.remove = eth_ice_dcf_pci_remove,
+};
+
+RTE_PMD_REGISTER_PCI(net_ice_dcf, rte_ice_dcf_pmd);
+RTE_PMD_REGISTER_PCI_TABLE(net_ice_dcf, pci_id_ice_dcf_map);
+RTE_PMD_REGISTER_KMOD_DEP(net_ice_dcf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_ice_dcf, "cap=dcf");
drivers/net/ice/ice_dcf_ethdev.h new file +33 -0
new file mode 100644
index 000000000..e95266599
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_ETHDEV_H_
+#define _ICE_DCF_ETHDEV_H_
+
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
+#include "ice_ethdev.h"
+#include "ice_dcf.h"
+
+#define ICE_DCF_MAX_RINGS  1
+
+struct ice_dcf_queue {
+	uint64_t dummy;
+};
+
+struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
+	struct ice_dcf_hw real_hw;
+	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
+	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
+};
+
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
+#endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +38 -0
new file mode 100644
index 000000000..bca9cd34a
@@ -0,0 +1,348 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2019 Intel Corporation
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <rte_alarm.h>
+
+#include "ice_dcf_ethdev.h"
+#include "ice_generic_flow.h"
+
+#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL	100000 /* us */
+
+static __rte_always_inline void
+ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
+		       uint16_t vsi_map)
+{
+	struct ice_vsi_ctx *vsi_ctx;
+
+	if (unlikely(vsi_handle >= ICE_MAX_VSI)) {
+		PMD_DRV_LOG(ERR, "Invalid vsi handle %u", vsi_handle);
+		return;
+	}
+
+	vsi_ctx = hw->vsi_ctx[vsi_handle];
+
+	if (vsi_map & VIRTCHNL_DCF_VF_VSI_VALID) {
+		if (!vsi_ctx)
+			vsi_ctx = ice_malloc(hw, sizeof(*vsi_ctx));
+
+		if (!vsi_ctx) {
+			PMD_DRV_LOG(ERR, "No memory for vsi context %u",
+				    vsi_handle);
+			return;
+		}
+
+		vsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>

drivers/net/ice/ice_dcf_parent.c line 48

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+					      VIRTCHNL_DCF_VF_VSI_ID_S;
+		hw->vsi_ctx[vsi_handle] = vsi_ctx;
+
+		PMD_DRV_LOG(DEBUG, "VF%u is assigned with vsi number %u",
+			    vsi_handle, vsi_ctx->vsi_num);
+	} else {
+		hw->vsi_ctx[vsi_handle] = NULL;
+
+		if (vsi_ctx)
+			ice_free(hw, vsi_ctx);

Doesn't need to check vsi_ctx is NUll or not, ice_free (rte_free) would do it inside.

Quoted 110 lines
drivers/net/ice/ice_dcf_parent.c new file +110 -0
+
+		PMD_DRV_LOG(NOTICE, "VF%u is disabled", vsi_handle);
+	}
+}
+
+static void
+ice_dcf_update_vf_vsi_map(struct ice_hw *hw, uint16_t num_vfs,
+			  uint16_t *vf_vsi_map)
+{
+	uint16_t vf_id;
+
+	for (vf_id = 0; vf_id < num_vfs; vf_id++)
+		ice_dcf_update_vsi_ctx(hw, vf_id, vf_vsi_map[vf_id]);
+}
+
+static void
+ice_dcf_vsi_update_service_handler(void *param)
+{
+	struct ice_dcf_hw *hw = param;
+
+	if (!ice_dcf_handle_vsi_update_event(hw)) {
+		struct ice_dcf_adapter *dcf_ad =
+			container_of(hw, struct ice_dcf_adapter, real_hw);
+
+		ice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw,
+					  hw->num_vfs, hw->vf_vsi_map);
+	}
+}
+
+void
+ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+			    uint8_t *msg, uint16_t msglen)
+{
+	struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;
+
+	if (msglen < sizeof(struct virtchnl_pf_event)) {
+		PMD_DRV_LOG(DEBUG, "Invalid event message length : %u", msglen);
+		return;
+	}
+
+	switch (pf_msg->event) {
+	case VIRTCHNL_EVENT_RESET_IMPENDING:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL * 2,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);
+		break;
+	case VIRTCHNL_EVENT_LINK_CHANGE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
+		break;
+	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
+		break;
+	case VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE event : VF%u with VSI num %u",
+			    pf_msg->event_data.vf_vsi_map.vf_id,
+			    pf_msg->event_data.vf_vsi_map.vsi_id);
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event);
+		break;
+	}
+}
+
+static int
+ice_dcf_init_parent_hw(struct ice_hw *hw)
+{
+	struct ice_aqc_get_phy_caps_data *pcaps;
+	enum ice_status status;
+
+	status = ice_aq_get_fw_ver(hw, NULL);
+	if (status)
+		return status;
+
+	status = ice_get_caps(hw);
+	if (status)
+		return status;
+
+	hw->port_info = (struct ice_port_info *)
+			ice_malloc(hw, sizeof(*hw->port_info));
+	if (!hw->port_info)
+		return ICE_ERR_NO_MEMORY;
+
+	/* set the back pointer to HW */
+	hw->port_info->hw = hw;
+
+	/* Initialize port_info struct with switch configuration data */
+	status = ice_get_initial_sw_cfg(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	pcaps = (struct ice_aqc_get_phy_caps_data *)
+		ice_malloc(hw, sizeof(*pcaps));
+	if (!pcaps) {
+		status = ICE_ERR_NO_MEMORY;
+		goto err_unroll_alloc;
+	}
+
+	/* Initialize port_info struct with PHY capabilities */
+	status = ice_aq_get_phy_caps(hw->port_info, false,
+				     ICE_AQC_REPORT_TOPO_CAP, pcaps, NULL);
+	ice_free(hw, pcaps);
+	if (status)
+		goto err_unroll_alloc;
+
+	/* Initialize port_info struct with link information */
+	status = ice_aq_get_link_info(hw->port_info, false, NULL, NULL);
+	if (status)
+		goto err_unroll_alloc;

drivers/net/ice/ice_dcf_parent.c line 168

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+
+	status = ice_init_fltr_mgmt_struct(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	status = ice_init_hw_tbls(hw);
+	if (status)
+		goto err_unroll_fltr_mgmt_struct;
+
+	PMD_DRV_LOG(INFO,

PMD_INIT_LOG

Quoted 15 lines
drivers/net/ice/ice_dcf_parent.c new file +15 -0
+		    "firmware %d.%d.%d api %d.%d.%d build 0x%08x",
+		    hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch,
+		    hw->api_maj_ver, hw->api_min_ver, hw->api_patch,
+		    hw->fw_build);
+
+	return ICE_SUCCESS;
+
+err_unroll_fltr_mgmt_struct:
+	ice_cleanup_fltr_mgmt_struct(hw);
+err_unroll_alloc:
+	ice_free(hw, hw->port_info);
+	hw->port_info = NULL;
+
+	return status;
+}

drivers/net/ice/ice_dcf_parent.c line 193

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+
+static void ice_dcf_uninit_parent_hw(struct ice_hw *hw)
+{
+	ice_cleanup_fltr_mgmt_struct(hw);
+
+	ice_free_seg(hw);
+	ice_free_hw_tbls(hw);
+
+	if (hw->port_info) {
+		ice_free(hw, hw->port_info);

Doesn't need to check whether hw->port_info is NULL or not, ice_free (rte_free) would do it inside.

Quoted 101 lines
drivers/net/ice/ice_dcf_parent.c new file +101 -0
+		hw->port_info = NULL;
+	}
+
+	ice_clear_all_vsi_ctx(hw);
+}
+
+static int
+ice_dcf_request_pkg_name(struct ice_hw *hw, char *pkg_name)
+{
+	struct ice_dcf_adapter *dcf_adapter =
+			container_of(hw, struct ice_dcf_adapter, parent.hw);
+
+	/* TODO: check with DSN firstly by iAVF */
+	PMD_DRV_LOG(DEBUG,
+		    "DCF VSI_ID = %u",
+		    dcf_adapter->real_hw.vsi_id);
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_UPDATES);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_DEFAULT);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	return -1;
+}
+
+static int
+ice_dcf_load_pkg(struct ice_hw *hw)
+{
+	char pkg_name[ICE_MAX_PKG_FILENAME_SIZE];
+	uint8_t *pkg_buf;
+	uint32_t buf_len;
+	struct stat st;
+	FILE *fp;
+	int err;
+
+	if (ice_dcf_request_pkg_name(hw, pkg_name)) {
+		PMD_INIT_LOG(ERR, "failed to locate the package file");
+		return -ENOENT;
+	}
+
+	PMD_INIT_LOG(DEBUG, "DDP package name: %s", pkg_name);
+
+	err = stat(pkg_name, &st);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to get file status");
+		return err;
+	}
+
+	buf_len = st.st_size;
+	pkg_buf = rte_malloc(NULL, buf_len, 0);
+	if (!pkg_buf) {
+		PMD_INIT_LOG(ERR, "failed to allocate buffer of size %u for package",
+			     buf_len);
+		return -1;
+	}
+
+	fp = fopen(pkg_name, "rb");
+	if (!fp)  {
+		PMD_INIT_LOG(ERR, "failed to open file: %s", pkg_name);
+		err = -1;
+		goto ret;
+	}
+
+	err = fread(pkg_buf, buf_len, 1, fp);
+	fclose(fp);
+	if (err != 1) {
+		PMD_INIT_LOG(ERR, "failed to read package data");
+		err = -1;
+		goto ret;
+	}
+
+	err = ice_copy_and_init_pkg(hw, pkg_buf, buf_len);
+	if (err)
+		PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d", err);
+
+ret:
+	rte_free(pkg_buf);
+	return err;
+}
+
+int
+ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+	struct ice_dcf_hw *hw = &adapter->real_hw;
+	const struct rte_ether_addr *mac;
+	int err;
+
+	parent_adapter->eth_dev = eth_dev;
+	parent_adapter->pf.adapter = parent_adapter;
+	parent_adapter->pf.dev_data = eth_dev->data;
+	parent_hw->back = parent_adapter;
+	parent_hw->mac_type = ICE_MAC_GENERIC;
+	parent_hw->vendor_id = ICE_INTEL_VENDOR_ID;

drivers/net/ice/ice_dcf_parent.c line 304

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+
+	ice_init_lock(&parent_hw->adminq.sq_lock);
+	ice_init_lock(&parent_hw->adminq.rq_lock);
+	parent_hw->aq_send_cmd_fn = ice_dcf_send_aq_cmd;
+	parent_hw->aq_send_cmd_param = &adapter->real_hw;
+	parent_hw->dcf_enabled = true;
+
+	err = ice_dcf_init_parent_hw(parent_hw);
+	if (err) {
+		PMD_DRV_LOG(ERR, "failed to init the DCF parent hardware with error %d",

PMD_INIT_LOG

drivers/net/ice/ice_dcf_parent.c line 311

Quoted 7 lines
drivers/net/ice/ice_dcf_parent.c new file +7 -0
+			    err);
+		return err;
+	}
+
+	err = ice_dcf_load_pkg(parent_hw);
+	if (err) {
+		PMD_DRV_LOG(ERR, "failed to load package with error %d",

PMD_INIT_LOG

Quoted 76 lines
drivers/net/ice/ice_dcf_parent.c new file +37 -0
+			    err);
+		goto uninit_hw;
+	}
+	parent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);
+
+	ice_dcf_update_vf_vsi_map(parent_hw,
+				  hw->num_vfs, hw->vf_vsi_map);
+
+	mac = (const struct rte_ether_addr *)hw->avf.mac.addr;
+	if (rte_is_valid_assigned_ether_addr(mac))
+		rte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);
+	else
+		rte_eth_random_addr(parent_adapter->pf.dev_addr.addr_bytes);
+
+	eth_dev->data->mac_addrs = &parent_adapter->pf.dev_addr;
+
+	return 0;
+
+uninit_hw:
+	ice_dcf_uninit_parent_hw(parent_hw);
+	return err;
+}
+
+void
+ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+
+	eth_dev->data->mac_addrs = NULL;
+
+	rte_eal_alarm_cancel(ice_dcf_vsi_update_service_handler,
+			     &adapter->real_hw);
+
+	ice_dcf_uninit_parent_hw(parent_hw);
+}
drivers/net/ice/meson.build +2 -2
index f9e897bbc..0df8ddc0f 100644
@@ -15,8 +15,8 @@ sources = files(
 	'ice_hash.c'
 	)
 
-deps += ['hash']
-includes += include_directories('base')
+deps += ['hash', 'net', 'common_iavf']
+includes += include_directories('base', '../../common/iavf')
 

if arch_subdir == 'x86'

	sources += files('ice_rxtx_vec_sse.c')
drivers/net/ice/meson.build +0 -0
@@ -37,4 +37,8 @@ if arch_subdir == 'x86'
 	endif

endif

drivers/net/ice/meson.build +4 -0
+sources += files('ice_dcf.c',
+		 'ice_dcf_parent.c',
+		 'ice_dcf_ethdev.c')
+

install_headers('rte_pmd_ice.h')

mk/rte.app.mk +0 -0
index d295ca0a5..f3798a09f 100644
@@ -185,6 +185,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e

_LDLIBS-$(CONFIG_RTE_LIBRTE_IAVF_PMD) += -lrte_pmd_iavf
_LDLIBS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += -lrte_pmd_ice
IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
ifeq ($(findstring y,$(IAVF-y)),y)
_LDLIBS-y += -lrte_common_iavf
endif
--
2.25.1

#13 lore raw

Re: [dpdk-dev] [PATCH v1 3/4] net/ice: add the DCF framework

Quoted 10 lines · Haiyue
Quoted 9 lines

drivers/net/ice/ice_dcf_ethdev.c line 120

Quoted 6 lines
drivers/net/ice/ice_dcf_ethdev.c new file +6 -0
+static int
+ice_dcf_dev_filter_ctrl(struct rte_eth_dev *dev,
+			enum rte_filter_type filter_type,
+			__rte_unused enum rte_filter_op filter_op,
+			__rte_unused void *arg)
+{

legacy filter API will be deprecated, I think we should avoid adding support in new PMD.

Quoted 6 lines

This is the entry for new filter:

dev->dev_ops->filter_ctrl(dev,

						    RTE_ETH_FILTER_GENERIC,
						    RTE_ETH_FILTER_GET,
						    &ops)

Right, I have some misunderstanding before, the filter API will be deprecated, but the dev->filter_ctrl ops is still needed.

Thanks,
Xiaolong

#14 lore raw

PATCH 4/4 doc: add release notes for Intel ice PMD

In reply to Haiyue Wang

Add release notes for the new Intel ice feature DCF (Device Config Function).

---
 doc/guides/rel_notes/release_20_05.rst | 5 +++++
 1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_20_05.rst +5 -0
index 000bbf501..f404ee7fd 100644
@@ -62,6 +62,11 @@ New Features
 
   * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF (Device Config Function) feature.
 
 Removed Items
 -------------
Signature · 1 line
2.25.1
#15 lore raw

Re: [dpdk-dev] [PATCH v1 4/4] doc: add release notes for Intel ice PMD

Release note doesn't have to be a separate patch, can go with the feature patch.

Thanks,
Xiaolong

Quoted 27 lines · Haiyue Wang

Add release notes for the new Intel ice feature DCF (Device Config Function).

---
doc/guides/rel_notes/release_20_05.rst | 5 +++++

1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_20_05.rst +5 -0
index 000bbf501..f404ee7fd 100644
@@ -62,6 +62,11 @@ New Features
 
  * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF (Device Config Function) feature.
 

Removed Items
-------------

Signature · 1 line
2.25.1
#16 lore raw

Re: [dpdk-dev] [PATCH v1 4/4] doc: add release notes for Intel ice PMD

Got it.

BR,
Haiyue

Quoted 42 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Monday, March 9, 2020 23:22
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v1 4/4] doc: add release notes for Intel ice PMD

Release note doesn't have to be a separate patch, can go with the feature patch.

Thanks,
Xiaolong

Quoted 27 lines · Haiyue Wang

Add release notes for the new Intel ice feature DCF (Device Config Function).

---
doc/guides/rel_notes/release_20_05.rst | 5 +++++

1 file changed, 5 insertions(+)
doc/guides/rel_notes/release_20_05.rst +5 -0
index 000bbf501..f404ee7fd 100644
@@ -62,6 +62,11 @@ New Features
 
  * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF (Device Config Function) feature.
 

Removed Items
-------------
--
2.25.1

#17 lore raw
In reply to Haiyue Wang
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Signature · 1 line
David Marchand
#18 lore raw

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

Thanks,
Xiaolong

Quoted 5 lines
Signature · 2 lines
-- 
David Marchand
#19 lore raw

09/03/2020 17:20, Ye Xiaolong:

Quoted 54 lines

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Quoted 8 lines

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

I think it would simpler to list dependencies as patchwork ids. Example:

	Depends-on: series-42, patch-12345
#20 lore raw
Quoted 64 lines · Thomas Monjalon

09/03/2020 17:20, Ye Xiaolong:

Quoted 54 lines

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Quoted 8 lines

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

Quoted 4 lines

I think it would simpler to list dependencies as patchwork ids. Example:

	Depends-on: series-42, patch-12345

+1. I don't think it should depend on a base-commit. If it doesn't apply/build/work with the latest upstream code then it's a valid error.

Quoted 1 line
#21 lore raw
Quoted 10 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Tuesday, March 10, 2020 03:34
To: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Ye, Xiaolong <[email protected]>
Cc: Wang, Haiyue <[email protected]>; dev <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>; Aaron Conole <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/4] add Intel DCF PMD support

Quoted 70 lines
Quoted 68 lines · Thomas Monjalon

09/03/2020 17:20, Ye Xiaolong:

Quoted 54 lines

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Quoted 8 lines

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

I think it would simpler to list dependencies as patchwork ids. Example:

	Depends-on: series-42, patch-12345

Just list the 'series' ? Since it can download the whole patchset with the single link format like:

Depends-on: series-8843 --> https://patchwork.dpdk.org/series/8843/mbox/

Quoted 4 lines

+1. I don't think it should depend on a base-commit. If it doesn't apply/build/work with the latest upstream code then it's a valid error.

Quoted 1 line
#22 lore raw

10/03/2020 03:00, Wang, Haiyue:

Quoted 81 lines
Quoted 10 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Tuesday, March 10, 2020 03:34
To: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Ye, Xiaolong <[email protected]>
Cc: Wang, Haiyue <[email protected]>; dev <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>; Aaron Conole <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/4] add Intel DCF PMD support

Quoted 70 lines
Quoted 68 lines · Thomas Monjalon

09/03/2020 17:20, Ye Xiaolong:

Quoted 54 lines

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Quoted 8 lines

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

I think it would simpler to list dependencies as patchwork ids. Example:

	Depends-on: series-42, patch-12345
Quoted 4 lines

Just list the 'series' ? Since it can download the whole patchset with the single link format like:

Depends-on: series-8843 --> https://patchwork.dpdk.org/series/8843/mbox/

Yes, I was proposing both format: series-X and patch-Y (on top of series-X). But we probably never need to be specific about a single patch. I think you are right, we can keep only "series-X" syntax,
and allow describing a list of series, ordered and separated with comma.

#23 lore raw
Quoted 85 lines · Thomas Monjalon

10/03/2020 03:00, Wang, Haiyue:

Quoted 84 lines
Quoted 10 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Tuesday, March 10, 2020 03:34
To: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Ye, Xiaolong <[email protected]>
Cc: Wang, Haiyue <[email protected]>; dev <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>; Aaron Conole <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/4] add Intel DCF PMD support

Quoted 70 lines
Quoted 68 lines · Thomas Monjalon

09/03/2020 17:20, Ye Xiaolong:

Quoted 54 lines

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Quoted 8 lines

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

I think it would simpler to list dependencies as patchwork ids. Example:

	Depends-on: series-42, patch-12345

Just list the 'series' ? Since it can download the whole patchset with the single link format like:

Quoted 7 lines
Quoted 1 line

Depends-on: series-8843 --> https://patchwork.dpdk.org/series/8843/mbox/

Yes, I was proposing both format: series-X and patch-Y (on top of series-X). But we probably never need to be specific about a single patch. I think you are right, we can keep only "series-X" syntax,
and allow describing a list of series, ordered and separated with comma.

+1 to "Depends-on: series-#####" syntax

#24 lore raw
Quoted 89 lines · Ferruh Yigit
Quoted 88 lines · Thomas Monjalon

10/03/2020 03:00, Wang, Haiyue:

Quoted 87 lines
Quoted 13 lines

-----Original Message-----
From: Kevin Traynor <[email protected]>
Sent: Tuesday, March 10, 2020 03:34
To: Thomas Monjalon <[email protected]>; David Marchand <[email protected]>; Ye, Xiaolong
<[email protected]>
Cc: Wang, Haiyue <[email protected]>; dev <[email protected]>;
Zhang, Qi Z <[email protected]>; Yang,
Qiming <[email protected]>; Xing, Beilei
<[email protected]>; Zhao1, Wei <[email protected]>;
Aaron Conole <[email protected]>; [email protected]; Yigit, Ferruh <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v1 0/4] add Intel DCF PMD support

Quoted 70 lines
Quoted 68 lines · Thomas Monjalon

09/03/2020 17:20, Ye Xiaolong:

Quoted 54 lines

Hi, David

Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

Agree, It'd be helpful if the cover letter of the first patch contains some base tree info including the base commit and dependency patchset info (if any), so the CI can determine the correct base on top of which the developer's patchset applies to avoid any apply issue and potential false positive.

And I know there is one option '--base'' of git format-patch which is dedicated for this kind of usage, it can help create the base tree info block which can be easily consumed by the CI. Here is the simple intro of it.

Imagine that on top of the public commit P (already in upstream), the developer applied well-known (on-flight, in the mailing list but not merged yet) patches X, Y and Z from somebody else or himself, and then built his three-patch series A, B, C, the commit history would be like:

................................................
---P---X---Y---Z---A---B---C
................................................

With git format-patch --base=P -3 C,

where P could be the exact commit sha, or variants e.g. HEAD~6, we can also use --base=auto for convenience, the base tree information block will be shown at the end of the first message the command outputs (either the first patch, or the cover letter), like this:

------------
base-commit: P
prerequisite-patch-id: X
prerequisite-patch-id: Y
prerequisite-patch-id: Z
------------

Quoted 8 lines

Here P is the commit sha, and X,Y,Z are the patch ids of the dependency patches.

With this info in place, I think CI should be able to setup the exact base for the coming patchset, the missing part I can see is the mapping of (in-flight patch <-> patch id), since we have all the in-flight patches in patchwork, creating and maintaining such mapping in DB is doable, what do you think?

I think it would simpler to list dependencies as patchwork ids. Example:

	Depends-on: series-42, patch-12345

Just list the 'series' ? Since it can download the whole patchset with the single link format like:

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

Depends-on: series-8843 --> https://patchwork.dpdk.org/series/8843/mbox/

Yes, I was proposing both format: series-X and patch-Y (on top of series-X). But we probably never need to be specific about a single patch. I think you are right, we can keep only "series-X" syntax,
and allow describing a list of series, ordered and separated with comma.

+1 to "Depends-on: series-#####" syntax

I can do this - but I actually prefer just putting the series in the brackets. Metadata tags in the message will be preserved in the commit history, but the details of which series to start with for checking out don't really need to be preserved. It's just a way to get the bot to test, right? Maybe it can help maintainers to script an auto-fetch, too.

#25 lore raw
In reply to David Marchand
Quoted 12 lines · David Marchand
Quoted 10 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ update ice base code

Quoted 6 lines

The problem is that the CI(s) won't handle this.
Example for the robot: https://travis-ci.com/ovsrobot/dpdk/builds/152461907

Maybe we could add something as an annotation to the cover letter or the first patch of a series so that the CI(s) can detect and try to be intelligent?

It's something that's possibly worth doing; I can update the bot to recognize:

series_XXX

in the cover-letter metadata (IE: between the '[...]'), and automatically check out the correct branch.

Additionally, if the idea is not to get the patch applied right away while finalizing on the preceding series, the RFC keyword will prevent the bot from running.

THAT SAID

In general, I dislike posting series that depend on other series. It makes review much harder, and if there's a feedback on the preceding series that requires lots of change, the dependent series may also need to be re-done completely.

I see there are more replies to this thread - sorry I didn't get to it yesterday (personal stuff).

#26 lore raw

v2 cover add Intel DCF PMD support

In reply to Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code
[2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
Signature · 1 line
2.25.1
#27 lore raw

PATCH v2 1/7 net/iavf: stop the PCI probe in DCF mode

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
 drivers/net/iavf/iavf_ethdev.c | 43 ++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
drivers/net/iavf/iavf_ethdev.c +43 -0
index 34913f9c4..c0b95e169 100644
@@ -1416,9 +1416,51 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+iavf_dcf_cap_check_handler(__rte_unused const char *key,
+			   const char *value, __rte_unused void *opaque)
+{
+	if (strcmp(value, "dcf"))
+		return -1;
+
+	return 0;
+}
+
+static int
+iavf_dcf_cap_selected(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	const char *key = "cap";
+	int ret = 0;
+
+	if (devargs == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return 0;
+
+	if (!rte_kvargs_count(kvlist, key))
+		goto exit;
+
+	/* dcf capability selected when there's a key-value pair: cap=dcf */
+	if (rte_kvargs_process(kvlist, key,
+			       iavf_dcf_cap_check_handler, NULL) < 0)
+		goto exit;
+
+	ret = 1;
+
+exit:
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (iavf_dcf_cap_selected(pci_dev->device.devargs))
+		return 1;
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1481,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
Signature · 1 line
2.25.1
Reviewed-by on v2 1/7
#28 lore raw

Re: [dpdk-dev] [PATCH v2 1/7] net/iavf: stop the PCI probe in DCF mode

Quoted 79 lines · Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
drivers/net/iavf/iavf_ethdev.c | 43 ++++++++++++++++++++++++++++++++++

1 file changed, 43 insertions(+)
drivers/net/iavf/iavf_ethdev.c +43 -0
index 34913f9c4..c0b95e169 100644
@@ -1416,9 +1416,51 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+iavf_dcf_cap_check_handler(__rte_unused const char *key,
+			   const char *value, __rte_unused void *opaque)
+{
+	if (strcmp(value, "dcf"))
+		return -1;
+
+	return 0;
+}
+
+static int
+iavf_dcf_cap_selected(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	const char *key = "cap";
+	int ret = 0;
+
+	if (devargs == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return 0;
+
+	if (!rte_kvargs_count(kvlist, key))
+		goto exit;
+
+	/* dcf capability selected when there's a key-value pair: cap=dcf */
+	if (rte_kvargs_process(kvlist, key,
+			       iavf_dcf_cap_check_handler, NULL) < 0)
+		goto exit;
+
+	ret = 1;
+
+exit:
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (iavf_dcf_cap_selected(pci_dev->device.devargs))
+		return 1;
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1481,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
Signature · 1 line
2.25.1
#29 lore raw

PATCH v2 2/7 net/ice: add the DCF hardware initialization

In reply to Haiyue Wang

Introduce the DCF (Device Config Function) feature in the ice PMD, it works as a standalone PMD which doesn't handle the packet Rx/Tx related things. Its hardware entity is the VF.

Add the basic DCF hardware initialization, this is specified by devarg 'cap=dcf'.

---
 doc/guides/nics/ice.rst                |  47 +++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/ice/Makefile               |   5 +
 drivers/net/ice/ice_dcf.c              | 474 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  52 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 317 +++++++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  24 ++
 drivers/net/ice/meson.build            |   7 +-
 mk/rte.app.mk                          |   1 +
 11 files changed, 931 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
doc/guides/nics/ice.rst +47 -0
index 8af32dabf..2639ae239 100644
@@ -240,6 +240,53 @@ report a MDD event and drop the packets.
 
 The APPs based on DPDK should avoid providing such packets.
 
+Device Config Function (DCF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This section demonstrates ICE DCF PMD, which shares the core module with ICE
+PMD and iAVF PMD.
+
+A DCF (Device Config Function) PMD bounds to the device's trusted VF with ID 0,
+it can act as a sole controlling entity to exercise advance functionality (such
+as switch, ACL) for the rest VFs.
+
+The DCF PMD needs to advertise and acquire DCF capability which allows DCF to
+send AdminQ commands that it would like to execute over to the PF and receive
+responses for the same from PF.
+
+.. _figure_ice_dcf:
+
+.. figure:: img/ice_dcf.*
+
+   DCF Communication flow.
+
+#. Create the VFs::
+
+      echo 4 > /sys/bus/pci/devices/0000\:18\:00.0/sriov_numvfs
+
+#. Enable the VF0 trust on::
+
+      ip link set dev enp24s0f0 vf 0 trust on
+
+#. Bind the VF0,  and run testpmd with 'cap=dcf' devarg::
+
+      testpmd -l 22-25 -n 4 -w 18:01.0,cap=dcf -- -i
+
+#. Monitor the VF2 interface network traffic::
+
+      tcpdump -e -nn -i enp24s1f2
+
+#. Create one flow to redirect the traffic to VF2 by DCF::
+
+      flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.2 \
+      dst is 192.168.0.3 / end actions vf id 2 / end
+
+#. Send the packet, and it should be displayed on tcpdump::
+
+      sendp(Ether(src='3c:fd:fe:aa:bb:78', dst='00:00:00:01:02:03')/IP(src=' \
+      192.168.0.2', dst="192.168.0.3")/TCP(flags='S')/Raw(load='XXXXXXXXXX'), \
+      iface="enp24s0f0", count=10)
+
 Sample Application Notes
 ------------------------
 
doc/guides/nics/img/ice_dcf.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..540823c4a05e9ea9d558d233fea77016d1ae5df3
GIT binary patch
doc/guides/rel_notes/release_20_05.rst +5 -0
index 000bbf501..f404ee7fd 100644
@@ -62,6 +62,11 @@ New Features
 
   * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF (Device Config Function) feature.
 
 Removed Items
 -------------
drivers/common/Makefile +1 -0
index 96bd7ac6e..df2e840cf 100644
@@ -31,6 +31,7 @@ DIRS-y += dpaax
 endif
 
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifneq (,$(findstring y,$(IAVF-y)))
 DIRS-y += iavf
 endif
drivers/net/ice/Makefile +5 -0
index e22c34287..f493c9ed7 100644
@@ -11,9 +11,11 @@ LIB = librte_pmd_ice.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/common/iavf
 
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs
 LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash
+LDLIBS += -lrte_net -lrte_common_iavf
 
 EXPORT_MAP := rte_pmd_ice_version.map
 
@@ -84,6 +86,9 @@ ifeq ($(CC_AVX2_SUPPORT), 1)
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
 
drivers/net/ice/ice_dcf.c new file +474 -0

474 lines not on this page · raw message

drivers/net/ice/ice_dcf.h new file +52 -0

52 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.c new file +317 -0

317 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.h new file +24 -0
new file mode 100644
index 000000000..0c34a0095
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_ETHDEV_H_
+#define _ICE_DCF_ETHDEV_H_
+
+#include "ice_ethdev.h"
+#include "ice_dcf.h"
+
+#define ICE_DCF_MAX_RINGS  1
+
+struct ice_dcf_queue {
+	uint64_t dummy;
+};
+
+struct ice_dcf_adapter {
+	struct ice_dcf_hw real_hw;
+	struct rte_ether_addr mac_addr;
+	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
+	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
+};
+
+#endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/meson.build +5 -2
index f9e897bbc..0ba9668d1 100644
@@ -15,8 +15,8 @@ sources = files(
 	'ice_hash.c'
 	)
 
-deps += ['hash']
-includes += include_directories('base')
+deps += ['hash', 'net', 'common_iavf']
+includes += include_directories('base', '../../common/iavf')
 
 if arch_subdir == 'x86'
 	sources += files('ice_rxtx_vec_sse.c')
@@ -37,4 +37,7 @@ if arch_subdir == 'x86'
 	endif
 endif
 
+sources += files('ice_dcf.c',
+		 'ice_dcf_ethdev.c')
+
 install_headers('rte_pmd_ice.h')
mk/rte.app.mk +1 -0
index d295ca0a5..f3798a09f 100644
@@ -185,6 +185,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IAVF_PMD)       += -lrte_pmd_iavf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ICE_PMD)        += -lrte_pmd_ice
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifeq ($(findstring y,$(IAVF-y)),y)
 _LDLIBS-y += -lrte_common_iavf
 endif
Signature · 1 line
2.25.1
#30 lore raw

PATCH v2 3/7 net/ice: initiate to acquire the DCF capability

In reply to Haiyue Wang

Since the DCF (Device Config Function) controls the flow setting of other VFs by the mailbox with PF, for security, it needs to acquire the DCF capability from PF when starts, and exits to disable it.

---
 drivers/net/ice/ice_dcf.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +27 -1
index efb258a5a..7a3626939 100644
@@ -227,7 +227,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	int err, i;
 
 	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
-	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
 	       VF_BASE_MODE_OFFLOADS;
 
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -264,6 +264,31 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int
 ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
 {
@@ -467,6 +492,7 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_intr_callback_unregister(intr_handle,
 				     ice_dcf_dev_interrupt_handler, hw);
 
+	ice_dcf_mode_disable(hw);
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
Signature · 1 line
2.25.1
Reviewed-by on v2 3/7
#31 lore raw

Re: [dpdk-dev] [PATCH v2 3/7] net/ice: initiate to acquire the DCF capability

For the subject, since this patch is about acquire + disable, how about

net/ice: support DCF capability acquire/disable

Quoted 3 lines · Haiyue Wang

Since the DCF (Device Config Function) controls the flow setting of other VFs by the mailbox with PF, for security, it needs to acquire the DCF capability from PF when starts, and exits to disable it.

s/exits to disable it/disable it when exits

Quoted 62 lines

---
drivers/net/ice/ice_dcf.c | 28 +++++++++++++++++++++++++++-

1 file changed, 27 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +26 -1
index efb258a5a..7a3626939 100644
@@ -227,7 +227,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	int err, i;
 
 	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
-	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
 	       VF_BASE_MODE_OFFLOADS;
 
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -264,6 +264,31 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+

static int
ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
{

drivers/net/ice/ice_dcf.c +1 -0
@@ -467,6 +492,7 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_intr_callback_unregister(intr_handle,
 				     ice_dcf_dev_interrupt_handler, hw);
 
+	ice_dcf_mode_disable(hw);
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
Signature · 1 line
2.25.1

For the patch,

#32 lore raw

Re: [dpdk-dev] [PATCH v2 3/7] net/ice: initiate to acquire the DCF capability

Quoted 11 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Friday, March 13, 2020 13:52
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v2 3/7] net/ice: initiate to acquire the DCF capability

For the subject, since this patch is about acquire + disable, how about

net/ice: support DCF capability acquire/disable

Make sense, will improve the title.

Quoted 8 lines · Haiyue Wang
Quoted 3 lines

Since the DCF (Device Config Function) controls the flow setting of other VFs by the mailbox with PF, for security, it needs to acquire the DCF capability from PF when starts, and exits to disable it.

s/exits to disable it/disable it when exits

OK.

Quoted 66 lines
Quoted 60 lines

---
drivers/net/ice/ice_dcf.c | 28 +++++++++++++++++++++++++++-

1 file changed, 27 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +26 -1
index efb258a5a..7a3626939 100644
@@ -227,7 +227,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	int err, i;
 
 	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
-	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
 	       VF_BASE_MODE_OFFLOADS;
 
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -264,6 +264,31 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+

static int
ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
{

drivers/net/ice/ice_dcf.c +1 -1
@@ -467,6 +492,7 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_intr_callback_unregister(intr_handle,
 				     ice_dcf_dev_interrupt_handler, hw);
 
+	ice_dcf_mode_disable(hw);
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
--
Quoted 2 lines

2.25.1

For the patch,

#33 lore raw

Re: [dpdk-dev] [PATCH v2 3/7] net/ice: initiate to acquire the DCF capability

In reply to Haiyue Wang
Quoted 5 lines · Haiyue Wang
drivers/net/ice/ice_dcf.c +4 -0
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 280

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,

Unnecessary cast.

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
#34 lore raw

Re: [dpdk-dev] [PATCH v2 3/7] net/ice: initiate to acquire the DCF capability

Quoted 11 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Friday, March 13, 2020 14:04
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v2 3/7] net/ice: initiate to acquire the DCF capability

Quoted 1 line · Haiyue Wang
Quoted 16 lines
Quoted 4 lines
drivers/net/ice/ice_dcf.c +4 -0
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 280

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  (uint8_t *)hw->arq_buf,

Unnecessary cast.

will be fixed in next patch.

Quoted 11 lines
Quoted 11 lines
drivers/net/ice/ice_dcf.c +10 -0
+					  ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
#35 lore raw

PATCH v2 4/7 net/ice: handle the AdminQ command by DCF

In reply to Haiyue Wang

The DCF (Device Config Function) splits the AdminQ command into two
parts: one is the descriptor of AdminQ command, the other is the buffer of AdminQ command (the descriptor has BUF flag set). When both of them are received by the PF, the PF will handle them as one command.

And also, the filled descriptor and buffer of the response will be sent back to DCF one by one through the virtchnl from PF.

---
 drivers/net/ice/ice_dcf.c | 65 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h |  4 ++-
 2 files changed, 68 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +65 -0
index 7a3626939..24ed31f35 100644
@@ -397,6 +397,71 @@ ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 	return err;
 }
 
+int
+ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+		    void *buf, uint16_t buf_size)
+{
+	struct dcf_virtchnl_cmd desc_cmd, buff_cmd;
+	struct ice_dcf_hw *hw = dcf_hw;
+	int err = 0;
+	int i = 0;
+
+	if ((buf && !buf_size) || (!buf && buf_size) ||
+	    buf_size > ICE_DCF_AQ_BUF_SZ)
+		return -EINVAL;
+
+	desc_cmd.v_op = VIRTCHNL_OP_DCF_CMD_DESC;
+	desc_cmd.req_msglen = sizeof(*desc);
+	desc_cmd.req_msg = (uint8_t *)desc;
+	desc_cmd.rsp_buflen = sizeof(*desc);
+	desc_cmd.rsp_msgbuf = (uint8_t *)desc;
+
+	if (buf == NULL)
+		return ice_dcf_execute_virtchnl_cmd(hw, &desc_cmd);
+
+	desc->flags |= rte_cpu_to_le_16(ICE_AQ_FLAG_BUF);
+
+	buff_cmd.v_op = VIRTCHNL_OP_DCF_CMD_BUFF;
+	buff_cmd.req_msglen = buf_size;
+	buff_cmd.req_msg = buf;
+	buff_cmd.rsp_buflen = buf_size;
+	buff_cmd.rsp_msgbuf = buf;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, &desc_cmd);
+	ice_dcf_vc_cmd_set(hw, &buff_cmd);
+
+	if (ice_dcf_vc_cmd_send(hw, &desc_cmd) ||
+	    ice_dcf_vc_cmd_send(hw, &buff_cmd)) {
+		err = -1;
+		PMD_DRV_LOG(ERR, "fail to send OP_DCF_CMD_DESC/BUFF");
+		goto ret;
+	}
+
+	do {
+		if ((!desc_cmd.pending && !buff_cmd.pending) ||
+		    (!desc_cmd.pending && desc_cmd.v_ret != IAVF_SUCCESS) ||
+		    (!buff_cmd.pending && buff_cmd.v_ret != IAVF_SUCCESS))
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (desc_cmd.v_ret != IAVF_SUCCESS || buff_cmd.v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (desc: %d / buff: %d)",
+			    i, desc_cmd.v_ret, buff_cmd.v_ret);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, &desc_cmd);
+	ice_dcf_aq_cmd_clear(hw, &buff_cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
drivers/net/ice/ice_dcf.h +3 -1
index f44c09db2..99bd53b02 100644
@@ -11,6 +11,7 @@
 #include <iavf_adminq_cmd.h>
 #include <iavf_type.h>
 
+#include "base/ice_type.h"
 #include "ice_logs.h"
 
 struct dcf_virtchnl_cmd {
@@ -45,7 +46,8 @@ struct ice_dcf_hw {
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
-
+int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+			void *buf, uint16_t buf_size);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
Signature · 1 line
2.25.1
#36 lore raw

PATCH v2 5/7 net/ice: export the DDP definition symbols

In reply to Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

The DCF (Device Config Function) feature shares the core functions of the ICE PMD, like it needs to export the DDP definition symbols for the new DCF PMD use.

---
 drivers/net/ice/ice_ethdev.c | 9 +--------
 drivers/net/ice/ice_ethdev.h | 8 ++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ice/ice_ethdev.c +1 -8
index b42deb0bc..8b9d211b0 100644
@@ -67,15 +67,8 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 
 #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100
 
-/* DDP package search path */
-#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
-#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
-
 #define ICE_OS_DEFAULT_PKG_NAME		"ICE OS Default Package"
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
-#define ICE_MAX_PKG_FILENAME_SIZE   256
 #define ICE_MAX_RES_DESC_NUM        1024
 
 int ice_logtype_init;
@@ -1833,7 +1826,7 @@ ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file)
 	return 0;
 }
 
-static enum ice_pkg_type
+enum ice_pkg_type
 ice_load_pkg_type(struct ice_hw *hw)
 {
 	enum ice_pkg_type package_type;
drivers/net/ice/ice_ethdev.h +8 -0
index da557a254..7b94a3c3e 100644
@@ -42,6 +42,13 @@
 
 #define ICE_MAX_PKT_TYPE  1024
 
+/* DDP package search path */
+#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
+#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
+#define ICE_MAX_PKG_FILENAME_SIZE   256
+
 /**
  * vlan_id is a 12 bit number.
  * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
@@ -457,6 +464,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+enum ice_pkg_type ice_load_pkg_type(struct ice_hw *hw);
 struct ice_vsi *
 ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type);
 int
Signature · 1 line
2.25.1
#37 lore raw

PATCH v2 6/7 net/ice: handle the PF initialization by DCF

In reply to Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will proxy the PF's AdminQ command through DCF's mailbox.

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions about the flow .

---
 drivers/net/ice/Makefile         |   1 +
 drivers/net/ice/ice_dcf.c        |   7 +-
 drivers/net/ice/ice_dcf.h        |   3 +
 drivers/net/ice/ice_dcf_ethdev.c |  10 +-
 drivers/net/ice/ice_dcf_ethdev.h |  11 +-
 drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
 drivers/net/ice/meson.build      |   3 +-
 7 files changed, 292 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
drivers/net/ice/Makefile +1 -0
index f493c9ed7..3ecc72219 100644
@@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c
 
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
drivers/net/ice/ice_dcf.c +6 -1
index 24ed31f35..480c449f5 100644
@@ -124,8 +124,13 @@ ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
 	}
 
 	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
-	if (unlikely(v_op == VIRTCHNL_OP_EVENT))
+	if (unlikely(v_op == VIRTCHNL_OP_EVENT)) {
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
 		return;
+	}
 
 	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
 
drivers/net/ice/ice_dcf.h +3 -0
index 99bd53b02..ecd6303a0 100644
@@ -36,6 +36,9 @@ struct ice_dcf_hw {
 	rte_spinlock_t vc_cmd_send_lock;
 	rte_spinlock_t vc_cmd_queue_lock;
 	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
 	uint8_t *arq_buf;
 
 	struct virtchnl_version_info virtchnl_version;
drivers/net/ice/ice_dcf_ethdev.c +7 -3
index 23f82a487..af94caeff 100644
@@ -145,8 +145,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
 	dev->tx_pkt_burst = NULL;
-	dev->data->mac_addrs = NULL;
 
+	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 }
 
@@ -225,13 +225,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
 
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
 	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init DCF hardware");
 		return -1;
 	}
 
-	rte_eth_random_addr(adapter->mac_addr.addr_bytes);
-	eth_dev->data->mac_addrs = &adapter->mac_addr;
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter");
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
 
 	return 0;
 }
drivers/net/ice/ice_dcf_ethdev.h +10 -1
index 0c34a0095..e60e808d8 100644
@@ -5,6 +5,9 @@
 #ifndef _ICE_DCF_ETHDEV_H_
 #define _ICE_DCF_ETHDEV_H_
 
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
 #include "ice_ethdev.h"
 #include "ice_dcf.h"
 
@@ -15,10 +18,16 @@ struct ice_dcf_queue {
 };
 
 struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
 	struct ice_dcf_hw real_hw;
-	struct rte_ether_addr mac_addr;
 	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
 	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
 };
 
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +263 -0

263 lines not on this page · raw message

drivers/net/ice/meson.build +2 -1
index 0ba9668d1..7e9037f3b 100644
@@ -38,6 +38,7 @@ if arch_subdir == 'x86'
 endif
 
 sources += files('ice_dcf.c',
-		 'ice_dcf_ethdev.c')
+		 'ice_dcf_ethdev.c',
+		 'ice_dcf_parent.c')
 
 install_headers('rte_pmd_ice.h')
Signature · 1 line
2.25.1
#38 lore raw

Re: [dpdk-dev] [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

Quoted 36 lines · Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will proxy the PF's AdminQ command through DCF's mailbox.

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions about the flow .

---

drivers/net/ice/Makefile         |   1 +
drivers/net/ice/ice_dcf.c        |   7 +-
drivers/net/ice/ice_dcf.h        |   3 +
drivers/net/ice/ice_dcf_ethdev.c |  10 +-
drivers/net/ice/ice_dcf_ethdev.h |  11 +-
drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
drivers/net/ice/meson.build      |   3 +-
7 files changed, 292 insertions(+), 6 deletions(-)

create mode 100644 drivers/net/ice/ice_dcf_parent.c

drivers/net/ice/Makefile +0 -0
index f493c9ed7..3ecc72219 100644
@@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 

SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c

# install this header file
SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
drivers/net/ice/ice_dcf.c +0 -0
index 24ed31f35..480c449f5 100644

drivers/net/ice/ice_dcf.c ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info) · line 127

Quoted 5 lines
drivers/net/ice/ice_dcf.c +1 -1
@@ -124,8 +124,13 @@ ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
 	}
 
 	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
-	if (unlikely(v_op == VIRTCHNL_OP_EVENT))
+	if (unlikely(v_op == VIRTCHNL_OP_EVENT)) {

Is this unlikely really needed?

Quoted 72 lines
drivers/net/ice/ice_dcf.c +5 -0
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
 		return;
+	}
 
 	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
 
drivers/net/ice/ice_dcf.h +3 -0
index 99bd53b02..ecd6303a0 100644
@@ -36,6 +36,9 @@ struct ice_dcf_hw {
 	rte_spinlock_t vc_cmd_send_lock;
 	rte_spinlock_t vc_cmd_queue_lock;
 	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
 	uint8_t *arq_buf;
 
 	struct virtchnl_version_info virtchnl_version;
drivers/net/ice/ice_dcf_ethdev.c +7 -3
index 23f82a487..af94caeff 100644
@@ -145,8 +145,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
 	dev->tx_pkt_burst = NULL;
-	dev->data->mac_addrs = NULL;
 
+	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 }
 
@@ -225,13 +225,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
 
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
 	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init DCF hardware");
 		return -1;
 	}
 
-	rte_eth_random_addr(adapter->mac_addr.addr_bytes);
-	eth_dev->data->mac_addrs = &adapter->mac_addr;
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter");
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
 
 	return 0;
 }
drivers/net/ice/ice_dcf_ethdev.h +3 -0
index 0c34a0095..e60e808d8 100644
@@ -5,6 +5,9 @@
 #ifndef _ICE_DCF_ETHDEV_H_
 #define _ICE_DCF_ETHDEV_H_
 
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
 #include "ice_ethdev.h"
 #include "ice_dcf.h"
 

drivers/net/ice/ice_dcf_ethdev.h struct ice_dcf_queue { · line 19

Quoted 7 lines
drivers/net/ice/ice_dcf_ethdev.h +2 -1
@@ -15,10 +18,16 @@ struct ice_dcf_queue {
 };
 
 struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
 	struct ice_dcf_hw real_hw;
-	struct rte_ether_addr mac_addr;

This one isn't needed at the first place.

Quoted 162 lines
drivers/net/ice/ice_dcf_ethdev.h +5 -0
 	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
 	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
 };
 
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +146 -0
new file mode 100644
index 000000000..4c3bb68b1
@@ -0,0 +1,263 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "ice_dcf_ethdev.h"
+
+void
+ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
+			    uint8_t *msg, uint16_t msglen)
+{
+	struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;
+
+	if (msglen < sizeof(struct virtchnl_pf_event)) {
+		PMD_DRV_LOG(DEBUG, "Invalid event message length : %u", msglen);
+		return;
+	}
+
+	switch (pf_msg->event) {
+	case VIRTCHNL_EVENT_RESET_IMPENDING:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
+		break;
+	case VIRTCHNL_EVENT_LINK_CHANGE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
+		break;
+	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event);
+		break;
+	}
+}
+
+static int
+ice_dcf_init_parent_hw(struct ice_hw *hw)
+{
+	struct ice_aqc_get_phy_caps_data *pcaps;
+	enum ice_status status;
+
+	status = ice_aq_get_fw_ver(hw, NULL);
+	if (status)
+		return status;
+
+	status = ice_get_caps(hw);
+	if (status)
+		return status;
+
+	hw->port_info = (struct ice_port_info *)
+			ice_malloc(hw, sizeof(*hw->port_info));
+	if (!hw->port_info)
+		return ICE_ERR_NO_MEMORY;
+
+	/* set the back pointer to HW */
+	hw->port_info->hw = hw;
+
+	/* Initialize port_info struct with switch configuration data */
+	status = ice_get_initial_sw_cfg(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	pcaps = (struct ice_aqc_get_phy_caps_data *)
+		ice_malloc(hw, sizeof(*pcaps));
+	if (!pcaps) {
+		status = ICE_ERR_NO_MEMORY;
+		goto err_unroll_alloc;
+	}
+
+	/* Initialize port_info struct with PHY capabilities */
+	status = ice_aq_get_phy_caps(hw->port_info, false,
+				     ICE_AQC_REPORT_TOPO_CAP, pcaps, NULL);
+	ice_free(hw, pcaps);
+	if (status)
+		goto err_unroll_alloc;
+
+	/* Initialize port_info struct with link information */
+	status = ice_aq_get_link_info(hw->port_info, false, NULL, NULL);
+	if (status)
+		goto err_unroll_alloc;
+
+	status = ice_init_fltr_mgmt_struct(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	status = ice_init_hw_tbls(hw);
+	if (status)
+		goto err_unroll_fltr_mgmt_struct;
+
+	PMD_INIT_LOG(INFO,
+		     "firmware %d.%d.%d api %d.%d.%d build 0x%08x",
+		     hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch,
+		     hw->api_maj_ver, hw->api_min_ver, hw->api_patch,
+		     hw->fw_build);
+
+	return ICE_SUCCESS;
+
+err_unroll_fltr_mgmt_struct:
+	ice_cleanup_fltr_mgmt_struct(hw);
+err_unroll_alloc:
+	ice_free(hw, hw->port_info);
+	hw->port_info = NULL;
+
+	return status;
+}
+
+static void ice_dcf_uninit_parent_hw(struct ice_hw *hw)
+{
+	ice_cleanup_fltr_mgmt_struct(hw);
+
+	ice_free_seg(hw);
+	ice_free_hw_tbls(hw);
+
+	ice_free(hw, hw->port_info);
+	hw->port_info = NULL;
+
+	ice_clear_all_vsi_ctx(hw);
+}
+
+static int
+ice_dcf_request_pkg_name(struct ice_hw *hw, char *pkg_name)
+{
+	struct ice_dcf_adapter *dcf_adapter =
+			container_of(hw, struct ice_dcf_adapter, parent.hw);
+
+	/* TODO: check with DSN firstly by iAVF */
+	PMD_INIT_LOG(DEBUG,
+		     "DCF VSI_ID = %u",
+		     dcf_adapter->real_hw.vsi_id);
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_UPDATES);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_DEFAULT);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	return -1;
+}
+
+static int
+ice_dcf_load_pkg(struct ice_hw *hw)

drivers/net/ice/ice_dcf_parent.c line 156

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c new file +10 -0
+{
+	char pkg_name[ICE_MAX_PKG_FILENAME_SIZE];
+	uint8_t *pkg_buf;
+	uint32_t buf_len;
+	struct stat st;
+	FILE *fp;
+	int err;
+
+	if (ice_dcf_request_pkg_name(hw, pkg_name)) {
+		PMD_INIT_LOG(ERR, "failed to locate the package file");

s/failed/Failed

drivers/net/ice/ice_dcf_parent.c line 164

Quoted 8 lines
drivers/net/ice/ice_dcf_parent.c new file +8 -0
+		return -ENOENT;
+	}
+
+	PMD_INIT_LOG(DEBUG, "DDP package name: %s", pkg_name);
+
+	err = stat(pkg_name, &st);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to get file status");

s/failed/Failed

Quoted 115 lines
drivers/net/ice/ice_dcf_parent.c new file +99 -0
+		return err;
+	}
+
+	buf_len = st.st_size;
+	pkg_buf = rte_malloc(NULL, buf_len, 0);
+	if (!pkg_buf) {
+		PMD_INIT_LOG(ERR, "failed to allocate buffer of size %u for package",
+			     buf_len);
+		return -1;
+	}
+
+	fp = fopen(pkg_name, "rb");
+	if (!fp)  {
+		PMD_INIT_LOG(ERR, "failed to open file: %s", pkg_name);
+		err = -1;
+		goto ret;
+	}
+
+	err = fread(pkg_buf, buf_len, 1, fp);
+	fclose(fp);
+	if (err != 1) {
+		PMD_INIT_LOG(ERR, "failed to read package data");
+		err = -1;
+		goto ret;
+	}
+
+	err = ice_copy_and_init_pkg(hw, pkg_buf, buf_len);
+	if (err)
+		PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d", err);
+
+ret:
+	rte_free(pkg_buf);
+	return err;
+}
+
+int
+ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+	struct ice_dcf_hw *hw = &adapter->real_hw;
+	const struct rte_ether_addr *mac;
+	int err;
+
+	parent_adapter->eth_dev = eth_dev;
+	parent_adapter->pf.adapter = parent_adapter;
+	parent_adapter->pf.dev_data = eth_dev->data;
+	parent_hw->back = parent_adapter;
+	parent_hw->mac_type = ICE_MAC_GENERIC;
+	parent_hw->vendor_id = ICE_INTEL_VENDOR_ID;
+
+	ice_init_lock(&parent_hw->adminq.sq_lock);
+	ice_init_lock(&parent_hw->adminq.rq_lock);
+	parent_hw->aq_send_cmd_fn = ice_dcf_send_aq_cmd;
+	parent_hw->aq_send_cmd_param = &adapter->real_hw;
+	parent_hw->dcf_enabled = true;
+
+	err = ice_dcf_init_parent_hw(parent_hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to init the DCF parent hardware with error %d",
+			     err);
+		return err;
+	}
+
+	err = ice_dcf_load_pkg(parent_hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to load package with error %d",
+			     err);
+		goto uninit_hw;
+	}
+	parent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);
+
+	mac = (const struct rte_ether_addr *)hw->avf.mac.addr;
+	if (rte_is_valid_assigned_ether_addr(mac))
+		rte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);
+	else
+		rte_eth_random_addr(parent_adapter->pf.dev_addr.addr_bytes);
+
+	eth_dev->data->mac_addrs = &parent_adapter->pf.dev_addr;
+
+	return 0;
+
+uninit_hw:
+	ice_dcf_uninit_parent_hw(parent_hw);
+	return err;
+}
+
+void
+ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+
+	eth_dev->data->mac_addrs = NULL;
+
+	ice_dcf_uninit_parent_hw(parent_hw);
+}
drivers/net/ice/meson.build +0 -0
index 0ba9668d1..7e9037f3b 100644
@@ -38,6 +38,7 @@ if arch_subdir == 'x86'

endif

sources += files('ice_dcf.c',

drivers/net/ice/meson.build +2 -1
-		 'ice_dcf_ethdev.c')
+		 'ice_dcf_ethdev.c',
+		 'ice_dcf_parent.c')

install_headers('rte_pmd_ice.h')

Signature · 1 line
2.25.1
#39 lore raw

Re: [dpdk-dev] [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

Quoted 7 lines · Ye Xiaolong

drivers/net/ice/ice_dcf_ethdev.h struct ice_dcf_queue { · line 19

Quoted 5 lines

struct ice_dcf_adapter {

(quoted diff) +2 -0
+	struct ice_adapter parent; /* Must be first */
+
	struct ice_dcf_hw real_hw;
drivers/net/ice/ice_dcf_ethdev.h +0 -1
-	struct rte_ether_addr mac_addr;

This one isn't needed at the first place.

My bad, please ignore this comment.

#40 lore raw

Re: [dpdk-dev] [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

In reply to Ye Xiaolong
Quoted 47 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Friday, March 13, 2020 16:00
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

Quoted 38 lines · Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will proxy the PF's AdminQ command through DCF's mailbox.

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions about the flow .

---

drivers/net/ice/Makefile         |   1 +
drivers/net/ice/ice_dcf.c        |   7 +-
drivers/net/ice/ice_dcf.h        |   3 +
drivers/net/ice/ice_dcf_ethdev.c |  10 +-
drivers/net/ice/ice_dcf_ethdev.h |  11 +-
drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
drivers/net/ice/meson.build      |   3 +-
7 files changed, 292 insertions(+), 6 deletions(-)

create mode 100644 drivers/net/ice/ice_dcf_parent.c

drivers/net/ice/Makefile +0 -0
index f493c9ed7..3ecc72219 100644
@@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 

SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c +SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c

# install this header file
SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
drivers/net/ice/ice_dcf.c +0 -0
index 24ed31f35..480c449f5 100644
@@ -124,8 +124,13 @@ ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
 	}
 
Quoted 6 lines

drivers/net/ice/ice_dcf.c ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info) · line 127

Quoted 3 lines
drivers/net/ice/ice_dcf.c +1 -1
 	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
-	if (unlikely(v_op == VIRTCHNL_OP_EVENT))
+	if (unlikely(v_op == VIRTCHNL_OP_EVENT)) {

Is this unlikely really needed?

Looks like 'unlikely' a little abuse. Will remove it in v3 ;-0

Quoted 248 lines
Quoted 72 lines
drivers/net/ice/ice_dcf.c +5 -0
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
 		return;
+	}
 
 	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
 
drivers/net/ice/ice_dcf.h +3 -0
index 99bd53b02..ecd6303a0 100644
@@ -36,6 +36,9 @@ struct ice_dcf_hw {
 	rte_spinlock_t vc_cmd_send_lock;
 	rte_spinlock_t vc_cmd_queue_lock;
 	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
 	uint8_t *arq_buf;
 
 	struct virtchnl_version_info virtchnl_version;
drivers/net/ice/ice_dcf_ethdev.c +7 -3
index 23f82a487..af94caeff 100644
@@ -145,8 +145,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
 	dev->tx_pkt_burst = NULL;
-	dev->data->mac_addrs = NULL;
 
+	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 }
 
@@ -225,13 +225,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
 
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
 	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init DCF hardware");
 		return -1;
 	}
 
-	rte_eth_random_addr(adapter->mac_addr.addr_bytes);
-	eth_dev->data->mac_addrs = &adapter->mac_addr;
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter");
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
 
 	return 0;
 }
drivers/net/ice/ice_dcf_ethdev.h +3 -0
index 0c34a0095..e60e808d8 100644
@@ -5,6 +5,9 @@
 #ifndef _ICE_DCF_ETHDEV_H_
 #define _ICE_DCF_ETHDEV_H_
 
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
 #include "ice_ethdev.h"
 #include "ice_dcf.h"
 

drivers/net/ice/ice_dcf_ethdev.h struct ice_dcf_queue { · line 19

Quoted 7 lines
drivers/net/ice/ice_dcf_ethdev.h +2 -1
@@ -15,10 +18,16 @@ struct ice_dcf_queue {
 };
 
 struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
 	struct ice_dcf_hw real_hw;
-	struct rte_ether_addr mac_addr;

This one isn't needed at the first place.

Quoted 166 lines
drivers/net/ice/ice_dcf_ethdev.h +5 -0
 	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
 	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
 };
 
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +150 -0
new file mode 100644
index 000000000..4c3bb68b1
@@ -0,0 +1,263 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include "ice_dcf_ethdev.h"
+
+void
+ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
+			    uint8_t *msg, uint16_t msglen)
+{
+	struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;
+
+	if (msglen < sizeof(struct virtchnl_pf_event)) {
+		PMD_DRV_LOG(DEBUG, "Invalid event message length : %u", msglen);
+		return;
+	}
+
+	switch (pf_msg->event) {
+	case VIRTCHNL_EVENT_RESET_IMPENDING:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
+		break;
+	case VIRTCHNL_EVENT_LINK_CHANGE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
+		break;
+	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
+		break;
+	default:
+		PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event);
+		break;
+	}
+}
+
+static int
+ice_dcf_init_parent_hw(struct ice_hw *hw)
+{
+	struct ice_aqc_get_phy_caps_data *pcaps;
+	enum ice_status status;
+
+	status = ice_aq_get_fw_ver(hw, NULL);
+	if (status)
+		return status;
+
+	status = ice_get_caps(hw);
+	if (status)
+		return status;
+
+	hw->port_info = (struct ice_port_info *)
+			ice_malloc(hw, sizeof(*hw->port_info));
+	if (!hw->port_info)
+		return ICE_ERR_NO_MEMORY;
+
+	/* set the back pointer to HW */
+	hw->port_info->hw = hw;
+
+	/* Initialize port_info struct with switch configuration data */
+	status = ice_get_initial_sw_cfg(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	pcaps = (struct ice_aqc_get_phy_caps_data *)
+		ice_malloc(hw, sizeof(*pcaps));
+	if (!pcaps) {
+		status = ICE_ERR_NO_MEMORY;
+		goto err_unroll_alloc;
+	}
+
+	/* Initialize port_info struct with PHY capabilities */
+	status = ice_aq_get_phy_caps(hw->port_info, false,
+				     ICE_AQC_REPORT_TOPO_CAP, pcaps, NULL);
+	ice_free(hw, pcaps);
+	if (status)
+		goto err_unroll_alloc;
+
+	/* Initialize port_info struct with link information */
+	status = ice_aq_get_link_info(hw->port_info, false, NULL, NULL);
+	if (status)
+		goto err_unroll_alloc;
+
+	status = ice_init_fltr_mgmt_struct(hw);
+	if (status)
+		goto err_unroll_alloc;
+
+	status = ice_init_hw_tbls(hw);
+	if (status)
+		goto err_unroll_fltr_mgmt_struct;
+
+	PMD_INIT_LOG(INFO,
+		     "firmware %d.%d.%d api %d.%d.%d build 0x%08x",
+		     hw->fw_maj_ver, hw->fw_min_ver, hw->fw_patch,
+		     hw->api_maj_ver, hw->api_min_ver, hw->api_patch,
+		     hw->fw_build);
+
+	return ICE_SUCCESS;
+
+err_unroll_fltr_mgmt_struct:
+	ice_cleanup_fltr_mgmt_struct(hw);
+err_unroll_alloc:
+	ice_free(hw, hw->port_info);
+	hw->port_info = NULL;
+
+	return status;
+}
+
+static void ice_dcf_uninit_parent_hw(struct ice_hw *hw)
+{
+	ice_cleanup_fltr_mgmt_struct(hw);
+
+	ice_free_seg(hw);
+	ice_free_hw_tbls(hw);
+
+	ice_free(hw, hw->port_info);
+	hw->port_info = NULL;
+
+	ice_clear_all_vsi_ctx(hw);
+}
+
+static int
+ice_dcf_request_pkg_name(struct ice_hw *hw, char *pkg_name)
+{
+	struct ice_dcf_adapter *dcf_adapter =
+			container_of(hw, struct ice_dcf_adapter, parent.hw);
+
+	/* TODO: check with DSN firstly by iAVF */
+	PMD_INIT_LOG(DEBUG,
+		     "DCF VSI_ID = %u",
+		     dcf_adapter->real_hw.vsi_id);
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_UPDATES);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	snprintf(pkg_name,
+		 ICE_MAX_PKG_FILENAME_SIZE, "%s", ICE_PKG_FILE_DEFAULT);
+	if (!access(pkg_name, 0))
+		return 0;
+
+	return -1;
+}
+
+static int
+ice_dcf_load_pkg(struct ice_hw *hw)
+{
+	char pkg_name[ICE_MAX_PKG_FILENAME_SIZE];
+	uint8_t *pkg_buf;
+	uint32_t buf_len;
Quoted 9 lines

drivers/net/ice/ice_dcf_parent.c line 156

Quoted 6 lines
drivers/net/ice/ice_dcf_parent.c new file +6 -0
+	struct stat st;
+	FILE *fp;
+	int err;
+
+	if (ice_dcf_request_pkg_name(hw, pkg_name)) {
+		PMD_INIT_LOG(ERR, "failed to locate the package file");

s/failed/Failed

Fixed in v3.

Quoted 11 lines

drivers/net/ice/ice_dcf_parent.c line 164

Quoted 8 lines
drivers/net/ice/ice_dcf_parent.c new file +8 -0
+		return -ENOENT;
+	}
+
+	PMD_INIT_LOG(DEBUG, "DDP package name: %s", pkg_name);
+
+	err = stat(pkg_name, &st);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to get file status");

s/failed/Failed

Fixed in v3.

Quoted 115 lines
Quoted 115 lines
drivers/net/ice/ice_dcf_parent.c new file +99 -0
+		return err;
+	}
+
+	buf_len = st.st_size;
+	pkg_buf = rte_malloc(NULL, buf_len, 0);
+	if (!pkg_buf) {
+		PMD_INIT_LOG(ERR, "failed to allocate buffer of size %u for package",
+			     buf_len);
+		return -1;
+	}
+
+	fp = fopen(pkg_name, "rb");
+	if (!fp)  {
+		PMD_INIT_LOG(ERR, "failed to open file: %s", pkg_name);
+		err = -1;
+		goto ret;
+	}
+
+	err = fread(pkg_buf, buf_len, 1, fp);
+	fclose(fp);
+	if (err != 1) {
+		PMD_INIT_LOG(ERR, "failed to read package data");
+		err = -1;
+		goto ret;
+	}
+
+	err = ice_copy_and_init_pkg(hw, pkg_buf, buf_len);
+	if (err)
+		PMD_INIT_LOG(ERR, "ice_copy_and_init_hw failed: %d", err);
+
+ret:
+	rte_free(pkg_buf);
+	return err;
+}
+
+int
+ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+	struct ice_dcf_hw *hw = &adapter->real_hw;
+	const struct rte_ether_addr *mac;
+	int err;
+
+	parent_adapter->eth_dev = eth_dev;
+	parent_adapter->pf.adapter = parent_adapter;
+	parent_adapter->pf.dev_data = eth_dev->data;
+	parent_hw->back = parent_adapter;
+	parent_hw->mac_type = ICE_MAC_GENERIC;
+	parent_hw->vendor_id = ICE_INTEL_VENDOR_ID;
+
+	ice_init_lock(&parent_hw->adminq.sq_lock);
+	ice_init_lock(&parent_hw->adminq.rq_lock);
+	parent_hw->aq_send_cmd_fn = ice_dcf_send_aq_cmd;
+	parent_hw->aq_send_cmd_param = &adapter->real_hw;
+	parent_hw->dcf_enabled = true;
+
+	err = ice_dcf_init_parent_hw(parent_hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to init the DCF parent hardware with error %d",
+			     err);
+		return err;
+	}
+
+	err = ice_dcf_load_pkg(parent_hw);
+	if (err) {
+		PMD_INIT_LOG(ERR, "failed to load package with error %d",
+			     err);
+		goto uninit_hw;
+	}
+	parent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);
+
+	mac = (const struct rte_ether_addr *)hw->avf.mac.addr;
+	if (rte_is_valid_assigned_ether_addr(mac))
+		rte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);
+	else
+		rte_eth_random_addr(parent_adapter->pf.dev_addr.addr_bytes);
+
+	eth_dev->data->mac_addrs = &parent_adapter->pf.dev_addr;
+
+	return 0;
+
+uninit_hw:
+	ice_dcf_uninit_parent_hw(parent_hw);
+	return err;
+}
+
+void
+ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)
+{
+	struct ice_dcf_adapter *adapter = eth_dev->data->dev_private;
+	struct ice_adapter *parent_adapter = &adapter->parent;
+	struct ice_hw *parent_hw = &parent_adapter->hw;
+
+	eth_dev->data->mac_addrs = NULL;
+
+	ice_dcf_uninit_parent_hw(parent_hw);
+}
drivers/net/ice/meson.build +0 -0
index 0ba9668d1..7e9037f3b 100644
@@ -38,6 +38,7 @@ if arch_subdir == 'x86'

endif

sources += files('ice_dcf.c',

drivers/net/ice/meson.build +2 -1
-		 'ice_dcf_ethdev.c')
+		 'ice_dcf_ethdev.c',
+		 'ice_dcf_parent.c')

install_headers('rte_pmd_ice.h')
--
2.25.1

#41 lore raw

Re: [dpdk-dev] [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

In reply to Haiyue Wang
Quoted 3 lines · Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will proxy the PF's AdminQ command through DCF's mailbox.

Proxy is a noun, so this sentence is a little bit confusing. Do you mean DCF will rely on the mailbox to serve as the proxy to pass the PF's AdminQ command?

Thanks,
Xiaolong

Quoted 15 lines

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions about the flow .

---

drivers/net/ice/Makefile         |   1 +
drivers/net/ice/ice_dcf.c        |   7 +-
drivers/net/ice/ice_dcf.h        |   3 +
drivers/net/ice/ice_dcf_ethdev.c |  10 +-
drivers/net/ice/ice_dcf_ethdev.h |  11 +-
drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
drivers/net/ice/meson.build      |   3 +-
7 files changed, 292 insertions(+), 6 deletions(-)

create mode 100644 drivers/net/ice/ice_dcf_parent.c

#42 lore raw

Re: [dpdk-dev] [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

Quoted 8 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Friday, March 13, 2020 22:07
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v2 6/7] net/ice: handle the PF initialization by DCF

Quoted 9 lines
Quoted 3 lines · Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will proxy the PF's AdminQ command through DCF's mailbox.

Proxy is a noun, so this sentence is a little bit confusing. Do you mean DCF will rely on the mailbox to serve as the proxy to pass the PF's AdminQ command?

Yes, exactly, should be "pass through the PF's ..."

Quoted 18 lines

Thanks,
Xiaolong

Quoted 15 lines

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions about the flow .

---

drivers/net/ice/Makefile         |   1 +
drivers/net/ice/ice_dcf.c        |   7 +-
drivers/net/ice/ice_dcf.h        |   3 +
drivers/net/ice/ice_dcf_ethdev.c |  10 +-
drivers/net/ice/ice_dcf_ethdev.h |  11 +-
drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
drivers/net/ice/meson.build      |   3 +-
7 files changed, 292 insertions(+), 6 deletions(-)

create mode 100644 drivers/net/ice/ice_dcf_parent.c

#43 lore raw

PATCH v2 7/7 net/ice: get the VF hardware index in DCF

In reply to Haiyue Wang

The DCF (Device Config Function) needs the hardware index of the VFs to control the flow setting. And also if the VF resets, the index may be changed, so it should handle this in VF reset event.

---
 drivers/net/ice/ice_dcf.c        | 81 +++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h        |  4 ++
 drivers/net/ice/ice_dcf_parent.c | 83 +++++++++++++++++++++++++++++++-
 3 files changed, 167 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +81 -0
index 480c449f5..1d3c8fa95 100644
@@ -269,6 +269,63 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	if (len < sizeof(*vsi_map) || !vsi_map->num_vfs ||
+	    len < sizeof(*vsi_map) +
+			(vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0])) {
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+	if (!hw->vf_vsi_map) {
+		hw->num_vfs = vsi_map->num_vfs;
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
+	}
+
+	if (!hw->vf_vsi_map) {
+		PMD_DRV_LOG(ERR, "Fail to alloc memory for VSI context");
+		return -ENOMEM;
+	}
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+
 static int
 ice_dcf_mode_disable(struct ice_dcf_hw *hw)
 {
@@ -467,6 +524,23 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 	return err;
 }
 
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	ice_dcf_enable_irq0(hw);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
@@ -534,6 +608,12 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 		goto err_alloc;
 	}
 
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   ice_dcf_dev_interrupt_handler, hw);
 	rte_intr_enable(&pci_dev->intr_handle);
@@ -566,5 +646,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
 	rte_free(hw->vf_res);
 }
drivers/net/ice/ice_dcf.h +4 -0
index ecd6303a0..12bef4a2a 100644
@@ -41,6 +41,9 @@ struct ice_dcf_hw {
 
 	uint8_t *arq_buf;
 
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
 	struct virtchnl_version_info virtchnl_version;
 	struct virtchnl_vf_resource *vf_res; /* VF resource */
 	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
@@ -51,6 +54,7 @@ int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
drivers/net/ice/ice_dcf_parent.c +82 -1

115 lines not on this page · raw message

Signature · 1 line
2.25.1
#44 lore raw

Re: [dpdk-dev] [PATCH v2 7/7] net/ice: get the VF hardware index in DCF

Quoted 20 lines · Haiyue Wang

The DCF (Device Config Function) needs the hardware index of the VFs to control the flow setting. And also if the VF resets, the index may be changed, so it should handle this in VF reset event.

---

drivers/net/ice/ice_dcf.c        | 81 +++++++++++++++++++++++++++++++
drivers/net/ice/ice_dcf.h        |  4 ++
drivers/net/ice/ice_dcf_parent.c | 83 +++++++++++++++++++++++++++++++-
3 files changed, 167 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +1 -0
index 480c449f5..1d3c8fa95 100644
@@ -269,6 +269,63 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 282

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_GET_VSI_MAP");

Better to make the err log format consistent, either "Failed to xxx" or "Fail to xxxx", I prefer to "Failed to xxx".

Quoted 5 lines
drivers/net/ice/ice_dcf.c +5 -0
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 297

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	if (len < sizeof(*vsi_map) || !vsi_map->num_vfs ||
+	    len < sizeof(*vsi_map) +
+			(vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0])) {

Better to use a tmp variable to make the code more readable. And is the first len < sizeof(*vsi_map) redundant?

Quoted 11 lines
drivers/net/ice/ice_dcf.c +11 -0
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 318

Quoted 10 lines
drivers/net/ice/ice_dcf.c +10 -0
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+	if (!hw->vf_vsi_map) {
+		hw->num_vfs = vsi_map->num_vfs;
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
+	}
+
+	if (!hw->vf_vsi_map) {
+		PMD_DRV_LOG(ERR, "Fail to alloc memory for VSI context");
+		return -ENOMEM;
+	}

I think above two blocks can be combined with one if (!hw->vf_vsi_map).

Quoted 105 lines
drivers/net/ice/ice_dcf.c +10 -0
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+

static int
ice_dcf_mode_disable(struct ice_dcf_hw *hw)
{

drivers/net/ice/ice_dcf.c +17 -0
@@ -467,6 +524,23 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 	return err;
 }
 
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	ice_dcf_enable_irq0(hw);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+

int
ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) {

drivers/net/ice/ice_dcf.c +7 -0
@@ -534,6 +608,12 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 		goto err_alloc;
 	}
 
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   ice_dcf_dev_interrupt_handler, hw);
 	rte_intr_enable(&pci_dev->intr_handle);
@@ -566,5 +646,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
 	rte_free(hw->vf_res);
 }
drivers/net/ice/ice_dcf.h +4 -0
index ecd6303a0..12bef4a2a 100644
@@ -41,6 +41,9 @@ struct ice_dcf_hw {
 
 	uint8_t *arq_buf;
 
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
 	struct virtchnl_version_info virtchnl_version;
 	struct virtchnl_vf_resource *vf_res; /* VF resource */
 	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
@@ -51,6 +54,7 @@ int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
drivers/net/ice/ice_dcf_parent.c +16 -0
index 4c3bb68b1..2735221e9 100644
@@ -5,10 +5,76 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <rte_alarm.h>
+
 #include "ice_dcf_ethdev.h"
 
+#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL	100000 /* us */
+
+static __rte_always_inline void
+ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
+		       uint16_t vsi_map)
+{
+	struct ice_vsi_ctx *vsi_ctx;
+
+	if (unlikely(vsi_handle >= ICE_MAX_VSI)) {
+		PMD_DRV_LOG(ERR, "Invalid vsi handle %u", vsi_handle);
+		return;
+	}
+
+	vsi_ctx = hw->vsi_ctx[vsi_handle];

drivers/net/ice/ice_dcf_parent.c line 35

Quoted 10 lines
drivers/net/ice/ice_dcf_parent.c +10 -0
+
+	if (vsi_map & VIRTCHNL_DCF_VF_VSI_VALID) {
+		if (!vsi_ctx)
+			vsi_ctx = ice_malloc(hw, sizeof(*vsi_ctx));
+
+		if (!vsi_ctx) {
+			PMD_DRV_LOG(ERR, "No memory for vsi context %u",
+				    vsi_handle);
+			return;
+		}

Above two blocks can be combined.

Quoted 47 lines
drivers/net/ice/ice_dcf_parent.c +40 -0
+
+		vsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>
+					      VIRTCHNL_DCF_VF_VSI_ID_S;
+		hw->vsi_ctx[vsi_handle] = vsi_ctx;
+
+		PMD_DRV_LOG(DEBUG, "VF%u is assigned with vsi number %u",
+			    vsi_handle, vsi_ctx->vsi_num);
+	} else {
+		hw->vsi_ctx[vsi_handle] = NULL;
+
+		ice_free(hw, vsi_ctx);
+
+		PMD_DRV_LOG(NOTICE, "VF%u is disabled", vsi_handle);
+	}
+}
+
+static void
+ice_dcf_update_vf_vsi_map(struct ice_hw *hw, uint16_t num_vfs,
+			  uint16_t *vf_vsi_map)
+{
+	uint16_t vf_id;
+
+	for (vf_id = 0; vf_id < num_vfs; vf_id++)
+		ice_dcf_update_vsi_ctx(hw, vf_id, vf_vsi_map[vf_id]);
+}
+
+static void
+ice_dcf_vsi_update_service_handler(void *param)
+{
+	struct ice_dcf_hw *hw = param;
+
+	if (!ice_dcf_handle_vsi_update_event(hw)) {
+		struct ice_dcf_adapter *dcf_ad =
+			container_of(hw, struct ice_dcf_adapter, real_hw);
+
+		ice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw,
+					  hw->num_vfs, hw->vf_vsi_map);
+	}
+}
+

void

drivers/net/ice/ice_dcf_parent.c +1 -1
-ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
+ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
			    uint8_t *msg, uint16_t msglen)
{
	struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;

drivers/net/ice/ice_dcf_parent.c ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw, · line 91

Quoted 5 lines
drivers/net/ice/ice_dcf_parent.c +2 -0
@@ -21,6 +87,8 @@ ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
 	switch (pf_msg->event) {
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL * 2,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);

Why * 2 for the VIRTCHNL_EVENT_RESET_IMPENDING event?

Quoted 18 lines
drivers/net/ice/ice_dcf_parent.c +7 -0
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
@@ -28,6 +96,13 @@ ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
 	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
 		break;
+	case VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE event : VF%u with VSI num %u",
+			    pf_msg->event_data.vf_vsi_map.vf_id,
+			    pf_msg->event_data.vf_vsi_map.vsi_id);
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event);
 		break;

drivers/net/ice/ice_dcf_parent.c ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev) · line 315

Quoted 6 lines
drivers/net/ice/ice_dcf_parent.c +3 -0
@@ -235,6 +310,9 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
 	}
 	parent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);
 
+	ice_dcf_update_vf_vsi_map(parent_hw,
+				  hw->num_vfs, hw->vf_vsi_map);
+

No need to split into 2 lines.

Quoted 15 lines
drivers/net/ice/ice_dcf_parent.c +3 -0
 	mac = (const struct rte_ether_addr *)hw->avf.mac.addr;
 	if (rte_is_valid_assigned_ether_addr(mac))
 		rte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);
@@ -259,5 +337,8 @@ ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->mac_addrs = NULL;
 
+	rte_eal_alarm_cancel(ice_dcf_vsi_update_service_handler,
+			     &adapter->real_hw);
+
 	ice_dcf_uninit_parent_hw(parent_hw);
 }
Signature · 1 line
2.25.1
#45 lore raw

Re: [dpdk-dev] [PATCH v2 7/7] net/ice: get the VF hardware index in DCF

Quoted 28 lines

-----Original Message-----
From: Ye, Xiaolong <[email protected]>
Sent: Friday, March 13, 2020 15:01
To: Wang, Haiyue <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>; Zhao1, Wei <[email protected]>
Subject: Re: [PATCH v2 7/7] net/ice: get the VF hardware index in DCF

Quoted 19 lines · Haiyue Wang

The DCF (Device Config Function) needs the hardware index of the VFs to control the flow setting. And also if the VF resets, the index may be changed, so it should handle this in VF reset event.

---

drivers/net/ice/ice_dcf.c        | 81 +++++++++++++++++++++++++++++++
drivers/net/ice/ice_dcf.h        |  4 ++
drivers/net/ice/ice_dcf_parent.c | 83 +++++++++++++++++++++++++++++++-
3 files changed, 167 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +0 -0
index 480c449f5..1d3c8fa95 100644
@@ -269,6 +269,63 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
Quoted 15 lines

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 282

Quoted 11 lines
drivers/net/ice/ice_dcf.c +11 -0
+static int
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_GET_VSI_MAP");

Better to make the err log format consistent, either "Failed to xxx" or "Fail to xxxx", I prefer to "Failed to xxx".

Fixed in v3 with "Failed to xxx".

Quoted 11 lines
Quoted 11 lines
drivers/net/ice/ice_dcf.c +10 -0
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
Quoted 8 lines

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 297

Quoted 5 lines
drivers/net/ice/ice_dcf.c +5 -0
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	if (len < sizeof(*vsi_map) || !vsi_map->num_vfs ||
+	    len < sizeof(*vsi_map) +
+			(vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0])) {

Better to use a tmp variable to make the code more readable. And is the first len < sizeof(*vsi_map) redundant?

Yes, and enhanced this with valid_msg_len for checking the length in v3.

Quoted 16 lines
Quoted 16 lines
drivers/net/ice/ice_dcf.c +15 -0
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+	if (!hw->vf_vsi_map) {
+		hw->num_vfs = vsi_map->num_vfs;
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
Quoted 9 lines

drivers/net/ice/ice_dcf.c ice_dcf_get_vf_resource(struct ice_dcf_hw *hw) · line 318

Quoted 6 lines
drivers/net/ice/ice_dcf.c +6 -0
+	}
+
+	if (!hw->vf_vsi_map) {
+		PMD_DRV_LOG(ERR, "Fail to alloc memory for VSI context");
+		return -ENOMEM;
+	}

I think above two blocks can be combined with one if (!hw->vf_vsi_map).

Done in v3.

Quoted 109 lines
Quoted 109 lines
drivers/net/ice/ice_dcf.c +10 -0
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+

static int
ice_dcf_mode_disable(struct ice_dcf_hw *hw)
{

drivers/net/ice/ice_dcf.c +17 -0
@@ -467,6 +524,23 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 	return err;
 }
 
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	ice_dcf_enable_irq0(hw);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+

int
ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw) {

drivers/net/ice/ice_dcf.c +7 -0
@@ -534,6 +608,12 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 		goto err_alloc;
 	}
 
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   ice_dcf_dev_interrupt_handler, hw);
 	rte_intr_enable(&pci_dev->intr_handle);
@@ -566,5 +646,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
 	rte_free(hw->vf_res);
 }
drivers/net/ice/ice_dcf.h +4 -0
index ecd6303a0..12bef4a2a 100644
@@ -41,6 +41,9 @@ struct ice_dcf_hw {
 
 	uint8_t *arq_buf;
 
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
 	struct virtchnl_version_info virtchnl_version;
 	struct virtchnl_vf_resource *vf_res; /* VF resource */
 	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
@@ -51,6 +54,7 @@ int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
drivers/net/ice/ice_dcf_parent.c +20 -0
index 4c3bb68b1..2735221e9 100644
@@ -5,10 +5,76 @@
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <rte_alarm.h>
+
 #include "ice_dcf_ethdev.h"
 
+#define ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL	100000 /* us */
+
+static __rte_always_inline void
+ice_dcf_update_vsi_ctx(struct ice_hw *hw, uint16_t vsi_handle,
+		       uint16_t vsi_map)
+{
+	struct ice_vsi_ctx *vsi_ctx;
+
+	if (unlikely(vsi_handle >= ICE_MAX_VSI)) {
+		PMD_DRV_LOG(ERR, "Invalid vsi handle %u", vsi_handle);
+		return;
+	}
+
+	vsi_ctx = hw->vsi_ctx[vsi_handle];
+
+	if (vsi_map & VIRTCHNL_DCF_VF_VSI_VALID) {
+		if (!vsi_ctx)
+			vsi_ctx = ice_malloc(hw, sizeof(*vsi_ctx));
Quoted 8 lines

drivers/net/ice/ice_dcf_parent.c line 35

Quoted 6 lines
drivers/net/ice/ice_dcf_parent.c +6 -0
+
+		if (!vsi_ctx) {
+			PMD_DRV_LOG(ERR, "No memory for vsi context %u",
+				    vsi_handle);
+			return;
+		}

Above two blocks can be combined.

Done in v3.

Quoted 47 lines
Quoted 47 lines
drivers/net/ice/ice_dcf_parent.c +40 -0
+
+		vsi_ctx->vsi_num = (vsi_map & VIRTCHNL_DCF_VF_VSI_ID_M) >>
+					      VIRTCHNL_DCF_VF_VSI_ID_S;
+		hw->vsi_ctx[vsi_handle] = vsi_ctx;
+
+		PMD_DRV_LOG(DEBUG, "VF%u is assigned with vsi number %u",
+			    vsi_handle, vsi_ctx->vsi_num);
+	} else {
+		hw->vsi_ctx[vsi_handle] = NULL;
+
+		ice_free(hw, vsi_ctx);
+
+		PMD_DRV_LOG(NOTICE, "VF%u is disabled", vsi_handle);
+	}
+}
+
+static void
+ice_dcf_update_vf_vsi_map(struct ice_hw *hw, uint16_t num_vfs,
+			  uint16_t *vf_vsi_map)
+{
+	uint16_t vf_id;
+
+	for (vf_id = 0; vf_id < num_vfs; vf_id++)
+		ice_dcf_update_vsi_ctx(hw, vf_id, vf_vsi_map[vf_id]);
+}
+
+static void
+ice_dcf_vsi_update_service_handler(void *param)
+{
+	struct ice_dcf_hw *hw = param;
+
+	if (!ice_dcf_handle_vsi_update_event(hw)) {
+		struct ice_dcf_adapter *dcf_ad =
+			container_of(hw, struct ice_dcf_adapter, real_hw);
+
+		ice_dcf_update_vf_vsi_map(&dcf_ad->parent.hw,
+					  hw->num_vfs, hw->vf_vsi_map);
+	}
+}
+

void

drivers/net/ice/ice_dcf_parent.c +1 -1
-ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
+ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
			    uint8_t *msg, uint16_t msglen)
{
	struct virtchnl_pf_event *pf_msg = (struct virtchnl_pf_event *)msg;
Quoted 9 lines

drivers/net/ice/ice_dcf_parent.c ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw, · line 91

Quoted 6 lines
drivers/net/ice/ice_dcf_parent.c +2 -0
@@ -21,6 +87,8 @@ ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
 	switch (pf_msg->event) {
 	case VIRTCHNL_EVENT_RESET_IMPENDING:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_RESET_IMPENDING event");
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL * 2,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);

Why * 2 for the VIRTCHNL_EVENT_RESET_IMPENDING event?

Original thought is VF itself reset needs more work (by referring to iavf PMD), after check, no need *2. Fixed in v3.

Quoted 21 lines
Quoted 21 lines
drivers/net/ice/ice_dcf_parent.c +7 -0
 		break;
 	case VIRTCHNL_EVENT_LINK_CHANGE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_LINK_CHANGE event");
@@ -28,6 +96,13 @@ ice_dcf_handle_pf_event_msg(__rte_unused struct ice_dcf_hw *dcf_hw,
 	case VIRTCHNL_EVENT_PF_DRIVER_CLOSE:
 		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_PF_DRIVER_CLOSE event");
 		break;
+	case VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE:
+		PMD_DRV_LOG(DEBUG, "VIRTCHNL_EVENT_DCF_VSI_MAP_UPDATE event : VF%u with VSI num %u",
+			    pf_msg->event_data.vf_vsi_map.vf_id,
+			    pf_msg->event_data.vf_vsi_map.vsi_id);
+		rte_eal_alarm_set(ICE_DCF_VSI_UPDATE_SERVICE_INTERVAL,
+				  ice_dcf_vsi_update_service_handler, dcf_hw);
+		break;
 	default:
 		PMD_DRV_LOG(ERR, "Unknown event received %u", pf_msg->event);
 		break;
@@ -235,6 +310,9 @@ ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev)
 	}
 	parent_adapter->active_pkg_type = ice_load_pkg_type(parent_hw);
 
Quoted 5 lines

drivers/net/ice/ice_dcf_parent.c ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev) · line 315

Quoted 3 lines
drivers/net/ice/ice_dcf_parent.c +3 -0
+	ice_dcf_update_vf_vsi_map(parent_hw,
+				  hw->num_vfs, hw->vf_vsi_map);
+

No need to split into 2 lines.

Done in v3.

Quoted 16 lines
Quoted 16 lines
drivers/net/ice/ice_dcf_parent.c +3 -1
 	mac = (const struct rte_ether_addr *)hw->avf.mac.addr;
 	if (rte_is_valid_assigned_ether_addr(mac))
 		rte_ether_addr_copy(mac, &parent_adapter->pf.dev_addr);
@@ -259,5 +337,8 @@ ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->mac_addrs = NULL;
 
+	rte_eal_alarm_cancel(ice_dcf_vsi_update_service_handler,
+			     &adapter->real_hw);
+
 	ice_dcf_uninit_parent_hw(parent_hw);
 }
--

2.25.1

#46 lore raw
In reply to Haiyue Wang

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if that is the correct way to go.

Paul

Quoted 63 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code [2]
https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode 100644

doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#47 lore raw

Hi Paul,

Yes, it's VF (VF hardware initialization like virtchnl). But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control.

BR,
Haiyue

Quoted 77 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:19
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if that is the correct way to go.

Paul

Quoted 63 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code [2]
https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode 100644

doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#48 lore raw

Hi Haiyue,

This statement is confusing to me "But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control." What do you mean by "flow setting"? The way I understand DCF working is that there is a trusted VF (the DCF) that is setting switch rules for other VFs on the same PF. The mechanism for doing that is the DCF sends a virtchnl message to the Linux kernel driver PF to add/delete a switch rule. None of this requires the ice PMD as far as I can tell. This seems like a driver just like the iavf driver; the iavf driver is separate from the ice PMD and it seems like DCF should also be separate.

Paul

Quoted 100 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Friday, March 13, 2020 9:25 AM
To: Stillwell Jr, Paul M <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul,

Yes, it's VF (VF hardware initialization like virtchnl). But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control.

BR,
Haiyue

Quoted 10 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:19
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 2 lines

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if

that is the correct way to go.

Quoted 16 lines

Paul

Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of

the VFs.

Quoted 52 lines
Quoted 51 lines

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code
[2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode

100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#49 lore raw

Hi Paul,

Quoted 8 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:50
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 4 lines

Hi Haiyue,

This statement is confusing to me "But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control." What do you mean by "flow setting"?

It is DPDP rte_flow API calling.

Quoted 3 lines

The way I understand DCF
working is that there is a trusted VF (the DCF) that is setting switch rules for other VFs on the same PF. The mechanism for doing that is the DCF sends a virtchnl message to the Linux kernel driver PF to

DCF needs: 1). virtchnl message is handles by 'dpdk/drivers/common/iavf/', which is the original iavf base code.

Quoted 1 line

add/delete a switch rule. None of this requires the ice PMD as far as I can tell. This seems like a

DCF needs: 2). add/delete a switch rule.

               rte_flow API --> 'dpdk/drivers/net/ice/ice_switch_filter.c/ice_generic_flow.c' (ice flow framework)
		                     |
                                 `--> 'dpdk/drivers/net/ice/base' ...

So, put it under the ice PMD is the best way.

Quoted 106 lines

driver just like the iavf driver; the iavf driver is separate from the ice PMD and it seems like DCF should also be separate.

Paul

Quoted 100 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Friday, March 13, 2020 9:25 AM
To: Stillwell Jr, Paul M <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul,

Yes, it's VF (VF hardware initialization like virtchnl). But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control.

BR,
Haiyue

Quoted 10 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:19
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 2 lines

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if

that is the correct way to go.

Quoted 16 lines

Paul

Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of

the VFs.

Quoted 52 lines
Quoted 51 lines

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code
[2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode

100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#50 lore raw

OK, I looked at the code further and it seems like what you are doing is you are using the iavf PCI device ID instead of the PF device ID when the user says cap=dcf. This doesn't seem like the right thing to do. Why not modify the iavf code to support being the DCF? Or create a new PMD? You are calling iavf functions from within the ice PMD which seems wrong to me.

Paul

Quoted 162 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Friday, March 13, 2020 10:05 AM
To: Stillwell Jr, Paul M <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul,

Quoted 9 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:50
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 4 lines

Hi Haiyue,

This statement is confusing to me "But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control." What

do you mean by "flow setting"?
It is DPDP rte_flow API calling.

Quoted 4 lines

The way I understand DCF
working is that there is a trusted VF (the DCF) that is setting switch rules for other VFs on the same PF. The mechanism for doing that is the DCF sends a virtchnl message to the Linux kernel driver PF to

DCF needs: 1). virtchnl message is handles by 'dpdk/drivers/common/iavf/', which is the original iavf base code.

Quoted 2 lines

add/delete a switch rule. None of this requires the ice PMD as far as I can tell. This seems like a

DCF needs: 2). add/delete a switch rule.

               rte_flow API -->
'dpdk/drivers/net/ice/ice_switch_filter.c/ice_generic_flow.c' (ice flow
framework)
                     |
                                 `--> 'dpdk/drivers/net/ice/base' ...

So, put it under the ice PMD is the best way.

Quoted 19 lines

driver just like the iavf driver; the iavf driver is separate from the ice PMD and it seems like DCF should also be separate.

Paul

Quoted 14 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Friday, March 13, 2020 9:25 AM
To: Stillwell Jr, Paul M <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul,

Yes, it's VF (VF hardware initialization like virtchnl). But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice

PMD flow control.

Quoted 64 lines
Quoted 64 lines

BR,
Haiyue

Quoted 11 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:19
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 3 lines

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if

that is the correct way to go.

Quoted 17 lines

Paul

Quoted 14 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of

the VFs.

Quoted 27 lines
Quoted 27 lines

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code [2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651

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

Quoted 22 lines
Quoted 21 lines
Quoted 20 lines
Quoted 19 lines
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create

mode
100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#51 lore raw
Quoted 11 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 01:48
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Yigit, Ferruh <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

OK, I looked at the code further and it seems like what you are doing is you are using the iavf PCI device ID instead of the PF device ID when the user says cap=dcf. This doesn't seem like the right thing to do.

No, how can you get the PF device ID from the VF hardware ? ;-)

Quoted 2 lines

Why not modify the iavf code to support being the DCF? Or create a new PMD? You are calling iavf functions from within the ice PMD which seems wrong to me.

No, you still can't get my point about the ice rte_flow framework. Please see Wei's next patch

https://patchwork.dpdk.org/patch/66621/ net/ice: enable switch flow on DCF

Quoted 166 lines

Paul

Quoted 162 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Friday, March 13, 2020 10:05 AM
To: Stillwell Jr, Paul M <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul,

Quoted 9 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:50
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 4 lines

Hi Haiyue,

This statement is confusing to me "But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice PMD flow control." What

do you mean by "flow setting"?
It is DPDP rte_flow API calling.

Quoted 4 lines

The way I understand DCF
working is that there is a trusted VF (the DCF) that is setting switch rules for other VFs on the same PF. The mechanism for doing that is the DCF sends a virtchnl message to the Linux kernel driver PF to

DCF needs: 1). virtchnl message is handles by 'dpdk/drivers/common/iavf/', which is the original iavf base code.

Quoted 2 lines

add/delete a switch rule. None of this requires the ice PMD as far as I can tell. This seems like a

DCF needs: 2). add/delete a switch rule.

               rte_flow API -->
'dpdk/drivers/net/ice/ice_switch_filter.c/ice_generic_flow.c' (ice flow
framework)
                     |
                                 `--> 'dpdk/drivers/net/ice/base' ...

So, put it under the ice PMD is the best way.

Quoted 19 lines

driver just like the iavf driver; the iavf driver is separate from the ice PMD and it seems like DCF should also be separate.

Paul

Quoted 14 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Friday, March 13, 2020 9:25 AM
To: Stillwell Jr, Paul M <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul,

Yes, it's VF (VF hardware initialization like virtchnl). But the flow setting is the ice PF AdminQ message, so the DCF shares most of ice

PMD flow control.

Quoted 64 lines
Quoted 64 lines

BR,
Haiyue

Quoted 11 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 00:19
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 3 lines

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if

that is the correct way to go.

Quoted 17 lines

Paul

Quoted 14 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of

the VFs.

Quoted 27 lines
Quoted 27 lines

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code [2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651

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

Quoted 22 lines
Quoted 21 lines
Quoted 20 lines
Quoted 19 lines
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create

mode
100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#52 lore raw
In reply to Stillwell Jr, Paul M

Hi Paul:

Quoted 10 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 12:19 AM
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 3 lines

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if that is the correct way to go.

From DPDK's view, DCF is NOT a VF driver, actually it behaves like a PF driver with control path only and it share most exist PF driver's API implementation , That's why we combined it with exist PF driver, so when the module driver/net/ice is compiled into a library, it can be probed as a PF driver or DCF base on device ID at runtime. And the is not special in DPDK, for example, the module in driver/net/i40e can be probed as i40e pf driver or i40e vf driver.
DCF take SR-IOV's mailbox as a message channel to communicate with the backend kernel driver, so iavf virtual channel is reused here, so we also need to link iavf share code.

And I agree, its always better if we can separate 2 different things while decouple all the common code into a share library to avoid duplicate code copy (just like we did on iavf share code) But in this case, a lot of code refectory is required , so far we just take the simple way, we may improve this in future.

Thanks
Qi

Quoted 69 lines

Paul

Quoted 39 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code [2]
https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

Quoted 7 lines
 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651

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

Quoted 18 lines
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode

100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#53 lore raw

See my responses inline.

Paul

Quoted 24 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Saturday, March 14, 2020 6:50 PM
To: Stillwell Jr, Paul M <[email protected]>; Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>; Liang, Cunming <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul:

Quoted 10 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 12:19 AM
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Quoted 6 lines
Quoted 3 lines

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if that is the correct way to go.

From DPDK's view, DCF is NOT a VF driver, actually it behaves like a PF driver with control path only and it share most exist PF driver's API implementation

It *is* a VF. The only way this will work is if the VF has the trust flag set and then it can become the DCF. You can't set the trust flag on a PF I don't think. That's the only way this will work because the kernel driver code has checks on the admin queue messages to see if the message is from a VF. If it's not a message from a specific VF, then the message will get rejected.

Quoted 89 lines

, That's why we combined it with exist PF driver, so when the module driver/net/ice is compiled into a library, it can be probed as a PF driver or DCF base on device ID at runtime.
And the is not special in DPDK, for example, the module in driver/net/i40e can be probed as i40e pf driver or i40e vf driver.
DCF take SR-IOV's mailbox as a message channel to communicate with the backend kernel driver, so iavf virtual channel is reused here, so we also need to link iavf share code.

And I agree, its always better if we can separate 2 different things while decouple all the common code into a share library to avoid duplicate code copy (just like we did on iavf share code) But in this case, a lot of code refectory is required , so far we just take the simple way, we may improve this in future.

Thanks
Qi

Quoted 16 lines

Paul

Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of

the VFs.

Quoted 53 lines
Quoted 26 lines

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code
[2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

Quoted 7 lines
 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651

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

Quoted 18 lines
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode

100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#54 lore raw
Quoted 42 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Tuesday, March 17, 2020 02:55
To: Zhang, Qi Z <[email protected]>; Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>; Liang, Cunming <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

See my responses inline.

Paul

Quoted 28 lines

-----Original Message-----
From: Zhang, Qi Z <[email protected]>
Sent: Saturday, March 14, 2020 6:50 PM
To: Stillwell Jr, Paul M <[email protected]>; Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>; Liang, Cunming <[email protected]>; Wu, Jingjing <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

Hi Paul:

Quoted 13 lines

-----Original Message-----
From: Stillwell Jr, Paul M <[email protected]>
Sent: Saturday, March 14, 2020 12:19 AM
To: Wang, Haiyue <[email protected]>; [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: RE: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

I'm confused. Shouldn't the DCF be a separate driver since it is a VF, not part of a PF? You are starting to combine PF/VF code and I'm not sure if that is the correct way to go.

Quoted 8 lines
Quoted 2 lines

From DPDK's view, DCF is NOT a VF driver, actually it behaves like a PF driver with control path only and it share most exist PF driver's API implementation

It *is* a VF. The only way this will work is if the VF has the trust flag set and then it can become the DCF. You can't set the trust flag on a PF I don't think. That's the only way this will work because the kernel driver code has checks on the admin queue messages to see if the message is from a VF. If it's not a message from a specific VF, then the message will get rejected.

This is absolutely right, and this is added into the guide about how to enable DCF. ;-)

And one important thing is that : VF with DCF capability is only bound to ice/kernel driver, so we can't add it into the generic iavf VF PMD, since it works on i40e/ice etc. And the main task about DCF is flow control, the AdminQ is implemented in ice PF PMD, and it just uses these AdminQ API to runs on VF hardware, not ice PF hardware.

Quoted 90 lines
Quoted 89 lines

, That's why we combined it with exist PF driver, so when the module driver/net/ice is compiled into a library, it can be probed as a PF driver or DCF base on device ID at runtime.
And the is not special in DPDK, for example, the module in driver/net/i40e can be probed as i40e pf driver or i40e vf driver.
DCF take SR-IOV's mailbox as a message channel to communicate with the backend kernel driver, so iavf virtual channel is reused here, so we also need to link iavf share code.

And I agree, its always better if we can separate 2 different things while decouple all the common code into a share library to avoid duplicate code copy (just like we did on iavf share code) But in this case, a lot of code refectory is required , so far we just take the simple way, we may improve this in future.

Thanks
Qi

Quoted 16 lines

Paul

Quoted 13 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Haiyue Wang
Sent: Monday, March 9, 2020 11:50 PM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v2 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of

the VFs.

Quoted 53 lines
Quoted 26 lines

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code
[2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: initiate to acquire the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

Quoted 7 lines
 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 651

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

Quoted 18 lines
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 344 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)  create mode

100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.25.1

#55 lore raw

v3 cover add Intel DCF PMD support

In reply to Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

This patchset is based on:
[1] https://patchwork.dpdk.org/cover/66417/ : update ice base code
[2] https://patchwork.dpdk.org/cover/66472/ : iavf share code update

Depends-on: series-8843
Depends-on: series-8855

v3:
1. Fixed the error log message format.
2. Fixed some memory allocation check.
3. Fixed some code style issue and commmit message description.

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: acquire and disable the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 652 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  61 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 343 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1528 insertions(+), 10 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
Signature · 1 line
2.25.1
#56 lore raw

PATCH v3 1/7 net/iavf: stop the PCI probe in DCF mode

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
 drivers/net/iavf/iavf_ethdev.c | 43 ++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
drivers/net/iavf/iavf_ethdev.c +43 -0
index 34913f9c4..c0b95e169 100644
@@ -1416,9 +1416,51 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+iavf_dcf_cap_check_handler(__rte_unused const char *key,
+			   const char *value, __rte_unused void *opaque)
+{
+	if (strcmp(value, "dcf"))
+		return -1;
+
+	return 0;
+}
+
+static int
+iavf_dcf_cap_selected(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	const char *key = "cap";
+	int ret = 0;
+
+	if (devargs == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return 0;
+
+	if (!rte_kvargs_count(kvlist, key))
+		goto exit;
+
+	/* dcf capability selected when there's a key-value pair: cap=dcf */
+	if (rte_kvargs_process(kvlist, key,
+			       iavf_dcf_cap_check_handler, NULL) < 0)
+		goto exit;
+
+	ret = 1;
+
+exit:
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (iavf_dcf_cap_selected(pci_dev->device.devargs))
+		return 1;
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1481,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
Signature · 1 line
2.25.1
#57 lore raw

PATCH v3 2/7 net/ice: add the DCF hardware initialization

In reply to Haiyue Wang

Introduce the DCF (Device Config Function) feature in the ice PMD, it works as a standalone PMD which doesn't handle the packet Rx/Tx related things. Its hardware entity is the VF.

Add the basic DCF hardware initialization, this is specified by devarg 'cap=dcf'.

---
 doc/guides/nics/ice.rst                |  47 +++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/ice/Makefile               |   5 +
 drivers/net/ice/ice_dcf.c              | 474 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  52 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 317 +++++++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  24 ++
 drivers/net/ice/meson.build            |   7 +-
 mk/rte.app.mk                          |   1 +
 11 files changed, 931 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
doc/guides/nics/ice.rst +47 -0
index 8af32dabf..2639ae239 100644
@@ -240,6 +240,53 @@ report a MDD event and drop the packets.
 
 The APPs based on DPDK should avoid providing such packets.
 
+Device Config Function (DCF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This section demonstrates ICE DCF PMD, which shares the core module with ICE
+PMD and iAVF PMD.
+
+A DCF (Device Config Function) PMD bounds to the device's trusted VF with ID 0,
+it can act as a sole controlling entity to exercise advance functionality (such
+as switch, ACL) for the rest VFs.
+
+The DCF PMD needs to advertise and acquire DCF capability which allows DCF to
+send AdminQ commands that it would like to execute over to the PF and receive
+responses for the same from PF.
+
+.. _figure_ice_dcf:
+
+.. figure:: img/ice_dcf.*
+
+   DCF Communication flow.
+
+#. Create the VFs::
+
+      echo 4 > /sys/bus/pci/devices/0000\:18\:00.0/sriov_numvfs
+
+#. Enable the VF0 trust on::
+
+      ip link set dev enp24s0f0 vf 0 trust on
+
+#. Bind the VF0,  and run testpmd with 'cap=dcf' devarg::
+
+      testpmd -l 22-25 -n 4 -w 18:01.0,cap=dcf -- -i
+
+#. Monitor the VF2 interface network traffic::
+
+      tcpdump -e -nn -i enp24s1f2
+
+#. Create one flow to redirect the traffic to VF2 by DCF::
+
+      flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.2 \
+      dst is 192.168.0.3 / end actions vf id 2 / end
+
+#. Send the packet, and it should be displayed on tcpdump::
+
+      sendp(Ether(src='3c:fd:fe:aa:bb:78', dst='00:00:00:01:02:03')/IP(src=' \
+      192.168.0.2', dst="192.168.0.3")/TCP(flags='S')/Raw(load='XXXXXXXXXX'), \
+      iface="enp24s0f0", count=10)
+
 Sample Application Notes
 ------------------------
 
doc/guides/nics/img/ice_dcf.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..540823c4a05e9ea9d558d233fea77016d1ae5df3
GIT binary patch
doc/guides/rel_notes/release_20_05.rst +5 -0
index 000bbf501..f404ee7fd 100644
@@ -62,6 +62,11 @@ New Features
 
   * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF (Device Config Function) feature.
 
 Removed Items
 -------------
drivers/common/Makefile +1 -0
index 96bd7ac6e..df2e840cf 100644
@@ -31,6 +31,7 @@ DIRS-y += dpaax
 endif
 
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifneq (,$(findstring y,$(IAVF-y)))
 DIRS-y += iavf
 endif
drivers/net/ice/Makefile +5 -0
index e22c34287..f493c9ed7 100644
@@ -11,9 +11,11 @@ LIB = librte_pmd_ice.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/common/iavf
 
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs
 LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash
+LDLIBS += -lrte_net -lrte_common_iavf
 
 EXPORT_MAP := rte_pmd_ice_version.map
 
@@ -84,6 +86,9 @@ ifeq ($(CC_AVX2_SUPPORT), 1)
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
 
drivers/net/ice/ice_dcf.c new file +474 -0

474 lines not on this page · raw message

drivers/net/ice/ice_dcf.h new file +52 -0

52 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.c new file +317 -0

317 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.h new file +24 -0
new file mode 100644
index 000000000..0c34a0095
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_ETHDEV_H_
+#define _ICE_DCF_ETHDEV_H_
+
+#include "ice_ethdev.h"
+#include "ice_dcf.h"
+
+#define ICE_DCF_MAX_RINGS  1
+
+struct ice_dcf_queue {
+	uint64_t dummy;
+};
+
+struct ice_dcf_adapter {
+	struct ice_dcf_hw real_hw;
+	struct rte_ether_addr mac_addr;
+	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
+	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
+};
+
+#endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/meson.build +5 -2
index f9e897bbc..0ba9668d1 100644
@@ -15,8 +15,8 @@ sources = files(
 	'ice_hash.c'
 	)
 
-deps += ['hash']
-includes += include_directories('base')
+deps += ['hash', 'net', 'common_iavf']
+includes += include_directories('base', '../../common/iavf')
 
 if arch_subdir == 'x86'
 	sources += files('ice_rxtx_vec_sse.c')
@@ -37,4 +37,7 @@ if arch_subdir == 'x86'
 	endif
 endif
 
+sources += files('ice_dcf.c',
+		 'ice_dcf_ethdev.c')
+
 install_headers('rte_pmd_ice.h')
mk/rte.app.mk +1 -0
index d295ca0a5..f3798a09f 100644
@@ -185,6 +185,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IAVF_PMD)       += -lrte_pmd_iavf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ICE_PMD)        += -lrte_pmd_ice
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifeq ($(findstring y,$(IAVF-y)),y)
 _LDLIBS-y += -lrte_common_iavf
 endif
Signature · 1 line
2.25.1
#58 lore raw

PATCH v3 3/7 net/ice: acquire and disable the DCF capability

In reply to Haiyue Wang

Since the DCF (Device Config Function) controls the flow setting of other VFs by the mailbox with PF, for security, it needs to acquire the DCF capability from PF when starts, and disable it when exits.

---
 drivers/net/ice/ice_dcf.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +26 -1
index 0a99cceb1..ab5bc7424 100644
@@ -227,7 +227,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	int err, i;
 
 	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
-	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
 	       VF_BASE_MODE_OFFLOADS;
 
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -264,6 +264,30 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Fail to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int
 ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
 {
@@ -467,6 +491,7 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_intr_callback_unregister(intr_handle,
 				     ice_dcf_dev_interrupt_handler, hw);
 
+	ice_dcf_mode_disable(hw);
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
Signature · 1 line
2.25.1
#59 lore raw

PATCH v3 4/7 net/ice: handle the AdminQ command by DCF

In reply to Haiyue Wang

The DCF (Device Config Function) splits the AdminQ command into two
parts: one is the descriptor of AdminQ command, the other is the buffer of AdminQ command (the descriptor has BUF flag set). When both of them are received by the PF, the PF will handle them as one command.

And also, the filled descriptor and buffer of the response will be sent back to DCF one by one through the virtchnl from PF.

---
 drivers/net/ice/ice_dcf.c | 65 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h |  4 ++-
 2 files changed, 68 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +65 -0
index ab5bc7424..89bc14774 100644
@@ -396,6 +396,71 @@ ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 	return err;
 }
 
+int
+ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+		    void *buf, uint16_t buf_size)
+{
+	struct dcf_virtchnl_cmd desc_cmd, buff_cmd;
+	struct ice_dcf_hw *hw = dcf_hw;
+	int err = 0;
+	int i = 0;
+
+	if ((buf && !buf_size) || (!buf && buf_size) ||
+	    buf_size > ICE_DCF_AQ_BUF_SZ)
+		return -EINVAL;
+
+	desc_cmd.v_op = VIRTCHNL_OP_DCF_CMD_DESC;
+	desc_cmd.req_msglen = sizeof(*desc);
+	desc_cmd.req_msg = (uint8_t *)desc;
+	desc_cmd.rsp_buflen = sizeof(*desc);
+	desc_cmd.rsp_msgbuf = (uint8_t *)desc;
+
+	if (buf == NULL)
+		return ice_dcf_execute_virtchnl_cmd(hw, &desc_cmd);
+
+	desc->flags |= rte_cpu_to_le_16(ICE_AQ_FLAG_BUF);
+
+	buff_cmd.v_op = VIRTCHNL_OP_DCF_CMD_BUFF;
+	buff_cmd.req_msglen = buf_size;
+	buff_cmd.req_msg = buf;
+	buff_cmd.rsp_buflen = buf_size;
+	buff_cmd.rsp_msgbuf = buf;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, &desc_cmd);
+	ice_dcf_vc_cmd_set(hw, &buff_cmd);
+
+	if (ice_dcf_vc_cmd_send(hw, &desc_cmd) ||
+	    ice_dcf_vc_cmd_send(hw, &buff_cmd)) {
+		err = -1;
+		PMD_DRV_LOG(ERR, "fail to send OP_DCF_CMD_DESC/BUFF");
+		goto ret;
+	}
+
+	do {
+		if ((!desc_cmd.pending && !buff_cmd.pending) ||
+		    (!desc_cmd.pending && desc_cmd.v_ret != IAVF_SUCCESS) ||
+		    (!buff_cmd.pending && buff_cmd.v_ret != IAVF_SUCCESS))
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (desc_cmd.v_ret != IAVF_SUCCESS || buff_cmd.v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (desc: %d / buff: %d)",
+			    i, desc_cmd.v_ret, buff_cmd.v_ret);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, &desc_cmd);
+	ice_dcf_aq_cmd_clear(hw, &buff_cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
drivers/net/ice/ice_dcf.h +3 -1
index f44c09db2..99bd53b02 100644
@@ -11,6 +11,7 @@
 #include <iavf_adminq_cmd.h>
 #include <iavf_type.h>
 
+#include "base/ice_type.h"
 #include "ice_logs.h"
 
 struct dcf_virtchnl_cmd {
@@ -45,7 +46,8 @@ struct ice_dcf_hw {
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
-
+int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+			void *buf, uint16_t buf_size);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
Signature · 1 line
2.25.1
#60 lore raw

PATCH v3 5/7 net/ice: export the DDP definition symbols

In reply to Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

The DCF (Device Config Function) feature shares the core functions of the ICE PMD, like it needs to export the DDP definition symbols for the new DCF PMD use.

---
 drivers/net/ice/ice_ethdev.c | 9 +--------
 drivers/net/ice/ice_ethdev.h | 8 ++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ice/ice_ethdev.c +1 -8
index 3498a5075..3c38472de 100644
@@ -67,15 +67,8 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 
 #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100
 
-/* DDP package search path */
-#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
-#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
-
 #define ICE_OS_DEFAULT_PKG_NAME		"ICE OS Default Package"
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
-#define ICE_MAX_PKG_FILENAME_SIZE   256
 #define ICE_MAX_RES_DESC_NUM        1024
 
 int ice_logtype_init;
@@ -1833,7 +1826,7 @@ ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file)
 	return 0;
 }
 
-static enum ice_pkg_type
+enum ice_pkg_type
 ice_load_pkg_type(struct ice_hw *hw)
 {
 	enum ice_pkg_type package_type;
drivers/net/ice/ice_ethdev.h +8 -0
index da557a254..7b94a3c3e 100644
@@ -42,6 +42,13 @@
 
 #define ICE_MAX_PKT_TYPE  1024
 
+/* DDP package search path */
+#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
+#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
+#define ICE_MAX_PKG_FILENAME_SIZE   256
+
 /**
  * vlan_id is a 12 bit number.
  * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
@@ -457,6 +464,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+enum ice_pkg_type ice_load_pkg_type(struct ice_hw *hw);
 struct ice_vsi *
 ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type);
 int
Signature · 1 line
2.25.1
#61 lore raw

PATCH v3 6/7 net/ice: handle the PF initialization by DCF

In reply to Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will pass through the PF's AdminQ command by the DCF's mailbox.

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions related to the flow.

---
 drivers/net/ice/Makefile         |   1 +
 drivers/net/ice/ice_dcf.c        |   7 +-
 drivers/net/ice/ice_dcf.h        |   3 +
 drivers/net/ice/ice_dcf_ethdev.c |  10 +-
 drivers/net/ice/ice_dcf_ethdev.h |  11 +-
 drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
 drivers/net/ice/meson.build      |   3 +-
 7 files changed, 292 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
drivers/net/ice/Makefile +1 -0
index f493c9ed7..3ecc72219 100644
@@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c
 
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
drivers/net/ice/ice_dcf.c +6 -1
index 89bc14774..f32a7ffdb 100644
@@ -124,8 +124,13 @@ ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
 	}
 
 	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
-	if (unlikely(v_op == VIRTCHNL_OP_EVENT))
+	if (v_op == VIRTCHNL_OP_EVENT) {
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
 		return;
+	}
 
 	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
 
drivers/net/ice/ice_dcf.h +3 -0
index 99bd53b02..ecd6303a0 100644
@@ -36,6 +36,9 @@ struct ice_dcf_hw {
 	rte_spinlock_t vc_cmd_send_lock;
 	rte_spinlock_t vc_cmd_queue_lock;
 	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
 	uint8_t *arq_buf;
 
 	struct virtchnl_version_info virtchnl_version;
drivers/net/ice/ice_dcf_ethdev.c +7 -3
index 23f82a487..af94caeff 100644
@@ -145,8 +145,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
 	dev->tx_pkt_burst = NULL;
-	dev->data->mac_addrs = NULL;
 
+	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 }
 
@@ -225,13 +225,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
 
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
 	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init DCF hardware");
 		return -1;
 	}
 
-	rte_eth_random_addr(adapter->mac_addr.addr_bytes);
-	eth_dev->data->mac_addrs = &adapter->mac_addr;
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter");
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
 
 	return 0;
 }
drivers/net/ice/ice_dcf_ethdev.h +10 -1
index 0c34a0095..e60e808d8 100644
@@ -5,6 +5,9 @@
 #ifndef _ICE_DCF_ETHDEV_H_
 #define _ICE_DCF_ETHDEV_H_
 
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
 #include "ice_ethdev.h"
 #include "ice_dcf.h"
 
@@ -15,10 +18,16 @@ struct ice_dcf_queue {
 };
 
 struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
 	struct ice_dcf_hw real_hw;
-	struct rte_ether_addr mac_addr;
 	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
 	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
 };
 
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +263 -0

263 lines not on this page · raw message

drivers/net/ice/meson.build +2 -1
index 0ba9668d1..7e9037f3b 100644
@@ -38,6 +38,7 @@ if arch_subdir == 'x86'
 endif
 
 sources += files('ice_dcf.c',
-		 'ice_dcf_ethdev.c')
+		 'ice_dcf_ethdev.c',
+		 'ice_dcf_parent.c')
 
 install_headers('rte_pmd_ice.h')
Signature · 1 line
2.25.1
#62 lore raw

PATCH v3 7/7 net/ice: get the VF hardware index in DCF

In reply to Haiyue Wang

The DCF (Device Config Function) needs the hardware index of the VFs to control the flow setting. And also if the VF resets, the index may be changed, so it should handle this in VF reset event.

---
 drivers/net/ice/ice_dcf.c        | 87 +++++++++++++++++++++++++++++++-
 drivers/net/ice/ice_dcf.h        |  4 ++
 drivers/net/ice/ice_dcf_parent.c | 82 +++++++++++++++++++++++++++++-
 3 files changed, 170 insertions(+), 3 deletions(-)
drivers/net/ice/ice_dcf.c +85 -2
index f32a7ffdb..88c905191 100644
@@ -269,6 +269,65 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint32_t valid_msg_len;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to send msg OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	valid_msg_len = (vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0]) +
+			sizeof(*vsi_map);
+	if (len != valid_msg_len) {
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+
+	if (!hw->vf_vsi_map) {
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
+		if (!hw->vf_vsi_map) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory for VSI context");
+			return -ENOMEM;
+		}
+
+		hw->num_vfs = vsi_map->num_vfs;
+	}
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+
 static int
 ice_dcf_mode_disable(struct ice_dcf_hw *hw)
 {
@@ -277,7 +336,7 @@ ice_dcf_mode_disable(struct ice_dcf_hw *hw)
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
 					  NULL, 0);
 	if (err) {
-		PMD_DRV_LOG(ERR, "Fail to send msg OP_DCF_DISABLE");
+		PMD_DRV_LOG(ERR, "Failed to send msg OP_DCF_DISABLE");
 		return err;
 	}
 
@@ -285,7 +344,7 @@ ice_dcf_mode_disable(struct ice_dcf_hw *hw)
 					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ, NULL);
 	if (err) {
 		PMD_DRV_LOG(ERR,
-			    "Fail to get response of OP_DCF_DISABLE %d",
+			    "Failed to get response of OP_DCF_DISABLE %d",
 			    err);
 		return -1;
 	}
@@ -466,6 +525,23 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 	return err;
 }
 
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	ice_dcf_enable_irq0(hw);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
@@ -533,6 +609,12 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 		goto err_alloc;
 	}
 
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   ice_dcf_dev_interrupt_handler, hw);
 	rte_intr_enable(&pci_dev->intr_handle);
@@ -565,5 +647,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
 	rte_free(hw->vf_res);
 }
drivers/net/ice/ice_dcf.h +4 -0
index ecd6303a0..12bef4a2a 100644
@@ -41,6 +41,9 @@ struct ice_dcf_hw {
 
 	uint8_t *arq_buf;
 
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
 	struct virtchnl_version_info virtchnl_version;
 	struct virtchnl_vf_resource *vf_res; /* VF resource */
 	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
@@ -51,6 +54,7 @@ int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
drivers/net/ice/ice_dcf_parent.c +81 -1

114 lines not on this page · raw message

Signature · 1 line
2.25.1
#63 lore raw

v4 cover add Intel DCF PMD support

In reply to Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

v4:
Change the alarm handler to thread service, since it will need to do more work.

v3:
1. Fixed the error log message format.
2. Fixed some memory allocation check.
3. Fixed some code style issue and commmit message description.

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: acquire and disable the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 658 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  63 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 351 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1544 insertions(+), 10 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
Signature · 1 line
2.26.0
#64 lore raw

PATCH v4 1/7 net/iavf: stop the PCI probe in DCF mode

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

---
 drivers/net/iavf/iavf_ethdev.c | 43 ++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
drivers/net/iavf/iavf_ethdev.c +43 -0
index 34913f9c4..c0b95e169 100644
@@ -1416,9 +1416,51 @@ iavf_dev_uninit(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static int
+iavf_dcf_cap_check_handler(__rte_unused const char *key,
+			   const char *value, __rte_unused void *opaque)
+{
+	if (strcmp(value, "dcf"))
+		return -1;
+
+	return 0;
+}
+
+static int
+iavf_dcf_cap_selected(struct rte_devargs *devargs)
+{
+	struct rte_kvargs *kvlist;
+	const char *key = "cap";
+	int ret = 0;
+
+	if (devargs == NULL)
+		return 0;
+
+	kvlist = rte_kvargs_parse(devargs->args, NULL);
+	if (kvlist == NULL)
+		return 0;
+
+	if (!rte_kvargs_count(kvlist, key))
+		goto exit;
+
+	/* dcf capability selected when there's a key-value pair: cap=dcf */
+	if (rte_kvargs_process(kvlist, key,
+			       iavf_dcf_cap_check_handler, NULL) < 0)
+		goto exit;
+
+	ret = 1;
+
+exit:
+	rte_kvargs_free(kvlist);
+	return ret;
+}
+
 static int eth_iavf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
 			     struct rte_pci_device *pci_dev)
 {
+	if (iavf_dcf_cap_selected(pci_dev->device.devargs))
+		return 1;
+
 	return rte_eth_dev_pci_generic_probe(pci_dev,
 		sizeof(struct iavf_adapter), iavf_dev_init);
 }
@@ -1439,6 +1481,7 @@ static struct rte_pci_driver rte_iavf_pmd = {
 RTE_PMD_REGISTER_PCI(net_iavf, rte_iavf_pmd);
 RTE_PMD_REGISTER_PCI_TABLE(net_iavf, pci_id_iavf_map);
 RTE_PMD_REGISTER_KMOD_DEP(net_iavf, "* igb_uio | vfio-pci");
+RTE_PMD_REGISTER_PARAM_STRING(net_iavf, "cap=dcf");
 RTE_INIT(iavf_init_log)
 {
 	iavf_logtype_init = rte_log_register("pmd.net.iavf.init");
Signature · 1 line
2.26.0
Reviewed-by Xiaolong Ye Acked-by on v4 1/7
#65 lore raw

Re: [dpdk-dev] [PATCH v4 1/7] net/iavf: stop the PCI probe in DCF mode

-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Haiyue Wang
Sent: Thursday, March 26, 2020 11:04 AM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [dpdk-dev] [PATCH v4 1/7] net/iavf: stop the PCI probe in DCF mode

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

So if the DCF (Device Config Function) mode is specified by the devarg 'cap=dcf', then it will stop the PCI probe in the iavf PMD.

#66 lore raw

PATCH v4 2/7 net/ice: add the DCF hardware initialization

In reply to Haiyue Wang

Introduce the DCF (Device Config Function) feature in the ice PMD, it works as a standalone PMD which doesn't handle the packet Rx/Tx related things. Its hardware entity is the VF.

Add the basic DCF hardware initialization, this is specified by devarg 'cap=dcf'.

---
 doc/guides/nics/ice.rst                |  47 +++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/ice/Makefile               |   5 +
 drivers/net/ice/ice_dcf.c              | 474 +++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  52 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 317 +++++++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  24 ++
 drivers/net/ice/meson.build            |   7 +-
 mk/rte.app.mk                          |   1 +
 11 files changed, 931 insertions(+), 2 deletions(-)
 create mode 100644 doc/guides/nics/img/ice_dcf.png
 create mode 100644 drivers/net/ice/ice_dcf.c
 create mode 100644 drivers/net/ice/ice_dcf.h
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.c
 create mode 100644 drivers/net/ice/ice_dcf_ethdev.h
doc/guides/nics/ice.rst +47 -0
index 8af32dabf..2639ae239 100644
@@ -240,6 +240,53 @@ report a MDD event and drop the packets.
 
 The APPs based on DPDK should avoid providing such packets.
 
+Device Config Function (DCF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This section demonstrates ICE DCF PMD, which shares the core module with ICE
+PMD and iAVF PMD.
+
+A DCF (Device Config Function) PMD bounds to the device's trusted VF with ID 0,
+it can act as a sole controlling entity to exercise advance functionality (such
+as switch, ACL) for the rest VFs.
+
+The DCF PMD needs to advertise and acquire DCF capability which allows DCF to
+send AdminQ commands that it would like to execute over to the PF and receive
+responses for the same from PF.
+
+.. _figure_ice_dcf:
+
+.. figure:: img/ice_dcf.*
+
+   DCF Communication flow.
+
+#. Create the VFs::
+
+      echo 4 > /sys/bus/pci/devices/0000\:18\:00.0/sriov_numvfs
+
+#. Enable the VF0 trust on::
+
+      ip link set dev enp24s0f0 vf 0 trust on
+
+#. Bind the VF0,  and run testpmd with 'cap=dcf' devarg::
+
+      testpmd -l 22-25 -n 4 -w 18:01.0,cap=dcf -- -i
+
+#. Monitor the VF2 interface network traffic::
+
+      tcpdump -e -nn -i enp24s1f2
+
+#. Create one flow to redirect the traffic to VF2 by DCF::
+
+      flow create 0 priority 0 ingress pattern eth / ipv4 src is 192.168.0.2 \
+      dst is 192.168.0.3 / end actions vf id 2 / end
+
+#. Send the packet, and it should be displayed on tcpdump::
+
+      sendp(Ether(src='3c:fd:fe:aa:bb:78', dst='00:00:00:01:02:03')/IP(src=' \
+      192.168.0.2', dst="192.168.0.3")/TCP(flags='S')/Raw(load='XXXXXXXXXX'), \
+      iface="enp24s0f0", count=10)
+
 Sample Application Notes
 ------------------------
 
doc/guides/nics/img/ice_dcf.png new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..540823c4a05e9ea9d558d233fea77016d1ae5df3
GIT binary patch
doc/guides/rel_notes/release_20_05.rst +5 -0
index 000bbf501..f404ee7fd 100644
@@ -62,6 +62,11 @@ New Features
 
   * Added support for matching on IPv4 Time To Live and IPv6 Hop Limit.
 
+* **Updated the Intel ice driver.**
+
+  Updated the Intel ice driver with new features and improvements, including:
+
+  * Added support for DCF (Device Config Function) feature.
 
 Removed Items
 -------------
drivers/common/Makefile +1 -0
index 96bd7ac6e..df2e840cf 100644
@@ -31,6 +31,7 @@ DIRS-y += dpaax
 endif
 
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifneq (,$(findstring y,$(IAVF-y)))
 DIRS-y += iavf
 endif
drivers/net/ice/Makefile +5 -0
index e22c34287..f493c9ed7 100644
@@ -11,9 +11,11 @@ LIB = librte_pmd_ice.a
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
 CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_SDK)/drivers/common/iavf
 
 LDLIBS += -lrte_eal -lrte_mbuf -lrte_ethdev -lrte_kvargs
 LDLIBS += -lrte_bus_pci -lrte_mempool -lrte_hash
+LDLIBS += -lrte_net -lrte_common_iavf
 
 EXPORT_MAP := rte_pmd_ice_version.map
 
@@ -84,6 +86,9 @@ ifeq ($(CC_AVX2_SUPPORT), 1)
 endif
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
 
drivers/net/ice/ice_dcf.c new file +474 -0

474 lines not on this page · raw message

drivers/net/ice/ice_dcf.h new file +52 -0

52 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.c new file +317 -0

317 lines not on this page · raw message

drivers/net/ice/ice_dcf_ethdev.h new file +24 -0
new file mode 100644
index 000000000..0c34a0095
@@ -0,0 +1,24 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2020 Intel Corporation
+ */
+
+#ifndef _ICE_DCF_ETHDEV_H_
+#define _ICE_DCF_ETHDEV_H_
+
+#include "ice_ethdev.h"
+#include "ice_dcf.h"
+
+#define ICE_DCF_MAX_RINGS  1
+
+struct ice_dcf_queue {
+	uint64_t dummy;
+};
+
+struct ice_dcf_adapter {
+	struct ice_dcf_hw real_hw;
+	struct rte_ether_addr mac_addr;
+	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
+	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
+};
+
+#endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/meson.build +5 -2
index f9e897bbc..0ba9668d1 100644
@@ -15,8 +15,8 @@ sources = files(
 	'ice_hash.c'
 	)
 
-deps += ['hash']
-includes += include_directories('base')
+deps += ['hash', 'net', 'common_iavf']
+includes += include_directories('base', '../../common/iavf')
 
 if arch_subdir == 'x86'
 	sources += files('ice_rxtx_vec_sse.c')
@@ -37,4 +37,7 @@ if arch_subdir == 'x86'
 	endif
 endif
 
+sources += files('ice_dcf.c',
+		 'ice_dcf_ethdev.c')
+
 install_headers('rte_pmd_ice.h')
mk/rte.app.mk +1 -0
index d295ca0a5..f3798a09f 100644
@@ -185,6 +185,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_I40E_PMD)       += -lrte_pmd_i40e
 _LDLIBS-$(CONFIG_RTE_LIBRTE_IAVF_PMD)       += -lrte_pmd_iavf
 _LDLIBS-$(CONFIG_RTE_LIBRTE_ICE_PMD)        += -lrte_pmd_ice
 IAVF-y := $(CONFIG_RTE_LIBRTE_IAVF_PMD)
+IAVF-y += $(CONFIG_RTE_LIBRTE_ICE_PMD)
 ifeq ($(findstring y,$(IAVF-y)),y)
 _LDLIBS-y += -lrte_common_iavf
 endif
Signature · 1 line
2.26.0
#67 lore raw

PATCH v4 3/7 net/ice: acquire and disable the DCF capability

In reply to Haiyue Wang

Since the DCF (Device Config Function) controls the flow setting of other VFs by the mailbox with PF, for security, it needs to acquire the DCF capability from PF when starts, and disable it when exits.

---
 drivers/net/ice/ice_dcf.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +26 -1
index 0a99cceb1..6ea68feb9 100644
@@ -227,7 +227,7 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	int err, i;
 
 	caps = VIRTCHNL_VF_OFFLOAD_WB_ON_ITR | VIRTCHNL_VF_OFFLOAD_RX_POLLING |
-	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED |
+	       VIRTCHNL_VF_CAP_ADV_LINK_SPEED | VIRTCHNL_VF_CAP_DCF |
 	       VF_BASE_MODE_OFFLOADS;
 
 	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_GET_VF_RESOURCES,
@@ -264,6 +264,30 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_mode_disable(struct ice_dcf_hw *hw)
+{
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to send msg OP_DCF_DISABLE");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_DISABLE,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ, NULL);
+	if (err) {
+		PMD_DRV_LOG(ERR,
+			    "Failed to get response of OP_DCF_DISABLE %d",
+			    err);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int
 ice_dcf_check_reset_done(struct ice_dcf_hw *hw)
 {
@@ -467,6 +491,7 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	rte_intr_callback_unregister(intr_handle,
 				     ice_dcf_dev_interrupt_handler, hw);
 
+	ice_dcf_mode_disable(hw);
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
Signature · 1 line
2.26.0
#68 lore raw

PATCH v4 4/7 net/ice: handle the AdminQ command by DCF

In reply to Haiyue Wang

The DCF (Device Config Function) splits the AdminQ command into two
parts: one is the descriptor of AdminQ command, the other is the buffer of AdminQ command (the descriptor has BUF flag set). When both of them are received by the PF, the PF will handle them as one command.

And also, the filled descriptor and buffer of the response will be sent back to DCF one by one through the virtchnl from PF.

---
 drivers/net/ice/ice_dcf.c | 65 +++++++++++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h |  4 ++-
 2 files changed, 68 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +65 -0
index 6ea68feb9..baef5b8dc 100644
@@ -396,6 +396,71 @@ ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 	return err;
 }
 
+int
+ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+		    void *buf, uint16_t buf_size)
+{
+	struct dcf_virtchnl_cmd desc_cmd, buff_cmd;
+	struct ice_dcf_hw *hw = dcf_hw;
+	int err = 0;
+	int i = 0;
+
+	if ((buf && !buf_size) || (!buf && buf_size) ||
+	    buf_size > ICE_DCF_AQ_BUF_SZ)
+		return -EINVAL;
+
+	desc_cmd.v_op = VIRTCHNL_OP_DCF_CMD_DESC;
+	desc_cmd.req_msglen = sizeof(*desc);
+	desc_cmd.req_msg = (uint8_t *)desc;
+	desc_cmd.rsp_buflen = sizeof(*desc);
+	desc_cmd.rsp_msgbuf = (uint8_t *)desc;
+
+	if (buf == NULL)
+		return ice_dcf_execute_virtchnl_cmd(hw, &desc_cmd);
+
+	desc->flags |= rte_cpu_to_le_16(ICE_AQ_FLAG_BUF);
+
+	buff_cmd.v_op = VIRTCHNL_OP_DCF_CMD_BUFF;
+	buff_cmd.req_msglen = buf_size;
+	buff_cmd.req_msg = buf;
+	buff_cmd.rsp_buflen = buf_size;
+	buff_cmd.rsp_msgbuf = buf;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+	ice_dcf_vc_cmd_set(hw, &desc_cmd);
+	ice_dcf_vc_cmd_set(hw, &buff_cmd);
+
+	if (ice_dcf_vc_cmd_send(hw, &desc_cmd) ||
+	    ice_dcf_vc_cmd_send(hw, &buff_cmd)) {
+		err = -1;
+		PMD_DRV_LOG(ERR, "fail to send OP_DCF_CMD_DESC/BUFF");
+		goto ret;
+	}
+
+	do {
+		if ((!desc_cmd.pending && !buff_cmd.pending) ||
+		    (!desc_cmd.pending && desc_cmd.v_ret != IAVF_SUCCESS) ||
+		    (!buff_cmd.pending && buff_cmd.v_ret != IAVF_SUCCESS))
+			break;
+
+		rte_delay_ms(ICE_DCF_ARQ_CHECK_TIME);
+	} while (i++ < ICE_DCF_ARQ_MAX_RETRIES);
+
+	if (desc_cmd.v_ret != IAVF_SUCCESS || buff_cmd.v_ret != IAVF_SUCCESS) {
+		err = -1;
+		PMD_DRV_LOG(ERR,
+			    "No response (%d times) or return failure (desc: %d / buff: %d)",
+			    i, desc_cmd.v_ret, buff_cmd.v_ret);
+	}
+
+ret:
+	ice_dcf_aq_cmd_clear(hw, &desc_cmd);
+	ice_dcf_aq_cmd_clear(hw, &buff_cmd);
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
drivers/net/ice/ice_dcf.h +3 -1
index f44c09db2..99bd53b02 100644
@@ -11,6 +11,7 @@
 #include <iavf_adminq_cmd.h>
 #include <iavf_type.h>
 
+#include "base/ice_type.h"
 #include "ice_logs.h"
 
 struct dcf_virtchnl_cmd {
@@ -45,7 +46,8 @@ struct ice_dcf_hw {
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
-
+int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
+			void *buf, uint16_t buf_size);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
Signature · 1 line
2.26.0
#69 lore raw

PATCH v4 5/7 net/ice: export the DDP definition symbols

In reply to Haiyue Wang

A new DCF PMD will be introduced, which runs on Intel VF hardware, and it is a pure software design to control the advance functionality (such as switch, ACL) for rest of the VFs.

The DCF (Device Config Function) feature shares the core functions of the ICE PMD, like it needs to export the DDP definition symbols for the new DCF PMD use.

---
 drivers/net/ice/ice_ethdev.c | 9 +--------
 drivers/net/ice/ice_ethdev.h | 8 ++++++++
 2 files changed, 9 insertions(+), 8 deletions(-)
drivers/net/ice/ice_ethdev.c +1 -8
index 3498a5075..3c38472de 100644
@@ -67,15 +67,8 @@ static struct proto_xtr_ol_flag ice_proto_xtr_ol_flag_params[] = {
 
 #define ICE_DFLT_OUTER_TAG_TYPE ICE_AQ_VSI_OUTER_TAG_VLAN_9100
 
-/* DDP package search path */
-#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
-#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
-#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
-
 #define ICE_OS_DEFAULT_PKG_NAME		"ICE OS Default Package"
 #define ICE_COMMS_PKG_NAME			"ICE COMMS Package"
-#define ICE_MAX_PKG_FILENAME_SIZE   256
 #define ICE_MAX_RES_DESC_NUM        1024
 
 int ice_logtype_init;
@@ -1833,7 +1826,7 @@ ice_pkg_file_search_path(struct rte_pci_device *pci_dev, char *pkg_file)
 	return 0;
 }
 
-static enum ice_pkg_type
+enum ice_pkg_type
 ice_load_pkg_type(struct ice_hw *hw)
 {
 	enum ice_pkg_type package_type;
drivers/net/ice/ice_ethdev.h +8 -0
index da557a254..7b94a3c3e 100644
@@ -42,6 +42,13 @@
 
 #define ICE_MAX_PKT_TYPE  1024
 
+/* DDP package search path */
+#define ICE_PKG_FILE_DEFAULT "/lib/firmware/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_UPDATES "/lib/firmware/updates/intel/ice/ddp/ice.pkg"
+#define ICE_PKG_FILE_SEARCH_PATH_DEFAULT "/lib/firmware/intel/ice/ddp/"
+#define ICE_PKG_FILE_SEARCH_PATH_UPDATES "/lib/firmware/updates/intel/ice/ddp/"
+#define ICE_MAX_PKG_FILENAME_SIZE   256
+
 /**
  * vlan_id is a 12 bit number.
  * The VFTA array is actually a 4096 bit array, 128 of 32bit elements.
@@ -457,6 +464,7 @@ struct ice_vsi_vlan_pvid_info {
 #define ICE_PF_TO_ETH_DEV(pf) \
 	(((struct ice_pf *)pf)->adapter->eth_dev)
 
+enum ice_pkg_type ice_load_pkg_type(struct ice_hw *hw);
 struct ice_vsi *
 ice_setup_vsi(struct ice_pf *pf, enum ice_vsi_type type);
 int
Signature · 1 line
2.26.0
#70 lore raw

PATCH v4 6/7 net/ice: handle the PF initialization by DCF

In reply to Haiyue Wang

The DCF (Device Config Function) works at the user PF level, it can't access the real PF hardware directly. So it will pass through the PF's AdminQ command by the DCF's mailbox.

And the DCF is mainly used to control the flow setting of other VFs, so it only needs to initialize some core functions related to the flow.

---
 drivers/net/ice/Makefile         |   1 +
 drivers/net/ice/ice_dcf.c        |   7 +-
 drivers/net/ice/ice_dcf.h        |   3 +
 drivers/net/ice/ice_dcf_ethdev.c |  10 +-
 drivers/net/ice/ice_dcf_ethdev.h |  11 +-
 drivers/net/ice/ice_dcf_parent.c | 263 +++++++++++++++++++++++++++++++
 drivers/net/ice/meson.build      |   3 +-
 7 files changed, 292 insertions(+), 6 deletions(-)
 create mode 100644 drivers/net/ice/ice_dcf_parent.c
drivers/net/ice/Makefile +1 -0
index f493c9ed7..3ecc72219 100644
@@ -88,6 +88,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_generic_flow.c
 
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf.c
 SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_ICE_PMD) += ice_dcf_parent.c
 
 # install this header file
 SYMLINK-$(CONFIG_RTE_LIBRTE_ICE_PMD)-include := rte_pmd_ice.h
drivers/net/ice/ice_dcf.c +6 -1
index baef5b8dc..c799cdf83 100644
@@ -124,8 +124,13 @@ ice_dcf_aq_cmd_handle(struct ice_dcf_hw *hw, struct iavf_arq_event_info *info)
 	}
 
 	v_op = rte_le_to_cpu_32(info->desc.cookie_high);
-	if (unlikely(v_op == VIRTCHNL_OP_EVENT))
+	if (v_op == VIRTCHNL_OP_EVENT) {
+		if (hw->vc_event_msg_cb != NULL)
+			hw->vc_event_msg_cb(hw,
+					    info->msg_buf,
+					    info->msg_len);
 		return;
+	}
 
 	v_ret = rte_le_to_cpu_32(info->desc.cookie_low);
 
drivers/net/ice/ice_dcf.h +3 -0
index 99bd53b02..ecd6303a0 100644
@@ -36,6 +36,9 @@ struct ice_dcf_hw {
 	rte_spinlock_t vc_cmd_send_lock;
 	rte_spinlock_t vc_cmd_queue_lock;
 	TAILQ_HEAD(, dcf_virtchnl_cmd) vc_cmd_queue;
+	void (*vc_event_msg_cb)(struct ice_dcf_hw *dcf_hw,
+				uint8_t *msg, uint16_t msglen);
+
 	uint8_t *arq_buf;
 
 	struct virtchnl_version_info virtchnl_version;
drivers/net/ice/ice_dcf_ethdev.c +7 -3
index 23f82a487..af94caeff 100644
@@ -145,8 +145,8 @@ ice_dcf_dev_close(struct rte_eth_dev *dev)
 	dev->dev_ops = NULL;
 	dev->rx_pkt_burst = NULL;
 	dev->tx_pkt_burst = NULL;
-	dev->data->mac_addrs = NULL;
 
+	ice_dcf_uninit_parent_adapter(dev);
 	ice_dcf_uninit_hw(dev, &adapter->real_hw);
 }
 
@@ -225,13 +225,17 @@ ice_dcf_dev_init(struct rte_eth_dev *eth_dev)
 
 	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
 
+	adapter->real_hw.vc_event_msg_cb = ice_dcf_handle_pf_event_msg;
 	if (ice_dcf_init_hw(eth_dev, &adapter->real_hw) != 0) {
 		PMD_INIT_LOG(ERR, "Failed to init DCF hardware");
 		return -1;
 	}
 
-	rte_eth_random_addr(adapter->mac_addr.addr_bytes);
-	eth_dev->data->mac_addrs = &adapter->mac_addr;
+	if (ice_dcf_init_parent_adapter(eth_dev) != 0) {
+		PMD_INIT_LOG(ERR, "Failed to init DCF parent adapter");
+		ice_dcf_uninit_hw(eth_dev, &adapter->real_hw);
+		return -1;
+	}
 
 	return 0;
 }
drivers/net/ice/ice_dcf_ethdev.h +10 -1
index 0c34a0095..e60e808d8 100644
@@ -5,6 +5,9 @@
 #ifndef _ICE_DCF_ETHDEV_H_
 #define _ICE_DCF_ETHDEV_H_
 
+#include "base/ice_common.h"
+#include "base/ice_adminq_cmd.h"
+
 #include "ice_ethdev.h"
 #include "ice_dcf.h"
 
@@ -15,10 +18,16 @@ struct ice_dcf_queue {
 };
 
 struct ice_dcf_adapter {
+	struct ice_adapter parent; /* Must be first */
+
 	struct ice_dcf_hw real_hw;
-	struct rte_ether_addr mac_addr;
 	struct ice_dcf_queue rxqs[ICE_DCF_MAX_RINGS];
 	struct ice_dcf_queue txqs[ICE_DCF_MAX_RINGS];
 };
 
+void ice_dcf_handle_pf_event_msg(struct ice_dcf_hw *dcf_hw,
+				 uint8_t *msg, uint16_t msglen);
+int ice_dcf_init_parent_adapter(struct rte_eth_dev *eth_dev);
+void ice_dcf_uninit_parent_adapter(struct rte_eth_dev *eth_dev);
+
 #endif /* _ICE_DCF_ETHDEV_H_ */
drivers/net/ice/ice_dcf_parent.c new file +263 -0

263 lines not on this page · raw message

drivers/net/ice/meson.build +2 -1
index 0ba9668d1..7e9037f3b 100644
@@ -38,6 +38,7 @@ if arch_subdir == 'x86'
 endif
 
 sources += files('ice_dcf.c',
-		 'ice_dcf_ethdev.c')
+		 'ice_dcf_ethdev.c',
+		 'ice_dcf_parent.c')
 
 install_headers('rte_pmd_ice.h')
Signature · 1 line
2.26.0
#71 lore raw

PATCH v4 7/7 net/ice: get the VF hardware index in DCF

In reply to Haiyue Wang

The DCF (Device Config Function) needs the hardware index of the VFs to control the flow setting. And also if the VF resets, the index may be changed, so it should handle this in VF reset event.

---
 drivers/net/ice/ice_dcf.c        | 89 +++++++++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h        |  6 +++
 drivers/net/ice/ice_dcf_parent.c | 90 +++++++++++++++++++++++++++++++-
 3 files changed, 184 insertions(+), 1 deletion(-)
drivers/net/ice/ice_dcf.c +89 -0
index c799cdf83..4c30f0e60 100644
@@ -269,6 +269,65 @@ ice_dcf_get_vf_resource(struct ice_dcf_hw *hw)
 	return 0;
 }
 
+static int
+ice_dcf_get_vf_vsi_map(struct ice_dcf_hw *hw)
+{
+	struct virtchnl_dcf_vsi_map *vsi_map;
+	uint32_t valid_msg_len;
+	uint16_t len;
+	int err;
+
+	err = ice_dcf_send_cmd_req_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  NULL, 0);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to send msg OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	err = ice_dcf_recv_cmd_rsp_no_irq(hw, VIRTCHNL_OP_DCF_GET_VSI_MAP,
+					  hw->arq_buf, ICE_DCF_AQ_BUF_SZ,
+					  &len);
+	if (err) {
+		PMD_DRV_LOG(ERR, "Failed to get response of OP_DCF_GET_VSI_MAP");
+		return err;
+	}
+
+	vsi_map = (struct virtchnl_dcf_vsi_map *)hw->arq_buf;
+	valid_msg_len = (vsi_map->num_vfs - 1) * sizeof(vsi_map->vf_vsi[0]) +
+			sizeof(*vsi_map);
+	if (len != valid_msg_len) {
+		PMD_DRV_LOG(ERR, "invalid vf vsi map response with length %u",
+			    len);
+		return -EINVAL;
+	}
+
+	if (hw->num_vfs != 0 && hw->num_vfs != vsi_map->num_vfs) {
+		PMD_DRV_LOG(ERR, "The number VSI map (%u) doesn't match the number of VFs (%u)",
+			    vsi_map->num_vfs, hw->num_vfs);
+		return -EINVAL;
+	}
+
+	len = vsi_map->num_vfs * sizeof(vsi_map->vf_vsi[0]);
+
+	if (!hw->vf_vsi_map) {
+		hw->vf_vsi_map = rte_zmalloc("vf_vsi_ctx", len, 0);
+		if (!hw->vf_vsi_map) {
+			PMD_DRV_LOG(ERR, "Failed to alloc memory for VSI context");
+			return -ENOMEM;
+		}
+
+		hw->num_vfs = vsi_map->num_vfs;
+	}
+
+	if (!memcmp(hw->vf_vsi_map, vsi_map->vf_vsi, len)) {
+		PMD_DRV_LOG(DEBUG, "VF VSI map doesn't change");
+		return 1;
+	}
+
+	rte_memcpy(hw->vf_vsi_map, vsi_map->vf_vsi, len);
+	return 0;
+}
+
 static int
 ice_dcf_mode_disable(struct ice_dcf_hw *hw)
 {
@@ -466,6 +525,28 @@ ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 	return err;
 }
 
+int
+ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw)
+{
+	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(hw->eth_dev);
+	int err = 0;
+
+	rte_spinlock_lock(&hw->vc_cmd_send_lock);
+
+	rte_intr_disable(&pci_dev->intr_handle);
+	ice_dcf_disable_irq0(hw);
+
+	if (ice_dcf_get_vf_resource(hw) || ice_dcf_get_vf_vsi_map(hw))
+		err = -1;
+
+	rte_intr_enable(&pci_dev->intr_handle);
+	ice_dcf_enable_irq0(hw);
+
+	rte_spinlock_unlock(&hw->vc_cmd_send_lock);
+
+	return err;
+}
+
 int
 ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 {
@@ -533,6 +614,13 @@ ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 		goto err_alloc;
 	}
 
+	if (ice_dcf_get_vf_vsi_map(hw) < 0) {
+		PMD_INIT_LOG(ERR, "Failed to get VF VSI map");
+		ice_dcf_mode_disable(hw);
+		goto err_alloc;
+	}
+
+	hw->eth_dev = eth_dev;
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   ice_dcf_dev_interrupt_handler, hw);
 	rte_intr_enable(&pci_dev->intr_handle);
@@ -565,5 +653,6 @@ ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw)
 	iavf_shutdown_adminq(&hw->avf);
 
 	rte_free(hw->arq_buf);
+	rte_free(hw->vf_vsi_map);
 	rte_free(hw->vf_res);
 }
drivers/net/ice/ice_dcf.h +6 -0
index ecd6303a0..d2e447b48 100644
@@ -41,16 +41,22 @@ struct ice_dcf_hw {
 
 	uint8_t *arq_buf;
 
+	uint16_t num_vfs;
+	uint16_t *vf_vsi_map;
+
 	struct virtchnl_version_info virtchnl_version;
 	struct virtchnl_vf_resource *vf_res; /* VF resource */
 	struct virtchnl_vsi_resource *vsi_res; /* LAN VSI */
 	uint16_t vsi_id;
+
+	struct rte_eth_dev *eth_dev;
 };
 
 int ice_dcf_execute_virtchnl_cmd(struct ice_dcf_hw *hw,
 				 struct dcf_virtchnl_cmd *cmd);
 int ice_dcf_send_aq_cmd(void *dcf_hw, struct ice_aq_desc *desc,
 			void *buf, uint16_t buf_size);
+int ice_dcf_handle_vsi_update_event(struct ice_dcf_hw *hw);
 int ice_dcf_init_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 void ice_dcf_uninit_hw(struct rte_eth_dev *eth_dev, struct ice_dcf_hw *hw);
 
drivers/net/ice/ice_dcf_parent.c +89 -1

122 lines not on this page · raw message

Signature · 1 line
2.26.0
Acked-by on the v4 series
#72 lore raw
In reply to Haiyue Wang
Quoted 60 lines

-----Original Message-----
From: Wang, Haiyue <[email protected]>
Sent: Thursday, March 26, 2020 11:04 AM
To: [email protected]; Ye, Xiaolong <[email protected]>; Zhang, Qi Z <[email protected]>; Yang, Qiming <[email protected]>; Xing, Beilei <[email protected]>
Cc: Zhao1, Wei <[email protected]>; Wang, Haiyue <[email protected]>
Subject: [PATCH v4 0/7] add Intel DCF PMD support

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

v4:
Change the alarm handler to thread service, since it will need to do more work.

v3:
1. Fixed the error log message format.
2. Fixed some memory allocation check.
3. Fixed some code style issue and commmit message description.

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: acquire and disable the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

 doc/guides/nics/ice.rst                |  47 ++
 doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
 doc/guides/rel_notes/release_20_05.rst |   5 +
 drivers/common/Makefile                |   1 +
 drivers/net/iavf/iavf_ethdev.c         |  43 ++
 drivers/net/ice/Makefile               |   6 +
 drivers/net/ice/ice_dcf.c              | 658
+++++++++++++++++++++++++
 drivers/net/ice/ice_dcf.h              |  63 +++
 drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
 drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
 drivers/net/ice/ice_dcf_parent.c       | 351 +++++++++++++
 drivers/net/ice/ice_ethdev.c           |   9 +-
 drivers/net/ice/ice_ethdev.h           |   8 +
 drivers/net/ice/meson.build            |   8 +-
 mk/rte.app.mk                          |   1 +
 15 files changed, 1544 insertions(+), 10 deletions(-)  create mode 100644
Quoted 8 lines

doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

--
2.26.0

#73 lore raw
In reply to Haiyue Wang

There is build error about this patchset, could you double check?

OS: CENTOS77-64
Target: x86_64-native-linuxapp-gcc+shared
LD librte_pmd_ice.so.20.0.2
CC sfc_ev.o
ice_dcf_parent.o: In function `ice_dcf_handle_pf_event_msg':
ice_dcf_parent.c:(.text+0x556): undefined reference to `pthread_create'
collect2: error: ld returned 1 exit status
make[6]: *** [librte_pmd_ice.so.20.0.2] Error 1
make[5]: *** [ice] Error 2
make[5]: *** Waiting for unfinished jobs....
CC sfc_port.o
CC bnxt_rxtx_vec_sse.o
CC sfc_rx.o
CC nicvf_hw.o
--
CC medford2_nic.o
LD librte_pmd_octeontx2.so.20.0.2
INSTALL-LIB librte_pmd_octeontx2.so.20.0.2
LD librte_pmd_sfc_efx.so.20.0.2
INSTALL-LIB librte_pmd_sfc_efx.so.20.0.2
make[4]: *** [net] Error 2
make[3]: *** [drivers] Error 2
make[2]: *** [all] Error 2
make[1]: *** [pre_install] Error 2
make: *** [install] Error 2

http://mails.dpdk.org/archives/test-report/2020-March/122145.html

Quoted 56 lines · Haiyue Wang

A DCF (Device Config Function) based approach is proposed where a device bound to the device's VF0 can act as a sole controlling entity to exercise advance functionality (such as switch, ACL) for rest of the VFs.

The DCF works as a standalone PMD to support this function, which shares the ice PMD flow control core function and the iavf virtchnl mailbox core module.

v4:
Change the alarm handler to thread service, since it will need to do more work.

v3:
1. Fixed the error log message format.
2. Fixed some memory allocation check.
3. Fixed some code style issue and commmit message description.

v2:
1. update the iavf patchset link.
2. split more patches for making this work be more understandable
3. fix the log function usage, devargs checking from v1.

Haiyue Wang (7):
net/iavf: stop the PCI probe in DCF mode
net/ice: add the DCF hardware initialization
net/ice: acquire and disable the DCF capability
net/ice: handle the AdminQ command by DCF
net/ice: export the DDP definition symbols
net/ice: handle the PF initialization by DCF
net/ice: get the VF hardware index in DCF

doc/guides/nics/ice.rst                |  47 ++
doc/guides/nics/img/ice_dcf.png        | Bin 0 -> 39168 bytes
doc/guides/rel_notes/release_20_05.rst |   5 +
drivers/common/Makefile                |   1 +
drivers/net/iavf/iavf_ethdev.c         |  43 ++
drivers/net/ice/Makefile               |   6 +
drivers/net/ice/ice_dcf.c              | 658 +++++++++++++++++++++++++
drivers/net/ice/ice_dcf.h              |  63 +++
drivers/net/ice/ice_dcf_ethdev.c       | 321 ++++++++++++
drivers/net/ice/ice_dcf_ethdev.h       |  33 ++
drivers/net/ice/ice_dcf_parent.c       | 351 +++++++++++++
drivers/net/ice/ice_ethdev.c           |   9 +-
drivers/net/ice/ice_ethdev.h           |   8 +
drivers/net/ice/meson.build            |   8 +-
mk/rte.app.mk                          |   1 +
15 files changed, 1544 insertions(+), 10 deletions(-)

create mode 100644 doc/guides/nics/img/ice_dcf.png create mode 100644 drivers/net/ice/ice_dcf.c create mode 100644 drivers/net/ice/ice_dcf.h create mode 100644 drivers/net/ice/ice_dcf_ethdev.c create mode 100644 drivers/net/ice/ice_dcf_ethdev.h create mode 100644 drivers/net/ice/ice_dcf_parent.c

Signature · 1 line
2.26.0