Skip to contentSkip to conversation

vdpa/sfc: introduce Xilinx vDPA driver

PATCH Superseded Vijay Srivastava 9 participants 122 messages Jul 7, 2021 – Nov 8, 2021 Page 2 of 2

Subsystems (2)
lore
Share & tools
lore
Reviewed-by on v3 9/10
#92 lore raw

Re: [dpdk-dev] [PATCH v3 09/10] vdpa/sfc: add support to set vring state

In reply to Vijay Srivastava
Quoted 87 lines

-----Original Message-----
From: Vijay Srivastava <[email protected]>
Sent: Friday, October 29, 2021 10:47 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; [email protected]; Vijay Kumar Srivastava <[email protected]>
Subject: [PATCH v3 09/10] vdpa/sfc: add support to set vring state

From: Vijay Kumar Srivastava <[email protected]>

Implements vDPA ops set_vring_state to configure vring state.

---
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 54 ++++++++++++++++++++++++++++++++++++++--
(quoted diff) +0 -1
-
 1 file changed, 50 insertions(+), 4 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_ops.c +50 -5
index 8551b65..3430643 100644
@@ -719,11 +719,57 @@
 static int
 sfc_vdpa_set_vring_state(int vid, int vring, int state)
 {
-	RTE_SET_USED(vid);
-	RTE_SET_USED(vring);
-	RTE_SET_USED(state);
+	struct sfc_vdpa_ops_data *ops_data;
+	struct rte_vdpa_device *vdpa_dev;
+	efx_rc_t rc;
+	int vring_max;
+	void *dev;
 
-	return -1;
+	vdpa_dev = rte_vhost_get_vdpa_device(vid);
+
+	ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev);
+	if (ops_data == NULL)
+		return -1;
+
+	dev = ops_data->dev_handle;
+
+	sfc_vdpa_info(dev,
+		      "vDPA ops set_vring_state: vid: %d, vring: %d, state:%d",
+		      vid, vring, state);
+
+	vring_max = (sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count * 2);
+
+	if (vring < 0 || vring > vring_max) {
+		sfc_vdpa_err(dev, "received invalid vring id : %d to set state",
+			     vring);
+		return -1;
+	}
+
+	/*
+	 * Skip if device is not yet started. virtqueues state can be
+	 * changed once it is created and other configurations are done.
+	 */
+	if (ops_data->state != SFC_VDPA_STATE_STARTED)
+		return 0;
+
+	if (ops_data->vq_cxt[vring].enable == state)
+		return 0;
+
+	if (state == 0) {
+		rc = sfc_vdpa_virtq_stop(ops_data, vring);
+		if (rc != 0) {
+			sfc_vdpa_err(dev, "virtqueue stop failed: %s",
+				     rte_strerror(rc));
+		}
+	} else {
+		rc = sfc_vdpa_virtq_start(ops_data, vring);
+		if (rc != 0) {
+			sfc_vdpa_err(dev, "virtqueue start failed: %s",
+				     rte_strerror(rc));
+		}
+	}
+
+	return rc;
 }
 
 static int
--
Quoted 1 line

1.8.3.1

#93 lore raw

PATCH v3 10/10 vdpa/sfc: set a multicast filter during vDPA init

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Insert unknown multicast filter to allow IPv6 neighbor discovery

---
 drivers/vdpa/sfc/sfc_vdpa.h        |  3 ++-
 drivers/vdpa/sfc/sfc_vdpa_filter.c | 19 +++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/vdpa/sfc/sfc_vdpa.h +2 -1
index dbd099f..bedc76c 100644
@@ -21,7 +21,7 @@
 #define SFC_VDPA_DEFAULT_MCDI_IOVA		0x200000000000
 
 /* Broadcast & Unicast MAC filters are supported */
-#define SFC_MAX_SUPPORTED_FILTERS		2
+#define SFC_MAX_SUPPORTED_FILTERS		3
 
 /*
  * Get function-local index of the associated VI from the
@@ -32,6 +32,7 @@
 enum sfc_vdpa_filter_type {
 	SFC_VDPA_BCAST_MAC_FILTER = 0,
 	SFC_VDPA_UCAST_MAC_FILTER = 1,
+	SFC_VDPA_MCAST_DST_FILTER = 2,
 	SFC_VDPA_FILTER_NTYPE
 };
 
drivers/vdpa/sfc/sfc_vdpa_filter.c +17 -2
index 03b6a5d..74204d3 100644
@@ -39,8 +39,12 @@
 	spec->efs_flags = EFX_FILTER_FLAG_RX;
 	spec->efs_dmaq_id = qid;
 
-	rc = efx_filter_spec_set_eth_local(spec, EFX_FILTER_SPEC_VID_UNSPEC,
-					   eth_addr);
+	if (eth_addr == NULL)
+		rc = efx_filter_spec_set_mc_def(spec);
+	else
+		rc = efx_filter_spec_set_eth_local(spec,
+						   EFX_FILTER_SPEC_VID_UNSPEC,
+						   eth_addr);
 	if (rc != 0)
 		return rc;
 
@@ -114,6 +118,17 @@ int sfc_vdpa_filter_config(struct sfc_vdpa_ops_data *ops_data)
 	else
 		sva->filters.filter_cnt++;
 
+	sfc_vdpa_log_init(sva, "insert unknown mcast filter");
+	spec = &sva->filters.spec[SFC_VDPA_MCAST_DST_FILTER];
+
+	rc = sfc_vdpa_set_mac_filter(nic, spec, qid, NULL);
+	if (rc != 0)
+		sfc_vdpa_err(sva,
+			     "mcast filter insertion failed: %s",
+			     rte_strerror(rc));
+	else
+		sva->filters.filter_cnt++;
+
 	sfc_vdpa_log_init(sva, "done");
 
 	return rc;
Signature · 1 line
1.8.3.1
Reviewed-by on v3 10/10
#94 lore raw

Re: [dpdk-dev] [PATCH v3 10/10] vdpa/sfc: set a multicast filter during vDPA init

Quoted 63 lines

-----Original Message-----
From: Vijay Srivastava <[email protected]>
Sent: Friday, October 29, 2021 10:47 PM
To: [email protected]
Cc: [email protected]; Xia, Chenbo <[email protected]>; [email protected]; Vijay Kumar Srivastava <[email protected]>
Subject: [PATCH v3 10/10] vdpa/sfc: set a multicast filter during vDPA init

From: Vijay Kumar Srivastava <[email protected]>

Insert unknown multicast filter to allow IPv6 neighbor discovery

---
 drivers/vdpa/sfc/sfc_vdpa.h        |  3 ++-
 drivers/vdpa/sfc/sfc_vdpa_filter.c | 19 +++++++++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)
drivers/vdpa/sfc/sfc_vdpa.h +2 -1
index dbd099f..bedc76c 100644
@@ -21,7 +21,7 @@
 #define SFC_VDPA_DEFAULT_MCDI_IOVA		0x200000000000
 
 /* Broadcast & Unicast MAC filters are supported */
