From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DC88CA2EDB for ; Fri, 6 Sep 2019 05:33:33 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0B6A81F0D4; Fri, 6 Sep 2019 05:33:33 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 2A3051F0B2 for ; Fri, 6 Sep 2019 05:33:30 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2019 20:33:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,472,1559545200"; d="scan'208";a="383123521" Received: from dpdk-dipei.sh.intel.com ([10.67.110.224]) by fmsmga005.fm.intel.com with ESMTP; 05 Sep 2019 20:33:28 -0700 From: Andy Pei To: dev@dpdk.org Cc: rosen.xu@intel.com, xiaolong.ye@intel.com, tiwei.bie@intel.com, xiao.w.wang@intel.com Date: Fri, 6 Sep 2019 11:20:48 +0800 Message-Id: <1567740051-367172-1-git-send-email-andy.pei@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH 1/4] vhost: introduce new API to get the active vring number 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" It's useful for hardware vhost backend (like vDPA devices) to set multiqueue configuration accordingly. Signed-off-by: Xiaolong Ye Signed-off-by: Andy Pei --- lib/librte_vhost/rte_vhost.h | 12 ++++++++++++ lib/librte_vhost/vhost.c | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/librte_vhost/rte_vhost.h b/lib/librte_vhost/rte_vhost.h index 7fb1729..28811b0 100644 --- a/lib/librte_vhost/rte_vhost.h +++ b/lib/librte_vhost/rte_vhost.h @@ -525,6 +525,18 @@ int rte_vhost_driver_callback_register(const char *path, uint16_t rte_vhost_get_vring_num(int vid); /** + * Get the number of active vrings of the device. + * + * @param vid + * vhost device ID + * + * @return + * The number of active vrings, 0 on failure + */ +uint16_t +rte_vhost_get_active_vring_num(int vid); + +/** * Get the virtio net device's ifname, which is the vhost-user socket * file path. * diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 981837b..c714818 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -674,6 +674,25 @@ return dev->nr_vring; } +uint16_t +rte_vhost_get_active_vring_num(int vid) +{ + struct virtio_net *dev = get_device(vid); + struct vhost_virtqueue *vq; + uint16_t qid; + + if (dev == NULL) + return 0; + + for (qid = 0; qid < dev->nr_vring; qid++) { + vq = dev->virtqueue[qid]; + if (!vq->enabled) + break; + } + + return qid; +} + int rte_vhost_get_ifname(int vid, char *buf, size_t len) { -- 1.8.3.1