Skip to contentSkip to conversation

vdpa/sfc: enable support for multi-queue

PATCH Superseded [email protected] 1 participant 7 messages Jul 8, 2022 – Jul 14, 2022 virtio core

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vdpa/sfc: enable support for multi-queue

From: Abhimanyu Saini <[email protected]>

Increase the number to defaut RX/TX queue pairs to 8, and add MQ feature flag to vDPA protocol features.

---
 drivers/vdpa/sfc/sfc_vdpa_hw.c  | 2 ++
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 6 ++++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_hw.c +2 -0
index a7018b1..edb7e35 100644
@@ -286,6 +286,8 @@
 	SFC_VDPA_ASSERT(max_queue_cnt > 0);
 
 	sva->max_queue_count = max_queue_cnt;
+	sfc_vdpa_log_init(sva, "NIC init done with %u pair(s) of queues",
+			  max_queue_cnt);
 
 	return 0;
 
drivers/vdpa/sfc/sfc_vdpa_ops.c +4 -2
index b84699d..e4cde34 100644
@@ -24,14 +24,16 @@
 		 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
 		 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
 		 (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \
-		 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD))
+		 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
+		 (1ULL << VHOST_USER_PROTOCOL_F_MQ))
 
 /*
  * Set of features which are enabled by default.
  * Protocol feature bit is needed to enable notification notifier ctrl.
  */
 #define SFC_VDPA_DEFAULT_FEATURES \