-#define SFC_MAX_SUPPORTED_FILTERS		2
+#define SFC_MAX_SUPPORTED_FILTERS		3
 
 /*
  * Get function-local index of the associated VI from the
@@ -32,6 +32,7 @@
 enum sfc_vdpa_filter_type {
 	SFC_VDPA_BCAST_MAC_FILTER = 0,
 	SFC_VDPA_UCAST_MAC_FILTER = 1,
+	SFC_VDPA_MCAST_DST_FILTER = 2,
 	SFC_VDPA_FILTER_NTYPE
 };
 
drivers/vdpa/sfc/sfc_vdpa_filter.c +6 -2
index 03b6a5d..74204d3 100644
@@ -39,8 +39,12 @@
 	spec->efs_flags = EFX_FILTER_FLAG_RX;
 	spec->efs_dmaq_id = qid;
 
-	rc = efx_filter_spec_set_eth_local(spec, EFX_FILTER_SPEC_VID_UNSPEC,
-					   eth_addr);
+	if (eth_addr == NULL)
+		rc = efx_filter_spec_set_mc_def(spec);
+	else
+		rc = efx_filter_spec_set_eth_local(spec,
+						   EFX_FILTER_SPEC_VID_UNSPEC,
+						   eth_addr);
 	if (rc != 0)
 		return rc;
 
@@ -114,6 +118,17 @@ int sfc_vdpa_filter_config(struct sfc_vdpa_ops_data
 *ops_data)
 	else

drivers/vdpa/sfc/sfc_vdpa_filter.c int sfc_vdpa_filter_config(struct sfc_vdpa_ops_data · line 129

Quoted 10 lines
drivers/vdpa/sfc/sfc_vdpa_filter.c +8 -0
 		sva->filters.filter_cnt++;
 
+	sfc_vdpa_log_init(sva, "insert unknown mcast filter");
+	spec = &sva->filters.spec[SFC_VDPA_MCAST_DST_FILTER];
+
+	rc = sfc_vdpa_set_mac_filter(nic, spec, qid, NULL);
+	if (rc != 0)
+		sfc_vdpa_err(sva,
+			     "mcast filter insertion failed: %s",
+			     rte_strerror(rc));

Can improve to use two lines.

With this fixed:

Quoted 8 lines
drivers/vdpa/sfc/sfc_vdpa_filter.c +3 -0
+	else
+		sva->filters.filter_cnt++;
+
 	sfc_vdpa_log_init(sva, "done");
 

return rc;
--
1.8.3.1

#95 lore raw

v4 cover vdpa/sfc: introduce Xilinx vDPA driver

In reply to Vijay Srivastava

This patch series introduces vDPA driver for Xilinx devices. The Xilinx vDPA (vhost data path acceleration) provides support for the Xilinx SN1022 SmartNICs.

Vijay Kumar Srivastava (10):
vdpa/sfc: introduce Xilinx vDPA driver
vdpa/sfc: add support for device initialization vdpa/sfc: add support to get device and protocol features vdpa/sfc: get device supported max queue count vdpa/sfc: add support to get VFIO device fd vdpa/sfc: add support for dev conf and dev close ops vdpa/sfc: add support to get queue notify area info vdpa/sfc: add support for MAC filter config vdpa/sfc: add support to set vring state vdpa/sfc: set a multicast filter during vDPA init

 MAINTAINERS                            |   6 +
 doc/guides/rel_notes/release_21_11.rst |   5 +
 doc/guides/vdpadevs/features/sfc.ini   |  19 +
 doc/guides/vdpadevs/index.rst          |   1 +
 doc/guides/vdpadevs/sfc.rst            | 107 ++++
 drivers/common/sfc_efx/efsys.h         |   2 +-
 drivers/common/sfc_efx/version.map     |  10 +
 drivers/vdpa/meson.build               |   1 +
 drivers/vdpa/sfc/meson.build           |  26 +
 drivers/vdpa/sfc/sfc_vdpa.c            | 363 +++++++++++++
 drivers/vdpa/sfc/sfc_vdpa.h            | 162 ++++++
 drivers/vdpa/sfc/sfc_vdpa_debug.h      |  21 +
 drivers/vdpa/sfc/sfc_vdpa_filter.c     | 150 ++++++
 drivers/vdpa/sfc/sfc_vdpa_hw.c         | 418 +++++++++++++++
 drivers/vdpa/sfc/sfc_vdpa_log.h        |  59 +++
 drivers/vdpa/sfc/sfc_vdpa_mcdi.c       |  74 +++
 drivers/vdpa/sfc/sfc_vdpa_ops.c        | 930 +++++++++++++++++++++++++++++++++
 drivers/vdpa/sfc/sfc_vdpa_ops.h        |  67 +++
 drivers/vdpa/sfc/version.map           |   3 +
 19 files changed, 2423 insertions(+), 1 deletion(-)
 create mode 100644 doc/guides/vdpadevs/features/sfc.ini
 create mode 100644 doc/guides/vdpadevs/sfc.rst
 create mode 100644 drivers/vdpa/sfc/meson.build
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa.h
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_debug.h
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_filter.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_hw.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_log.h
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_mcdi.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.h
 create mode 100644 drivers/vdpa/sfc/version.map
Signature · 1 line
1.8.3.1
#96 lore raw

PATCH v4 1/10 vdpa/sfc: introduce Xilinx vDPA driver

From: Vijay Kumar Srivastava <[email protected]>

Add new vDPA PMD to support vDPA operations of Xilinx devices. This patch implements probe and remove functions.

---
v2:
* Updated logging macros to remove redundant code.

v3:
* Replaced depreciated whitelist with allowlist.
* Text corrections in the sfc.rst and commit msg.
* Added sfc in the toctree of doc/guides/vdpadevs/index.rst.
* Removed extra compiler flags.

v4:
* Removed redundant NULL checks.
* Removed unused pci_addr from adapter structure.
* Updated format specifiers in log messages.

 MAINTAINERS                            |   6 +
 doc/guides/rel_notes/release_21_11.rst |   5 +
 doc/guides/vdpadevs/features/sfc.ini   |   9 ++
 doc/guides/vdpadevs/index.rst          |   1 +
 doc/guides/vdpadevs/sfc.rst            |  97 ++++++++++++
 drivers/vdpa/meson.build               |   1 +
 drivers/vdpa/sfc/meson.build           |  22 +++
 drivers/vdpa/sfc/sfc_vdpa.c            | 282 +++++++++++++++++++++++++++++++++
 drivers/vdpa/sfc/sfc_vdpa.h            |  39 +++++
 drivers/vdpa/sfc/sfc_vdpa_log.h        |  56 +++++++
 drivers/vdpa/sfc/version.map           |   3 +
 11 files changed, 521 insertions(+)
 create mode 100644 doc/guides/vdpadevs/features/sfc.ini
 create mode 100644 doc/guides/vdpadevs/sfc.rst
 create mode 100644 drivers/vdpa/sfc/meson.build
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa.h
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_log.h
 create mode 100644 drivers/vdpa/sfc/version.map
MAINTAINERS +6 -0
index be2c9b6..5d12c49 100644
@@ -1236,6 +1236,12 @@ F: drivers/vdpa/mlx5/
 F: doc/guides/vdpadevs/mlx5.rst
 F: doc/guides/vdpadevs/features/mlx5.ini
 
+Xilinx sfc vDPA
+M: Vijay Kumar Srivastava <[email protected]>
+F: drivers/vdpa/sfc/
+F: doc/guides/vdpadevs/sfc.rst
+F: doc/guides/vdpadevs/features/sfc.ini
+
 
 Eventdev Drivers
 ----------------
doc/guides/rel_notes/release_21_11.rst +5 -0
index c68f122..0859b9b 100644
@@ -324,6 +324,11 @@ New Features
   with the capability for the application to configure the hash key, the
   RETA and the hash types. Virtio hash reporting is yet to be added.
 
+* **Added new vDPA PMD based on Xilinx devices.**
+
+  Added a new Xilinx vDPA  (``sfc_vdpa``) PMD.
+  See the :doc:`../vdpadevs/sfc` guide for more details on this driver.
+
 
 Removed Items
 -------------
doc/guides/vdpadevs/features/sfc.ini new file +9 -0
new file mode 100644
index 0000000..71b6158
@@ -0,0 +1,9 @@
+;
+; Supported features of the 'sfc' vDPA driver.
+;
+; Refer to default.ini for the full list of available driver features.
+;
+[Features]
+Linux			= Y
+x86-64			= Y
+Usage doc		= Y
doc/guides/vdpadevs/index.rst +1 -0
index 1a13efe..cc2f858 100644
@@ -14,3 +14,4 @@ which can be used from an application through vhost API.
     features_overview
     ifc
     mlx5
+    sfc
doc/guides/vdpadevs/sfc.rst new file +97 -0

97 lines not on this page · raw message

drivers/vdpa/meson.build +1 -0
index f765fe3..77412c7 100644
@@ -8,6 +8,7 @@ endif
 drivers = [
         'ifc',
         'mlx5',
+        'sfc',
 ]
 std_deps = ['bus_pci', 'kvargs']
 std_deps += ['vhost']
drivers/vdpa/sfc/meson.build new file +22 -0
new file mode 100644
index 0000000..4255d65
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Copyright(c) 2020-2021 Xilinx, Inc.
+
+if (arch_subdir != 'x86' or not dpdk_conf.get('RTE_ARCH_64')) and (arch_subdir != 'arm' or not host_machine.cpu_family().startswith('aarch64'))
+	build = false
+	reason = 'only supported on x86_64 and aarch64'
+endif
+
+fmt_name = 'sfc_vdpa'
+extra_flags = []
+
+foreach flag: extra_flags
+	if cc.has_argument(flag)
+		cflags += flag
+	endif
+endforeach
+
+deps += ['common_sfc_efx', 'bus_pci']
+sources = files(
+	'sfc_vdpa.c',
+)
drivers/vdpa/sfc/sfc_vdpa.c new file +282 -0

282 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa.h new file +39 -0
new file mode 100644
index 0000000..2ae9ec3
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+
+#ifndef _SFC_VDPA_H
+#define _SFC_VDPA_H
+
+#include <stdint.h>
+#include <sys/queue.h>
+
+#include <rte_bus_pci.h>
+
+#include "sfc_vdpa_log.h"
+
+/* Adapter private data */
+struct sfc_vdpa_adapter {
+	TAILQ_ENTRY(sfc_vdpa_adapter)	next;
+	struct rte_pci_device		*pdev;
+
+	char				log_prefix[SFC_VDPA_LOG_PREFIX_MAX];
+	uint32_t			logtype_main;
+
+	int				vfio_group_fd;
+	int				vfio_dev_fd;
+	int				vfio_container_fd;
+	int				iommu_group_num;
+};
+
+uint32_t
+sfc_vdpa_register_logtype(const struct rte_pci_addr *pci_addr,
+			  const char *lt_prefix_str,
+			  uint32_t ll_default);
+
+struct sfc_vdpa_adapter *
+sfc_vdpa_get_adapter_by_dev(struct rte_pci_device *pdev);
+
+#endif  /* _SFC_VDPA_H */
+
drivers/vdpa/sfc/sfc_vdpa_log.h new file +56 -0

56 lines not on this page · raw message

drivers/vdpa/sfc/version.map new file +3 -0
new file mode 100644
index 0000000..4a76d1d
@@ -0,0 +1,3 @@
+DPDK_21 {
+	local: *;
+};
Signature · 1 line
1.8.3.1
Reviewed-by on v4 1/10
#97 lore raw
Quoted 34 lines · Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Add new vDPA PMD to support vDPA operations of Xilinx devices. This patch implements probe and remove functions.

---
v2:
* Updated logging macros to remove redundant code.

v3:
* Replaced depreciated whitelist with allowlist.
* Text corrections in the sfc.rst and commit msg.
* Added sfc in the toctree of doc/guides/vdpadevs/index.rst.
* Removed extra compiler flags.

v4:
* Removed redundant NULL checks.
* Removed unused pci_addr from adapter structure.
* Updated format specifiers in log messages.

  MAINTAINERS                            |   6 +
  doc/guides/rel_notes/release_21_11.rst |   5 +
  doc/guides/vdpadevs/features/sfc.ini   |   9 ++
  doc/guides/vdpadevs/index.rst          |   1 +
  doc/guides/vdpadevs/sfc.rst            |  97 ++++++++++++
  drivers/vdpa/meson.build               |   1 +
  drivers/vdpa/sfc/meson.build           |  22 +++
  drivers/vdpa/sfc/sfc_vdpa.c            | 282 +++++++++++++++++++++++++++++++++
  drivers/vdpa/sfc/sfc_vdpa.h            |  39 +++++
  drivers/vdpa/sfc/sfc_vdpa_log.h        |  56 +++++++
  drivers/vdpa/sfc/version.map           |   3 +
  11 files changed, 521 insertions(+)
Quoted 8 lines

