DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Ouyang Changchun <changchun.ouyang@intel.com>
Cc: dev@dpdk.org
Subject: [dpdk-dev] [RFC 09/10] virtio: fix how states are handled during initialization
Date: Mon, 25 Aug 2014 19:07:55 -0700	[thread overview]
Message-ID: <20140826020856.221149388@networkplumber.org> (raw)
In-Reply-To: <20140826020746.062748014@networkplumber.org>

[-- Attachment #1: virtio-state.patch --]
[-- Type: text/plain, Size: 3987 bytes --]

Change order of initialiazation to match Linux kernel.
Don't blow away control queue by doing reset when stopped.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>


---
 lib/librte_pmd_virtio/virtio_ethdev.c |   50 ++++++++++------------------------
 lib/librte_pmd_virtio/virtio_rxtx.c   |    2 +
 2 files changed, 18 insertions(+), 34 deletions(-)

--- a/lib/librte_pmd_virtio/virtio_ethdev.c	2014-08-25 19:00:11.062556360 -0700
+++ b/lib/librte_pmd_virtio/virtio_ethdev.c	2014-08-25 19:00:12.122562032 -0700
@@ -394,9 +394,11 @@ virtio_dev_cq_queue_setup(struct rte_eth
 static void
 virtio_dev_close(struct rte_eth_dev *dev)
 {
-	PMD_INIT_LOG(DEBUG, "virtio_dev_close");
+	struct virtio_hw *hw = dev->data->dev_private;
 
-	virtio_dev_stop(dev);
+	vtpci_irq_config(hw, VIRTIO_MSI_NO_VECTOR);
+	vtpci_reset(hw);
+	virtio_dev_free_mbufs(dev);
 }
 
 /*
@@ -811,6 +813,9 @@ eth_virtio_dev_init(__rte_unused struct
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY)
 		return 0;
 
+	/* Tell the host we've noticed this device. */
+	vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
+
 	pci_dev = eth_dev->pci_dev;
 	if (virtio_resource_init(pci_dev) < 0)
 		return -1;
@@ -821,9 +826,6 @@ eth_virtio_dev_init(__rte_unused struct
 	/* Reset the device although not necessary at startup */
 	vtpci_reset(hw);
 
-	/* Tell the host we've noticed this device. */
-	vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
-
 	/* Tell the host we've known how to drive the device. */
 	vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
 	virtio_negotiate_features(hw);
@@ -912,6 +914,9 @@ eth_virtio_dev_init(__rte_unused struct
 	/* Setup interrupt callback  */
 	rte_intr_callback_register(&pci_dev->intr_handle,
 				   virtio_interrupt_handler, eth_dev);
+
+	virtio_dev_cq_start(eth_dev);
+
 	return 0;
 }
 
@@ -982,19 +987,8 @@ virtio_dev_configure(struct rte_eth_dev
 static int
 virtio_dev_start(struct rte_eth_dev *dev)
 {
-	uint16_t nb_queues, i;
 	struct virtio_hw *hw = dev->data->dev_private;
-
-	/* Tell the host we've noticed this device. */
-	vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_ACK);
-
-	/* Tell the host we've known how to drive the device. */
-	vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
-
-	virtio_dev_cq_start(dev);
-
-	/* Do final configuration before rx/tx engine starts */
-	virtio_dev_rxtx_start(dev);
+	uint16_t nb_queues;
 
 	/* check if lsc interrupt feature is enabled */
 	if (dev->data->dev_conf.intr_conf.lsc) {
@@ -1024,18 +1018,8 @@ virtio_dev_start(struct rte_eth_dev *dev
 			return -EINVAL;
 	}
 
-	PMD_INIT_LOG(DEBUG, "nb_queues=%d", nb_queues);
-
-	for (i = 0; i < nb_queues; i++)
-		virtqueue_notify(dev->data->rx_queues[i]);
-
-	PMD_INIT_LOG(DEBUG, "Notified backend at initialization");
-
-	for (i = 0; i < dev->data->nb_rx_queues; i++)
-		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]);
-
-	for (i = 0; i < dev->data->nb_tx_queues; i++)
-		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->tx_queues[i]);
+	/* Do final configuration before rx/tx engine starts */
+	virtio_dev_rxtx_start(dev);
 
 	return 0;
 }
@@ -1089,12 +1073,10 @@ static void virtio_dev_free_mbufs(struct
 static void
 virtio_dev_stop(struct rte_eth_dev *dev)
 {
-	struct virtio_hw *hw = dev->data->dev_private;
+	if (dev->data->dev_conf.intr_conf.lsc)
+		rte_intr_disable(&dev->pci_dev->intr_handle);
 
-	/* reset the NIC */
-	vtpci_irq_config(hw, 0);
-	vtpci_reset(hw);
-	virtio_dev_free_mbufs(dev);
+	memset(&dev->data->dev_link, 0, sizeof(struct rte_eth_link));
 }
 
 static int
--- a/lib/librte_pmd_virtio/virtio_rxtx.c	2014-08-25 19:00:11.062556360 -0700
+++ b/lib/librte_pmd_virtio/virtio_rxtx.c	2014-08-25 19:00:11.062556360 -0700
@@ -350,6 +350,8 @@ virtio_dev_rxtx_start(struct rte_eth_dev
 	for (i = 0; i < dev->data->nb_rx_queues; i++) {
 		virtio_dev_vring_start(dev->data->rx_queues[i], VTNET_RQ);
 		VIRTQUEUE_DUMP((struct virtqueue *)dev->data->rx_queues[i]);
+
+		virtqueue_notify(dev->data->rx_queues[i]);
 	}
 
 	/* Start tx vring. */

  parent reply	other threads:[~2014-08-26  2:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-26  2:07 [dpdk-dev] [RFC 00/10] virtio patches Stephen Hemminger
2014-08-26  2:07 ` [dpdk-dev] [RFC 01/10] virtio: rearrange resource initialization Stephen Hemminger
2014-08-26  7:14   ` Ouyang, Changchun
2014-08-26  2:07 ` [dpdk-dev] [RFC 02/10] virtio: use weak barriers Stephen Hemminger
2014-08-26  2:07 ` [dpdk-dev] [RFC 03/10] virtio: allow starting with link down Stephen Hemminger
2014-08-26  2:07 ` [dpdk-dev] [RFC 04/10] virtio: add support for Link State interrupt Stephen Hemminger
2014-08-26  2:07 ` [dpdk-dev] [RFC 05/10] ether: add soft vlan encap/decap functions Stephen Hemminger
2014-08-26  2:07 ` [dpdk-dev] [RFC 06/10] virtio: use software vlan stripping Stephen Hemminger
2014-08-26  8:37   ` Ouyang, Changchun
2014-08-26 16:24     ` Stephen Hemminger
2014-08-27  5:42       ` Ouyang, Changchun
2014-08-27 18:04         ` Stephen Hemminger
2014-08-26  2:07 ` [dpdk-dev] [RFC 07/10] virtio: remove unnecessary adapter structure Stephen Hemminger
2014-08-26  6:43   ` Ouyang, Changchun
2014-08-26  2:07 ` [dpdk-dev] [RFC 08/10] virtio: remove redundant vq_alignment Stephen Hemminger
2014-08-26  8:41   ` Ouyang, Changchun
2014-08-26  2:07 ` Stephen Hemminger [this message]
2014-08-26  2:07 ` [dpdk-dev] [RFC 10/10] virtio: add support for promiscious and multicast Stephen Hemminger
2014-08-26  6:55   ` Ouyang, Changchun

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=20140826020856.221149388@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=changchun.ouyang@intel.com \
    --cc=dev@dpdk.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).