-		(1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
+		((1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
+		 (1ULL << VIRTIO_NET_F_MQ))
 
 #define SFC_VDPA_MSIX_IRQ_SET_BUF_LEN \
 		(sizeof(struct vfio_irq_set) + \
drivers/vdpa/sfc/sfc_vdpa_ops.h +1 -1
index 9dbd5b8..5c8e352 100644
@@ -7,7 +7,7 @@
 
 #include <rte_vdpa.h>
 
-#define SFC_VDPA_MAX_QUEUE_PAIRS		1
+#define SFC_VDPA_MAX_QUEUE_PAIRS		8
 
 enum sfc_vdpa_context {
 	SFC_VDPA_AS_VF
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 vdpa/sfc: enable support for multi-queue

From: Abhimanyu Saini <[email protected]>

Increase the number to default RX/TX queue pairs to 8, and add MQ feature flag to vDPA protocol features.

---
v2:
Fix checkpatch warnings

 drivers/vdpa/sfc/sfc_vdpa_hw.c  | 2 ++
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 6 ++++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_hw.c +2 -0
index a7018b1..edb7e35 100644
@@ -286,6 +286,8 @@
 	SFC_VDPA_ASSERT(max_queue_cnt > 0);
 
 	sva->max_queue_count = max_queue_cnt;
+	sfc_vdpa_log_init(sva, "NIC init done with %u pair(s) of queues",
+			  max_queue_cnt);
 
 	return 0;
 
drivers/vdpa/sfc/sfc_vdpa_ops.c +4 -2
index b84699d..e4cde34 100644
@@ -24,14 +24,16 @@
 		 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
 		 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
 		 (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \
-		 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD))
+		 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
+		 (1ULL << VHOST_USER_PROTOCOL_F_MQ))
 
 /*
  * Set of features which are enabled by default.
  * Protocol feature bit is needed to enable notification notifier ctrl.
  */
 #define SFC_VDPA_DEFAULT_FEATURES \
-		(1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
+		((1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
+		 (1ULL << VIRTIO_NET_F_MQ))
 
 #define SFC_VDPA_MSIX_IRQ_SET_BUF_LEN \
 		(sizeof(struct vfio_irq_set) + \
drivers/vdpa/sfc/sfc_vdpa_ops.h +1 -1
index 9dbd5b8..5c8e352 100644
@@ -7,7 +7,7 @@
 
 #include <rte_vdpa.h>
 
-#define SFC_VDPA_MAX_QUEUE_PAIRS		1
+#define SFC_VDPA_MAX_QUEUE_PAIRS		8
 
 enum sfc_vdpa_context {
 	SFC_VDPA_AS_VF
Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 1/5 common/sfc_efx/base: remove VQ index check during VQ start

In reply to [email protected]

From: Abhimanyu Saini <[email protected]>

The used/avail queue indexes are not bound by queue size, because H/W calculates descriptor entry index by performing a simple modulo between queue index and queue_size

So, do not check initial used and avail queue indexes against queue size because it is possible for these indexes to be greater than queue size in the following cases:
1) The queue is created to be migrated into, or
2) The client issues a qstop/qstart after running datapath

Fixes 4dda72dbdeab3 ("common/sfc_efx/base: add base virtio support for vDPA")
---
 drivers/common/sfc_efx/base/rhead_virtio.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/common/sfc_efx/base/rhead_virtio.c +1 -11
index 335cb74..7f08717 100644
@@ -47,14 +47,6 @@
 		goto fail2;
 	}
 
-	if (evvdp != NULL) {
-		if ((evvdp->evvd_vq_cidx > evvcp->evvc_vq_size) ||
-		    (evvdp->evvd_vq_pidx > evvcp->evvc_vq_size)) {
-			rc = EINVAL;
-			goto fail3;
-		}
-	}
-
 	req.emr_cmd = MC_CMD_VIRTIO_INIT_QUEUE;
 	req.emr_in_buf = payload;
 	req.emr_in_length = MC_CMD_VIRTIO_INIT_QUEUE_REQ_LEN;
@@ -116,15 +108,13 @@
 
 	if (req.emr_rc != 0) {
 		rc = req.emr_rc;
-		goto fail4;
+		goto fail3;
 	}
 
 	evvp->evv_vi_index = vi_index;
 
 	return (0);
 
-fail4:
-	EFSYS_PROBE(fail4);
 fail3:
 	EFSYS_PROBE(fail3);
 fail2:
Signature · 1 line
1.8.3.1
#3 lore raw

PATCH 2/5 vdpa/sfc: enable support for multi-queue

From: Abhimanyu Saini <[email protected]>

Increase the number to defaut RX/TX queue pairs to 8, and add MQ feature flag to vDPA protocol features.

---
 drivers/vdpa/sfc/sfc_vdpa_hw.c  | 2 ++
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 6 ++++--
 drivers/vdpa/sfc/sfc_vdpa_ops.h | 2 +-
 3 files changed, 7 insertions(+), 3 deletions(-)
drivers/vdpa/sfc/sfc_vdpa_hw.c +2 -0
index a7018b1..edb7e35 100644
@@ -286,6 +286,8 @@
 	SFC_VDPA_ASSERT(max_queue_cnt > 0);
 
 	sva->max_queue_count = max_queue_cnt;
+	sfc_vdpa_log_init(sva, "NIC init done with %u pair(s) of queues",
+			  max_queue_cnt);
 
 	return 0;
 
drivers/vdpa/sfc/sfc_vdpa_ops.c +4 -2
index b84699d..e4cde34 100644
@@ -24,14 +24,16 @@
 		 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_REQ) | \
 		 (1ULL << VHOST_USER_PROTOCOL_F_SLAVE_SEND_FD) | \
 		 (1ULL << VHOST_USER_PROTOCOL_F_HOST_NOTIFIER) | \
-		 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD))
+		 (1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD) | \
+		 (1ULL << VHOST_USER_PROTOCOL_F_MQ))
 
 /*
  * Set of features which are enabled by default.
  * Protocol feature bit is needed to enable notification notifier ctrl.
  */
 #define SFC_VDPA_DEFAULT_FEATURES \
