[v3,06/11] vdpa/nfp: add the interrupt logic of vring relay

Message ID 20240617062708.2932037-7-chaoyong.he@corigine.com (mailing list archive)
State Superseded
Delegated to: Maxime Coquelin
Headers
Series support software live migration |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He June 17, 2024, 6:27 a.m. UTC
From: Xinying Yu <xinying.yu@corigine.com>

Add the interrupt setup logic of vring relay.

The epoll fd is provided here so host can get the interrupt from device
on Rx direction, all other operations on vring relay are based on this.

Signed-off-by: Xinying Yu <xinying.yu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/vdpa/nfp/nfp_vdpa.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)
  

Comments

Maxime Coquelin June 18, 2024, 8:14 a.m. UTC | #1
On 6/17/24 08:27, Chaoyong He wrote:
> From: Xinying Yu <xinying.yu@corigine.com>
> 
> Add the interrupt setup logic of vring relay.
> 
> The epoll fd is provided here so host can get the interrupt from device
> on Rx direction, all other operations on vring relay are based on this.
> 
> Signed-off-by: Xinying Yu <xinying.yu@corigine.com>
> Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
> Reviewed-by: Long Wu <long.wu@corigine.com>
> Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
> ---
>   drivers/vdpa/nfp/nfp_vdpa.c | 24 ++++++++++++++++++++++--
>   1 file changed, 22 insertions(+), 2 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/drivers/vdpa/nfp/nfp_vdpa.c b/drivers/vdpa/nfp/nfp_vdpa.c
index 45092cb0af..1643ebbb8c 100644
--- a/drivers/vdpa/nfp/nfp_vdpa.c
+++ b/drivers/vdpa/nfp/nfp_vdpa.c
@@ -336,8 +336,10 @@  nfp_vdpa_stop(struct nfp_vdpa_dev *device)
 }
 
 static int
-nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device)
+nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device,
+		bool relay)
 {
+	int fd;
 	int ret;
 	uint16_t i;
 	int *fd_ptr;
@@ -366,6 +368,19 @@  nfp_vdpa_enable_vfio_intr(struct nfp_vdpa_dev *device)
 		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = vring.callfd;
 	}
 
+	if (relay) {
+		for (i = 0; i < nr_vring; i += 2) {
+			fd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC);
+			if (fd < 0) {
+				DRV_VDPA_LOG(ERR, "Can't setup eventfd");
+				return -EINVAL;
+			}
+
+			device->intr_fd[i] = fd;
+			fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = fd;
+		}
+	}
+
 	ret = ioctl(device->vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
 	if (ret != 0) {
 		DRV_VDPA_LOG(ERR, "Error enabling MSI-X interrupts.");
@@ -556,7 +571,7 @@  update_datapath(struct nfp_vdpa_dev *device)
 		if (ret != 0)
 			goto unlock_exit;
 
-		ret = nfp_vdpa_enable_vfio_intr(device);
+		ret = nfp_vdpa_enable_vfio_intr(device, false);
 		if (ret != 0)
 			goto dma_map_rollback;
 
@@ -619,6 +634,11 @@  nfp_vdpa_sw_fallback(struct nfp_vdpa_dev *device)
 		goto error;
 	}
 
+	/* Setup interrupt for vring relay */
+	ret = nfp_vdpa_enable_vfio_intr(device, true);
+	if (ret != 0)
+		goto error;
+
 	device->hw.sw_fallback_running = true;
 
 	return 0;