From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f65.google.com (mail-wm0-f65.google.com [74.125.82.65]) by dpdk.org (Postfix) with ESMTP id 2B0C5379B for ; Fri, 23 Dec 2016 16:58:41 +0100 (CET) Received: by mail-wm0-f65.google.com with SMTP id c85so4111520wmi.1 for ; Fri, 23 Dec 2016 07:58:41 -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=GKsxW86LhSG73By/rttadZZdjv7jVwEn2ak6AAt4a7w=; b=fmZfruigL1EEjGGCGaIWE8OY4BLZMn+2R5hB0usMvAOtWJgRtu+3Gsxx4M9TzwD556 EB+4hzFfo+OF4Knlp2Etg7hp5J6x31gOwSj2EQOh/X2GG8Ww3AkCzezqXSv35ulAFQeT lOR2J9JDUiUzuAmgSgeMQTG4Zrm0LXay5xS6101Scf7jhlytkdTmflBbD1TPCVmb8EBH BviQSVmSz+ARk5Z50mrdj8fpaImrDiAsv0atXgSrIsOtKxdEIwK01Vh4cXp2ULVeayaj eZG/1OxWj5DrU7I28y2UfHQ9MSkLzeEoP7utJM7VtzV/ZVPAjhbGdcXwfaksZ3ZyQrXy sAWg== 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=GKsxW86LhSG73By/rttadZZdjv7jVwEn2ak6AAt4a7w=; b=UxjaGJUOGPyTBEj0Uk1/leow5Zq1Fpnsd7duLGu7fu701zOAJye4fARHaIUvpWo9Ut PG6jHEipa9W71LjVh2ouvS0p8vE9Gr4PdoAmzhgvx7/WV2GDwPvCmsVKJhgM6ighJSMR kHdZmquuQu+oF5fw5OY/8rR+Xuzr+ZR4VF+F00pX7pi3js1BbvNqGt5VKQU9wF1Tyhtj SAa7nNyQ87y09XJQ5z7KW3Zn+/yGTACbXpn/edMuKvQKGEbmNn7gtwWBrcjBMpEch7Mp a3Y5aJFsZR7G/BYiFI8jXoJgAbQIEHtAYi2vycW33iHQdWZnNPYM1KavVVt7UkrRaqtl tpOQ== X-Gm-Message-State: AIkVDXIQfrPaprLuMAw8bbBkywEJraoGPNACth5n4nWAIE77xVeu+NL37VDwGBGX6YY4QQ== X-Received: by 10.28.137.81 with SMTP id l78mr16021638wmd.36.1482508720874; Fri, 23 Dec 2016 07:58:40 -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.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Dec 2016 07:58:39 -0800 (PST) Sender: Jan Blunck 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:01 +0100 Message-Id: <1482508691-11408-11-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 10/20] 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: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Dec 2016 15:58:41 -0000 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 Acked-by: Shreyansh Jain --- drivers/net/virtio/virtio_ethdev.c | 14 ++++++++------ drivers/net/virtio/virtio_pci.h | 6 ++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 5c8afb5..80b661d 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1151,7 +1151,7 @@ virtio_negotiate_features(struct virtio_hw *hw, uint64_t req_features) * if link state changed. */ static void -virtio_interrupt_handler(__rte_unused struct rte_intr_handle *handle, +virtio_interrupt_handler(struct rte_intr_handle *handle, void *param) { struct rte_eth_dev *dev = param; @@ -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(handle) < 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_ */ -- 2.7.4