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 CECD2A04FF; Thu, 24 Mar 2022 13:47:10 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 881834283F; Thu, 24 Mar 2022 13:46:54 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 77D6E42839 for ; Thu, 24 Mar 2022 13:46:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648126013; 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=Oej7xKPEY/fBSrVyhUV8IBfUJvzn7NWbDhuU3QizcB0=; b=RFIDCzHiVQ6jwcZt0vciI5mjIkkfpwbp/dctgut3bJaBMu7TwScJho+tlDZiEbG7kFvfDv KXxEz1bowEGFduK0NuHySBIcFD5i27vpIvymOhOdNz7wvHEZGmnb6h6lso8jg+bweT18Zs EZQX+VnpABtGCIUyskp1vMCF5pua0n4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-451-wXva82sDP36m5x8GFnRGbQ-1; Thu, 24 Mar 2022 08:46:49 -0400 X-MC-Unique: wXva82sDP36m5x8GFnRGbQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5FE8A1044565; Thu, 24 Mar 2022 12:46:49 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64E7540CFD07; Thu, 24 Mar 2022 12:46:48 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com, i.maximets@ovn.org Cc: Maxime Coquelin Subject: [PATCH v2 4/5] vhost: add statistics for guest notifications Date: Thu, 24 Mar 2022 13:46:37 +0100 Message-Id: <20220324124638.32672-5-maxime.coquelin@redhat.com> In-Reply-To: <20220324124638.32672-1-maxime.coquelin@redhat.com> References: <20220324124638.32672-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 This patch adds a new virtqueue statistic for guest notifications. It is useful to deduce from hypervisor side whether the corresponding guest Virtio device is using Kernel Virtio-net driver or DPDK Virtio PMD. Signed-off-by: Maxime Coquelin --- lib/vhost/vhost.c | 1 + lib/vhost/vhost.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 80ed024019..58b58fc40e 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -42,6 +42,7 @@ static const struct vhost_vq_stats_name_off vhost_vq_stat_strings[] = { {"size_512_1023_packets", offsetof(struct vhost_virtqueue, stats.size_bins[5])}, {"size_1024_1518_packets", offsetof(struct vhost_virtqueue, stats.size_bins[6])}, {"size_1519_max_packets", offsetof(struct vhost_virtqueue, stats.size_bins[7])}, + {"guest_notifications", offsetof(struct vhost_virtqueue, stats.guest_notifications)}, }; #define VHOST_NB_VQ_STATS RTE_DIM(vhost_vq_stat_strings) diff --git a/lib/vhost/vhost.h b/lib/vhost/vhost.h index 01b97011aa..13c5c2266d 100644 --- a/lib/vhost/vhost.h +++ b/lib/vhost/vhost.h @@ -133,6 +133,7 @@ struct virtqueue_stats { uint64_t broadcast; /* Size bins in array as RFC 2819, undersized [0], 64 [1], etc */ uint64_t size_bins[8]; + uint64_t guest_notifications; }; /** @@ -871,6 +872,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq) (vq->callfd >= 0)) || unlikely(!signalled_used_valid)) { eventfd_write(vq->callfd, (eventfd_t) 1); + if (dev->flags & VIRTIO_DEV_STATS_ENABLED) + vq->stats.guest_notifications++; if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified(dev->vid); } @@ -879,6 +882,8 @@ vhost_vring_call_split(struct virtio_net *dev, struct vhost_virtqueue *vq) if (!(vq->avail->flags & VRING_AVAIL_F_NO_INTERRUPT) && (vq->callfd >= 0)) { eventfd_write(vq->callfd, (eventfd_t)1); + if (dev->flags & VIRTIO_DEV_STATS_ENABLED) + vq->stats.guest_notifications++; if (dev->notify_ops->guest_notified) dev->notify_ops->guest_notified(dev->vid); } -- 2.35.1