From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 6241358CF for ; Sun, 4 Dec 2016 01:17:50 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP; 03 Dec 2016 16:17:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,295,1477983600"; d="scan'208";a="13266373" Received: from dpdk06.sh.intel.com ([10.239.129.195]) by orsmga002.jf.intel.com with ESMTP; 03 Dec 2016 16:17:48 -0800 From: Jianfeng Tan To: dev@dpdk.org Cc: yuanhan.liu@linux.intel.com, stephen@networkplumber.org, Jianfeng Tan Date: Sun, 4 Dec 2016 00:18:19 +0000 Message-Id: <1480810702-114815-3-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480810702-114815-1-git-send-email-jianfeng.tan@intel.com> References: <1480810702-114815-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH 2/5] net/virtio: setup Rx fastpath interrupts 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: Sun, 04 Dec 2016 00:17:50 -0000 In virtio, each rx queue has one exclusive interrupt (corresponding to irqfd in the qemu/kvm) to get notified when packets are available in that queue. That is to say, queues cannot share interrupt. So we have 1:1 mapping between queues and interrupts. This patch creates eventfds for each Rx queue and configures the info into kernel. Signed-off-by: Jianfeng Tan --- drivers/net/virtio/virtio_ethdev.c | 42 +++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 681a86b..886524c 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1474,6 +1474,9 @@ virtio_dev_start(struct rte_eth_dev *dev) struct virtnet_rx *rxvq; struct virtnet_tx *txvq __rte_unused; struct virtio_hw *hw = dev->data->dev_private; + struct rte_intr_handle *intr_handle = &dev->pci_dev->intr_handle; + + rte_intr_disable(intr_handle); /* check if lsc interrupt feature is enabled */ if (dev->data->dev_conf.intr_conf.lsc) { @@ -1482,9 +1485,37 @@ virtio_dev_start(struct rte_eth_dev *dev) return -ENOTSUP; } - if (rte_intr_enable(&dev->pci_dev->intr_handle) < 0) { - PMD_DRV_LOG(ERR, "interrupt enable failed"); - return -EIO; + } + + if (dev->data->dev_conf.intr_conf.rxq) { + /* + * 1. uio, igb_uio, vfio (type1): lsc and rxq interrupt share + * one interrupt. + * 2. vfio (noiommu): . + */ + uint32_t intr_vector; + + if (!rte_intr_cap_multiple(intr_handle)) { + PMD_INIT_LOG(ERR, "Multiple intr vector not supported"); + return -1; + } + + intr_vector = dev->data->nb_rx_queues; + if (rte_intr_efd_enable(intr_handle, intr_vector)) { + PMD_INIT_LOG(ERR, "Fail to create eventfd"); + return -1; + } + } + + if (rte_intr_dp_is_en(intr_handle) && !intr_handle->intr_vec) { + intr_handle->intr_vec = + rte_zmalloc("intr_vec", + dev->data->nb_rx_queues * sizeof(int), + 0); + if (!intr_handle->intr_vec) { + PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues" + " intr_vec\n", dev->data->nb_rx_queues); + return -ENOMEM; } } @@ -1520,6 +1551,11 @@ virtio_dev_start(struct rte_eth_dev *dev) VIRTQUEUE_DUMP(txvq->vq); } + if (rte_intr_enable(intr_handle) < 0) { + PMD_DRV_LOG(ERR, "interrupt enable failed"); + return -EIO; + } + return 0; } -- 2.7.4