All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] net/virtio: access interrupt handler directly
@ 2017-01-12  6:03 Yuanhan Liu
  2017-01-12  6:03 ` [PATCH 2/2] net/virtio: do not store PCI device pointer at shared memory Yuanhan Liu
  2017-01-13 13:51 ` [PATCH 1/2] net/virtio: access interrupt handler directly Yuanhan Liu
  0 siblings, 2 replies; 3+ messages in thread
From: Yuanhan Liu @ 2017-01-12  6:03 UTC (permalink / raw)
  To: dev; +Cc: Yuanhan Liu

Since commit 0e1b45a284b4 ("ethdev: decouple interrupt handling from
PCI device"), intr_handle is stored at eth_dev struct, that we could
use it directly. Thus there is no need to get it from hw.

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 9 ++++-----
 drivers/net/virtio/virtio_pci.h    | 6 ------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 495de11..edef2a2 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -1397,7 +1397,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 
 	/* Setup interrupt callback  */
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-		rte_intr_callback_register(vtpci_intr_handle(hw),
+		rte_intr_callback_register(eth_dev->intr_handle,
 			virtio_interrupt_handler, eth_dev);
 
 	return 0;
@@ -1425,7 +1425,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 
 	/* reset interrupt callback  */
 	if (eth_dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
-		rte_intr_callback_unregister(vtpci_intr_handle(hw),
+		rte_intr_callback_unregister(eth_dev->intr_handle,
 						virtio_interrupt_handler,
 						eth_dev);
 	if (hw->dev)
@@ -1544,7 +1544,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 			return -ENOTSUP;
 		}
 
-		if (rte_intr_enable(vtpci_intr_handle(hw)) < 0) {
+		if (rte_intr_enable(dev->intr_handle) < 0) {
 			PMD_DRV_LOG(ERR, "interrupt enable failed");
 			return -EIO;
 		}
@@ -1636,13 +1636,12 @@ 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(vtpci_intr_handle(hw));
+		rte_intr_disable(dev->intr_handle);
 
 	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 38a71a4..511a1c8 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -333,12 +333,6 @@ int vtpci_init(struct rte_pci_device *, 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;
-}
-
 extern const struct virtio_pci_ops legacy_ops;
 extern const struct virtio_pci_ops modern_ops;
 extern const struct virtio_pci_ops virtio_user_ops;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] net/virtio: do not store PCI device pointer at shared memory
  2017-01-12  6:03 [PATCH 1/2] net/virtio: access interrupt handler directly Yuanhan Liu
@ 2017-01-12  6:03 ` Yuanhan Liu
  2017-01-13 13:51 ` [PATCH 1/2] net/virtio: access interrupt handler directly Yuanhan Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Yuanhan Liu @ 2017-01-12  6:03 UTC (permalink / raw)
  To: dev; +Cc: Yuanhan Liu

hw->dev, a pointer to pci_dev, was actually not used, until the
refactor of decouping from PCI device. This would somehow break
the multiple process again, since "hw" is stored at shared memory,
while "pci_dev" is not: the primary and secondary process could
have different address for it, while just one value is allowed.

Thus we should not store it to "hw", instead, we could retrieve
it from the "eth_dev->device" field.

Fixes: ae34410a8a8a ("ethdev: move info filling of PCI into drivers")
Fixes: eac901ce29be ("ethdev: decouple from PCI device")

Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
 drivers/net/virtio/virtio_ethdev.c | 16 ++++++++--------
 drivers/net/virtio/virtio_pci.c    |  2 --
 drivers/net/virtio/virtio_pci.h    |  1 -
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index edef2a2..f596f4d 100644
--- a/drivers/net/virtio/virtio_ethdev.c
+++ b/drivers/net/virtio/virtio_ethdev.c
@@ -489,7 +489,7 @@ struct rte_virtio_xstats_name_off {
 	 * virtual address. And we need properly set _offset_, please see
 	 * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information.
 	 */
-	if (hw->dev)
+	if (!hw->virtio_user_dev)
 		vq->offset = offsetof(struct rte_mbuf, buf_physaddr);
 	else {
 		vq->vq_ring_mem = (uintptr_t)mz->addr;
@@ -1194,7 +1194,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 	struct virtio_hw *hw = eth_dev->data->dev_private;
 	struct virtio_net_config *config;
 	struct virtio_net_config local_config;
-	struct rte_pci_device *pci_dev = hw->dev;
+	struct rte_pci_device *pci_dev = NULL;
 	int ret;
 
 	/* Reset the device although not necessary at startup */
@@ -1214,8 +1214,10 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 	else
 		eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
 
-	if (pci_dev)
+	if (eth_dev->device) {
+		pci_dev = RTE_DEV_TO_PCI(eth_dev->device);
 		rte_eth_copy_pci_info(eth_dev, pci_dev);
+	}
 
 	rx_func_get(eth_dev);
 
@@ -1406,8 +1408,6 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 static int
 eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev)
 {
-	struct virtio_hw *hw = eth_dev->data->dev_private;
-
 	PMD_INIT_FUNC_TRACE();
 
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
@@ -1428,8 +1428,8 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 		rte_intr_callback_unregister(eth_dev->intr_handle,
 						virtio_interrupt_handler,
 						eth_dev);
-	if (hw->dev)
-		rte_eal_pci_unmap_device(hw->dev);
+	if (eth_dev->device)
+		rte_eal_pci_unmap_device(RTE_DEV_TO_PCI(eth_dev->device));
 
 	PMD_INIT_LOG(DEBUG, "dev_uninit completed");
 
@@ -1687,7 +1687,7 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
 	uint64_t tso_mask;
 	struct virtio_hw *hw = dev->data->dev_private;
 
-	dev_info->pci_dev = hw->dev;
+	dev_info->pci_dev = dev->device ? RTE_DEV_TO_PCI(dev->device) : NULL;
 	dev_info->max_rx_queues =
 		RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES);
 	dev_info->max_tx_queues =
diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
index f5754e5..fbdb5b7 100644
--- a/drivers/net/virtio/virtio_pci.c
+++ b/drivers/net/virtio/virtio_pci.c
@@ -730,8 +730,6 @@
 vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw,
 	   uint32_t *dev_flags)
 {
-	hw->dev = dev;
-
 	/*
 	 * Try if we can succeed reading virtio pci caps, which exists
 	 * only on modern pci device. If failed, we fallback to legacy
diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h
index 511a1c8..4235bef 100644
--- a/drivers/net/virtio/virtio_pci.h
+++ b/drivers/net/virtio/virtio_pci.h
@@ -258,7 +258,6 @@ struct virtio_hw {
 	uint32_t    notify_off_multiplier;
 	uint8_t     *isr;
 	uint16_t    *notify_base;
-	struct rte_pci_device *dev;
 	struct virtio_pci_common_cfg *common_cfg;
 	struct virtio_net_config *dev_cfg;
 	void	    *virtio_user_dev;
-- 
1.9.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] net/virtio: access interrupt handler directly
  2017-01-12  6:03 [PATCH 1/2] net/virtio: access interrupt handler directly Yuanhan Liu
  2017-01-12  6:03 ` [PATCH 2/2] net/virtio: do not store PCI device pointer at shared memory Yuanhan Liu
@ 2017-01-13 13:51 ` Yuanhan Liu
  1 sibling, 0 replies; 3+ messages in thread
From: Yuanhan Liu @ 2017-01-13 13:51 UTC (permalink / raw)
  To: dev

On Thu, Jan 12, 2017 at 02:03:19PM +0800, Yuanhan Liu wrote:
> Since commit 0e1b45a284b4 ("ethdev: decouple interrupt handling from
> PCI device"), intr_handle is stored at eth_dev struct, that we could
> use it directly. Thus there is no need to get it from hw.
> 
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> ---

Both applied to dpdk-next-virtio.

	--yliu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-13 13:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-12  6:03 [PATCH 1/2] net/virtio: access interrupt handler directly Yuanhan Liu
2017-01-12  6:03 ` [PATCH 2/2] net/virtio: do not store PCI device pointer at shared memory Yuanhan Liu
2017-01-13 13:51 ` [PATCH 1/2] net/virtio: access interrupt handler directly Yuanhan Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.