virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: Eli Cohen <elic@nvidia.com>,
	mst@redhat.com, virtualization@lists.linux-foundation.org
Cc: eperezma@redhat.com
Subject: Re: [PATCH v2 3/6] vdpa/mlx5: Decouple virtqueue callback from struct mlx5_vdpa_virtqueue
Date: Thu, 19 Aug 2021 11:37:56 +0800	[thread overview]
Message-ID: <ccf36dfb-0bd5-5dc4-b713-a2018ffd8b50@redhat.com> (raw)
In-Reply-To: <20210817060250.188705-4-elic@nvidia.com>


在 2021/8/17 下午2:02, Eli Cohen 写道:
> Instead, define an array of struct vdpa_callback on struct mlx5_vdpa_net
> and use it to store callbacks for any virtqueue provided. This is
> required due to the fact that callback configurations arrive before feature
> negotiation. With control VQ and multiqueue introduced next we want to
> save the information until after feature negotiation where we know the
> CVQ index.
>
> Signed-off-by: Eli Cohen <elic@nvidia.com>


Acked-by: Jason Wang <jasowang@redhat.com>

A question: Do we need to reset the cb during device reset?

Thanks


> ---
>   drivers/vdpa/mlx5/net/mlx5_vnet.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> index a1cf58a53d42..222ddfbde116 100644
> --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c
> +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c
> @@ -90,7 +90,6 @@ struct mlx5_vq_restore_info {
>   	u16 avail_index;
>   	u16 used_index;
>   	bool ready;
> -	struct vdpa_callback cb;
>   	bool restore;
>   };
>   
> @@ -100,7 +99,6 @@ struct mlx5_vdpa_virtqueue {
>   	u64 device_addr;
>   	u64 driver_addr;
>   	u32 num_ent;
> -	struct vdpa_callback event_cb;
>   
>   	/* Resources for implementing the notification channel from the device
>   	 * to the driver. fwqp is the firmware end of an RC connection; the
> @@ -140,6 +138,7 @@ struct mlx5_vdpa_net {
>   	struct mlx5_vdpa_net_resources res;
>   	struct virtio_net_config config;
>   	struct mlx5_vdpa_virtqueue vqs[MLX5_MAX_SUPPORTED_VQS];
> +	struct vdpa_callback event_cbs[MLX5_MAX_SUPPORTED_VQS + 1];
>   
>   	/* Serialize vq resources creation and destruction. This is required
>   	 * since memory map might change and we need to destroy and create
> @@ -481,6 +480,10 @@ static int mlx5_vdpa_poll_one(struct mlx5_vdpa_cq *vcq)
>   
>   static void mlx5_vdpa_handle_completions(struct mlx5_vdpa_virtqueue *mvq, int num)
>   {
> +	struct mlx5_vdpa_net *ndev = mvq->ndev;
> +	struct vdpa_callback *event_cb;
> +
> +	event_cb = &ndev->event_cbs[mvq->index];
>   	mlx5_cq_set_ci(&mvq->cq.mcq);
>   
>   	/* make sure CQ cosumer update is visible to the hardware before updating
> @@ -488,8 +491,8 @@ static void mlx5_vdpa_handle_completions(struct mlx5_vdpa_virtqueue *mvq, int nu
>   	 */
>   	dma_wmb();
>   	rx_post(&mvq->vqqp, num);
> -	if (mvq->event_cb.callback)
> -		mvq->event_cb.callback(mvq->event_cb.private);
> +	if (event_cb->callback)
> +		event_cb->callback(event_cb->private);
>   }
>   
>   static void mlx5_vdpa_cq_comp(struct mlx5_core_cq *mcq, struct mlx5_eqe *eqe)
> @@ -1385,9 +1388,8 @@ static void mlx5_vdpa_set_vq_cb(struct vdpa_device *vdev, u16 idx, struct vdpa_c
>   {
>   	struct mlx5_vdpa_dev *mvdev = to_mvdev(vdev);
>   	struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev);
> -	struct mlx5_vdpa_virtqueue *vq = &ndev->vqs[idx];
>   
> -	vq->event_cb = *cb;
> +	ndev->event_cbs[idx] = *cb;
>   }
>   
>   static void mlx5_vdpa_set_vq_ready(struct vdpa_device *vdev, u16 idx, bool ready)
> @@ -1624,7 +1626,6 @@ static int save_channel_info(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqu
>   	ri->desc_addr = mvq->desc_addr;
>   	ri->device_addr = mvq->device_addr;
>   	ri->driver_addr = mvq->driver_addr;
> -	ri->cb = mvq->event_cb;
>   	ri->restore = true;
>   	return 0;
>   }
> @@ -1669,7 +1670,6 @@ static void restore_channels_info(struct mlx5_vdpa_net *ndev)
>   		mvq->desc_addr = ri->desc_addr;
>   		mvq->device_addr = ri->device_addr;
>   		mvq->driver_addr = ri->driver_addr;
> -		mvq->event_cb = ri->cb;
>   	}
>   }
>   

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

  parent reply	other threads:[~2021-08-19  3:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210817060250.188705-1-elic@nvidia.com>
     [not found] ` <20210817060250.188705-3-elic@nvidia.com>
2021-08-19  3:32   ` [PATCH v2 2/6] vdpa/mlx5: function prototype modifications in preparation to control VQ Jason Wang
     [not found] ` <20210817060250.188705-4-elic@nvidia.com>
2021-08-19  3:37   ` Jason Wang [this message]
     [not found] ` <20210817060250.188705-5-elic@nvidia.com>
2021-08-19  3:40   ` [PATCH v2 4/6] vdpa/mlx5: Ensure valid indices are provided Jason Wang
     [not found] ` <20210817060250.188705-6-elic@nvidia.com>
2021-08-19  4:04   ` [PATCH v2 5/6] vdpa/mlx5: Add support for control VQ and MAC setting Jason Wang
     [not found]     ` <20210819060641.GA161591@mtl-vdi-166.wap.labs.mlnx>
2021-08-19  7:12       ` Jason Wang
     [not found]         ` <20210819072145.GA166182@mtl-vdi-166.wap.labs.mlnx>
2021-08-19  7:37           ` Jason Wang
     [not found]           ` <20210819072438.GB166182@mtl-vdi-166.wap.labs.mlnx>
2021-08-19  7:41             ` Jason Wang
     [not found]               ` <20210819074819.GA167253@mtl-vdi-166.wap.labs.mlnx>
     [not found]                 ` <20210819081535.GB167253@mtl-vdi-166.wap.labs.mlnx>
2021-08-19  8:19                   ` Jason Wang
     [not found] ` <20210817060250.188705-7-elic@nvidia.com>
2021-08-19  4:07   ` [PATCH v2 6/6] vdpa/mlx5: Add multiqueue support Jason Wang
     [not found]     ` <20210819061547.GD161591@mtl-vdi-166.wap.labs.mlnx>
2021-08-19  7:12       ` 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=ccf36dfb-0bd5-5dc4-b713-a2018ffd8b50@redhat.com \
    --to=jasowang@redhat.com \
    --cc=elic@nvidia.com \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=virtualization@lists.linux-foundation.org \
    /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).