create mode 100644 doc/guides/vdpadevs/features/sfc.ini create mode 100644 doc/guides/vdpadevs/sfc.rst create mode 100644 drivers/vdpa/sfc/meson.build create mode 100644 drivers/vdpa/sfc/sfc_vdpa.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa.h create mode 100644 drivers/vdpa/sfc/sfc_vdpa_log.h create mode 100644 drivers/vdpa/sfc/version.map

Thanks,
Maxime

#98 lore raw
In reply to Vijay Srivastava

drivers/vdpa/sfc/version.map line 3

Quoted 9 lines · Vijay Srivastava
drivers/vdpa/sfc/version.map new file +3 -0
new file mode 100644
index 0000000..4a76d1d
@@ -0,0 +1,3 @@
+DPDK_21 {
+	local: *;
+};

It is DPDK_22 now

#99 lore raw
Quoted 13 lines · Ferruh Yigit

drivers/vdpa/sfc/version.map line 3

Quoted 9 lines · Vijay Srivastava
drivers/vdpa/sfc/version.map new file +3 -0
new file mode 100644
index 0000000..4a76d1d
@@ -0,0 +1,3 @@
+DPDK_21 {
+    local: *;
+};

It is DPDK_22 now

Good catch, I missed it.
Should I fixup in my branch or you take care of it?

Thanks,
Maxime

#100 lore raw
Quoted 17 lines · Maxime Coquelin
Quoted 13 lines · Ferruh Yigit

drivers/vdpa/sfc/version.map line 3

Quoted 9 lines · Vijay Srivastava
drivers/vdpa/sfc/version.map new file +3 -0
new file mode 100644
index 0000000..4a76d1d
@@ -0,0 +1,3 @@
+DPDK_21 {
+    local: *;
+};

It is DPDK_22 now

Quoted 3 lines

Good catch, I missed it.
Should I fixup in my branch or you take care of it?

If it is just this, or similar a few small issues, I can fix in next-net.

#101 lore raw
In reply to Vijay Srivastava

drivers/vdpa/sfc/sfc_vdpa.c line 5

Quoted 11 lines · Vijay Srivastava
drivers/vdpa/sfc/sfc_vdpa.c new file +5 -0
new file mode 100644
index 0000000..f087944
@@ -0,0 +1,282 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+

Only sfc has that blank line between SPDX tag and Copyright, is it intentional?

+Hemant, not sure if we enforce any specific syntax?

If there is no specific reason, I think better to have common syntax, that helps to scripts etc..
It may be noise to update existing code, but we can fix it in new code.

#102 lore raw
Quoted 15 lines · Ferruh Yigit

drivers/vdpa/sfc/sfc_vdpa.c line 5

Quoted 11 lines · Vijay Srivastava
drivers/vdpa/sfc/sfc_vdpa.c new file +5 -0
new file mode 100644
index 0000000..f087944
@@ -0,0 +1,282 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+

Only sfc has that blank line between SPDX tag and Copyright, is it intentional?

As far as I remember it is not intentional. Just coincident and may be definitely fixed in vdpa/sfc.

Quoted 8 lines

+Hemant, not sure if we enforce any specific syntax?

If there is no specific reason, I think better to have common syntax, that helps to scripts etc..
It may be noise to update existing code, but we can fix it in new code.

+1

#103 lore raw
Quoted 24 lines · Andrew Rybchenko
Quoted 15 lines · Ferruh Yigit

drivers/vdpa/sfc/sfc_vdpa.c line 5

Quoted 11 lines · Vijay Srivastava
drivers/vdpa/sfc/sfc_vdpa.c new file +5 -0
new file mode 100644
index 0000000..f087944
@@ -0,0 +1,282 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+

Only sfc has that blank line between SPDX tag and Copyright, is it intentional?

As far as I remember it is not intentional. Just coincident and may be definitely fixed in vdpa/sfc.

Quoted 4 lines

+Hemant, not sure if we enforce any specific syntax?

Quoted 7 lines
Quoted 4 lines

If there is no specific reason, I think better to have common syntax, that helps to scripts etc..
It may be noise to update existing code, but we can fix it in new code.

+1

If there is not objection, I will remove that empty lines in this set, while merging next-net.

#104 lore raw
Quoted 30 lines · Andrew Rybchenko
Quoted 29 lines · Ferruh Yigit
Quoted 7 lines · Vijay Srivastava
Quoted 6 lines
(quoted diff) +0 -0

b/drivers/vdpa/sfc/sfc_vdpa.c new file mode 100644 index 0000000..f087944

drivers/vdpa/sfc/sfc_vdpa.c new file +0 -0
@@ -0,0 +1,282 @@
Quoted 8 lines

drivers/vdpa/sfc/sfc_vdpa.c line 5

Quoted 5 lines
drivers/vdpa/sfc/sfc_vdpa.c new file +5 -0
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+

Only sfc has that blank line between SPDX tag and Copyright, is it intentional?

As far as I remember it is not intentional. Just coincident and may be definitely fixed in vdpa/sfc.

Quoted 8 lines

+Hemant, not sure if we enforce any specific syntax?

If there is no specific reason, I think better to have common syntax, that helps to scripts etc..
It may be noise to update existing code, but we can fix it in new code.

Quoted 5 lines
Quoted 2 lines

+1

If there is not objection, I will remove that empty lines in this set, while merging next-net.

[Hemant] I saw it late.
There is no restrictions to have blank lines between copyright and SPDX. But it looks clean without that.

#105 lore raw
In reply to Vijay Srivastava

drivers/vdpa/sfc/meson.build line 5

Quoted 11 lines · Vijay Srivastava
drivers/vdpa/sfc/meson.build new file +5 -0
new file mode 100644
index 0000000..4255d65
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Copyright(c) 2020-2021 Xilinx, Inc.
+
+if (arch_subdir != 'x86' or not dpdk_conf.get('RTE_ARCH_64')) and (arch_subdir != 'arm' or not host_machine.cpu_family().startswith('aarch64'))

This line is too long, I will break second part after 'and' to next line in next-net.

#106 lore raw
In reply to Vijay Srivastava
Quoted 18 lines · Vijay Srivastava
drivers/vdpa/sfc/meson.build new file +12 -0
new file mode 100644
index 0000000..4255d65
@@ -0,0 +1,22 @@
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Copyright(c) 2020-2021 Xilinx, Inc.
+
+if (arch_subdir != 'x86' or not dpdk_conf.get('RTE_ARCH_64')) and (arch_subdir != 'arm' or not host_machine.cpu_family().startswith('aarch64'))
+	build = false
+	reason = 'only supported on x86_64 and aarch64'
+endif
+
+fmt_name = 'sfc_vdpa'
+extra_flags = []
+

drivers/vdpa/sfc/meson.build line 22

Quoted 10 lines
drivers/vdpa/sfc/meson.build new file +10 -0
+foreach flag: extra_flags
+	if cc.has_argument(flag)
+		cflags += flag
+	endif
+endforeach
+
+deps += ['common_sfc_efx', 'bus_pci']
+sources = files(
+	'sfc_vdpa.c',
+)

'./devtools/check-meson.py' is failing [1], I guess it is because of whitespace space vs tab, will fix in next-net.

[1]

$ ./devtools/check-meson.py
Error parsing drivers/vdpa/sfc/meson.build:5, got some tabulation
Error parsing drivers/vdpa/sfc/meson.build:6, got some tabulation
Error parsing drivers/vdpa/sfc/meson.build:13, got some tabulation
Error parsing drivers/vdpa/sfc/meson.build:14, got some tabulation
Error parsing drivers/vdpa/sfc/meson.build:15, got some tabulation
Error parsing drivers/vdpa/sfc/meson.build:20, got some tabulation
Error: Incorrect indent at drivers/vdpa/sfc/meson.build:21
#107 lore raw

PATCH v4 2/10 vdpa/sfc: add support for device initialization

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Add HW initialization and vDPA device registration support.

---
v2:
* Used rte_memzone_reserve_aligned for mcdi buffer allocation.
* Freeing mcdi buff when DMA map fails.
* Fixed one typo.

v4:
* Removed unused enum fields.
* Updated format specifiers in log messages.
* Changed do/while loop used during mcdi buffer mapping into for() loop.

 doc/guides/vdpadevs/sfc.rst       |   6 +
 drivers/vdpa/sfc/meson.build      |   3 +
 drivers/vdpa/sfc/sfc_vdpa.c       |  23 +++
 drivers/vdpa/sfc/sfc_vdpa.h       |  49 +++++-
 drivers/vdpa/sfc/sfc_vdpa_debug.h |  21 +++
 drivers/vdpa/sfc/sfc_vdpa_hw.c    | 326 ++++++++++++++++++++++++++++++++++++++
 drivers/vdpa/sfc/sfc_vdpa_log.h   |   3 +
 drivers/vdpa/sfc/sfc_vdpa_mcdi.c  |  74 +++++++++
 drivers/vdpa/sfc/sfc_vdpa_ops.c   | 129 +++++++++++++++
 drivers/vdpa/sfc/sfc_vdpa_ops.h   |  34 ++++
 10 files changed, 667 insertions(+), 1 deletion(-)
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_debug.h
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_hw.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_mcdi.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.c
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.h
doc/guides/vdpadevs/sfc.rst +6 -0
index 44e694f..d06c427 100644
@@ -95,3 +95,9 @@ SFC vDPA PMD provides the following log types available for control:
   Matches a subset of per-port log types registered during runtime.
   A full name for a particular type may be obtained by appending a
   dot and a PCI device identifier (``XXXX:XX:XX.X``) to the prefix.
+
+- ``pmd.vdpa.sfc.mcdi`` (default level is **notice**)
+
+  Extra logging of the communication with the NIC's management CPU.
+  The format of the log is consumed by the netlogdecode cross-platform
+  tool. May be managed per-port, as explained above.
drivers/vdpa/sfc/meson.build +3 -0
index 4255d65..dc333de 100644
@@ -19,4 +19,7 @@ endforeach
 deps += ['common_sfc_efx', 'bus_pci']
 sources = files(
 	'sfc_vdpa.c',
+	'sfc_vdpa_hw.c',
+	'sfc_vdpa_mcdi.c',
+	'sfc_vdpa_ops.c',
 )
