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 EE6CC2B9C for ; Fri, 30 Dec 2016 06:44:15 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 29 Dec 2016 21:44:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,428,1477983600"; d="scan'208";a="1105915656" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.67.162]) by fmsmga002.fm.intel.com with ESMTP; 29 Dec 2016 21:44:14 -0800 Date: Fri, 30 Dec 2016 13:46:00 +0800 From: Yuanhan Liu To: Jianfeng Tan Cc: dev@dpdk.org, stephen@networkplumber.org Message-ID: <20161230054600.GG21789@yliu-dev.sh.intel.com> References: <1482996643-113253-1-git-send-email-jianfeng.tan@intel.com> <1482996643-113253-4-git-send-email-jianfeng.tan@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1482996643-113253-4-git-send-email-jianfeng.tan@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [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: Fri, 30 Dec 2016 05:44:16 -0000 On Thu, Dec 29, 2016 at 07:30:37AM +0000, Jianfeng Tan wrote: > 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, Please keep the vertical alignment here. > .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); Such debug info should not exist only in one callback. It should be in the caller of this callback, before invoke it. > + 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, Ditto. > .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); > +} No need to introduce a wrapper for a vtpci_ops, instead, just invoke it directly. --yliu