From mboxrd@z Thu Jan 1 00:00:00 1970 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=-14.8 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 E621FC07E95 for ; Wed, 7 Jul 2021 05:26:10 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 4556A61CB2 for ; Wed, 7 Jul 2021 05:26:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4556A61CB2 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 [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 790A7406FF; Wed, 7 Jul 2021 07:26:09 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 1D3A04069E for ; Wed, 7 Jul 2021 07:26:06 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10037"; a="206228973" X-IronPort-AV: E=Sophos;i="5.83,331,1616482800"; d="scan'208";a="206228973" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jul 2021 22:26:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,331,1616482800"; d="scan'208";a="457351114" Received: from npg_dpdk_virtio_jiayuhu_07.sh.intel.com ([10.67.119.25]) by orsmga008.jf.intel.com with ESMTP; 06 Jul 2021 22:26:04 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, Jiayu Hu Date: Wed, 7 Jul 2021 07:54:02 -0400 Message-Id: <1625658843-89612-1-git-send-email-jiayu.hu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1622646329-279450-1-git-send-email-jiayu.hu@intel.com> References: <1622646329-279450-1-git-send-email-jiayu.hu@intel.com> Subject: [dpdk-dev] [PATCH v2] vhost: allow to check in-flight packets for async vhost X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" This patch allows to check the amount of in-flight packets for vhost queues which register async channel acceleration. Signed-off-by: Jiayu Hu --- v2: * use DEBUG log level * return -1 when async is not registered doc/guides/prog_guide/vhost_lib.rst | 5 +++++ lib/vhost/rte_vhost_async.h | 14 ++++++++++++++ lib/vhost/version.map | 3 +++ lib/vhost/vhost.c | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/doc/guides/prog_guide/vhost_lib.rst b/doc/guides/prog_guide/vhost_lib.rst index d18fb98..9fdc6d5 100644 --- a/doc/guides/prog_guide/vhost_lib.rst +++ b/doc/guides/prog_guide/vhost_lib.rst @@ -281,6 +281,11 @@ The following is an overview of some key Vhost API functions: Poll enqueue completion status from async data path. Completed packets are returned to applications through ``pkts``. +* ``rte_vhost_async_get_inflight(vid, queue_id)`` + + This function returns the amount of in-flight packets by now for the + vhost queue which registers async channel acceleration. + Vhost-user Implementations -------------------------- diff --git a/lib/vhost/rte_vhost_async.h b/lib/vhost/rte_vhost_async.h index 6faa31f..553da4d 100644 --- a/lib/vhost/rte_vhost_async.h +++ b/lib/vhost/rte_vhost_async.h @@ -193,4 +193,18 @@ __rte_experimental uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id, struct rte_mbuf **pkts, uint16_t count); +/** + * This function returns the amount of in-flight packets by now + * for the vhost queue which registers async channel acceleration. + * + * @param vid + * id of vhost device to enqueue data + * @param queue_id + * queue id to enqueue data + * @return + * the amount of in-flight packets on success; -1 on failure + */ +__rte_experimental +int rte_vhost_async_get_inflight(int vid, uint16_t queue_id); + #endif /* _RTE_VHOST_ASYNC_H_ */ diff --git a/lib/vhost/version.map b/lib/vhost/version.map index 9103a23..28238cb 100644 --- a/lib/vhost/version.map +++ b/lib/vhost/version.map @@ -79,4 +79,7 @@ EXPERIMENTAL { # added in 21.05 rte_vhost_get_negotiated_protocol_features; + + # added in 21.08 + rte_vhost_async_get_inflight; }; diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 53a470f..3f82d3f 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1778,5 +1778,38 @@ int rte_vhost_async_channel_unregister(int vid, uint16_t queue_id) return ret; } +int rte_vhost_async_get_inflight(int vid, uint16_t queue_id) +{ + struct vhost_virtqueue *vq; + struct virtio_net *dev = get_device(vid); + int ret = -1; + + if (dev == NULL) + return ret; + + if (queue_id >= VHOST_MAX_VRING) + return ret; + + vq = dev->virtqueue[queue_id]; + + if (vq == NULL) + return ret; + + if (!vq->async_registered) + return ret; + + if (!rte_spinlock_trylock(&vq->access_lock)) { + VHOST_LOG_CONFIG(DEBUG, "Failed to check in-flight packets. " + "virt queue busy.\n"); + return ret; + } + + ret = vq->async_pkts_inflight_n; + rte_spinlock_unlock(&vq->access_lock); + + return ret; + +} + RTE_LOG_REGISTER_SUFFIX(vhost_config_log_level, config, INFO); RTE_LOG_REGISTER_SUFFIX(vhost_data_log_level, data, WARNING); -- 2.7.4