From nobody Wed Sep 17 09:19:02 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A39CC4332F for ; Thu, 22 Dec 2022 05:02:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbiLVFCI (ORCPT ); Thu, 22 Dec 2022 00:02:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229801AbiLVFB4 (ORCPT ); Thu, 22 Dec 2022 00:01:56 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F90D6277 for ; Wed, 21 Dec 2022 21:01:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671685271; 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=rgUs5kldoyEdjYJksPr3TrwRDSigjzyb5OPBQ9Ca66Q=; b=EoDnWhdNYjVrtmy2fKsfMYyJE2N7cF2jAfHuNWGxMsIvOKhkeF9mw5IU8Ki7ay6Dk9nTZZ 6skgU6bOAG5hjEb6Ke0ZUBuvTIos+Z2rUl5+IYGA10X+qezyeF4XqUxu/iGy+rs6X1i3XD +7bepYFIjRaps23VkSghwGfgNPOpOt0= 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-619-fsVfP8CGMsWlCeS8wOnn7A-1; Thu, 22 Dec 2022 00:01:10 -0500 X-MC-Unique: fsVfP8CGMsWlCeS8wOnn7A-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 05A3D8588E4; Thu, 22 Dec 2022 05:01:10 +0000 (UTC) Received: from localhost.localdomain (ovpn-13-15.pek2.redhat.com [10.72.13.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5219D40C2064; Thu, 22 Dec 2022 05:01:06 +0000 (UTC) From: Jason Wang To: mst@redhat.com, jasowang@redhat.com Cc: sgarzare@redhat.com, eperezma@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 3/4] vdpa_sim: support vendor statistics Date: Thu, 22 Dec 2022 13:00:51 +0800 Message-Id: <20221222050052.20785-4-jasowang@redhat.com> In-Reply-To: <20221222050052.20785-1-jasowang@redhat.com> References: <20221222050052.20785-1-jasowang@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds a new config ops callback to allow individual simulator to implement the vendor stats callback. Signed-off-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 14 ++++++++++++++ drivers/vdpa/vdpa_sim/vdpa_sim.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_= sim.c index 55aaa023a6e2..ed3147f1877a 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -426,6 +426,18 @@ static int vdpasim_get_vq_state(struct vdpa_device *vd= pa, u16 idx, return 0; } =20 +static int vdpasim_get_vq_stats(struct vdpa_device *vdpa, u16 idx, + struct sk_buff *msg, + struct netlink_ext_ack *extack) +{ + struct vdpasim *vdpasim =3D vdpa_to_sim(vdpa); + + if (vdpasim->dev_attr.get_stats) + return vdpasim->dev_attr.get_stats(vdpasim, idx, + msg, extack); + return -EOPNOTSUPP; +} + static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa) { return VDPASIM_QUEUE_ALIGN; @@ -710,6 +722,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = =3D { .set_vq_ready =3D vdpasim_set_vq_ready, .get_vq_ready =3D vdpasim_get_vq_ready, .set_vq_state =3D vdpasim_set_vq_state, + .get_vendor_vq_stats =3D vdpasim_get_vq_stats, .get_vq_state =3D vdpasim_get_vq_state, .get_vq_align =3D vdpasim_get_vq_align, .get_vq_group =3D vdpasim_get_vq_group, @@ -743,6 +756,7 @@ static const struct vdpa_config_ops vdpasim_batch_confi= g_ops =3D { .set_vq_ready =3D vdpasim_set_vq_ready, .get_vq_ready =3D vdpasim_get_vq_ready, .set_vq_state =3D vdpasim_set_vq_state, + .get_vendor_vq_stats =3D vdpasim_get_vq_stats, .get_vq_state =3D vdpasim_get_vq_state, .get_vq_align =3D vdpasim_get_vq_align, .get_vq_group =3D vdpasim_get_vq_group, diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_= sim.h index 51c070a543f1..d2a08c0abad7 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.h +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h @@ -48,6 +48,9 @@ struct vdpasim_dev_attr { work_func_t work_fn; void (*get_config)(struct vdpasim *vdpasim, void *config); void (*set_config)(struct vdpasim *vdpasim, const void *config); + int (*get_stats)(struct vdpasim *vdpasim, u16 idx, + struct sk_buff *msg, + struct netlink_ext_ack *extack); }; =20 /* State of each vdpasim device */ --=20 2.25.1