From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f169.google.com (mail-pd0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id 41C93B399 for ; Tue, 26 Aug 2014 04:05:01 +0200 (CEST) Received: by mail-pd0-f169.google.com with SMTP id y10so21565337pdj.14 for ; Mon, 25 Aug 2014 19:08:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-type:content-disposition; bh=RF/dphg1iGNb9vn/a3uSRy3QoGgDe9f8+Ujm1igUg/k=; b=eTWS9x/79BhutEecVQW4Pij1Y35vD12e2ne+sdfCrJi39qdGtnw8DCNVmB8kAxKViO OyaCySERBIaLGqPGiNY6+nTEpErnYYDQfuT0k5NJlHjADubsasIZGOO1XiakKQygWMK3 mnBYTPBwKu1fOnHt9XUysyCotBhPN1cCKofQYdkq7f1eynoa+9VAHNJb3ofz0gnVXKfL A1q+BMHNRs+Xkrt/GwBxO2OXhsp3oUkRcVjJREbIZ86zlzVK5/UF2cvA2oW75YSLMWur SdAeuTstUaF3CQo6P1e5z3IZ4FQtCeFXX8H5CdQ6JWsEdtTxzKNXfsYnQC7+Gn3GvyX0 dhEA== X-Gm-Message-State: ALoCoQmH9JsoHwVVSJ/NaPu+vn0Xq3gU3x0w5t0teHT0/eJMIKyHcHWfHkC2PM8N2NwLdDYEFaRE X-Received: by 10.70.52.199 with SMTP id v7mr20237196pdo.49.1409018938397; Mon, 25 Aug 2014 19:08:58 -0700 (PDT) Received: from localhost (static-50-53-65-80.bvtn.or.frontiernet.net. [50.53.65.80]) by mx.google.com with ESMTPSA id aq1sm1110239pbc.96.2014.08.25.19.08.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Aug 2014 19:08:57 -0700 (PDT) Message-Id: <20140826020856.221149388@networkplumber.org> User-Agent: quilt/0.63-1 Date: Mon, 25 Aug 2014 19:07:55 -0700 From: Stephen Hemminger To: Ouyang Changchun References: <20140826020746.062748014@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=virtio-state.patch Cc: dev@dpdk.org Subject: [dpdk-dev] [RFC 09/10] virtio: fix how states are handled during initialization X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2014 02:05:01 -0000 Change order of initialiazation to match Linux kernel. Don't blow away control queue by doing reset when stopped. Signed-off-by: Stephen Hemminger --- 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. */