From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 090873777 for ; Thu, 29 Dec 2016 08:30:08 +0100 (CET) Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP; 28 Dec 2016 23:30:08 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,425,1477983600"; d="scan'208";a="44228319" Received: from dpdk06.sh.intel.com ([10.239.129.195]) by orsmga004.jf.intel.com with ESMTP; 28 Dec 2016 23:30:07 -0800 From: Jianfeng Tan To: dev@dpdk.org Cc: yuanhan.liu@linux.intel.com, stephen@networkplumber.org, Jianfeng Tan Date: Thu, 29 Dec 2016 07:30:37 +0000 Message-Id: <1482996643-113253-4-git-send-email-jianfeng.tan@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1482996643-113253-1-git-send-email-jianfeng.tan@intel.com> References: <1480810702-114815-1-git-send-email-jianfeng.tan@intel.com> <1482996643-113253-1-git-send-email-jianfeng.tan@intel.com> Subject: [dpdk-dev] [PATCH v2 3/9] net/virtio: add PCI ops for queue/irq binding 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: Thu, 29 Dec 2016 07:30:09 -0000 Add handler in virtio_pci_ops to set queue/irq bind. Signed-off-by: Jianfeng Tan --- drivers/net/virtio/virtio_pci.c | 29 +++++++++++++++++++++++++++++ drivers/net/virtio/virtio_pci.h | 5 +++++ 2 files changed, 34 insertions(+) diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c index 9b47165..4e706cf 100644 --- a/drivers/net/virtio/virtio_pci.c +++ b/drivers/net/virtio/virtio_pci.c @@ -217,6 +217,18 @@ legacy_set_config_irq(struct virtio_hw *hw, uint16_t vec) } static uint16_t +legacy_set_queue_irq(struct virtio_hw *hw, struct virtqueue *vq, uint16_t vec) +{ + uint16_t dst; + + rte_eal_pci_ioport_write(&hw->io, &vq->vq_queue_index, 2, + VIRTIO_PCI_QUEUE_SEL); + rte_eal_pci_ioport_write(&hw->io, &vec, 2, VIRTIO_MSI_QUEUE_VECTOR); + rte_eal_pci_ioport_read(&hw->io, &dst, 2, VIRTIO_MSI_QUEUE_VECTOR); + return dst; +} + +static uint16_t legacy_get_queue_num(struct virtio_hw *hw, uint16_t queue_id) { uint16_t dst; @@ -310,6 +322,7 @@ static const struct virtio_pci_ops legacy_ops = { .set_features = legacy_set_features, .get_isr = legacy_get_isr, .set_config_irq = legacy_set_config_irq, + .set_queue_irq = legacy_set_queue_irq, .get_queue_num = legacy_get_queue_num, .setup_queue = legacy_setup_queue, .del_queue = legacy_del_queue, @@ -449,6 +462,15 @@ modern_set_config_irq(struct virtio_hw *hw, uint16_t vec) } static uint16_t +modern_set_queue_irq(struct virtio_hw *hw, struct virtqueue *vq, uint16_t vec) +{ + PMD_INIT_LOG(INFO, "vq: %u, vec: %u", vq->vq_queue_index, vec); + io_write16(vq->vq_queue_index, &hw->common_cfg->queue_select); + io_write16(vec, &hw->common_cfg->queue_msix_vector); + return io_read16(&hw->common_cfg->queue_msix_vector); +} + +static uint16_t modern_get_queue_num(struct virtio_hw *hw, uint16_t queue_id) { io_write16(queue_id, &hw->common_cfg->queue_select); @@ -526,6 +548,7 @@ static const struct virtio_pci_ops modern_ops = { .set_features = modern_set_features, .get_isr = modern_get_isr, .set_config_irq = modern_set_config_irq, + .set_queue_irq = modern_set_queue_irq, .get_queue_num = modern_get_queue_num, .setup_queue = modern_setup_queue, .del_queue = modern_del_queue, @@ -605,6 +628,12 @@ vtpci_irq_config(struct virtio_hw *hw, uint16_t vec) return hw->vtpci_ops->set_config_irq(hw, vec); } +uint16_t +vtpci_irq_queue(struct virtqueue *vq, uint16_t vec) +{ + return vq->hw->vtpci_ops->set_queue_irq(vq->hw, vq, vec); +} + static void * get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap) { diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index de271bf..d12d40f 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -235,6 +235,9 @@ struct virtio_pci_ops { uint16_t (*set_config_irq)(struct virtio_hw *hw, uint16_t vec); + uint16_t (*set_queue_irq)(struct virtio_hw *hw, struct virtqueue *vq, + uint16_t vec); + uint16_t (*get_queue_num)(struct virtio_hw *hw, uint16_t queue_id); int (*setup_queue)(struct virtio_hw *hw, struct virtqueue *vq); void (*del_queue)(struct virtio_hw *hw, struct virtqueue *vq); @@ -317,4 +320,6 @@ uint8_t vtpci_isr(struct virtio_hw *); uint16_t vtpci_irq_config(struct virtio_hw *, uint16_t); +uint16_t vtpci_irq_queue(struct virtqueue *vq, uint16_t vec); + #endif /* _VIRTIO_PCI_H_ */ -- 2.7.4