From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id D7ED3F932 for ; Tue, 17 Jan 2017 03:30:17 +0100 (CET) Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 08564C057FAC; Tue, 17 Jan 2017 02:30:18 +0000 (UTC) Received: from [10.72.6.29] (vpn1-6-29.pek2.redhat.com [10.72.6.29]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0H2UCCW002179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 16 Jan 2017 21:30:15 -0500 To: Jianfeng Tan , dev@dpdk.org References: <1480810702-114815-1-git-send-email-jianfeng.tan@intel.com> <1484578022-92705-1-git-send-email-jianfeng.tan@intel.com> <1484578022-92705-6-git-send-email-jianfeng.tan@intel.com> Cc: yuanhan.liu@linux.intel.com, stephen@networkplumber.org, lei.a.yao@intel.com From: Jason Wang Message-ID: Date: Tue, 17 Jan 2017 10:30:10 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: <1484578022-92705-6-git-send-email-jianfeng.tan@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 17 Jan 2017 02:30:18 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH v3 05/10] net/virtio: add Rx queue intr enable/disable functions 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: Tue, 17 Jan 2017 02:30:18 -0000 On 2017年01月16日 22:46, Jianfeng Tan wrote: > This patch implements interrupt enable/disable functions for each > Rx queue. And we rely on flags of avail queue as the hint for virtio > device to interrupt virtio driver or not. > > Signed-off-by: Jianfeng Tan > --- > drivers/net/virtio/virtio_ethdev.c | 22 ++++++++++++++++++++++ > drivers/net/virtio/virtqueue.c | 11 ----------- > drivers/net/virtio/virtqueue.h | 16 +++++++++++++++- > 3 files changed, 37 insertions(+), 12 deletions(-) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index bec2be2..4224d17 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -717,6 +717,26 @@ virtio_mtu_set(struct rte_eth_dev *dev, uint16_t mtu) > return 0; > } > > +static int > +virtio_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id) > +{ > + struct virtnet_rx *rxvq = dev->data->rx_queues[queue_id]; > + struct virtqueue *vq = rxvq->vq; > + > + virtqueue_enable_intr(vq); > + return 0; > +} > + > +static int > +virtio_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id) > +{ > + struct virtnet_rx *rxvq = dev->data->rx_queues[queue_id]; > + struct virtqueue *vq = rxvq->vq; > + > + virtqueue_disable_intr(vq); > + return 0; > +} > + > /* > * dev_ops for virtio, bare necessities for basic operation > */ > @@ -738,6 +758,8 @@ static const struct eth_dev_ops virtio_eth_dev_ops = { > .xstats_reset = virtio_dev_stats_reset, > .link_update = virtio_dev_link_update, > .rx_queue_setup = virtio_dev_rx_queue_setup, > + .rx_queue_intr_enable = virtio_dev_rx_queue_intr_enable, > + .rx_queue_intr_disable = virtio_dev_rx_queue_intr_disable, > .rx_queue_release = virtio_dev_queue_release, > .rx_descriptor_done = virtio_dev_rx_queue_done, > .tx_queue_setup = virtio_dev_tx_queue_setup, > diff --git a/drivers/net/virtio/virtqueue.c b/drivers/net/virtio/virtqueue.c > index 7f60e3e..9ad77b8 100644 > --- a/drivers/net/virtio/virtqueue.c > +++ b/drivers/net/virtio/virtqueue.c > @@ -38,17 +38,6 @@ > #include "virtio_logs.h" > #include "virtio_pci.h" > > -void > -virtqueue_disable_intr(struct virtqueue *vq) > -{ > - /* > - * Set VRING_AVAIL_F_NO_INTERRUPT to hint host > - * not to interrupt when it consumes packets > - * Note: this is only considered a hint to the host > - */ > - vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; > -} > - > /* > * Two types of mbuf to be cleaned: > * 1) mbuf that has been consumed by backend but not used by virtio. > diff --git a/drivers/net/virtio/virtqueue.h b/drivers/net/virtio/virtqueue.h > index b1070e0..f9e3736 100644 > --- a/drivers/net/virtio/virtqueue.h > +++ b/drivers/net/virtio/virtqueue.h > @@ -274,7 +274,21 @@ vring_desc_init(struct vring_desc *dp, uint16_t n) > /** > * Tell the backend not to interrupt us. > */ > -void virtqueue_disable_intr(struct virtqueue *vq); > +static inline void > +virtqueue_disable_intr(struct virtqueue *vq) > +{ > + vq->vq_ring.avail->flags |= VRING_AVAIL_F_NO_INTERRUPT; > +} I think we'd better consider to implement even index in the future. Thanks > + > +/** > + * Tell the backend to interrupt us. > + */ > +static inline void > +virtqueue_enable_intr(struct virtqueue *vq) > +{ > + vq->vq_ring.avail->flags &= (~VRING_AVAIL_F_NO_INTERRUPT); > +} > + > /** > * Dump virtqueue internal structures, for debug purpose only. > */