All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	bpf@vger.kernel.org, virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH v3 03/17] virtio: queue_reset: struct virtio_config_ops add callbacks for queue_reset
Date: Tue, 8 Feb 2022 10:58:45 +0800	[thread overview]
Message-ID: <b0debb2b-7548-c354-2128-2ddf56bf5c18@redhat.com> (raw)
In-Reply-To: <1644218386.0457659-1-xuanzhuo@linux.alibaba.com>


在 2022/2/7 下午3:19, Xuan Zhuo 写道:
> On Mon, 7 Feb 2022 14:45:02 +0800, Jason Wang <jasowang@redhat.com> wrote:
>> 在 2022/1/26 下午3:35, Xuan Zhuo 写道:
>>> Performing reset on a queue is divided into two steps:
>>>
>>> 1. reset_vq: reset one vq
>>> 2. enable_reset_vq: re-enable the reset queue
>>>
>>> In the first step, these tasks will be completed:
>>>       1. notify the hardware queue to reset
>>>       2. recycle the buffer from vq
>>>       3. release the ring of the vq
>>>
>>> The second step is similar to find vqs,
>>
>> Not sure, since find_vqs will usually try to allocate interrupts.
>>
>>
> Yes.
>
>
>>>    passing parameters callback and
>>> name, etc. Based on the original vq, the ring is re-allocated and
>>> configured to the backend.
>>
>> I wonder whether we really have such requirement.
>>
>> For example, do we really have a use case that may change:
>>
>> vq callback, ctx, ring_num or even re-create the virtqueue?
> 1. virtqueue is not recreated
> 2. ring_num can be used to modify ring num by ethtool -G


It looks to me we don't support this right now.


>
> There is really no scene to modify vq callback, ctx, name.
>
> Do you mean we still use the old one instead of adding these parameters?


Yes, I think for driver we need to implement the function that is needed 
for the first user (e.g AF_XDP). If there's no use case, we can leave 
those extension for the future.

Thanks


