From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 77727374C for ; Tue, 23 May 2017 14:52:03 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2017 05:52:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,382,1491289200"; d="scan'208";a="104378261" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga005.jf.intel.com with ESMTP; 23 May 2017 05:52:02 -0700 Received: from fmsmsx114.amr.corp.intel.com (10.18.116.8) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 May 2017 05:52:00 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX114.amr.corp.intel.com (10.18.116.8) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 May 2017 05:51:59 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by shsmsx102.ccr.corp.intel.com ([169.254.2.246]) with mapi id 14.03.0319.002; Tue, 23 May 2017 20:51:57 +0800 From: "Wang, Zhihong" To: Jens Freimann CC: "dev@dpdk.org" , "yuanhan.liu@linux.intel.com" Thread-Topic: [dpdk-dev] [PATCH] vhost: support rx_queue_count Thread-Index: AQHS0tHORjPuuZeLM0yQLuDyWcgEJqIBSqqAgACWVUA= Date: Tue, 23 May 2017 12:51:56 +0000 Message-ID: <8F6C2BD409508844A0EFC19955BE09415127D9EE@SHSMSX103.ccr.corp.intel.com> References: <1495483268-60184-1-git-send-email-zhihong.wang@intel.com> <20170523115335.gtykyluswrsjuls3@dhcp-192-218.str.redhat.com> In-Reply-To: <20170523115335.gtykyluswrsjuls3@dhcp-192-218.str.redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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 12:52:04 -0000 > -----Original Message----- > From: Jens Freimann [mailto:jfreiman@redhat.com] > Sent: Tuesday, May 23, 2017 7:54 PM > To: Wang, Zhihong > Cc: dev@dpdk.org; yuanhan.liu@linux.intel.com > Subject: Re: [dpdk-dev] [PATCH] vhost: support rx_queue_count >=20 > 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 >=20 > s/ops ops/ops/ ? Thanks a lot! >=20 > > 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 =3D dev->data->rx_queues[rx_queue_id]; > > + if (!vq) >=20 > nitpick, but it should be "if (vq =3D=3D NULL" according to the coding st= yle guide >=20 > > + return 0; > > + > > + return rte_vhost_rx_queue_count(vq->vid, vq->virtqueue_id); > > +} > > + > > static const struct eth_dev_ops ops =3D { > > .dev_start =3D eth_dev_start, > > .dev_stop =3D eth_dev_stop, > > @@ -984,6 +996,7 @@ static const struct eth_dev_ops ops =3D { > > .rx_queue_release =3D eth_queue_release, > > .tx_queue_release =3D eth_queue_release, > > .tx_done_cleanup =3D eth_tx_done_cleanup, > > + .rx_queue_count =3D eth_rx_queue_count, > > .link_update =3D eth_link_update, > > .stats_get =3D eth_stats_get, > > .stats_reset =3D 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 =3D get_device(vid); > > + if (!dev) >=20 > same here >=20 > > + return 0; > > + > > + if (unlikely(qid >=3D dev->nr_vring || (qid & 1) =3D=3D 0)) { > > + RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue > idx %d.\n", > > + dev->vid, __func__, qid); > > + return 0; > > + } > > + > > + vq =3D dev->virtqueue[qid]; >=20 > check for vq =3D=3D NULL? >=20 > regards, > Jens