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 06EDE374F for ; Tue, 23 May 2017 15:10:14 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2017 06:10:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,382,1491289200"; d="scan'208";a="104385062" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by orsmga005.jf.intel.com with ESMTP; 23 May 2017 06:10:09 -0700 Received: from irsmsx156.ger.corp.intel.com (10.108.20.68) by irsmsx105.ger.corp.intel.com (163.33.3.28) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 23 May 2017 14:10:08 +0100 Received: from irsmsx106.ger.corp.intel.com ([169.254.8.202]) by IRSMSX156.ger.corp.intel.com ([169.254.3.246]) with mapi id 14.03.0319.002; Tue, 23 May 2017 14:10:08 +0100 From: "Loftus, Ciara" To: "Wang, Zhihong" , "dev@dpdk.org" CC: "yuanhan.liu@linux.intel.com" , "Wang, Zhihong" Thread-Topic: [dpdk-dev] [PATCH] vhost: support rx_queue_count Thread-Index: AQHS0tHbos4cdK0YV0aQtJZ13vdb6qIB5IsQ Date: Tue, 23 May 2017 13:10:07 +0000 Message-ID: <74F120C019F4A64C9B78E802F6AD4CC24FA4D84F@IRSMSX106.ger.corp.intel.com> References: <1495483268-60184-1-git-send-email-zhihong.wang@intel.com> In-Reply-To: <1495483268-60184-1-git-send-email-zhihong.wang@intel.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOGJhMzJmZDgtNDA4OS00NWVjLThlZTktOGFmYzhmNTAyMDE3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE2LjUuOS4zIiwiVHJ1c3RlZExhYmVsSGFzaCI6IkFQdHE4U3FZcjlhMTZlRENsMkxhYTVxQ3d0ZUZ5TTZQYTFxXC94MzZ1blBzPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [163.33.239.180] 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 13:10:15 -0000 >=20 > This patch implements the ops rx_queue_count for vhost PMD by adding > a helper function rte_vhost_rx_queue_count in vhost lib. >=20 > The ops ops rx_queue_count gets vhost RX queue avail count and helps > to understand the queue fill level. >=20 > 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(+) >=20 > 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; > } >=20 > +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) > + 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); >=20 > +/** > + * 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; >=20 > } 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, >=20 > 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) > + return 0; > + > + if (unlikely(qid >=3D dev->nr_vring || (qid & 1) =3D=3D 0)) { I assume the '& 1' is to ensure it's a virtio txq? It might be clearer to u= se the VIRTIO_TXQ var or similar to make this clearer. > + RTE_LOG(ERR, VHOST_DATA, "(%d) %s: invalid virtqueue idx > %d.\n", > + dev->vid, __func__, qid); > + return 0; > + } > + > + vq =3D dev->virtqueue[qid]; > + if (unlikely(vq->enabled =3D=3D 0)) > + return 0; > + > + return *((volatile uint16_t *)&vq->avail->idx) - vq->last_avail_idx; > +} > -- > 2.7.4 Acked-by: Ciara Loftus