drivers/vdpa/sfc/sfc_vdpa.c +23 -0
index f087944..da75ba6 100644
@@ -228,6 +228,19 @@ struct sfc_vdpa_adapter *
 		goto fail_vfio_setup;
 	}
 
+	sfc_vdpa_log_init(sva, "hw init");
+	if (sfc_vdpa_hw_init(sva) != 0) {
+		sfc_vdpa_err(sva, "failed to init HW %s", pci_dev->name);
+		goto fail_hw_init;
+	}
+
+	sfc_vdpa_log_init(sva, "dev init");
+	sva->ops_data = sfc_vdpa_device_init(sva, SFC_VDPA_AS_VF);
+	if (sva->ops_data == NULL) {
+		sfc_vdpa_err(sva, "failed vDPA dev init %s", pci_dev->name);
+		goto fail_dev_init;
+	}
+
 	pthread_mutex_lock(&sfc_vdpa_adapter_list_lock);
 	TAILQ_INSERT_TAIL(&sfc_vdpa_adapter_list, sva, next);
 	pthread_mutex_unlock(&sfc_vdpa_adapter_list_lock);
@@ -236,6 +249,12 @@ struct sfc_vdpa_adapter *
 
 	return 0;
 
+fail_dev_init:
+	sfc_vdpa_hw_fini(sva);
+
+fail_hw_init:
+	sfc_vdpa_vfio_teardown(sva);
+
 fail_vfio_setup:
 fail_set_log_prefix:
 	rte_free(sva);
@@ -262,6 +281,10 @@ struct sfc_vdpa_adapter *
 	TAILQ_REMOVE(&sfc_vdpa_adapter_list, sva, next);
 	pthread_mutex_unlock(&sfc_vdpa_adapter_list_lock);
 
+	sfc_vdpa_device_fini(sva->ops_data);
+
+	sfc_vdpa_hw_fini(sva);
+
 	sfc_vdpa_vfio_teardown(sva);
 
 	rte_free(sva);
drivers/vdpa/sfc/sfc_vdpa.h +48 -1

72 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_debug.h new file +21 -0
new file mode 100644
index 0000000..cfa8cc5
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+
+#ifndef _SFC_VDPA_DEBUG_H_
+#define _SFC_VDPA_DEBUG_H_
+
+#include <rte_debug.h>
+
+#ifdef RTE_LIBRTE_SFC_VDPA_DEBUG
+/* Avoid dependency from RTE_LOG_DP_LEVEL to be able to enable debug check
+ * in the driver only.
+ */
+#define SFC_VDPA_ASSERT(exp)			RTE_VERIFY(exp)
+#else
+/* If the driver debug is not enabled, follow DPDK debug/non-debug */
+#define SFC_VDPA_ASSERT(exp)			RTE_ASSERT(exp)
+#endif
+
+#endif /* _SFC_VDPA_DEBUG_H_ */
drivers/vdpa/sfc/sfc_vdpa_hw.c new file +326 -0

326 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_log.h +3 -0
index 858e5ee..4e7a84f 100644
@@ -21,6 +21,9 @@
 /** Name prefix for the per-device log type used to report basic information */
 #define SFC_VDPA_LOGTYPE_MAIN_STR	SFC_VDPA_LOGTYPE_PREFIX "main"
 
+/** Device MCDI log type name prefix */
+#define SFC_VDPA_LOGTYPE_MCDI_STR	SFC_VDPA_LOGTYPE_PREFIX "mcdi"
+
 #define SFC_VDPA_LOG_PREFIX_MAX	32
 
 /* Log PMD message, automatically add prefix and \n */
drivers/vdpa/sfc/sfc_vdpa_mcdi.c new file +74 -0

74 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_ops.c new file +129 -0

129 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_ops.h new file +34 -0
new file mode 100644
index 0000000..baa4293
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2020-2021 Xilinx, Inc.
+ */
+
+#ifndef _SFC_VDPA_OPS_H
+#define _SFC_VDPA_OPS_H
+
+#include <rte_vdpa.h>
+
+#define SFC_VDPA_MAX_QUEUE_PAIRS		1
+
+enum sfc_vdpa_context {
+	SFC_VDPA_AS_VF
+};
+
+enum sfc_vdpa_state {
+	SFC_VDPA_STATE_UNINITIALIZED = 0,
+	SFC_VDPA_STATE_INITIALIZED,
+};
+
+struct sfc_vdpa_ops_data {
+	void				*dev_handle;
+	struct rte_vdpa_device		*vdpa_dev;
+	enum sfc_vdpa_context		vdpa_context;
+	enum sfc_vdpa_state		state;
+};
+
+struct sfc_vdpa_ops_data *
+sfc_vdpa_device_init(void *adapter, enum sfc_vdpa_context context);
+void
+sfc_vdpa_device_fini(struct sfc_vdpa_ops_data *ops_data);
+
+#endif /* _SFC_VDPA_OPS_H */
Signature · 1 line
1.8.3.1
Reviewed-by on v4 2/10
#108 lore raw

Re: [dpdk-dev] [PATCH v4 02/10] vdpa/sfc: add support for device initialization

Quoted 28 lines · Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Add HW initialization and vDPA device registration support.

---
v2:
* Used rte_memzone_reserve_aligned for mcdi buffer allocation.
* Freeing mcdi buff when DMA map fails.
* Fixed one typo.

v4:
* Removed unused enum fields.
* Updated format specifiers in log messages.
* Changed do/while loop used during mcdi buffer mapping into for() loop.

  doc/guides/vdpadevs/sfc.rst       |   6 +
  drivers/vdpa/sfc/meson.build      |   3 +
  drivers/vdpa/sfc/sfc_vdpa.c       |  23 +++
  drivers/vdpa/sfc/sfc_vdpa.h       |  49 +++++-
  drivers/vdpa/sfc/sfc_vdpa_debug.h |  21 +++
  drivers/vdpa/sfc/sfc_vdpa_hw.c    | 326 ++++++++++++++++++++++++++++++++++++++
  drivers/vdpa/sfc/sfc_vdpa_log.h   |   3 +
  drivers/vdpa/sfc/sfc_vdpa_mcdi.c  |  74 +++++++++
  drivers/vdpa/sfc/sfc_vdpa_ops.c   | 129 +++++++++++++++
  drivers/vdpa/sfc/sfc_vdpa_ops.h   |  34 ++++
  10 files changed, 667 insertions(+), 1 deletion(-)
Quoted 6 lines

create mode 100644 drivers/vdpa/sfc/sfc_vdpa_debug.h create mode 100644 drivers/vdpa/sfc/sfc_vdpa_hw.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_mcdi.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.h

Note that rte_vdpa_dev.h was renamed to vdpa_driver.h yesterday, so if you have to post a new revision you'll have to do the change, otherwise I'll do it while applying.

Thanks,
Maxime

#109 lore raw

PATCH v4 3/10 vdpa/sfc: add support to get device and protocol features

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement vDPA ops get_feature and get_protocol_features. This patch retrieves device supported features and enables protocol features.

---
 doc/guides/vdpadevs/features/sfc.ini | 10 ++++
 drivers/common/sfc_efx/efsys.h       |  2 +-
 drivers/common/sfc_efx/version.map   | 10 ++++
 drivers/vdpa/sfc/sfc_vdpa.c          | 20 ++++++++
 drivers/vdpa/sfc/sfc_vdpa.h          |  2 +
 drivers/vdpa/sfc/sfc_vdpa_hw.c       | 13 ++++++
 drivers/vdpa/sfc/sfc_vdpa_ops.c      | 91 ++++++++++++++++++++++++++++++++----
 drivers/vdpa/sfc/sfc_vdpa_ops.h      |  3 ++
 8 files changed, 142 insertions(+), 9 deletions(-)
doc/guides/vdpadevs/features/sfc.ini +10 -0
index 71b6158..700d061 100644
@@ -4,6 +4,16 @@
 ; Refer to default.ini for the full list of available driver features.
 ;
 [Features]
+csum			= Y
+guest csum		= Y
+host tso4		= Y
+host tso6		= Y
+version 1		= Y
+mrg rxbuf		= Y
+any layout		= Y
+in_order		= Y
+proto host notifier	= Y
+IOMMU platform		= Y
 Linux			= Y
 x86-64			= Y
 Usage doc		= Y
drivers/common/sfc_efx/efsys.h +1 -1
index d133d61..37ec6b9 100644
@@ -187,7 +187,7 @@
 
 #define EFSYS_OPT_MAE 1
 
-#define EFSYS_OPT_VIRTIO 0
+#define EFSYS_OPT_VIRTIO 1
 
 /* ID */
 
drivers/common/sfc_efx/version.map +10 -0
index 642a62e..ec86220 100644
@@ -247,6 +247,16 @@ INTERNAL {
 	efx_txq_nbufs;
 	efx_txq_size;
 
+	efx_virtio_fini;
+	efx_virtio_get_doorbell_offset;
+	efx_virtio_get_features;
+	efx_virtio_init;
+	efx_virtio_qcreate;
+	efx_virtio_qdestroy;
+	efx_virtio_qstart;
+	efx_virtio_qstop;
+	efx_virtio_verify_features;
+
 	sfc_efx_dev_class_get;
 	sfc_efx_family;
 
drivers/vdpa/sfc/sfc_vdpa.c +20 -0
index da75ba6..7b9ebcc 100644
@@ -43,6 +43,26 @@ struct sfc_vdpa_adapter *
 	return found ? sva : NULL;
 }
 
