Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FCB3C43331 for ; Fri, 6 Sep 2019 03:33:34 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 2C5E0206B8 for ; Fri, 6 Sep 2019 03:33:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2C5E0206B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org 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