From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9F041A0C40; Tue, 8 Jun 2021 16:30:48 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84F8F410F2; Tue, 8 Jun 2021 16:30:43 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 8FF87410F1 for ; Tue, 8 Jun 2021 16:30:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623162642; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zSOVQOHtgmAE0IZ0qcz4WH/UzTRfHDGimZeKac7tDbE=; b=NzJJGWp7PPwTkBO8fzRR0ErANr6nuJrbeg4etkHghcGFCBSUUW/zZqskDofiZ8JPbKnpix Nh3sOMUqImvR6OuaEgbqPza9FUwcIfuuR3p3fEHEtj3V7Cc5yQ8sVtw768+yQwbuxx9ot4 TMZ1jcrLLeNe7lZRgVU/OWIA0Cv6xwY= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-6bKxSN_HNW6Tbid2Z0z9Kg-1; Tue, 08 Jun 2021 10:30:41 -0400 X-MC-Unique: 6bKxSN_HNW6Tbid2Z0z9Kg-1 Received: by mail-wr1-f71.google.com with SMTP id u5-20020adf9e050000b029010df603f280so9520206wre.18 for ; Tue, 08 Jun 2021 07:30:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=zSOVQOHtgmAE0IZ0qcz4WH/UzTRfHDGimZeKac7tDbE=; b=rHI8/v5seu4SQAQbYhKLNisV2kE+axm9PXaIY5ijFd7S/uryHKOFo97fYOVtxJnrpC W97NLAOxi/J8eeniSmUJuK7cXrexHaxGpjO2TpVeykAAIUgM+Mq6TLjplxguWBqQU3Jn gMzRLasQ6b/uRTw2UjnJSOv6+qCqKzTNLyIYM9hCGX4XjBMITv63QJ4HLz9g3roibBH+ zCXEOjdwvr0V1l1KSOKkuDPVizQEAj7u+tqJDc6nQKe3/oRUnvTGMfIrjGqmBzjAvdE/ vsLM2Ks/8Rq73aydq7ctxt+1z2D91KLZCyE4XSwNe6KjATECVjHNUCBQ18926RrQQj+g KVDQ== X-Gm-Message-State: AOAM530eK8jeY7gOBRp78SuBDfL4Sht1dbXthJF51wsdgxFMliJj/8Qj A3jq9NRfiHl6DujOB+o33ImWBiv/B1BpTk/8C97CRoVhKp02iS/e10EIVKWIL9Si6ccv6Rv6lT4 q4vc= X-Received: by 2002:a7b:c24a:: with SMTP id b10mr37740wmj.1.1623162639601; Tue, 08 Jun 2021 07:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/ncbxp4z+gOW857CY0qwaPn1Kfq/XJDBuTchEJwVSuqWzWMHz5NmUVGVF+Yf96es/8Ae6RA== X-Received: by 2002:a7b:c24a:: with SMTP id b10mr37735wmj.1.1623162639278; Tue, 08 Jun 2021 07:30:39 -0700 (PDT) Received: from [192.168.1.205] (219-230-83-45.ftth.cust.kwaoo.net. [45.83.230.219]) by smtp.gmail.com with ESMTPSA id v17sm12192531wrp.36.2021.06.08.07.30.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 08 Jun 2021 07:30:38 -0700 (PDT) To: Jiayu Hu , dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com References: <1622646329-279450-1-git-send-email-jiayu.hu@intel.com> From: Maxime Coquelin Message-ID: Date: Tue, 8 Jun 2021 16:30:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1622646329-279450-1-git-send-email-jiayu.hu@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mcoqueli@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] 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" Hi Jiayu, On 6/2/21 5:05 PM, Jiayu Hu wrote: > This patch allows to check the amount of in-flight packets > for vhost queues which register async channel acceleration. > > Signed-off-by: Jiayu Hu > --- > doc/guides/prog_guide/vhost_lib.rst | 5 +++++ > lib/vhost/rte_vhost_async.h | 14 ++++++++++++++ > lib/vhost/version.map | 3 +++ > lib/vhost/vhost.c | 35 +++++++++++++++++++++++++++++++++++ > 4 files changed, 57 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 c96f633..4547705 100644 > --- a/lib/vhost/vhost.c > +++ b/lib/vhost/vhost.c > @@ -1780,5 +1780,40 @@ 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; > + > + ret = 0; > + > + if (!vq->async_registered) > + return ret; > + > + if (!rte_spinlock_trylock(&vq->access_lock)) { > + VHOST_LOG_CONFIG(ERR, "Failed to check in-flight packets. " > + "virt queue busy.\n"); Maybe better to use DEBUG log level here, as it could flood the logs. > + return -1; > + } > + > + 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); >