+struct sfc_vdpa_ops_data *
+sfc_vdpa_get_data_by_dev(struct rte_vdpa_device *vdpa_dev)
+{
+	bool found = false;
+	struct sfc_vdpa_adapter *sva;
+
+	pthread_mutex_lock(&sfc_vdpa_adapter_list_lock);
+
+	TAILQ_FOREACH(sva, &sfc_vdpa_adapter_list, next) {
+		if (vdpa_dev == sva->ops_data->vdpa_dev) {
+			found = true;
+			break;
+		}
+	}
+
+	pthread_mutex_unlock(&sfc_vdpa_adapter_list_lock);
+
+	return found ? sva->ops_data : NULL;
+}
+
 static int
 sfc_vdpa_vfio_setup(struct sfc_vdpa_adapter *sva)
 {
drivers/vdpa/sfc/sfc_vdpa.h +2 -0
index bd3c437..dd3ca80 100644
@@ -59,6 +59,8 @@ struct sfc_vdpa_adapter {
 
 struct sfc_vdpa_adapter *
 sfc_vdpa_get_adapter_by_dev(struct rte_pci_device *pdev);
+struct sfc_vdpa_ops_data *
+sfc_vdpa_get_data_by_dev(struct rte_vdpa_device *vdpa_dev);
 
 int
 sfc_vdpa_hw_init(struct sfc_vdpa_adapter *sva);
drivers/vdpa/sfc/sfc_vdpa_hw.c +13 -0
index dfb6d4f..dca7034 100644
@@ -277,10 +277,20 @@
 	if (rc != 0)
 		goto fail_estimate_rsrc_limits;
 
+	sfc_vdpa_log_init(sva, "init virtio");
+	rc = efx_virtio_init(enp);
+	if (rc != 0) {
+		sfc_vdpa_err(sva, "virtio init failed: %s", rte_strerror(rc));
+		goto fail_virtio_init;
+	}
+
 	sfc_vdpa_log_init(sva, "done");
 
 	return 0;
 
+fail_virtio_init:
+	efx_nic_fini(enp);
+
 fail_estimate_rsrc_limits:
 fail_nic_reset:
 	efx_nic_unprobe(enp);
@@ -309,6 +319,9 @@
 
 	sfc_vdpa_log_init(sva, "entry");
 
+	sfc_vdpa_log_init(sva, "virtio fini");
+	efx_virtio_fini(enp);
+
 	sfc_vdpa_log_init(sva, "unprobe nic");
 	efx_nic_unprobe(enp);
 
drivers/vdpa/sfc/sfc_vdpa_ops.c +83 -8

138 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_ops.h +3 -0
index baa4293..7b77df0 100644
@@ -24,6 +24,9 @@ struct sfc_vdpa_ops_data {
 	struct rte_vdpa_device		*vdpa_dev;
 	enum sfc_vdpa_context		vdpa_context;
 	enum sfc_vdpa_state		state;
+
+	uint64_t			dev_features;
+	uint64_t			drv_features;
 };
 
 struct sfc_vdpa_ops_data *
Signature · 1 line
1.8.3.1
#110 lore raw

PATCH v4 4/10 vdpa/sfc: get device supported max queue count

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement vDPA ops get_queue_num to get the maximum number of queues supported by the device.

---
v4:
* Updated format specifier in log message.

 drivers/vdpa/sfc/sfc_vdpa_ops.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_ops.c +13 -3
index 5750944..9a95211 100644
@@ -31,10 +31,20 @@
 static int
 sfc_vdpa_get_queue_num(struct rte_vdpa_device *vdpa_dev, uint32_t *queue_num)
 {
-	RTE_SET_USED(vdpa_dev);
-	RTE_SET_USED(queue_num);
+	struct sfc_vdpa_ops_data *ops_data;
+	void *dev;
 
-	return -1;
+	ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev);
+	if (ops_data == NULL)
+		return -1;
+
+	dev = ops_data->dev_handle;
+	*queue_num = sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count;
+
+	sfc_vdpa_info(dev, "vDPA ops get_queue_num :: supported queue num : %u",
+		      *queue_num);
+
+	return 0;
 }
 
 static int
Signature · 1 line
1.8.3.1
#111 lore raw

PATCH v4 5/10 vdpa/sfc: add support to get VFIO device fd

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement vDPA ops get_vfio_device_fd to get the VFIO device fd.

---
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
drivers/vdpa/sfc/sfc_vdpa_ops.c +24 -0
index 9a95211..b5815df 100644
@@ -145,6 +145,29 @@
 	return -1;
 }
 
+static int
+sfc_vdpa_get_vfio_device_fd(int vid)
+{
+	struct rte_vdpa_device *vdpa_dev;
+	struct sfc_vdpa_ops_data *ops_data;
+	int vfio_dev_fd;
+	void *dev;
+
+	vdpa_dev = rte_vhost_get_vdpa_device(vid);
+
+	ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev);
+	if (ops_data == NULL)
+		return -1;
+
+	dev = ops_data->dev_handle;
+	vfio_dev_fd = sfc_vdpa_adapter_by_dev_handle(dev)->vfio_dev_fd;
+
+	sfc_vdpa_info(dev, "vDPA ops get_vfio_device_fd :: vfio fd : %d",
+		      vfio_dev_fd);
+
+	return vfio_dev_fd;
+}
+
 static struct rte_vdpa_dev_ops sfc_vdpa_ops = {
 	.get_queue_num = sfc_vdpa_get_queue_num,
 	.get_features = sfc_vdpa_get_features,
@@ -153,6 +176,7 @@
 	.dev_close = sfc_vdpa_dev_close,
 	.set_vring_state = sfc_vdpa_set_vring_state,
 	.set_features = sfc_vdpa_set_features,
+	.get_vfio_device_fd = sfc_vdpa_get_vfio_device_fd,
 };
 
 struct sfc_vdpa_ops_data *
Signature · 1 line
1.8.3.1
#112 lore raw

PATCH v4 6/10 vdpa/sfc: add support for dev conf and dev close ops

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement vDPA ops dev_conf and dev_close for DMA mapping, interrupt and virtqueue configurations.

---
v2:
* Removed redundant null check while calling free().
* Added error handling for rte_vhost_get_vhost_vring().

v4:
* Removed rc for rte_vfio_container_dma_unmap from label failed_vfio_dma_map.
* Updated VFIO_DEVICE_SET_IRQS parameter fields for intr disable.
* Removed goto label fail_vring_map.

 drivers/vdpa/sfc/sfc_vdpa.c     |   6 +
 drivers/vdpa/sfc/sfc_vdpa.h     |  43 ++++
 drivers/vdpa/sfc/sfc_vdpa_hw.c  |  69 ++++++
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 525 ++++++++++++++++++++++++++++++++++++++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h |  28 +++
 5 files changed, 651 insertions(+), 20 deletions(-)
drivers/vdpa/sfc/sfc_vdpa.c +6 -0
index 7b9ebcc..f548c1e 100644
@@ -242,6 +242,8 @@ struct sfc_vdpa_ops_data *
 
 	sfc_vdpa_log_init(sva, "entry");
 
