From patchwork Sun Nov 20 10:05:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Blunck X-Patchwork-Id: 17101 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 74DAF5A0A; Sun, 20 Nov 2016 11:08:24 +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 A55EC558C for ; Sun, 20 Nov 2016 11:07:13 +0100 (CET) Received: by mail-wm0-f66.google.com with SMTP id m203so18247516wma.3 for ; Sun, 20 Nov 2016 02:07:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Vqsnq0DRarx5VjEXq3bCGmBdgE22ORvL4YPUXUJNE+8=; b=sxXfX0BIrv9P3QLMhpnYLifJWXN9CLipbHKqZF9VIfx2h8ONchdWSl4K0wJKKiq60g Yh2Nuv/O64BdM3sxnOjltpVPIdIg1RN/iFbr0rXo+scs7dMlJSotuQjCWcRJ7cfepLHK yKxYWuIMMBbBDMHTKMZQxmfHK1nz8urxYhcU7pDjXlZeo9vm6a++C3BpX9aDDL0ROZ11 7RNI32aAniJwY4+T/1CuhkYZ19HK/92/YWpUrHRd0JUxDDAInKyFomnl1ydMIxt+szTt MjLIU+g/5mNN9yyk6lTTqJLfgzpzelKem7PZG+s8PM6wLPyL/2X1kr65yFuHTxJj+kSQ uBmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Vqsnq0DRarx5VjEXq3bCGmBdgE22ORvL4YPUXUJNE+8=; b=E1WhMI9nIlhJ5hQp7lGePUp7VINZ10nBMpFHN/X9qbmfsMV6YK/1Z8J7rAX1ufyQjZ QjSSj1ifdAZr7sLG/djWUksUuRmS7W3W6OYRILG1e53wVzOJiyo5GFaRjioh/G7uPIgZ Qx9p22D/oEsfqhHMrNv71j9y+HYwNZKjp3qoXASkzgjqYpXUbtb1xDgqRjEoHpvWc7iU Oz1btPMxDjhy5sUMCu6JEhduG8fJ4ecbUoBQnbmcjpdsF7vv9SZi6jHDfUbbT/upypQ3 YH1NPTtjXirpPIrK1HVfnmz3dJHE37xeczaQJCw7yYowhwVkoIpd5tz7ce7o5MyNoCX4 me7w== X-Gm-Message-State: AKaTC01wkGco7JH2VSYPInWO6UUIfOdycANPUVSVnFSjE+1nLnKaeY/XYAxuxv0pR/n09g== X-Received: by 10.28.58.14 with SMTP id h14mr8085611wma.7.1479636432982; Sun, 20 Nov 2016 02:07:12 -0800 (PST) Received: from weierstrass.local.net ([91.200.110.70]) by smtp.gmail.com with ESMTPSA id d184sm13235434wmd.8.2016.11.20.02.07.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Nov 2016 02:07:12 -0800 (PST) From: Jan Blunck To: dev@dpdk.org Cc: shreyansh.jain@nxp.com Date: Sun, 20 Nov 2016 11:05:25 +0100 Message-Id: <1479636327-4166-5-git-send-email-jblunck@infradead.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1479636327-4166-1-git-send-email-jblunck@infradead.org> References: <1479636327-4166-1-git-send-email-jblunck@infradead.org> Subject: [dpdk-dev] [PATCH 5/7] virtio: Add vtpci_intr_handle() helper to get rte_intr_handle 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 --- drivers/net/virtio/virtio_ethdev.c | 12 +++++++----- drivers/net/virtio/virtio_pci.h | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 741688e..da9668e 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -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(vtpci_intr_handle(hw)) < 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_ */