From patchwork Fri Dec 23 15:58:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Blunck X-Patchwork-Id: 18494 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 579F4F927; Fri, 23 Dec 2016 16:59:03 +0100 (CET) Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 9FD6338EB for ; Fri, 23 Dec 2016 16:58:42 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id c85so4111620wmi.1 for ; Fri, 23 Dec 2016 07:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=6Pwtjfg7m6dOnFHHgpJfnNd1ZUMD3Qgr66SlPxI4Ixs=; b=E11ZgaOMHzA4vCrbnqz6dyvLYT1Z3O96FYciy9hPY/LDhzT2GQyd+y5RJtb1K12k17 U0YtTWAhQ0hwRcleQmjDkQ7LKSFoj5OigvdLqRq33d+rJn5PNKhcQWXDzYvx8wTgoh+X aumoFMDssR9EItKAiOMZoJB/9KSOy8mIM7LQ3UEDHnKvcQvW4q+O1rsPV5CDTON8HxfE z2TXtogQFBGEVZ5dZss0whA/QyM4DV5/NjSmEbjIYriT/oz+esyw41LtbW4JoJWzZH/Z vw4jQ9cF/IK1AcrXKx7pYkbJJK0lhKEsOPEjdLfoXOu8dUJIVcR5IWRVeFx3mzKrTcXf qTRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:in-reply-to:references; bh=6Pwtjfg7m6dOnFHHgpJfnNd1ZUMD3Qgr66SlPxI4Ixs=; b=bw9kK79bU/y+kBUMQQGgG93peck3Z3STOakoqgB0XFgrW15riZ+YPdwxwZO7GGOqc4 I0OrUD45YnEvhy6u/M/6Us83k3wjpCEorklU6ulxDohOTVfcnZIsQ43fMssKrlvrRFaJ /yaK4OQLvuGgSv4SkpdWsqua17tRMmeZOptcPiox7WgfJoSbaWnj0HZQ133N996fWKRb MlSYTmJI1evO35xg11DrBQah0gBcusq3TzxgRBXLDNtuQ48tdyl9dIZhiilwKHyZISI7 7Y22mp20fPCfi6SyXjX4zu3GiYazm1dhP0FBP5tvpaEUCLq2nY/M7721/ywJL9sUnZUA /oEw== X-Gm-Message-State: AIkVDXLvVTsSYJoDqUvgPo/+F5HkmQLAYzomG/+OFkqPrYYcMkFtVY7z3APp26lHi2+PCA== X-Received: by 10.28.142.16 with SMTP id q16mr13752888wmd.35.1482508722342; Fri, 23 Dec 2016 07:58:42 -0800 (PST) Received: from weierstrass.local.net ([91.200.109.169]) by smtp.gmail.com with ESMTPSA id jm6sm41027072wjb.27.2016.12.23.07.58.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Dec 2016 07:58:41 -0800 (PST) From: Jan Blunck To: dev@dpdk.org Cc: shreyansh.jain@nxp.com, david.marchand@6wind.com, stephen@networkplumber.org Date: Fri, 23 Dec 2016 16:58:02 +0100 Message-Id: <1482508691-11408-12-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482508691-11408-1-git-send-email-jblunck@infradead.org> References: <1482508691-11408-1-git-send-email-jblunck@infradead.org> In-Reply-To: <1482332986-7599-1-git-send-email-jblunck@infradead.org> References: <1482332986-7599-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH v5 11/20] virtio: Don't depend on struct rte_eth_dev's pci_dev X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" We don't need to depend on rte_eth_dev->pci_dev to differentiate between the virtio_user and the virtio_pci case. Instead we can use the private virtio_hw struct to get that information. Signed-off-by: Jan Blunck Acked-by: Shreyansh Jain --- drivers/net/virtio/virtio_ethdev.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 80b661d..26848e4 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -483,11 +483,11 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t vtpci_queue_idx) hw->cvq = cvq; } - /* For virtio_user case (that is when dev->pci_dev is NULL), we use + /* For virtio_user case (that is when hw->dev is NULL), we use * virtual address. And we need properly set _offset_, please see * VIRTIO_MBUF_DATA_DMA_ADDR in virtqueue.h for more information. */ - if (dev->pci_dev) + if (hw->dev) vq->offset = offsetof(struct rte_mbuf, buf_physaddr); else { vq->vq_ring_mem = (uintptr_t)mz->addr; @@ -1190,7 +1190,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) 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 = eth_dev->pci_dev; + struct rte_pci_device *pci_dev = hw->dev; int ret; /* Reset the device although not necessary at startup */ @@ -1210,7 +1210,8 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) else eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC; - rte_eth_copy_pci_info(eth_dev, pci_dev); + if (pci_dev) + rte_eth_copy_pci_info(eth_dev, pci_dev); rx_func_get(eth_dev); @@ -1294,7 +1295,6 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev) { struct virtio_hw *hw = eth_dev->data->dev_private; - struct rte_pci_device *pci_dev; uint32_t dev_flags = RTE_ETH_DEV_DETACHABLE; int ret; @@ -1317,10 +1317,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) return -ENOMEM; } - pci_dev = eth_dev->pci_dev; - - if (pci_dev) { - ret = vtpci_init(pci_dev, hw, &dev_flags); + /* For virtio_user case the hw->virtio_user_dev is populated by + * virtio_user_eth_dev_alloc() before eth_virtio_dev_init() is called. + */ + if (!hw->virtio_user_dev) { + ret = vtpci_init(eth_dev->pci_dev, hw, &dev_flags); if (ret) return ret; } @@ -1343,7 +1344,6 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) 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(); @@ -1353,7 +1353,6 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) virtio_dev_stop(eth_dev); virtio_dev_close(eth_dev); - pci_dev = eth_dev->pci_dev; eth_dev->dev_ops = NULL; eth_dev->tx_pkt_burst = NULL; @@ -1367,7 +1366,8 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) rte_intr_callback_unregister(vtpci_intr_handle(hw), virtio_interrupt_handler, eth_dev); - rte_eal_pci_unmap_device(pci_dev); + if (hw->dev) + rte_eal_pci_unmap_device(hw->dev); PMD_INIT_LOG(DEBUG, "dev_uninit completed");