+	sfc_vdpa_adapter_lock_init(sva);
+
 	sfc_vdpa_log_init(sva, "vfio init");
 	if (sfc_vdpa_vfio_setup(sva) < 0) {
 		sfc_vdpa_err(sva, "failed to setup device %s", pci_dev->name);
@@ -276,6 +278,8 @@ struct sfc_vdpa_ops_data *
 	sfc_vdpa_vfio_teardown(sva);
 
 fail_vfio_setup:
+	sfc_vdpa_adapter_lock_fini(sva);
+
 fail_set_log_prefix:
 	rte_free(sva);
 
@@ -307,6 +311,8 @@ struct sfc_vdpa_ops_data *
 
 	sfc_vdpa_vfio_teardown(sva);
 
+	sfc_vdpa_adapter_lock_fini(sva);
+
 	rte_free(sva);
 
 	return 0;
drivers/vdpa/sfc/sfc_vdpa.h +43 -0

53 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_hw.c +69 -0

81 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_ops.c +505 -20

561 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_ops.h +28 -0
index 7b77df0..d20d219 100644
@@ -17,16 +17,44 @@ enum sfc_vdpa_context {
 enum sfc_vdpa_state {
 	SFC_VDPA_STATE_UNINITIALIZED = 0,
 	SFC_VDPA_STATE_INITIALIZED,
+	SFC_VDPA_STATE_CONFIGURING,
+	SFC_VDPA_STATE_CONFIGURED,
+	SFC_VDPA_STATE_CLOSING,
+	SFC_VDPA_STATE_CLOSED,
+	SFC_VDPA_STATE_STARTING,
+	SFC_VDPA_STATE_STARTED,
+	SFC_VDPA_STATE_STOPPING,
 };
 
+struct sfc_vdpa_vring_info {
+	uint64_t	desc;
+	uint64_t	avail;
+	uint64_t	used;
+	uint64_t	size;
+	uint16_t	last_avail_idx;
+	uint16_t	last_used_idx;
+};
+
+typedef struct sfc_vdpa_vq_context_s {
+	uint8_t				enable;
+	uint32_t			pidx;
+	uint32_t			cidx;
+	efx_virtio_vq_t			*vq;
+} sfc_vdpa_vq_context_t;
+
 struct sfc_vdpa_ops_data {
 	void				*dev_handle;
+	int				vid;
 	struct rte_vdpa_device		*vdpa_dev;
 	enum sfc_vdpa_context		vdpa_context;
 	enum sfc_vdpa_state		state;
 
 	uint64_t			dev_features;
 	uint64_t			drv_features;
+	uint64_t			req_features;
+
+	uint16_t			vq_count;
+	struct sfc_vdpa_vq_context_s	vq_cxt[SFC_VDPA_MAX_QUEUE_PAIRS * 2];
 };
 
 struct sfc_vdpa_ops_data *
Signature · 1 line
1.8.3.1
Reviewed-by on v4 6/10
#113 lore raw

Re: [dpdk-dev] [PATCH v4 06/10] vdpa/sfc: add support for dev conf and dev close ops

Quoted 24 lines · Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement vDPA ops dev_conf and dev_close for DMA mapping, interrupt and virtqueue configurations.

---
v2:
* Removed redundant null check while calling free().
* Added error handling for rte_vhost_get_vhost_vring().

v4:
* Removed rc for rte_vfio_container_dma_unmap from label failed_vfio_dma_map.
* Updated VFIO_DEVICE_SET_IRQS parameter fields for intr disable.
* Removed goto label fail_vring_map.

  drivers/vdpa/sfc/sfc_vdpa.c     |   6 +
  drivers/vdpa/sfc/sfc_vdpa.h     |  43 ++++
  drivers/vdpa/sfc/sfc_vdpa_hw.c  |  69 ++++++
  drivers/vdpa/sfc/sfc_vdpa_ops.c | 525 ++++++++++++++++++++++++++++++++++++++--
  drivers/vdpa/sfc/sfc_vdpa_ops.h |  28 +++
  5 files changed, 651 insertions(+), 20 deletions(-)

...

Quoted 16 lines
drivers/vdpa/sfc/sfc_vdpa_ops.c +16 -0
+static uint64_t
+hva_to_gpa(int vid, uint64_t hva)
+{
+	struct rte_vhost_memory *vhost_mem = NULL;
+	struct rte_vhost_mem_region *mem_reg = NULL;
+	uint32_t i;
+	uint64_t gpa = 0;
+
+	if (rte_vhost_get_mem_table(vid, &vhost_mem) < 0)
+		goto error;
+
+	for (i = 0; i < vhost_mem->nregions; i++) {
+		mem_reg = &vhost_mem->regions[i];
+
+		if (hva >= mem_reg->host_user_addr &&
+				hva < mem_reg->host_user_addr + mem_reg->size) {

drivers/vdpa/sfc/sfc_vdpa_ops.c line 93

Quoted 10 lines
drivers/vdpa/sfc/sfc_vdpa_ops.c +10 -0
+			gpa = (hva - mem_reg->host_user_addr) +
+				mem_reg->guest_phys_addr;
+			break;
+		}
+	}
+
+error:
+	free(vhost_mem);
+	return gpa;
+}

It would be done later, but all the vDPA drivers have (almost) the same function, so it would make sense to add a Vhost API that would make use of Vhost's hva_to_gpa.

Thanks,
Maxime

#114 lore raw

PATCH v4 7/10 vdpa/sfc: add support to get queue notify area info

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement the vDPA ops get_notify_area to get the notify area info of the queue.

---
v2:
* Added error log in sfc_vdpa_get_notify_area.

v4:
* Updated parameter for sfc_vdpa_setup_notify_ctrl

 drivers/vdpa/sfc/sfc_vdpa_ops.c | 156 ++++++++++++++++++++++++++++++++++++++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h |   2 +
 2 files changed, 152 insertions(+), 6 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_ops.c +150 -6
index f0be652..1725597 100644
@@ -3,6 +3,8 @@
  * Copyright(c) 2020-2021 Xilinx, Inc.
  */
 
+#include <pthread.h>
+#include <unistd.h>
 #include <sys/ioctl.h>
 
 #include <rte_errno.h>
@@ -532,6 +534,55 @@
 	return 0;
 }
 
+static void *
+sfc_vdpa_notify_ctrl(void *arg)
+{
+	struct sfc_vdpa_ops_data *ops_data;
+	int vid;
+
+	ops_data = arg;
+	if (ops_data == NULL)
+		return NULL;
+
+	sfc_vdpa_adapter_lock(ops_data->dev_handle);
+
+	vid = ops_data->vid;
+
+	if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0)
+		sfc_vdpa_info(ops_data->dev_handle,
+			      "vDPA (%s): Notifier could not get configured",
+			      ops_data->vdpa_dev->device->name);
+
+	sfc_vdpa_adapter_unlock(ops_data->dev_handle);
+
+	return NULL;
+}
+
+static int
+sfc_vdpa_setup_notify_ctrl(struct sfc_vdpa_ops_data *ops_data)
+{
+	int ret;
+
+	ops_data->is_notify_thread_started = false;
+
+	/*
+	 * Use rte_vhost_host_notifier_ctrl in a thread to avoid
+	 * dead lock scenario when multiple VFs are used in single vdpa
+	 * application and multiple VFs are passed to a single VM.
+	 */
+	ret = pthread_create(&ops_data->notify_tid, NULL,
+			     sfc_vdpa_notify_ctrl, ops_data);
+	if (ret != 0) {
+		sfc_vdpa_err(ops_data->dev_handle,
+			     "failed to create notify_ctrl thread: %s",
+			     rte_strerror(ret));
+		return -1;
+	}
+	ops_data->is_notify_thread_started = true;
+
+	return 0;
+}
+
 static int
 sfc_vdpa_dev_config(int vid)
 {
@@ -565,18 +616,19 @@
 	if (rc != 0)
 		goto fail_vdpa_start;
 
-	sfc_vdpa_adapter_unlock(ops_data->dev_handle);
+	rc = sfc_vdpa_setup_notify_ctrl(ops_data);
+	if (rc != 0)
+		goto fail_vdpa_notify;
 
-	sfc_vdpa_log_init(ops_data->dev_handle, "vhost notifier ctrl");
-	if (rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, true) != 0)
-		sfc_vdpa_info(ops_data->dev_handle,
-			      "vDPA (%s): software relay for notify is used.",
-			      vdpa_dev->device->name);
+	sfc_vdpa_adapter_unlock(ops_data->dev_handle);
 
 	sfc_vdpa_log_init(ops_data->dev_handle, "done");
 
 	return 0;
 
+fail_vdpa_notify:
+	sfc_vdpa_stop(ops_data);
+
 fail_vdpa_start:
 	sfc_vdpa_close(ops_data);
 
@@ -589,6 +641,7 @@
 static int
 sfc_vdpa_dev_close(int vid)
 {
+	int ret;
 	struct rte_vdpa_device *vdpa_dev;
 	struct sfc_vdpa_ops_data *ops_data;
 
@@ -603,6 +656,23 @@
 	}
 
 	sfc_vdpa_adapter_lock(ops_data->dev_handle);
+	if (ops_data->is_notify_thread_started == true) {
+		void *status;
+		ret = pthread_cancel(ops_data->notify_tid);
+		if (ret != 0) {
+			sfc_vdpa_err(ops_data->dev_handle,
+				     "failed to cancel notify_ctrl thread: %s",
+				     rte_strerror(ret));
+		}
+
+		ret = pthread_join(ops_data->notify_tid, &status);
+		if (ret != 0) {
+			sfc_vdpa_err(ops_data->dev_handle,
+				     "failed to join terminated notify_ctrl thread: %s",
+				     rte_strerror(ret));
+		}
+	}
+	ops_data->is_notify_thread_started = false;
 
 	sfc_vdpa_stop(ops_data);
 	sfc_vdpa_close(ops_data);
@@ -653,6 +723,79 @@
 	return vfio_dev_fd;
 }
 
+static int
+sfc_vdpa_get_notify_area(int vid, int qid, uint64_t *offset, uint64_t *size)
+{
+	int ret;
+	efx_nic_t *nic;
+	int vfio_dev_fd;
+	efx_rc_t rc;
+	unsigned int bar_offset;
+	struct rte_vdpa_device *vdpa_dev;
+	struct sfc_vdpa_ops_data *ops_data;
+	struct vfio_region_info reg = { .argsz = sizeof(reg) };
+	const efx_nic_cfg_t *encp;
+	int max_vring_cnt;
+	int64_t len;
+	void *dev;
+
+	vdpa_dev = rte_vhost_get_vdpa_device(vid);
+
+	ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev);
+	if (ops_data == NULL)
+		return -1;
+
+	dev = ops_data->dev_handle;
+
+	vfio_dev_fd = sfc_vdpa_adapter_by_dev_handle(dev)->vfio_dev_fd;
+	max_vring_cnt =
+		(sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count * 2);
+
+	nic = sfc_vdpa_adapter_by_dev_handle(ops_data->dev_handle)->nic;
+	encp = efx_nic_cfg_get(nic);
+
+	if (qid >= max_vring_cnt) {
+		sfc_vdpa_err(dev, "invalid qid : %d", qid);
+		return -1;
+	}
+
+	if (ops_data->vq_cxt[qid].enable != B_TRUE) {
+		sfc_vdpa_err(dev, "vq is not enabled");
+		return -1;
+	}
+
+	rc = efx_virtio_get_doorbell_offset(ops_data->vq_cxt[qid].vq,
+					    &bar_offset);
+	if (rc != 0) {
+		sfc_vdpa_err(dev, "failed to get doorbell offset: %s",
+			     rte_strerror(rc));
+		return rc;
+	}
+
+	reg.index = sfc_vdpa_adapter_by_dev_handle(dev)->mem_bar.esb_rid;
+	ret = ioctl(vfio_dev_fd, VFIO_DEVICE_GET_REGION_INFO, &reg);
+	if (ret != 0) {
+		sfc_vdpa_err(dev, "could not get device region info: %s",
+			     strerror(errno));
+		return ret;
+	}
+
+	*offset = reg.offset + bar_offset;
+
+	len = (1U << encp->enc_vi_window_shift) / 2;
+	if (len >= sysconf(_SC_PAGESIZE)) {
+		*size = sysconf(_SC_PAGESIZE);
+	} else {
+		sfc_vdpa_err(dev, "invalid VI window size : 0x%" PRIx64, len);
+		return -1;
+	}
+
+	sfc_vdpa_info(dev, "vDPA ops get_notify_area :: offset : 0x%" PRIx64,
+		      *offset);
+
+	return 0;
+}
+
 static struct rte_vdpa_dev_ops sfc_vdpa_ops = {
 	.get_queue_num = sfc_vdpa_get_queue_num,
 	.get_features = sfc_vdpa_get_features,
@@ -662,6 +805,7 @@
 	.set_vring_state = sfc_vdpa_set_vring_state,
 	.set_features = sfc_vdpa_set_features,
 	.get_vfio_device_fd = sfc_vdpa_get_vfio_device_fd,
+	.get_notify_area = sfc_vdpa_get_notify_area,
 };
 
 struct sfc_vdpa_ops_data *
