DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jan Blunck <jblunck@infradead.org>
To: dev@dpdk.org
Cc: shreyansh.jain@nxp.com, david.marchand@6wind.com,
	stephen@networkplumber.org
Subject: [dpdk-dev] [PATCH v5 10/20] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle
Date: Fri, 23 Dec 2016 16:58:01 +0100	[thread overview]
Message-ID: <1482508691-11408-11-git-send-email-jblunck@infradead.org> (raw)
In-Reply-To: <1482508691-11408-1-git-send-email-jblunck@infradead.org>
In-Reply-To: <1482332986-7599-1-git-send-email-jblunck@infradead.org>

This adds a helper to get the rte_intr_handle from the virtio_hw. This is
safe to do since the usage of the helper is guarded by RTE_ETH_DEV_INTR_LSC
which is only set if we found a PCI device during initialization.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/net/virtio/virtio_ethdev.c | 14 ++++++++------
 drivers/net/virtio/virtio_pci.h    |  6 ++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 5c8afb5..80b661d 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1151,7 +1151,7 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features)
  * if link state changed.
  */
 static void
-virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
+virtio_interrupt_handler(struct rte_intr_handle *handle,
 			 void *param)
 {
 	struct rte_eth_dev *dev = param;
@@ -1162,7 +1162,7 @@ virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle,
 	isr = vtpci_isr(hw);
 	PMD_DRV_LOG(INFO, "interrupt status = %#x", isr);
 
-	if (rte_intr_enable(&dev->pci_dev->intr_handle) < 0)
+	if (rte_intr_enable(handle) < 0)
 		PMD_DRV_LOG(ERR, "interrupt enable failed");
 
 	if (isr & VIRTIO_PCI_ISR_CONFIG) {
@@ -1334,7 +1334,7 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
 
 	/* Setup interrupt callback  */
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-		rte_intr_callback_register(&pci_dev->intr_handle,
+		rte_intr_callback_register(vtpci_intr_handle(hw),
 			virtio_interrupt_handler, eth_dev);
 
 	return 0;
@@ -1344,6 +1344,7 @@ static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
 	struct rte_pci_device *pci_dev;
+	struct virtio_hw *hw = eth_dev->data->dev_private;
 
 	PMD_INIT_FUNC_TRACE();
 
@@ -1363,7 +1364,7 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 
 	/* reset interrupt callback  */
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-		rte_intr_callback_unregister(&pci_dev->intr_handle,
+		rte_intr_callback_unregister(vtpci_intr_handle(hw),
 						virtio_interrupt_handler,
 						eth_dev);
 	rte_eal_pci_unmap_device(pci_dev);
@@ -1481,7 +1482,7 @@ virtio_dev_start(struct rte_eth_dev *dev)
 			return -ENOTSUP;
 		}
 
-		if (rte_intr_enable(&dev->pci_dev->intr_handle) < 0) {
+		if (rte_intr_enable(vtpci_intr_handle(hw)) < 0) {
 			PMD_DRV_LOG(ERR, "interrupt enable failed");
 			return -EIO;
 		}
@@ -1573,12 +1574,13 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
+	struct virtio_hw *hw = dev->data->dev_private;
 	struct rte_eth_link link;
 
 	PMD_INIT_LOG(DEBUG, "stop");
 
 	if (dev->data->dev_conf.intr_conf.lsc)
-		rte_intr_disable(&dev->pci_dev->intr_handle);
+		rte_intr_disable(vtpci_intr_handle(hw));
 
 	memset(&link, 0, sizeof(link));
 	virtio_dev_atomic_write_link_status(dev, &link);
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index de271bf..5373e39 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -317,4 +317,10 @@ uint8_t vtpci_isr(struct virtio_hw *);
 
 uint16_t vtpci_irq_config(struct virtio_hw *, uint16_t);
 
+static inline struct rte_intr_handle *
+vtpci_intr_handle(struct virtio_hw *hw)
+{
+	return hw->dev ? &hw->dev->intr_handle : NULL;
+}
+
 #endif /* _VIRTIO_PCI_H_ */
-- 
2.7.4

  parent reply	other threads:[~2016-12-23 15:58 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21 15:09 [dpdk-dev] [PATCH v4 00/23] Decouple ethdev from PCI device Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 01/23] eal: define container_of macro Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 02/23] eal: Allow passing const rte_intr_handle Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 03/23] rte_device: make driver pointer const Jan Blunck
2016-12-22  7:18   ` Shreyansh Jain
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 04/23] pmd: remove useless reset of dev_info->dev_pci Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 05/23] e1000: localize mapping from eth_dev to pci Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 06/23] ixgbe: localize mapping from eth_dev to pci_device Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 07/23] i40e: localize mapping of eth_dev to pci Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 08/23] broadcom: localize mapping from " Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 09/23] virtio: Don't fill dev_info->driver_name Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 10/23] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle Jan Blunck
2016-12-21 20:08   ` Stephen Hemminger
2016-12-23 11:04     ` Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 11/23] virtio: Don't depend on struct rte_eth_dev's pci_dev Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 12/23] bnx2x: localize mapping from eth_dev to pci Jan Blunck
2016-12-21 16:35   ` Harish Patil
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 13/23] fm10k: " Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 14/23] qede: localize mapping of " Jan Blunck
2016-12-21 16:35   ` Harish Patil
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 15/23] szedata2: localize handling of pci resources Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 16/23] nfp: localize rte_pci_device handling Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 17/23] vmxnet3: use eth_dev->data->drv_name instead of pci_drv name Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 18/23] ethdev: Helper to map to struct rte_pci_device Jan Blunck
2016-12-22 15:21   ` Thomas Monjalon
2016-12-22 18:13     ` Jan Blunck
2016-12-23  8:30       ` Thomas Monjalon
2016-12-23 10:27         ` Jan Blunck
2016-12-23 12:47           ` Thomas Monjalon
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 19/23] drivers: Replace per-PMD macros with rte_eth_dev_to_pci() helper Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 20/23] drivers: Use " Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 21/23] ethdev: Move filling of rte_eth_dev_info->pci_dev to dev_infos_get() Jan Blunck
2016-12-21 20:09   ` Stephen Hemminger
2016-12-22  8:11     ` Shreyansh Jain
2016-12-23 10:50       ` Jan Blunck
2016-12-23 11:11         ` Shreyansh Jain
     [not found]           ` <CALe+Z005ByAFq03su4VO_=sH299zS_zAQWjyfyW8jQ3sD7zPrw@mail.gmail.com>
2016-12-23 11:39             ` Shreyansh Jain
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 22/23] ethdev: Decouple interrupt handling from PCI device Jan Blunck
2016-12-22 15:13   ` Thomas Monjalon
2016-12-22 18:26     ` Jan Blunck
2016-12-21 15:09 ` [dpdk-dev] [PATCH v4 23/23] ethdev: Decouple struct rte_eth_dev from struct rte_pci_device Jan Blunck
2016-12-22 15:22   ` Thomas Monjalon
2016-12-22 15:26 ` [dpdk-dev] [PATCH v4 00/23] Decouple ethdev from PCI device Thomas Monjalon
2016-12-23 14:28   ` Thomas Monjalon
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 00/20] " Jan Blunck
2016-12-25 22:33   ` Thomas Monjalon
2017-01-03 12:20     ` Ferruh Yigit
2017-01-06 10:07       ` Andrew Rybchenko
2017-01-03 12:24     ` Ferruh Yigit
2017-01-03 14:06       ` Thomas Monjalon
2017-01-03 14:40         ` Ferruh Yigit
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 01/20] eal: define container_of macro Jan Blunck
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 02/20] eal: Allow passing const rte_intr_handle Jan Blunck
2017-01-17  4:42   ` Tan, Jianfeng
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 03/20] rte_device: make driver pointer const Jan Blunck
2016-12-23 16:19   ` Thomas Monjalon
2016-12-23 22:08   ` Stephen Hemminger
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 04/20] pmd: remove useless reset of dev_info->dev_pci Jan Blunck
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 05/20] e1000: localize mapping from eth_dev to pci Jan Blunck
2016-12-23 16:20   ` Thomas Monjalon
2016-12-23 22:06   ` Stephen Hemminger
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 06/20] ixgbe: localize mapping from eth_dev to pci_device Jan Blunck
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 07/20] i40e: localize mapping of eth_dev to pci Jan Blunck
2016-12-23 15:57 ` [dpdk-dev] [PATCH v5 08/20] broadcom: localize mapping from " Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 09/20] virtio: Don't fill dev_info->driver_name Jan Blunck
2016-12-23 15:58 ` Jan Blunck [this message]
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 11/20] virtio: Don't depend on struct rte_eth_dev's pci_dev Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 12/20] bnx2x: localize mapping from eth_dev to pci Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 13/20] fm10k: " Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 14/20] qede: localize mapping of " Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 15/20] szedata2: localize handling of pci resources Jan Blunck
2016-12-23 18:31   ` Thomas Monjalon
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 16/20] nfp: localize rte_pci_device handling Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 17/20] vmxnet3: use eth_dev->data->drv_name instead of pci_drv name Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 18/20] ethdev: Decouple interrupt handling from PCI device Jan Blunck
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 19/20] ethdev: Move dev_info filling of PCI information into drivers Jan Blunck
2016-12-23 18:45   ` Thomas Monjalon
2016-12-23 15:58 ` [dpdk-dev] [PATCH v5 20/20] ethdev: Decouple from PCI device Jan Blunck
2016-12-23 16:17   ` Thomas Monjalon
2016-12-23 16:20     ` Jan Blunck

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=1482508691-11408-11-git-send-email-jblunck@infradead.org \
    --to=jblunck@infradead.org \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=shreyansh.jain@nxp.com \
    --cc=stephen@networkplumber.org \
    /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).