-		(1ULL << VHOST_USER_F_PROTOCOL_FEATURES)
+		((1ULL << VHOST_USER_F_PROTOCOL_FEATURES) | \
+		 (1ULL << VIRTIO_NET_F_MQ))
 
 #define SFC_VDPA_MSIX_IRQ_SET_BUF_LEN \
 		(sizeof(struct vfio_irq_set) + \
drivers/vdpa/sfc/sfc_vdpa_ops.h +1 -1
index 9dbd5b8..5c8e352 100644
@@ -7,7 +7,7 @@
 
 #include <rte_vdpa.h>
 
-#define SFC_VDPA_MAX_QUEUE_PAIRS		1
+#define SFC_VDPA_MAX_QUEUE_PAIRS		8
 
 enum sfc_vdpa_context {
 	SFC_VDPA_AS_VF
Signature · 1 line
1.8.3.1
#4 lore raw

PATCH 3/5 common/sfc_efx/base: update MCDI headers

In reply to [email protected]

From: Abhimanyu Saini <[email protected]>

Regenerate MCDI headers from smartnic_registry:72940ad

---
 drivers/common/sfc_efx/base/efx_regs_mcdi.h | 36 ++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 11 deletions(-)
drivers/common/sfc_efx/base/efx_regs_mcdi.h +25 -11
index 2daf825..d1d8093 100644
@@ -28071,18 +28071,26 @@
 #define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_FEATURES_HI_WIDTH 32
 /*            Enum values, see field(s): */
 /*               MC_CMD_VIRTIO_GET_FEATURES/MC_CMD_VIRTIO_GET_FEATURES_OUT/FEATURES */
-/* The initial producer index for this queue's used ring. If this queue is
- * being created to be migrated into, this should be the FINAL_PIDX value
- * returned by MC_CMD_VIRTIO_FINI_QUEUE of the queue being migrated from.
- * Otherwise, it should be zero.
+/* The initial available index for this virtqueue. If this queue is being
+ * created to be migrated into, this should be the FINAL_AVAIL_IDX value
+ * returned by MC_CMD_VIRTIO_FINI_QUEUE of the queue being migrated from (or
+ * equivalent if the original queue was on a thirdparty device). Otherwise, it
+ * should be zero.
  */
+#define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_AVAIL_IDX_OFST 56
+#define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_AVAIL_IDX_LEN 4
+/* Alias of INITIAL_AVAIL_IDX, kept for compatibility. */
 #define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_PIDX_OFST 56
 #define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_PIDX_LEN 4
-/* The initial consumer index for this queue's available ring. If this queue is
- * being created to be migrated into, this should be the FINAL_CIDX value
- * returned by MC_CMD_VIRTIO_FINI_QUEUE of the queue being migrated from.
- * Otherwise, it should be zero.
- */
+/* The initial used index for this virtqueue. If this queue is being created to
+ * be migrated into, this should be the FINAL_USED_IDX value returned by
+ * MC_CMD_VIRTIO_FINI_QUEUE of the queue being migrated from (or equivalent if
+ * the original queue was on a thirdparty device). Otherwise, it should be
+ * zero.
+ */
+#define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_USED_IDX_OFST 60
+#define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_USED_IDX_LEN 4
+/* Alias of INITIAL_USED_IDX, kept for compatibility. */
 #define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_CIDX_OFST 60
 #define	MC_CMD_VIRTIO_INIT_QUEUE_REQ_INITIAL_CIDX_LEN 4
 /* A MAE_MPORT_SELECTOR defining which mport this queue should be associated
@@ -28128,10 +28136,16 @@
 
 /* MC_CMD_VIRTIO_FINI_QUEUE_RESP msgresponse */
 #define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_LEN 8
-/* The producer index of the used ring when the queue was stopped. */
+/* The available index of the virtqueue when the queue was stopped. */
+#define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_AVAIL_IDX_OFST 0
+#define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_AVAIL_IDX_LEN 4
+/* Alias of FINAL_AVAIL_IDX, kept for compatibility. */
 #define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_PIDX_OFST 0
 #define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_PIDX_LEN 4
-/* The consumer index of the available ring when the queue was stopped. */
+/* The used index of the virtqueue when the queue was stopped. */
+#define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_USED_IDX_OFST 4
+#define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_USED_IDX_LEN 4
+/* Alias of FINAL_USED_IDX, kept for compatibility. */
 #define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_CIDX_OFST 4
 #define	MC_CMD_VIRTIO_FINI_QUEUE_RESP_FINAL_CIDX_LEN 4
 
Signature · 1 line
1.8.3.1
#5 lore raw

PATCH 4/5 common/sfc_efx/base: use the updated definitions of cidx/pidx

In reply to [email protected]

From: Abhimanyu Saini <[email protected]>

Change cidx and pidx definition to mean used queue and avail queue index respectively.

---
 drivers/common/sfc_efx/base/efx.h          | 12 ++++++------
 drivers/common/sfc_efx/base/rhead_virtio.c | 16 ++++++++--------
 drivers/vdpa/sfc/sfc_vdpa_ops.c            |  4 ++--
 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/common/sfc_efx/base/efx.h +6 -6
index 95f5fb6..c19205c 100644
@@ -4886,17 +4886,17 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 
 typedef struct efx_virtio_vq_dyncfg_s {
 	/*
-	 * If queue is being created to be migrated then this
-	 * should be the FINAL_PIDX value returned by MC_CMD_VIRTIO_FINI_QUEUE
+	 * If queue is being created to be migrated then this should be
+	 * the FINAL_AVAIL_IDX value returned by MC_CMD_VIRTIO_FINI_QUEUE
 	 * of the queue being migrated from. Otherwise, it should be zero.
 	 */
-	uint32_t		evvd_vq_pidx;
+	uint32_t		evvd_vq_avail_idx;
 	/*
-	 * If this queue is being created to be migrated then this
-	 * should be the FINAL_CIDX value returned by MC_CMD_VIRTIO_FINI_QUEUE
+	 * If queue is being created to be migrated then this should be
+	 * the FINAL_USED_IDX value returned by MC_CMD_VIRTIO_FINI_QUEUE
 	 * of the queue being migrated from. Otherwise, it should be zero.
 	 */
-	uint32_t		evvd_vq_cidx;
+	uint32_t		evvd_vq_used_idx;
 } efx_virtio_vq_dyncfg_t;
 
 /*
drivers/common/sfc_efx/base/rhead_virtio.c +8 -8
index 7f08717..5a2ebe8 100644
@@ -95,10 +95,10 @@
 		evvcp->evcc_features >> 32);
 
 	if (evvdp != NULL) {
-		MCDI_IN_SET_DWORD(req, VIRTIO_INIT_QUEUE_REQ_INITIAL_PIDX,
-			evvdp->evvd_vq_pidx);
-		MCDI_IN_SET_DWORD(req, VIRTIO_INIT_QUEUE_REQ_INITIAL_CIDX,
-			evvdp->evvd_vq_cidx);
+		MCDI_IN_SET_DWORD(req, VIRTIO_INIT_QUEUE_REQ_INITIAL_AVAIL_IDX,
+			evvdp->evvd_vq_avail_idx);
+		MCDI_IN_SET_DWORD(req, VIRTIO_INIT_QUEUE_REQ_INITIAL_USED_IDX,
+			evvdp->evvd_vq_used_idx);
 	}
 
 	MCDI_IN_SET_DWORD(req, VIRTIO_INIT_QUEUE_REQ_MPORT_SELECTOR,
@@ -161,10 +161,10 @@
 	}
 
 	if (evvdp != NULL) {
-		evvdp->evvd_vq_pidx =
-		    MCDI_OUT_DWORD(req, VIRTIO_FINI_QUEUE_RESP_FINAL_PIDX);
-		evvdp->evvd_vq_cidx =
-		    MCDI_OUT_DWORD(req, VIRTIO_FINI_QUEUE_RESP_FINAL_CIDX);
+		evvdp->evvd_vq_avail_idx =
+		    MCDI_OUT_DWORD(req, VIRTIO_FINI_QUEUE_RESP_FINAL_AVAIL_IDX);
+		evvdp->evvd_vq_used_idx =
+		    MCDI_OUT_DWORD(req, VIRTIO_FINI_QUEUE_RESP_FINAL_USED_IDX);
 	}
 
 	return (0);
drivers/vdpa/sfc/sfc_vdpa_ops.c +2 -2
index e4cde34..426c7ac 100644
@@ -260,8 +260,8 @@
 	vq_cfg.evvc_used_ring_addr  = vring.used;
 	vq_cfg.evvc_vq_size = vring.size;
 
-	vq_dyncfg.evvd_vq_pidx = vring.last_used_idx;
-	vq_dyncfg.evvd_vq_cidx = vring.last_avail_idx;
+	vq_dyncfg.evvd_vq_used_idx  = vring.last_used_idx;
+	vq_dyncfg.evvd_vq_avail_idx = vring.last_avail_idx;
 
 	/* MSI-X vector is function-relative */
 	vq_cfg.evvc_msix_vector = RTE_INTR_VEC_RXTX_OFFSET + vq_num;
Signature · 1 line
1.8.3.1
#6 lore raw

PATCH 5/5 vdpa/sfc: Add support for SW assisted live migration

In reply to [email protected]

From: Abhimanyu Saini <[email protected]>

In SW assisted live migration, vDPA driver will stop all virtqueues and setup up SW vrings to relay the communication between the virtio driver and the vDPA device using an event driven relay thread

This will allow vDPA driver to help on guest dirty page logging for live migration.

---
 drivers/vdpa/sfc/sfc_vdpa.h     |   1 +
 drivers/vdpa/sfc/sfc_vdpa_ops.c | 336 +++++++++++++++++++++++++++++++++++++---
 drivers/vdpa/sfc/sfc_vdpa_ops.h |  15 +-
 3 files changed, 329 insertions(+), 23 deletions(-)
drivers/vdpa/sfc/sfc_vdpa.h +1 -0
index daeb27d..ae522ca 100644
@@ -18,6 +18,7 @@
 
 #define SFC_VDPA_MAC_ADDR			"mac"
 #define SFC_VDPA_DEFAULT_MCDI_IOVA		0x200000000000
+#define SFC_SW_VRING_IOVA			0x300000000000
 
 /* Broadcast & Unicast MAC filters are supported */
 #define SFC_MAX_SUPPORTED_FILTERS		3
drivers/vdpa/sfc/sfc_vdpa_ops.c +315 -21

459 lines not on this page · raw message

drivers/vdpa/sfc/sfc_vdpa_ops.h +13 -2
index 5c8e352..dd301ba 100644
@@ -6,8 +6,11 @@
 #define _SFC_VDPA_OPS_H
 
 #include <rte_vdpa.h>
+#include <vdpa_driver.h>
 
 #define SFC_VDPA_MAX_QUEUE_PAIRS		8
+#define SFC_VDPA_USED_RING_LEN(size) \
+	((size) * sizeof(struct vring_used_elem) + sizeof(uint16_t) * 3)
 
 enum sfc_vdpa_context {
 	SFC_VDPA_AS_VF
@@ -37,9 +40,10 @@ struct sfc_vdpa_vring_info {
 typedef struct sfc_vdpa_vq_context_s {
 	volatile void			*doorbell;
 	uint8_t				enable;
-	uint32_t			pidx;
-	uint32_t			cidx;
 	efx_virtio_vq_t			*vq;
+
+	uint64_t			sw_vq_iova;
+	uint64_t			sw_vq_size;
 } sfc_vdpa_vq_context_t;
 
 struct sfc_vdpa_ops_data {
@@ -57,6 +61,13 @@ struct sfc_vdpa_ops_data {
 
 	uint16_t			vq_count;
 	struct sfc_vdpa_vq_context_s	vq_cxt[SFC_VDPA_MAX_QUEUE_PAIRS * 2];
+
+	int				epfd;
+	uint64_t			sw_vq_iova;
+	bool				sw_fallback_mode;
+	pthread_t			sw_relay_thread_id;
+	struct vring			sw_vq[SFC_VDPA_MAX_QUEUE_PAIRS * 2];
+	int				intr_fd[SFC_VDPA_MAX_QUEUE_PAIRS * 2];
 };
 
 struct sfc_vdpa_ops_data *
Signature · 1 line
1.8.3.1