drivers/vdpa/sfc/sfc_vdpa_ops.h +2 -0
index d20d219..9b94aca 100644
@@ -48,6 +48,8 @@ struct sfc_vdpa_ops_data {
 	struct rte_vdpa_device		*vdpa_dev;
 	enum sfc_vdpa_context		vdpa_context;
 	enum sfc_vdpa_state		state;
+	pthread_t			notify_tid;
+	bool				is_notify_thread_started;
 
 	uint64_t			dev_features;
 	uint64_t			drv_features;
Signature · 1 line
1.8.3.1
Reviewed-by on v4 7/10
#115 lore raw

Re: [dpdk-dev] [PATCH v4 07/10] vdpa/sfc: add support to get queue notify area info

Quoted 11 lines · Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implement the vDPA ops get_notify_area to get the notify area info of the queue.

---
v2:
* Added error log in sfc_vdpa_get_notify_area.

Quoted 6 lines

v4:
* Updated parameter for sfc_vdpa_setup_notify_ctrl

  drivers/vdpa/sfc/sfc_vdpa_ops.c | 156 ++++++++++++++++++++++++++++++++++++++--
  drivers/vdpa/sfc/sfc_vdpa_ops.h |   2 +
  2 files changed, 152 insertions(+), 6 deletions(-)

Thanks,
Maxime

#116 lore raw

PATCH v4 8/10 vdpa/sfc: add support for MAC filter config

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Add support for unicast and broadcast MAC filter configuration.

---
v4:
* Removed redundant NULL check.
* Improved line usage by rearranging function params.

 doc/guides/vdpadevs/sfc.rst        |   4 ++
 drivers/vdpa/sfc/meson.build       |   1 +
 drivers/vdpa/sfc/sfc_vdpa.c        |  32 +++++++++
 drivers/vdpa/sfc/sfc_vdpa.h        |  30 ++++++++
 drivers/vdpa/sfc/sfc_vdpa_filter.c | 136 +++++++++++++++++++++++++++++++++++++
 drivers/vdpa/sfc/sfc_vdpa_hw.c     |  10 +++
 drivers/vdpa/sfc/sfc_vdpa_ops.c    |  17 +++++
 7 files changed, 230 insertions(+)
 create mode 100644 drivers/vdpa/sfc/sfc_vdpa_filter.c
doc/guides/vdpadevs/sfc.rst +4 -0
index d06c427..512f23e 100644
@@ -71,6 +71,10 @@ boolean parameters value.
   **vdpa** device will work as vdpa device and will be probed by vdpa/sfc driver.
   If this parameter is not specified then ef100 device will operate as network device.
 
+- ``mac`` [mac address]
+
+  Configures MAC address which would be used to setup MAC filters.
+
 
 Dynamic Logging Parameters
 ~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/vdpa/sfc/meson.build +1 -0
index dc333de..2ca33bc 100644
@@ -22,4 +22,5 @@ sources = files(
 	'sfc_vdpa_hw.c',
 	'sfc_vdpa_mcdi.c',
 	'sfc_vdpa_ops.c',
+	'sfc_vdpa_filter.c',
 )
drivers/vdpa/sfc/sfc_vdpa.c +32 -0
index f548c1e..78b280e 100644
@@ -8,7 +8,9 @@
 #include <sys/queue.h>
 
 #include <rte_common.h>
+#include <rte_devargs.h>
 #include <rte_errno.h>
+#include <rte_kvargs.h>
 #include <rte_string_fns.h>
 #include <rte_vfio.h>
 #include <rte_vhost.h>
@@ -198,6 +200,31 @@ struct sfc_vdpa_ops_data *
 	return ret < 0 ? RTE_LOGTYPE_PMD : ret;
 }
 
