All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: virtualization@lists.linux.dev, jasowang@redhat.com,
	xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
	parav@nvidia.com, feliu@nvidia.com, hengqi@linux.alibaba.com
Subject: Re: [PATCH virtio 04/19] virtio: introduce virtio_queue_info struct and find_vqs_info() config op
Date: Wed, 3 Jul 2024 09:02:58 -0400	[thread overview]
Message-ID: <20240703085123-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20240703123913.969202-5-jiri@resnulli.us>

On Wed, Jul 03, 2024 at 02:38:58PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> Introduce a structure virtio_queue_info to carry name, callback and ctx
> together. In order to allow config implementations to accept config op
> with array of virtio_queue_info structures, introduce a new
> find_vqs_info() op. Do the needed conversion in virtio_find_vqs_ctx().
> Note that whole virtio_find_vqs_ctx() is going to be eventually removed
> at the and of this patchset.
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
>  include/linux/virtio_config.h | 51 ++++++++++++++++++++++++++++++++---
>  1 file changed, 48 insertions(+), 3 deletions(-)
> 
> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
> index 82a1d798b2f1..21029afeede1 100644
> --- a/include/linux/virtio_config.h
> +++ b/include/linux/virtio_config.h
> @@ -18,6 +18,16 @@ struct virtio_shm_region {
>  
>  typedef void vq_callback_t(struct virtqueue *);
>  
> +struct virtio_queue_info {

I'd do virtio_queue_info -> virtqueue_info

linux$ git grep virtqueue_|wc -l
734
linux$ git grep virtio_queue_|wc -l
7



> +	const char *name; /* mainly for debugging, may be NULL for vq

Capital M pls.
vq -> a virtqueue

> +			   * unused by driver.
> +			   */
> +	vq_callback_t *callback; /* May be NULL for vq that do

do -> does

> +				  * not need a callback.
> +				  */


        /*
         * Use this style for comments
	 * which do not fit on one line, please.
         */
	int and_the_code_comes_here_afterwards;



	
> +	bool ctx;
> +};
> +
>  /**
>   * struct virtio_config_ops - operations for configuring a virtio device
>   * Note: Do not assume that a transport implements all of the operations
> @@ -58,6 +68,12 @@ typedef void vq_callback_t(struct virtqueue *);
>   *	names: array of virtqueue names (mainly for debugging)
>   *		include a NULL entry for vqs unused by driver
>   *	Returns 0 on success or error status
> + * @find_vqs_info: find virtqueues and instantiate them.
> + *	vdev: the virtio_device
> + *	nvqs: the number of virtqueues to find
> + *	vqs: on success, includes new virtqueues
> + *	vqs_info: array of virtqueue info structures

See, here you actually said "virtqueue info"

> + *	Returns 0 on success or error status
>   * @del_vqs: free virtqueues found by find_vqs().
>   * @synchronize_cbs: synchronize with the virtqueue callbacks (optional)
>   *      The function guarantees that all memory operations on the
> @@ -109,6 +125,10 @@ struct virtio_config_ops {
>  			struct virtqueue *vqs[], vq_callback_t *callbacks[],
>  			const char * const names[], const bool *ctx,
>  			struct irq_affinity *desc);
> +	int (*find_vqs_info)(struct virtio_device *vdev, unsigned int nvqs,
> +			     struct virtqueue *vqs[],
> +			     struct virtio_queue_info vqs_info[],
> +			     struct irq_affinity *desc);
>  	void (*del_vqs)(struct virtio_device *);
>  	void (*synchronize_cbs)(struct virtio_device *);
>  	u64 (*get_features)(struct virtio_device *vdev);
> @@ -117,7 +137,7 @@ struct virtio_config_ops {
>  	int (*set_vq_affinity)(struct virtqueue *vq,
>  			       const struct cpumask *cpu_mask);
>  	const struct cpumask *(*get_vq_affinity)(struct virtio_device *vdev,
> -			int index);
> +						 int index);
>  	bool (*get_shm_region)(struct virtio_device *vdev,
>  			       struct virtio_shm_region *region, u8 id);
>  	int (*disable_vq_and_reset)(struct virtqueue *vq);
> @@ -210,14 +230,39 @@ static inline bool virtio_has_dma_quirk(const struct virtio_device *vdev)
>  	return !virtio_has_feature(vdev, VIRTIO_F_ACCESS_PLATFORM);
>  }
>  
> +static inline
> +int virtio_find_vqs_info(struct virtio_device *vdev, unsigned int nvqs,
> +			 struct virtqueue *vqs[],
> +			 struct virtio_queue_info vqs_info[],
> +			 struct irq_affinity *desc)
> +{
> +	return vdev->config->find_vqs_info(vdev, nvqs, vqs, vqs_info, desc);
> +}
> +
>  static inline
>  int virtio_find_vqs_ctx(struct virtio_device *vdev, unsigned nvqs,
>  			struct virtqueue *vqs[], vq_callback_t *callbacks[],
>  			const char * const names[], const bool *ctx,
>  			struct irq_affinity *desc)
>  {
> -	return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks, names, ctx,
> -				      desc);
> +	struct virtio_queue_info *vqs_info;
> +	int err, i;
> +
> +	if (!vdev->config->find_vqs_info)
> +		return vdev->config->find_vqs(vdev, nvqs, vqs, callbacks,
> +					      names, ctx, desc);
> +
> +	vqs_info = kmalloc_array(nvqs, sizeof(*vqs_info), GFP_KERNEL);
> +	if (!vqs_info)
> +		return -ENOMEM;
> +	for (i = 0; i < nvqs; i++) {
> +		vqs_info[i].name = names[i];
> +		vqs_info[i].callback = callbacks[i];
> +		vqs_info[i].ctx = ctx ? ctx[i] : false;
> +	}
> +	err = virtio_find_vqs_info(vdev, nvqs, vqs, vqs_info, desc);
> +	kfree(vqs_info);
> +	return err;
>  }
>  
>  static inline
> -- 
> 2.45.2


  reply	other threads:[~2024-07-03 13:03 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 12:38 [PATCH virtio 00/19] virtio: consolidate vq info args of find_vqs() Jiri Pirko
2024-07-03 12:38 ` [PATCH virtio 01/19] caif_virtio: use virtio_find_single_vq() for single virtqueue finding Jiri Pirko
2024-07-03 12:38 ` [PATCH virtio 02/19] virtio: make virtio_find_vqs() call virtio_find_vqs_ctx() Jiri Pirko
2024-07-03 12:38 ` [PATCH virtio 03/19] virtio: make virtio_find_single_vq() call virtio_find_vqs() Jiri Pirko
2024-07-03 12:38 ` [PATCH virtio 04/19] virtio: introduce virtio_queue_info struct and find_vqs_info() config op Jiri Pirko
2024-07-03 13:02   ` Michael S. Tsirkin [this message]
2024-07-03 13:23     ` Jiri Pirko
2024-07-03 12:38 ` [PATCH virtio 05/19] virtio_pci: convert vp_*find_vqs() ops to find_vqs_info() Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 06/19] virtio: convert find_vqs() op implementations " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 07/19] virtio: call virtio_find_vqs_info() from virtio_find_single_vq() directly Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 08/19] virtio: remove the original find_vqs() op Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 09/19] virtio: rename find_vqs_info() op to find_vqs() Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 10/19] virtio_blk: convert to use virtio_find_vqs_info() Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 11/19] virtio_console: " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 12/19] virtio_crypto: " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 13/19] virtio_net: " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 14/19] scsi: virtio_scsi: " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 15/19] virtiofs: " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 16/19] virtio_balloon: " Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 17/19] virtio: convert the rest virtio_find_vqs() users to virtio_find_vqs_info() Jiri Pirko
2024-07-03 13:11   ` Michael S. Tsirkin
2024-07-03 13:22     ` Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 18/19] virtio: remove unused virtio_find_vqs() and virtio_find_vqs_ctx() helpers Jiri Pirko
2024-07-03 12:39 ` [PATCH virtio 19/19] virtio: rename virtio_find_vqs_info() to virtio_find_vqs() Jiri Pirko
2024-07-03 12:50 ` [PATCH virtio 00/19] virtio: consolidate vq info args of find_vqs() Michael S. Tsirkin
2024-07-03 13:24   ` Jiri Pirko
2024-07-03 13:37     ` Michael S. Tsirkin
2024-07-04 11:38       ` Xuan Zhuo
2024-07-04 12:39         ` Michael S. Tsirkin
2024-07-04 12:55           ` 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=20240703085123-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=eperezma@redhat.com \
    --cc=feliu@nvidia.com \
    --cc=hengqi@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.