patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Kevin Traynor <ktraynor@redhat.com>
To: Wei Huang <wei.huang@intel.com>
Cc: Tianfei Zhang <tianfei.zhang@intel.com>, dpdk stable <stable@dpdk.org>
Subject: patch 'raw/ifpga: fix interrupt handle allocation' has been queued to stable release 21.11.1
Date: Tue,  8 Mar 2022 14:14:53 +0000	[thread overview]
Message-ID: <20220308141500.286915-38-ktraynor@redhat.com> (raw)
In-Reply-To: <20220308141500.286915-1-ktraynor@redhat.com>

Hi,

FYI, your patch has been queued to stable release 21.11.1

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 03/14/22. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/3d2cba4108dabd7fec774c0dfffb1b4e0876e4b8

Thanks.

Kevin

---
From 3d2cba4108dabd7fec774c0dfffb1b4e0876e4b8 Mon Sep 17 00:00:00 2001
From: Wei Huang <wei.huang@intel.com>
Date: Fri, 18 Feb 2022 02:38:48 -0500
Subject: [PATCH] raw/ifpga: fix interrupt handle allocation

[ upstream commit 20659eb38099033b9aa4f7476a7ba7b5d3258569 ]

Allocate FPGA interrupt handle instance for each card.

Fixes: e0a1aafe2af9 ("raw/ifpga: introduce IRQ functions")

Signed-off-by: Wei Huang <wei.huang@intel.com>
Acked-by: Tianfei Zhang <tianfei.zhang@intel.com>
---
 drivers/raw/ifpga/ifpga_rawdev.c | 94 +++++++++++++++++++-------------
 drivers/raw/ifpga/ifpga_rawdev.h |  7 ++-
 2 files changed, 62 insertions(+), 39 deletions(-)

diff --git a/drivers/raw/ifpga/ifpga_rawdev.c b/drivers/raw/ifpga/ifpga_rawdev.c
index 5baa0bdd47..c2e74518aa 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.c
+++ b/drivers/raw/ifpga/ifpga_rawdev.c
@@ -72,8 +72,4 @@ static int ifpga_monitor_start;
 static pthread_t ifpga_monitor_start_thread;
 
-#define IFPGA_MAX_IRQ 12
-/* 0 for FME interrupt, others are reserved for AFU irq */
-static struct rte_intr_handle *ifpga_irq_handle[IFPGA_MAX_IRQ];
-
 static struct ifpga_rawdev *
 ifpga_rawdev_allocate(struct rte_rawdev *rawdev);
@@ -119,4 +115,5 @@ ifpga_rawdev_allocate(struct rte_rawdev *rawdev)
 	struct ifpga_rawdev *dev;
 	uint16_t dev_id;
+	int i = 0;
 
 	dev = ifpga_rawdev_get(rawdev);
@@ -135,4 +132,6 @@ ifpga_rawdev_allocate(struct rte_rawdev *rawdev)
 	dev->rawdev = rawdev;
 	dev->dev_id = dev_id;
+	for (i = 0; i < IFPGA_MAX_IRQ; i++)
+		dev->intr_handle[i] = NULL;
 
 	return dev;
@@ -1342,28 +1341,45 @@ fme_interrupt_handler(void *param)
 
 int