+static int
+sfc_vdpa_kvargs_parse(struct sfc_vdpa_adapter *sva)
+{
+	struct rte_pci_device *pci_dev = sva->pdev;
+	struct rte_devargs *devargs = pci_dev->device.devargs;
+	/*
+	 * To get the device class a mandatory param 'class' is being
+	 * used so included SFC_EFX_KVARG_DEV_CLASS in the param list.
+	 */
+	const char **params = (const char *[]){
+		RTE_DEVARGS_KEY_CLASS,
+		SFC_VDPA_MAC_ADDR,
+		NULL,
+	};
+
+	if (devargs == NULL)
+		return 0;
+
+	sva->kvargs = rte_kvargs_parse(devargs->args, params);
+	if (sva->kvargs == NULL)
+		return -EINVAL;
+
+	return 0;
+}
+
 static struct rte_pci_id pci_id_sfc_vdpa_efx_map[] = {
 	{ RTE_PCI_DEVICE(EFX_PCI_VENID_XILINX, EFX_PCI_DEVID_RIVERHEAD_VF) },
 	{ .vendor_id = 0, /* sentinel */ },
@@ -240,6 +267,10 @@ struct sfc_vdpa_ops_data *
 	if (ret != 0)
 		goto fail_set_log_prefix;
 
+	ret = sfc_vdpa_kvargs_parse(sva);
+	if (ret != 0)
+		goto fail_kvargs_parse;
+
 	sfc_vdpa_log_init(sva, "entry");
 
 	sfc_vdpa_adapter_lock_init(sva);
@@ -280,6 +311,7 @@ struct sfc_vdpa_ops_data *
 fail_vfio_setup:
 	sfc_vdpa_adapter_lock_fini(sva);
 
+fail_kvargs_parse:
 fail_set_log_prefix:
 	rte_free(sva);
 
drivers/vdpa/sfc/sfc_vdpa.h +30 -0
index 38fd5de..81fc39d 100644
@@ -17,8 +17,29 @@
 #include "sfc_vdpa_log.h"
 #include "sfc_vdpa_ops.h"
 
+#define SFC_VDPA_MAC_ADDR			"mac"
 #define SFC_VDPA_DEFAULT_MCDI_IOVA		0x200000000000
 
+/* Broadcast & Unicast MAC filters are supported */
+#define SFC_MAX_SUPPORTED_FILTERS		2
+
+/*
+ * Get function-local index of the associated VI from the
+ * virtqueue number. Queue 0 is reserved for MCDI
+ */
+#define SFC_VDPA_GET_VI_INDEX(vq_num) (((vq_num) / 2) + 1)
+
+enum sfc_vdpa_filter_type {
+	SFC_VDPA_BCAST_MAC_FILTER = 0,
+	SFC_VDPA_UCAST_MAC_FILTER = 1,
+	SFC_VDPA_FILTER_NTYPE
+};
+
+typedef struct sfc_vdpa_filter_s {
+	int				filter_cnt;
+	efx_filter_spec_t		spec[SFC_MAX_SUPPORTED_FILTERS];
+} sfc_vdpa_filter_t;
+
 /* Adapter private data */
 struct sfc_vdpa_adapter {
 	TAILQ_ENTRY(sfc_vdpa_adapter)	next;
@@ -31,6 +52,8 @@ struct sfc_vdpa_adapter {
 	rte_spinlock_t			lock;
 	struct rte_pci_device		*pdev;
 
+	struct rte_kvargs		*kvargs;
+
 	efx_family_t			family;
 	efx_nic_t			*nic;
 	rte_spinlock_t			nic_lock;
@@ -45,6 +68,8 @@ struct sfc_vdpa_adapter {
 	char				log_prefix[SFC_VDPA_LOG_PREFIX_MAX];
 	uint32_t			logtype_main;
 
+	sfc_vdpa_filter_t		filters;
+
 	int				vfio_group_fd;
 	int				vfio_dev_fd;
 	int				vfio_container_fd;
@@ -82,6 +107,11 @@ struct sfc_vdpa_ops_data *
 int
 sfc_vdpa_dma_map(struct sfc_vdpa_ops_data *vdpa_data, bool do_map);
 
+int
+sfc_vdpa_filter_remove(struct sfc_vdpa_ops_data *ops_data);
+int
+sfc_vdpa_filter_config(struct sfc_vdpa_ops_data *ops_data);
+
 static inline struct sfc_vdpa_adapter *
 sfc_vdpa_adapter_by_dev_handle(void *dev_handle)
 {
drivers/vdpa/sfc/sfc_vdpa_filter.c new file +136 -0

136 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_hw.c +10 -0
index d3459ee..463498c 100644
@@ -353,10 +353,20 @@
 		goto fail_virtio_init;
 	}
 
+	sfc_vdpa_log_init(sva, "init filter");
+	rc = efx_filter_init(enp);
+	if (rc != 0) {
+		sfc_vdpa_err(sva, "filter init failed: %s", rte_strerror(rc));
+		goto fail_filter_init;
+	}
+
 	sfc_vdpa_log_init(sva, "done");
 
 	return 0;
 
+fail_filter_init:
+	efx_virtio_fini(enp);
+
 fail_virtio_init:
 	efx_nic_fini(enp);
 
drivers/vdpa/sfc/sfc_vdpa_ops.c +17 -0
index 1725597..9d4ed34 100644
@@ -421,6 +421,8 @@
 
 	sfc_vdpa_disable_vfio_intr(ops_data);
 
+	sfc_vdpa_filter_remove(ops_data);
+
 	ops_data->state = SFC_VDPA_STATE_CONFIGURED;
 }
 
@@ -460,12 +462,27 @@
 			goto fail_vq_start;
 	}
 
+	ops_data->vq_count = i;
+
+	sfc_vdpa_log_init(ops_data->dev_handle,
+			  "configure MAC filters");
+	rc = sfc_vdpa_filter_config(ops_data);
+	if (rc != 0) {
+		sfc_vdpa_err(ops_data->dev_handle,
+			     "MAC filter config failed: %s",
+			     rte_strerror(rc));
+		goto fail_filter_cfg;
+	}
+
 	ops_data->state = SFC_VDPA_STATE_STARTED;
 
 	sfc_vdpa_log_init(ops_data->dev_handle, "done");
 
 	return 0;
 
+fail_filter_cfg:
+	/* remove already created filters */
+	sfc_vdpa_filter_remove(ops_data);
 fail_vq_start:
 	/* stop already started virtqueues */
 	for (j = 0; j < i; j++)
Signature · 1 line
1.8.3.1
Reviewed-by on v4 8/10
#117 lore raw

Re: [dpdk-dev] [PATCH v4 08/10] vdpa/sfc: add support for MAC filter config

Quoted 19 lines · Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Add support for unicast and broadcast MAC filter configuration.

---
v4:
* Removed redundant NULL check.
* Improved line usage by rearranging function params.

  doc/guides/vdpadevs/sfc.rst        |   4 ++
  drivers/vdpa/sfc/meson.build       |   1 +
  drivers/vdpa/sfc/sfc_vdpa.c        |  32 +++++++++
  drivers/vdpa/sfc/sfc_vdpa.h        |  30 ++++++++
  drivers/vdpa/sfc/sfc_vdpa_filter.c | 136 +++++++++++++++++++++++++++++++++++++
  drivers/vdpa/sfc/sfc_vdpa_hw.c     |  10 +++
  drivers/vdpa/sfc/sfc_vdpa_ops.c    |  17 +++++
  7 files changed, 230 insertions(+)
Quoted 2 lines

create mode 100644 drivers/vdpa/sfc/sfc_vdpa_filter.c

Thanks,
Maxime

#118 lore raw

PATCH v4 9/10 vdpa/sfc: add support to set vring state

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Implements vDPA ops set_vring_state to configure vring state.

---
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 54 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 50 insertions(+), 4 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_ops.c +50 -4
index 9d4ed34..c5c97b8 100644
@@ -702,11 +702,57 @@
 static int
 sfc_vdpa_set_vring_state(int vid, int vring, int state)
 {
-	RTE_SET_USED(vid);
-	RTE_SET_USED(vring);
-	RTE_SET_USED(state);
+	struct sfc_vdpa_ops_data *ops_data;
+	struct rte_vdpa_device *vdpa_dev;
+	efx_rc_t rc;
+	int vring_max;
+	void *dev;
 
-	return -1;
+	vdpa_dev = rte_vhost_get_vdpa_device(vid);
+
+	ops_data = sfc_vdpa_get_data_by_dev(vdpa_dev);
+	if (ops_data == NULL)
+		return -1;
+
+	dev = ops_data->dev_handle;
+
+	sfc_vdpa_info(dev,
+		      "vDPA ops set_vring_state: vid: %d, vring: %d, state:%d",
+		      vid, vring, state);
+
+	vring_max = (sfc_vdpa_adapter_by_dev_handle(dev)->max_queue_count * 2);
+
+	if (vring < 0 || vring > vring_max) {
+		sfc_vdpa_err(dev, "received invalid vring id : %d to set state",
+			     vring);
+		return -1;
+	}
+
+	/*
+	 * Skip if device is not yet started. virtqueues state can be
+	 * changed once it is created and other configurations are done.
+	 */
+	if (ops_data->state != SFC_VDPA_STATE_STARTED)
+		return 0;
+
+	if (ops_data->vq_cxt[vring].enable == state)
+		return 0;
+
+	if (state == 0) {
+		rc = sfc_vdpa_virtq_stop(ops_data, vring);
+		if (rc != 0) {
+			sfc_vdpa_err(dev, "virtqueue stop failed: %s",
+				     rte_strerror(rc));
+		}
+	} else {
+		rc = sfc_vdpa_virtq_start(ops_data, vring);
+		if (rc != 0) {
+			sfc_vdpa_err(dev, "virtqueue start failed: %s",
+				     rte_strerror(rc));
+		}
+	}
+
+	return rc;
 }
 
 static int
Signature · 1 line
1.8.3.1
#119 lore raw

PATCH v4 10/10 vdpa/sfc: set a multicast filter during vDPA init

In reply to Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Insert unknown multicast filter to allow IPv6 neighbor discovery

---
v4:
* Improved line usage by rearranging function params.

 drivers/vdpa/sfc/sfc_vdpa.h        |  3 ++-
 drivers/vdpa/sfc/sfc_vdpa_filter.c | 20 +++++++++++++++++---
 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/vdpa/sfc/sfc_vdpa.h +2 -1
index 81fc39d..080f2d6 100644
@@ -21,7 +21,7 @@
 #define SFC_VDPA_DEFAULT_MCDI_IOVA		0x200000000000
 
 /* Broadcast & Unicast MAC filters are supported */
-#define SFC_MAX_SUPPORTED_FILTERS		2
+#define SFC_MAX_SUPPORTED_FILTERS		3
 
 /*
  * Get function-local index of the associated VI from the
@@ -32,6 +32,7 @@
 enum sfc_vdpa_filter_type {
 	SFC_VDPA_BCAST_MAC_FILTER = 0,
 	SFC_VDPA_UCAST_MAC_FILTER = 1,
+	SFC_VDPA_MCAST_DST_FILTER = 2,
 	SFC_VDPA_FILTER_NTYPE
 };
 
drivers/vdpa/sfc/sfc_vdpa_filter.c +17 -3
index 9687278..4c133aa 100644
@@ -39,8 +39,12 @@
 	spec->efs_flags = EFX_FILTER_FLAG_RX;
 	spec->efs_dmaq_id = qid;
 
-	rc = efx_filter_spec_set_eth_local(spec, EFX_FILTER_SPEC_VID_UNSPEC,
-					   eth_addr);
+	if (eth_addr == NULL)
+		rc = efx_filter_spec_set_mc_def(spec);
+	else
+		rc = efx_filter_spec_set_eth_local(spec,
+						   EFX_FILTER_SPEC_VID_UNSPEC,
+						   eth_addr);
 	if (rc != 0)
 		return rc;
 
@@ -103,8 +107,18 @@ int sfc_vdpa_filter_config(struct sfc_vdpa_ops_data *ops_data)
 	rc = sfc_vdpa_set_mac_filter(nic, spec, qid,
 				     ucast_eth_addr.addr_bytes);
 	if (rc != 0)
+		sfc_vdpa_err(sva, "unicast MAC filter insertion failed: %s",
+			     rte_strerror(rc));
+	else
+		sva->filters.filter_cnt++;
+
+	sfc_vdpa_log_init(sva, "insert unknown mcast filter");
+	spec = &sva->filters.spec[SFC_VDPA_MCAST_DST_FILTER];
+
+	rc = sfc_vdpa_set_mac_filter(nic, spec, qid, NULL);
+	if (rc != 0)
 		sfc_vdpa_err(sva,
-			     "unicast MAC filter insertion failed: %s",
+			     "mcast filter insertion failed: %s",
 			     rte_strerror(rc));
 	else
 		sva->filters.filter_cnt++;
Signature · 1 line
1.8.3.1
Reviewed-by on v4 10/10
#120 lore raw

Re: [dpdk-dev] [PATCH v4 10/10] vdpa/sfc: set a multicast filter during vDPA init

Quoted 7 lines · Vijay Srivastava

From: Vijay Kumar Srivastava <[email protected]>

Insert unknown multicast filter to allow IPv6 neighbor discovery

Quoted 8 lines

---
v4:
* Improved line usage by rearranging function params.

  drivers/vdpa/sfc/sfc_vdpa.h        |  3 ++-
  drivers/vdpa/sfc/sfc_vdpa_filter.c | 20 +++++++++++++++++---
  2 files changed, 19 insertions(+), 4 deletions(-)

Thanks,
Maxime

#121 lore raw
In reply to Vijay Srivastava
Quoted 36 lines · Vijay Srivastava

This patch series introduces vDPA driver for Xilinx devices. The Xilinx vDPA (vhost data path acceleration) provides support for the Xilinx SN1022 SmartNICs.

Vijay Kumar Srivastava (10):
vdpa/sfc: introduce Xilinx vDPA driver vdpa/sfc: add support for device initialization vdpa/sfc: add support to get device and protocol features vdpa/sfc: get device supported max queue count vdpa/sfc: add support to get VFIO device fd vdpa/sfc: add support for dev conf and dev close ops vdpa/sfc: add support to get queue notify area info vdpa/sfc: add support for MAC filter config vdpa/sfc: add support to set vring state vdpa/sfc: set a multicast filter during vDPA init

  MAINTAINERS                            |   6 +
  doc/guides/rel_notes/release_21_11.rst |   5 +
  doc/guides/vdpadevs/features/sfc.ini   |  19 +
  doc/guides/vdpadevs/index.rst          |   1 +
  doc/guides/vdpadevs/sfc.rst            | 107 ++++
  drivers/common/sfc_efx/efsys.h         |   2 +-
  drivers/common/sfc_efx/version.map     |  10 +
  drivers/vdpa/meson.build               |   1 +
  drivers/vdpa/sfc/meson.build           |  26 +
  drivers/vdpa/sfc/sfc_vdpa.c            | 363 +++++++++++++
  drivers/vdpa/sfc/sfc_vdpa.h            | 162 ++++++
  drivers/vdpa/sfc/sfc_vdpa_debug.h      |  21 +
  drivers/vdpa/sfc/sfc_vdpa_filter.c     | 150 ++++++
  drivers/vdpa/sfc/sfc_vdpa_hw.c         | 418 +++++++++++++++
  drivers/vdpa/sfc/sfc_vdpa_log.h        |  59 +++
  drivers/vdpa/sfc/sfc_vdpa_mcdi.c       |  74 +++
  drivers/vdpa/sfc/sfc_vdpa_ops.c        | 930 +++++++++++++++++++++++++++++++++
  drivers/vdpa/sfc/sfc_vdpa_ops.h        |  67 +++
  drivers/vdpa/sfc/version.map           |   3 +
  19 files changed, 2423 insertions(+), 1 deletion(-)
Quoted 14 lines

create mode 100644 doc/guides/vdpadevs/features/sfc.ini create mode 100644 doc/guides/vdpadevs/sfc.rst create mode 100644 drivers/vdpa/sfc/meson.build create mode 100644 drivers/vdpa/sfc/sfc_vdpa.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa.h create mode 100644 drivers/vdpa/sfc/sfc_vdpa_debug.h create mode 100644 drivers/vdpa/sfc/sfc_vdpa_filter.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_hw.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_log.h create mode 100644 drivers/vdpa/sfc/sfc_vdpa_mcdi.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.c create mode 100644 drivers/vdpa/sfc/sfc_vdpa_ops.h create mode 100644 drivers/vdpa/sfc/version.map

Applied to dpdk-next-virtio/main, with fixing the vdpa driver header inclusion.

Thanks,
Maxime