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 BC84D2C24 for ; Tue, 23 May 2017 13:53:37 +0200 (CEST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB36080C0B; Tue, 23 May 2017 11:53:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EB36080C0B Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jfreiman@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EB36080C0B Received: from localhost (dhcp-192-218.str.redhat.com [10.33.192.218]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74B5B7FCEC; Tue, 23 May 2017 11:53:36 +0000 (UTC) Date: Tue, 23 May 2017 13:53:35 +0200 From: Jens Freimann To: Zhihong Wang Cc: dev@dpdk.org, yuanhan.liu@linux.intel.com Message-ID: <20170523115335.gtykyluswrsjuls3@dhcp-192-218.str.redhat.com> References: <1495483268-60184-1-git-send-email-zhihong.wang@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1495483268-60184-1-git-send-email-zhihong.wang@intel.com> User-Agent: NeoMutt/20170428 (1.8.2) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 23 May 2017 11:53:37 +0000 (UTC) Subject: Re: [dpdk-dev] [PATCH] vhost: support rx_queue_count 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, 23 May 2017 11:53:38 -0000 On Mon, May 22, 2017 at 04:01:08PM -0400, Zhihong Wang wrote: > This patch implements the ops rx_queue_count for vhost PMD by adding > a helper function rte_vhost_rx_queue_count in vhost lib. > > The ops ops rx_queue_count gets vhost RX queue avail count and helps s/ops ops/ops/ ? > to understand the queue fill level. > > Signed-off-by: Zhihong Wang > --- > drivers/net/vhost/rte_eth_vhost.c | 13 +++++++++++++ > lib/librte_vhost/rte_vhost.h | 12 ++++++++++++ > lib/librte_vhost/rte_vhost_version.map | 7 +++++++ > lib/librte_vhost/vhost.c | 23 +++++++++++++++++++++++ > 4 files changed, 55 insertions(+) > > diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c > index 257bf6d..e3a3fe0 100644 > --- a/drivers/net/vhost/rte_eth_vhost.c > +++ b/drivers/net/vhost/rte_eth_vhost.c > @@ -973,6 +973,18 @@ eth_link_update(struct rte_eth_dev *dev __rte_unused, > return 0; > } > > +static uint32_t > +eth_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id) > +{ > + struct vhost_queue *vq; > + > + vq = dev->data->rx_queues[rx_queue_id]; > + if (!vq) nitpick, but it should be "if (vq == NULL" according to the coding style guide > + return 0; > + > + return rte_vhost_rx_queue_count(vq->vid, vq->virtqueue_id); > +} > + > static const struct eth_dev_ops ops = { > .dev_start = eth_dev_start, > .dev_stop = eth_dev_stop, > @@ -984,6 +996,7 @@ static const struct eth_dev_ops ops = { > .rx_queue_release = eth_queue_release, > .tx_queue_release = eth_queue_release, > .tx_done_cleanup = eth_tx_done_cleanup, > + .rx_queue_count = eth_rx_queue_count, > .link_update = eth_link_update, > .stats_get = eth_stats_get, > .stats_reset = eth_stats_reset, > diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h > index 605e47c..f64ed20 100644 > --- a/lib/librte_vhost/rte_vhost.h > +++ b/lib/librte_vhost/rte_vhost.h > @@ -432,6 +432,18 @@ int rte_vhost_get_mem_table(int vid, struct rte_vhost_memory **mem); > int rte_vhost_get_vhost_vring(int vid, uint16_t vring_idx, > struct rte_vhost_vring *vring); > > +/** > + * Get vhost RX queue avail count. > + * > + * @param vid > + * vhost device ID > + * @param qid > + * virtio queue index in mq case > + * @return > + * num of desc available > + */ > +uint32_t rte_vhost_rx_queue_count(int vid, uint16_t qid); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_vhost/rte_vhost_version.map b/lib/librte_vhost/rte_vhost_version.map > index 0785873..1e70495 100644 > --- a/lib/librte_vhost/rte_vhost_version.map > +++ b/lib/librte_vhost/rte_vhost_version.map > @@ -45,3 +45,10 @@ DPDK_17.05 { > rte_vhost_log_write; > > } DPDK_16.07; > + > +DPDK_17.08 { > + global: > + > + rte_vhost_rx_queue_count; > + > +} DPDK_17.05; > diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c > index 0b19d2e..140d2ae 100644 > --- a/lib/librte_vhost/vhost.c > +++ b/lib/librte_vhost/vhost.c > @@ -475,3 +475,26 @@ rte_vhost_log_used_vring(int vid, uint16_t vring_idx, > > vhost_log_used_vring(dev, vq, offset, len); > } > + > +uint32_t > +rte_vhost_rx_queue_count(int vid, uint16_t qid) > +{ > + struct virtio_net *dev; > + struct vhost_virtqueue *vq; > + > + dev = get_device(vid); > + if (!dev) same here > + return 0; > + > + if (unlikely(qid >= dev->nr_vring || (qid & 1) == 0)) { > + RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx %d.\n", > + dev->vid, __func__, qid); > + return 0; > + } > + > + vq = dev->virtqueue[qid]; check for vq == NULL? regards, Jens