>
> Thanks.
>
>> Thanks
>>
>>
>>> So add two callbacks reset_vq, enable_reset_vq to struct
>>> virtio_config_ops.
>>>
>>> Add a structure for passing parameters. This will facilitate subsequent
>>> expansion of the parameters of enable reset vq.
>>> There is currently only one default extended parameter ring_num.
>>>
>>> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
>>> ---
>>>    include/linux/virtio_config.h | 43 ++++++++++++++++++++++++++++++++++-
>>>    1 file changed, 42 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
>>> index 4d107ad31149..51dd8461d1b6 100644
>>> --- a/include/linux/virtio_config.h
>>> +++ b/include/linux/virtio_config.h
>>> @@ -16,6 +16,44 @@ struct virtio_shm_region {
>>>    	u64 len;
>>>    };
>>>
>>> +typedef void vq_callback_t(struct virtqueue *);
>>> +
>>> +/* virtio_reset_vq: specify parameters for queue_reset
>>> + *
>>> + *	vdev: the device
>>> + *	queue_index: the queue index
>>> + *
>>> + *	free_unused_cb: callback to free unused bufs
>>> + *	data: used by free_unused_cb
>>> + *
>>> + *	callback: callback for the virtqueue, NULL for vq that do not need a
>>> + *	          callback
>>> + *	name: virtqueue names (mainly for debugging), NULL for vq unused by
>>> + *	      driver
>>> + *	ctx: ctx
>>> + *
>>> + *	ring_num: specify ring num for the vq to be re-enabled. 0 means use the
>>> + *	          default value. MUST be a power of 2.
>>> + */
>>> +struct virtio_reset_vq;
>>> +typedef void vq_reset_callback_t(struct virtio_reset_vq *param, void *buf);
>>> +struct virtio_reset_vq {
>>> +	struct virtio_device *vdev;
>>> +	u16 queue_index;
>>> +
>>> +	/* reset vq param */
>>> +	vq_reset_callback_t *free_unused_cb;
>>> +	void *data;
>>> +
>>> +	/* enable reset vq param */
>>> +	vq_callback_t *callback;
>>> +	const char *name;
>>> +	const bool *ctx;
>>> +
>>> +	/* ext enable reset vq param */
>>> +	u16 ring_num;
>>> +};
>>> +
>>>    /**
>>>     * virtio_config_ops - operations for configuring a virtio device
>>>     * Note: Do not assume that a transport implements all of the operations
>>> @@ -74,8 +112,9 @@ struct virtio_shm_region {
>>>     * @set_vq_affinity: set the affinity for a virtqueue (optional).
>>>     * @get_vq_affinity: get the affinity for a virtqueue (optional).
>>>     * @get_shm_region: get a shared memory region based on the index.
>>> + * @reset_vq: reset a queue individually
>>> + * @enable_reset_vq: enable a reset queue
>>>     */
>>> -typedef void vq_callback_t(struct virtqueue *);
>>>    struct virtio_config_ops {
>>>    	void (*enable_cbs)(struct virtio_device *vdev);
>>>    	void (*get)(struct virtio_device *vdev, unsigned offset,
>>> @@ -100,6 +139,8 @@ struct virtio_config_ops {
>>>    			int index);
>>>    	bool (*get_shm_region)(struct virtio_device *vdev,
>>>    			       struct virtio_shm_region *region, u8 id);
>>> +	int (*reset_vq)(struct virtio_reset_vq *param);
>>> +	struct virtqueue *(*enable_reset_vq)(struct virtio_reset_vq *param);
>>>    };
>>>
>>>    /* If driver didn't advertise the feature, it will never appear. */


WARNING: multiple messages have this Message-ID (diff)
From: Jason Wang <jasowang@redhat.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: Jesper Dangaard Brouer <hawk@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	netdev@vger.kernel.org, John Fastabend <john.fastabend@gmail.com>,
	Alexei Starovoitov <ast@kernel.org>,
	virtualization@lists.linux-foundation.org,
	Jakub Kicinski <kuba@kernel.org>,
	bpf@vger.kernel.org, "David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v3 03/17] virtio: queue_reset: struct virtio_config_ops add callbacks for queue_reset
Date: Tue, 8 Feb 2022 10:58:45 +0800	[thread overview]
Message-ID: <b0debb2b-7548-c354-2128-2ddf56bf5c18@redhat.com> (raw)
In-Reply-To: <1644218386.0457659-1-xuanzhuo@linux.alibaba.com>


在 2022/2/7 下午3:19, Xuan Zhuo 写道:
> On Mon, 7 Feb 2022 14:45:02 +0800, Jason Wang <jasowang@redhat.com> wrote:
>> 在 2022/1/26 下午3:35, Xuan Zhuo 写道:
>>> Performing reset on a queue is divided into two steps:
>>>
>>> 1. reset_vq: reset one vq
>>> 2. enable_reset_vq: re-enable the reset queue
>>>
>>> In the first step, these tasks will be completed:
>>>       1. notify the hardware queue to reset
>>>       2. recycle the buffer from vq
>>>       3. release the ring of the vq
>>>
>>> The second step is similar to find vqs,
>>
>> Not sure, since find_vqs will usually try to allocate interrupts.
>>
>>
> Yes.
>
>
>>>    passing parameters callback and
>>> name, etc. Based on the original vq, the ring is re-allocated and
>>> configured to the backend.
>>
>> I wonder whether we really have such requirement.
>>
>> For example, do we really have a use case that may change:
>>
>> vq callback, ctx, ring_num or even re-create the virtqueue?
> 1. virtqueue is not recreated
> 2. ring_num can be used to modify ring num by ethtool -G


It looks to me we don't support this right now.


>
> There is really no scene to modify vq callback, ctx, name.
>
> Do you mean we still use the old one instead of adding these parameters?


Yes, I think for driver we need to implement the function that is needed 
for the first user (e.g AF_XDP). If there's no use case, we can leave 
those extension for the future.

Thanks


>
> Thanks.
>
>> Thanks
>>
>>
>>> So add two callbacks reset_vq, enable_reset_vq to struct
>>> virtio_config_ops.
>>>
>>> Add a structure for passing parameters. This will facilitate subsequent
>>> expansion of the parameters of enable reset vq.
>>> There is currently only one default extended parameter ring_num.
>>>
>>> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
>>> ---
>>>    include/linux/virtio_config.h | 43 ++++++++++++++++++++++++++++++++++-
>>>    1 file changed, 42 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h
>>> index 4d107ad31149..51dd8461d1b6 100644
>>> --- a/include/linux/virtio_config.h
>>> +++ b/include/linux/virtio_config.h
>>> @@ -16,6 +16,44 @@ struct virtio_shm_region {
>>>    	u64 len;
>>>    };
>>>
>>> +typedef void vq_callback_t(struct virtqueue *);
>>> +
>>> +/* virtio_reset_vq: specify parameters for queue_reset
>>> + *
>>> + *	vdev: the device
>>> + *	queue_index: the queue index
>>> + *
>>> + *	free_unused_cb: callback to free unused bufs
>>> + *	data: used by free_unused_cb
>>> + *
>>> + *	callback: callback for the virtqueue, NULL for vq that do not need a
>>> + *	          callback
>>> + *	name: virtqueue names (mainly for debugging), NULL for vq unused by
>>> + *	      driver
>>> + *	ctx: ctx
>>> + *
>>> + *	ring_num: specify ring num for the vq to be re-enabled. 0 means use the
>>> + *	          default value. MUST be a power of 2.
>>> + */
>>> +struct virtio_reset_vq;
>>> +typedef void vq_reset_callback_t(struct virtio_reset_vq *param, void *buf);
>>> +struct virtio_reset_vq {
>>> +	struct virtio_device *vdev;
>>> +	u16 queue_index;
>>> +
>>> +	/* reset vq param */
>>> +	vq_reset_callback_t *free_unused_cb;
>>> +	void *data;
>>> +
>>> +	/* enable reset vq param */
>>> +	vq_callback_t *callback;
>>> +	const char *name;
>>> +	const bool *ctx;
>>> +
>>> +	/* ext enable reset vq param */
>>> +	u16 ring_num;
>>> +};
>>> +
>>>    /**
>>>     * virtio_config_ops - operations for configuring a virtio device
>>>     * Note: Do not assume that a transport implements all of the operations
>>> @@ -74,8 +112,9 @@ struct virtio_shm_region {
>>>     * @set_vq_affinity: set the affinity for a virtqueue (optional).
>>>     * @get_vq_affinity: get the affinity for a virtqueue (optional).
>>>     * @get_shm_region: get a shared memory region based on the index.
>>> + * @reset_vq: reset a queue individually
>>> + * @enable_reset_vq: enable a reset queue
>>>     */
>>> -typedef void vq_callback_t(struct virtqueue *);
>>>    struct virtio_config_ops {
>>>    	void (*enable_cbs)(struct virtio_device *vdev);
>>>    	void (*get)(struct virtio_device *vdev, unsigned offset,
>>> @@ -100,6 +139,8 @@ struct virtio_config_ops {
>>>    			int index);
>>>    	bool (*get_shm_region)(struct virtio_device *vdev,
>>>    			       struct virtio_shm_region *region, u8 id);
>>> +	int (*reset_vq)(struct virtio_reset_vq *param);
>>> +	struct virtqueue *(*enable_reset_vq)(struct virtio_reset_vq *param);
>>>    };
>>>
>>>    /* If driver didn't advertise the feature, it will never appear. */

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

  reply	other threads:[~2022-02-08  2:58 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-26  7:35 [PATCH v3 00/17] virtio pci support VIRTIO_F_RING_RESET Xuan Zhuo
2022-01-26  7:35 ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 01/17] virtio_pci: struct virtio_pci_common_cfg add queue_notify_data Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-02-07  3:41   ` Jason Wang
2022-02-07  3:41     ` Jason Wang
2022-02-07  6:04     ` Xuan Zhuo
2022-02-07  8:06       ` Jason Wang
2022-02-07  8:06         ` Jason Wang
2022-02-08  2:17         ` Xuan Zhuo
2022-02-08  3:03           ` Jason Wang
2022-02-08  3:03             ` Jason Wang
2022-02-08  3:18             ` Xuan Zhuo
2022-02-08  3:24               ` Jason Wang
2022-02-08  3:24                 ` Jason Wang
2022-02-08  3:25                 ` Xuan Zhuo
2022-02-08  3:36                   ` Jason Wang
2022-02-08  3:36                     ` Jason Wang
2022-01-26  7:35 ` [PATCH v3 02/17] virtio: queue_reset: add VIRTIO_F_RING_RESET Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 03/17] virtio: queue_reset: struct virtio_config_ops add callbacks for queue_reset Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-02-07  6:45   ` Jason Wang
2022-02-07  6:45     ` Jason Wang
2022-02-07  7:19     ` Xuan Zhuo
2022-02-08  2:58       ` Jason Wang [this message]
2022-02-08  2:58         ` Jason Wang
2022-02-08  3:00         ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 04/17] virtio: queue_reset: add helper Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 05/17] vritio_ring: queue_reset: extract the release function of the vq ring Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 06/17] virtio_ring: queue_reset: split: add __vring_init_virtqueue() Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 07/17] virtio_ring: queue_reset: split: support enable reset queue Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 08/17] virtio_ring: queue_reset: packed: " Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 09/17] virtio_ring: queue_reset: add vring_reset_virtqueue() Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 10/17] virtio_pci: queue_reset: update struct virtio_pci_common_cfg and option functions Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 11/17] virtio_pci: queue_reset: release vq by vp_dev->vqs Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 12/17] virtio_pci: queue_reset: setup_vq use vring_setup_virtqueue() Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 13/17] virtio_pci: queue_reset: support VIRTIO_F_RING_RESET Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-02-07  6:57   ` Jason Wang
2022-02-07  6:57     ` Jason Wang
2022-02-07  7:59     ` Xuan Zhuo
2022-02-08  2:55       ` Jason Wang
2022-02-08  2:55         ` Jason Wang
2022-02-08  6:47         ` xuanzhuo
2022-02-08  6:47           ` xuanzhuo
2022-02-08  7:35         ` Xuan Zhuo
2022-02-09  5:44           ` Jason Wang
2022-02-09  5:44             ` Jason Wang
2022-02-09  6:05             ` Xuan Zhuo
2022-02-09  6:05               ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 14/17] virtio_net: virtnet_tx_timeout() fix style Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 15/17] virtio_net: virtnet_tx_timeout() stop ref sq->vq Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 16/17] virtio_net: split free_unused_bufs() Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-01-26  7:35 ` [PATCH v3 17/17] virtio_net: support pair disable/enable Xuan Zhuo
2022-01-26  7:35   ` Xuan Zhuo
2022-02-07  3:39 ` [PATCH v3 00/17] virtio pci support VIRTIO_F_RING_RESET Jason Wang
2022-02-07  3:39   ` Jason Wang
2022-02-07  6:02   ` Xuan Zhuo
2022-02-08  2:59     ` Jason Wang
2022-02-08  2:59       ` Jason Wang
2022-02-08  3:14       ` Xuan Zhuo
2022-02-08  7:51         ` Xuan Zhuo
2022-02-08  7:51           ` Xuan Zhuo
2022-02-09  5:39           ` Jason Wang
2022-02-09  5:39             ` Jason Wang

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=b0debb2b-7548-c354-2128-2ddf56bf5c18@redhat.com \
    --to=jasowang@redhat.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    --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.