From: Jiri Pirko <jiri@resnulli.us>
To: virtualization@lists.linux.dev
Cc: mst@redhat.com, jasowang@redhat.com, xuanzhuo@linux.alibaba.com,
eperezma@redhat.com, parav@nvidia.com, feliu@nvidia.com,
hengqi@linux.alibaba.com
Subject: [PATCH virtio v4 16/19] virtio_balloon: convert to use virtio_find_vqs_info()
Date: Mon, 8 Jul 2024 09:48:11 +0200 [thread overview]
Message-ID: <20240708074814.1739223-17-jiri@resnulli.us> (raw)
In-Reply-To: <20240708074814.1739223-1-jiri@resnulli.us>
From: Jiri Pirko <jiri@nvidia.com>
Instead of passing separate names and callbacks arrays
to virtio_find_vqs(), have one of virtual_queue_info structs and
pass it to virtio_find_vqs_info().
Suggested-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
v1->v2:
- s/virtio_queue_info/virtqueue_info/
---
drivers/virtio/virtio_balloon.c | 34 +++++++++++++--------------------
1 file changed, 13 insertions(+), 21 deletions(-)
diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
index 9a61febbd2f7..cfa710abf441 100644
--- a/drivers/virtio/virtio_balloon.c
+++ b/drivers/virtio/virtio_balloon.c
@@ -560,9 +560,8 @@ static void update_balloon_size_func(struct work_struct *work)
static int init_vqs(struct virtio_balloon *vb)
{
+ struct virtqueue_info vqs_info[VIRTIO_BALLOON_VQ_MAX] = {};
struct virtqueue *vqs[VIRTIO_BALLOON_VQ_MAX];
- vq_callback_t *callbacks[VIRTIO_BALLOON_VQ_MAX];
- const char *names[VIRTIO_BALLOON_VQ_MAX];
int err;
/*
@@ -570,33 +569,26 @@ static int init_vqs(struct virtio_balloon *vb)
* will be NULL if the related feature is not enabled, which will
* cause no allocation for the corresponding virtqueue in find_vqs.
*/
- callbacks[VIRTIO_BALLOON_VQ_INFLATE] = balloon_ack;
- names[VIRTIO_BALLOON_VQ_INFLATE] = "inflate";
- callbacks[VIRTIO_BALLOON_VQ_DEFLATE] = balloon_ack;
- names[VIRTIO_BALLOON_VQ_DEFLATE] = "deflate";
- callbacks[VIRTIO_BALLOON_VQ_STATS] = NULL;
- names[VIRTIO_BALLOON_VQ_STATS] = NULL;
- callbacks[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL;
- names[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL;
- names[VIRTIO_BALLOON_VQ_REPORTING] = NULL;
+ vqs_info[VIRTIO_BALLOON_VQ_INFLATE].callback = balloon_ack;
+ vqs_info[VIRTIO_BALLOON_VQ_INFLATE].name = "inflate";
+ vqs_info[VIRTIO_BALLOON_VQ_DEFLATE].callback = balloon_ack;
+ vqs_info[VIRTIO_BALLOON_VQ_DEFLATE].name = "deflate";
if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_STATS_VQ)) {
- names[VIRTIO_BALLOON_VQ_STATS] = "stats";
- callbacks[VIRTIO_BALLOON_VQ_STATS] = stats_request;
+ vqs_info[VIRTIO_BALLOON_VQ_STATS].name = "stats";
+ vqs_info[VIRTIO_BALLOON_VQ_STATS].callback = stats_request;
}
- if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT)) {
- names[VIRTIO_BALLOON_VQ_FREE_PAGE] = "free_page_vq";
- callbacks[VIRTIO_BALLOON_VQ_FREE_PAGE] = NULL;
- }
+ if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_FREE_PAGE_HINT))
+ vqs_info[VIRTIO_BALLOON_VQ_FREE_PAGE].name = "free_page_vq";
if (virtio_has_feature(vb->vdev, VIRTIO_BALLOON_F_REPORTING)) {
- names[VIRTIO_BALLOON_VQ_REPORTING] = "reporting_vq";
- callbacks[VIRTIO_BALLOON_VQ_REPORTING] = balloon_ack;
+ vqs_info[VIRTIO_BALLOON_VQ_REPORTING].name = "reporting_vq";
+ vqs_info[VIRTIO_BALLOON_VQ_REPORTING].callback = balloon_ack;
}
- err = virtio_find_vqs(vb->vdev, VIRTIO_BALLOON_VQ_MAX, vqs,
- callbacks, names, NULL);
+ err = virtio_find_vqs_info(vb->vdev, VIRTIO_BALLOON_VQ_MAX, vqs,
+ vqs_info, NULL);
if (err)
return err;
--
2.45.2
next prev parent reply other threads:[~2024-07-08 7:48 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 7:47 [PATCH virtio v4 00/19] virtio: consolidate vq info args of find_vqs() Jiri Pirko
2024-07-08 7:47 ` [PATCH virtio v4 01/19] caif_virtio: use virtio_find_single_vq() for single virtqueue finding Jiri Pirko
2024-07-08 7:47 ` [PATCH virtio v4 02/19] virtio: make virtio_find_vqs() call virtio_find_vqs_ctx() Jiri Pirko
2024-07-08 7:47 ` [PATCH virtio v4 03/19] virtio: make virtio_find_single_vq() call virtio_find_vqs() Jiri Pirko
2024-07-08 7:47 ` [PATCH virtio v4 04/19] virtio: introduce virtio_queue_info struct and find_vqs_info() config op Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 05/19] virtio_pci: convert vp_*find_vqs() ops to find_vqs_info() Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 06/19] virtio: convert find_vqs() op implementations " Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 07/19] virtio: call virtio_find_vqs_info() from virtio_find_single_vq() directly Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 08/19] virtio: remove the original find_vqs() op Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 09/19] virtio: rename find_vqs_info() op to find_vqs() Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 10/19] virtio_blk: convert to use virtio_find_vqs_info() Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 11/19] virtio_console: " Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 12/19] virtio_crypto: " Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 13/19] virtio_net: " Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 14/19] scsi: virtio_scsi: " Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 15/19] virtiofs: " Jiri Pirko
2024-07-08 7:48 ` Jiri Pirko [this message]
2024-07-08 7:48 ` [PATCH virtio v4 17/19] virtio: convert the rest virtio_find_vqs() users to virtio_find_vqs_info() Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 18/19] virtio: remove unused virtio_find_vqs() and virtio_find_vqs_ctx() helpers Jiri Pirko
2024-07-08 7:48 ` [PATCH virtio v4 19/19] virtio: rename virtio_find_vqs_info() to virtio_find_vqs() Jiri Pirko
2024-07-08 13:58 ` [PATCH virtio v4 00/19] virtio: consolidate vq info args of find_vqs() Michael S. Tsirkin
2024-07-09 9:48 ` Jiri Pirko
2024-07-09 9:57 ` Jiri Pirko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240708074814.1739223-17-jiri@resnulli.us \
--to=jiri@resnulli.us \
--cc=eperezma@redhat.com \
--cc=feliu@nvidia.com \
--cc=hengqi@linux.alibaba.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=parav@nvidia.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).