-ifpga_unregister_msix_irq(enum ifpga_irq_type type,
+ifpga_unregister_msix_irq(struct ifpga_rawdev *dev, enum ifpga_irq_type type,
 		int vec_start, rte_intr_callback_fn handler, void *arg)
 {
-	struct rte_intr_handle *intr_handle;
-	int rc, i;
+	struct rte_intr_handle **intr_handle;
+	int rc = 0;
+	int i = vec_start + 1;
+
+	if (!dev)
+		return -ENODEV;
 
 	if (type == IFPGA_FME_IRQ)
-		intr_handle = ifpga_irq_handle[0];
+		intr_handle = (struct rte_intr_handle **)&dev->intr_handle[0];
 	else if (type == IFPGA_AFU_IRQ)
-		intr_handle = ifpga_irq_handle[vec_start + 1];
+		intr_handle = (struct rte_intr_handle **)&dev->intr_handle[i];
 	else
-		return 0;
+		return -EINVAL;
 
-	rte_intr_efd_disable(intr_handle);
+	if ((*intr_handle) == NULL) {
+		IFPGA_RAWDEV_PMD_ERR("%s interrupt %d not registered\n",
+			type == IFPGA_FME_IRQ ? "FME" : "AFU",
+			type == IFPGA_FME_IRQ ? 0 : vec_start);
+		return -ENOENT;
+	}
 
-	rc = rte_intr_callback_unregister(intr_handle, handler, arg);
+	rte_intr_efd_disable(*intr_handle);
+
+	rc = rte_intr_callback_unregister(*intr_handle, handler, arg);
+	if (rc < 0) {
+		IFPGA_RAWDEV_PMD_ERR("Failed to unregister %s interrupt %d\n",
+			type == IFPGA_FME_IRQ ? "FME" : "AFU",
+			type == IFPGA_FME_IRQ ? 0 : vec_start);
+	} else {
+		rte_intr_instance_free(*intr_handle);
+		*intr_handle = NULL;
+	}
 
-	for (i = 0; i < IFPGA_MAX_IRQ; i++)
-		rte_intr_instance_free(ifpga_irq_handle[i]);
 	return rc;
 }
 
 int
-ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id,
 		enum ifpga_irq_type type, int vec_start, int count,
 		rte_intr_callback_fn handler, const char *name,
@@ -1371,5 +1387,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 {
 	int ret;
-	struct rte_intr_handle *intr_handle;
+	struct rte_intr_handle **intr_handle;
 	struct opae_adapter *adapter;
 	struct opae_manager *mgr;
@@ -1377,12 +1393,8 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 	int *intr_efds = NULL, nb_intr, i;
 
-	for (i = 0; i < IFPGA_MAX_IRQ; i++) {
-		ifpga_irq_handle[i] =
-			rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
-		if (ifpga_irq_handle[i] == NULL)
-			return -ENOMEM;
-	}
+	if (!dev || !dev->rawdev)
+		return -ENODEV;
 
-	adapter = ifpga_rawdev_get_priv(dev);
+	adapter = ifpga_rawdev_get_priv(dev->rawdev);
 	if (!adapter)
 		return -ENODEV;
@@ -1393,30 +1405,38 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 
 	if (type == IFPGA_FME_IRQ) {
-		intr_handle = ifpga_irq_handle[0];
+		intr_handle = (struct rte_intr_handle **)&dev->intr_handle[0];
 		count = 1;
 	} else if (type == IFPGA_AFU_IRQ) {
-		intr_handle = ifpga_irq_handle[vec_start + 1];
+		i = vec_start + 1;
+		intr_handle = (struct rte_intr_handle **)&dev->intr_handle[i];
 	} else {
 		return -EINVAL;
 	}
 
-	if (rte_intr_type_set(intr_handle, RTE_INTR_HANDLE_VFIO_MSIX))
+	if (*intr_handle)
+		return -EBUSY;
+
+	*intr_handle = rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_PRIVATE);
+	if (!(*intr_handle))
+		return -ENOMEM;
+
+	if (rte_intr_type_set(*intr_handle, RTE_INTR_HANDLE_VFIO_MSIX))
 		return -rte_errno;
 
-	ret = rte_intr_efd_enable(intr_handle, count);
+	ret = rte_intr_efd_enable(*intr_handle, count);
 	if (ret)
 		return -ENODEV;
 
-	if (rte_intr_fd_set(intr_handle,
-			rte_intr_efds_index_get(intr_handle, 0)))
+	if (rte_intr_fd_set(*intr_handle,
+			rte_intr_efds_index_get(*intr_handle, 0)))
 		return -rte_errno;
 
 	IFPGA_RAWDEV_PMD_DEBUG("register %s irq, vfio_fd=%d, fd=%d\n",
-			name, rte_intr_dev_fd_get(intr_handle),
-			rte_intr_fd_get(intr_handle));
+			name, rte_intr_dev_fd_get(*intr_handle),
+			rte_intr_fd_get(*intr_handle));
 
 	if (type == IFPGA_FME_IRQ) {
 		struct fpga_fme_err_irq_set err_irq_set;
-		err_irq_set.evtfd = rte_intr_efds_index_get(intr_handle,
+		err_irq_set.evtfd = rte_intr_efds_index_get(*intr_handle,
 								   0);
 
@@ -1429,5 +1449,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 			return -EINVAL;
 
-		nb_intr = rte_intr_nb_intr_get(intr_handle);
+		nb_intr = rte_intr_nb_intr_get(*intr_handle);
 
 		intr_efds = calloc(nb_intr, sizeof(int));
@@ -1436,5 +1456,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 
 		for (i = 0; i < nb_intr; i++)
-			intr_efds[i] = rte_intr_efds_index_get(intr_handle, i);
+			intr_efds[i] = rte_intr_efds_index_get(*intr_handle, i);
 
 		ret = opae_acc_set_irq(acc, vec_start, count, intr_efds);
@@ -1446,5 +1466,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
 
 	/* register interrupt handler using DPDK API */
-	ret = rte_intr_callback_register(intr_handle,
+	ret = rte_intr_callback_register(*intr_handle,
 			handler, (void *)arg);
 	if (ret) {
@@ -1548,5 +1568,5 @@ ifpga_rawdev_create(struct rte_pci_device *pci_dev,
 	}
 
-	ret = ifpga_register_msix_irq(rawdev, 0, IFPGA_FME_IRQ, 0, 0,
+	ret = ifpga_register_msix_irq(dev, 0, IFPGA_FME_IRQ, 0, 0,
 			fme_interrupt_handler, "fme_irq", mgr);
 	if (ret)
@@ -1605,5 +1625,5 @@ ifpga_rawdev_destroy(struct rte_pci_device *pci_dev)
 		return -ENODEV;
 
-	if (ifpga_unregister_msix_irq(IFPGA_FME_IRQ, 0,
+	if (ifpga_unregister_msix_irq(dev, IFPGA_FME_IRQ, 0,
 				fme_interrupt_handler, mgr) < 0)
 		return -EINVAL;
diff --git a/drivers/raw/ifpga/ifpga_rawdev.h b/drivers/raw/ifpga/ifpga_rawdev.h
index 61c8366707..6e09afead3 100644
--- a/drivers/raw/ifpga/ifpga_rawdev.h
+++ b/drivers/raw/ifpga/ifpga_rawdev.h
@@ -51,4 +51,5 @@ ifpga_rawdev_get_priv(const struct rte_rawdev *rawdev)
 #define IFPGA_RAWDEV_MSIX_IRQ_NUM 7
 #define IFPGA_RAWDEV_NUM 32
+#define IFPGA_MAX_IRQ 12
 
 struct ifpga_rawdev {
@@ -60,4 +61,6 @@ struct ifpga_rawdev {
 	char fvl_bdf[8][16];
 	char parent_bdf[16];
+	/* 0 for FME interrupt, others are reserved for AFU irq */
+	void *intr_handle[IFPGA_MAX_IRQ];
 };
 
@@ -71,10 +74,10 @@ enum ifpga_irq_type {
 
 int
-ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+ifpga_register_msix_irq(struct ifpga_rawdev *dev, int port_id,
 		enum ifpga_irq_type type, int vec_start, int count,
 		rte_intr_callback_fn handler, const char *name,
 		void *arg);
 int
-ifpga_unregister_msix_irq(enum ifpga_irq_type type,
+ifpga_unregister_msix_irq(struct ifpga_rawdev *dev, enum ifpga_irq_type type,
 		int vec_start, rte_intr_callback_fn handler, void *arg);
 
-- 
2.34.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2022-03-08 13:55:29.328249914 +0000
+++ 0038-raw-ifpga-fix-interrupt-handle-allocation.patch	2022-03-08 13:55:28.509315199 +0000
@@ -1 +1 @@
-From 20659eb38099033b9aa4f7476a7ba7b5d3258569 Mon Sep 17 00:00:00 2001
+From 3d2cba4108dabd7fec774c0dfffb1b4e0876e4b8 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 20659eb38099033b9aa4f7476a7ba7b5d3258569 ]
+
@@ -9 +10,0 @@
-Cc: stable@dpdk.org
@@ -19 +20 @@
-index 6beecb710a..cc569c5e71 100644
+index 5baa0bdd47..c2e74518aa 100644
@@ -44 +45 @@
-@@ -1341,28 +1340,45 @@ fme_interrupt_handler(void *param)
+@@ -1342,28 +1341,45 @@ fme_interrupt_handler(void *param)
@@ -101 +102 @@
-@@ -1370,5 +1386,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+@@ -1371,5 +1387,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
@@ -108 +109 @@
-@@ -1376,12 +1392,8 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+@@ -1377,12 +1393,8 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
@@ -124 +125 @@
-@@ -1392,30 +1404,38 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+@@ -1393,30 +1405,38 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
@@ -172 +173 @@
-@@ -1428,5 +1448,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+@@ -1429,5 +1449,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
@@ -179 +180 @@
-@@ -1435,5 +1455,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+@@ -1436,5 +1456,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
@@ -186 +187 @@
-@@ -1445,5 +1465,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
+@@ -1446,5 +1466,5 @@ ifpga_register_msix_irq(struct rte_rawdev *dev, int port_id,
@@ -193 +194 @@
-@@ -1547,5 +1567,5 @@ ifpga_rawdev_create(struct rte_pci_device *pci_dev,
+@@ -1548,5 +1568,5 @@ ifpga_rawdev_create(struct rte_pci_device *pci_dev,
@@ -200 +201 @@
-@@ -1604,5 +1624,5 @@ ifpga_rawdev_destroy(struct rte_pci_device *pci_dev)
+@@ -1605,5 +1625,5 @@ ifpga_rawdev_destroy(struct rte_pci_device *pci_dev)


  parent reply	other threads:[~2022-03-08 14:16 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08 14:14 patch 'event/cnxk: fix sub-event clearing mask length' " Kevin Traynor
2022-03-08 14:14 ` patch 'event/cnxk: fix Rx adapter config check' " Kevin Traynor
2022-03-08 14:14 ` patch 'event/dlb2: add shift value check in sparse dequeue' " Kevin Traynor
2022-03-08 14:14 ` patch 'app/compress-perf: fix cycle count operations allocation' " Kevin Traynor
2022-03-08 14:14 ` patch 'app/compress-perf: optimize operations pool " Kevin Traynor
2022-03-08 14:14 ` patch 'compress/mlx5: support out-of-space status' " Kevin Traynor
2022-03-08 14:14 ` patch 'app/compress-perf: fix socket ID type during init' " Kevin Traynor
2022-03-08 14:14 ` patch 'app/compress-perf: fix number of queue pairs to setup' " Kevin Traynor
2022-03-08 14:14 ` patch 'compressdev: fix socket ID type' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/hns3: remove duplicate macro definition' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/hns3: fix RSS TC mode entry' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/hns3: fix VF " Kevin Traynor
2022-03-08 14:14 ` patch 'net/hns3: increase time waiting for PF reset completion' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/ixgbe: fix FSP check for X550EM devices' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/iavf: support NAT-T / UDP encapsulation' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/iavf: fix function pointer in multi-process' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix indexed pool fetch overlap' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix destroying empty matchers list' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix shared counter flag in flow validation' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix check in count action " Kevin Traynor
2022-03-08 14:14 ` patch 'net/txgbe: fix queue statistics mapping' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/kni: fix config initialization' " Kevin Traynor
2022-03-08 14:14 ` patch 'doc: fix typos and punctuation in flow API guide' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix GRE item translation in Verbs' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: reduce flex item flow handle size' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix matcher priority with ICMP or ICMPv6' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/mlx5: fix flex item header length translation' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/iavf: fix AES-GMAC IV size' " Kevin Traynor
2022-03-08 14:14 ` patch 'common/cnxk: fix bitmap usage for TM' " Kevin Traynor
2022-03-08 14:14 ` patch 'common/cnxk: fix mbuf data offset for VF' " Kevin Traynor
2022-03-08 14:14 ` patch 'net/ice: fix Tx offload path choice' " Kevin Traynor
2022-03-08 14:14 ` patch 'vhost: fix linker script syntax' " Kevin Traynor
2022-03-08 14:14 ` patch 'examples/vhost: fix launch with physical port' " Kevin Traynor
2022-03-08 14:14 ` patch 'eal/linux: fix device monitor stop return' " Kevin Traynor
2022-03-08 14:14 ` patch 'sched: remove useless malloc in PIE data init' " Kevin Traynor
2022-03-08 14:14 ` patch 'gpu/cuda: fix dependency loading path' " Kevin Traynor
2022-03-08 14:14 ` patch 'raw/ifpga: fix variable initialization in probing' " Kevin Traynor
2022-03-08 14:14 ` Kevin Traynor [this message]
2022-03-08 14:14 ` patch 'raw/ifpga: fix monitor thread' " Kevin Traynor
2022-03-08 14:14 ` patch 'app/pdump: abort on multi-core capture limit' " Kevin Traynor
2022-03-08 14:14 ` patch 'pcapng: handle failure of link status query' " Kevin Traynor
2022-03-08 14:14 ` patch 'test/bpf: skip dump if conversion fails' " Kevin Traynor
2022-03-08 14:14 ` patch 'app/dumpcap: check for failure to set promiscuous' " Kevin Traynor
2022-03-08 14:14 ` patch 'examples/distributor: reduce Tx queue number to 1' " Kevin Traynor
2022-03-08 14:15 ` patch 'examples/flow_classify: fix failure message' " Kevin Traynor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220308141500.286915-38-ktraynor@redhat.com \
    --to=ktraynor@redhat.com \
    --cc=stable@dpdk.org \
    --cc=tianfei.zhang@intel.com \
    --cc=wei.huang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).