linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eli Cohen <eli@mellanox.com>
To: mst@redhat.com, jasowang@redhat.com,
	virtualization@lists.linux-foundation.org,
	linux-kernel@vger.kernel.org
Cc: shahafs@mellanox.com, saeedm@mellanox.com, parav@mellanox.com
Subject: [PATCH V4 linux-next 05/12] vdpasim: support batch updating
Date: Tue,  4 Aug 2020 19:20:41 +0300	[thread overview]
Message-ID: <20200804162048.22587-6-eli@mellanox.com> (raw)
In-Reply-To: <20200804162048.22587-1-eli@mellanox.com>

From: Jason Wang <jasowang@redhat.com>

The vDPA simulator support both set_map() and dma_map()/dma_unmap()
operations. But vhost-vdpa can only use one of them. So this patch
introduce a module parameter (batch_mapping) that let vpda_sim to
support only one of those dma operations. The batched mapping via
set_map() is enabled by default.

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/vdpa/vdpa_sim/vdpa_sim.c | 40 +++++++++++++++++++++++++++++---
 1 file changed, 37 insertions(+), 3 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 13febedd73ee..07ded545197d 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -34,6 +34,10 @@
 #define DRV_DESC     "vDPA Device Simulator"
 #define DRV_LICENSE  "GPL v2"
 
+static int batch_mapping = 1;
+module_param(batch_mapping, int, 0444);
+MODULE_PARM_DESC(batch_mapping, "Batched mapping 1 -Enable; 0 - Disable");
+
 struct vdpasim_virtqueue {
 	struct vringh vring;
 	struct vringh_kiov iov;
@@ -334,15 +338,21 @@ static const struct dma_map_ops vdpasim_dma_ops = {
 };
 
 static const struct vdpa_config_ops vdpasim_net_config_ops;
+static const struct vdpa_config_ops vdpasim_net_batch_config_ops;
 
 static struct vdpasim *vdpasim_create(void)
 {
+	const struct vdpa_config_ops *ops;
 	struct vdpasim *vdpasim;
 	struct device *dev;
 	int ret = -ENOMEM;
 
-	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL,
-				    &vdpasim_net_config_ops);
+	if (batch_mapping)
+		ops = &vdpasim_net_batch_config_ops;
+	else
+		ops = &vdpasim_net_config_ops;
+
+	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops);
 	if (!vdpasim)
 		goto err_alloc;
 
@@ -641,12 +651,36 @@ static const struct vdpa_config_ops vdpasim_net_config_ops = {
 	.get_config             = vdpasim_get_config,
 	.set_config             = vdpasim_set_config,
 	.get_generation         = vdpasim_get_generation,
-	.set_map                = vdpasim_set_map,
 	.dma_map                = vdpasim_dma_map,
 	.dma_unmap              = vdpasim_dma_unmap,
 	.free                   = vdpasim_free,
 };
 
+static const struct vdpa_config_ops vdpasim_net_batch_config_ops = {
+	.set_vq_address         = vdpasim_set_vq_address,
+	.set_vq_num             = vdpasim_set_vq_num,
+	.kick_vq                = vdpasim_kick_vq,
+	.set_vq_cb              = vdpasim_set_vq_cb,
+	.set_vq_ready           = vdpasim_set_vq_ready,
+	.get_vq_ready           = vdpasim_get_vq_ready,
+	.set_vq_state           = vdpasim_set_vq_state,
+	.get_vq_state           = vdpasim_get_vq_state,
+	.get_vq_align           = vdpasim_get_vq_align,
+	.get_features           = vdpasim_get_features,
+	.set_features           = vdpasim_set_features,
+	.set_config_cb          = vdpasim_set_config_cb,
+	.get_vq_num_max         = vdpasim_get_vq_num_max,
+	.get_device_id          = vdpasim_get_device_id,
+	.get_vendor_id          = vdpasim_get_vendor_id,
+	.get_status             = vdpasim_get_status,
+	.set_status             = vdpasim_set_status,
+	.get_config             = vdpasim_get_config,
+	.set_config             = vdpasim_set_config,
+	.get_generation         = vdpasim_get_generation,
+	.set_map                = vdpasim_set_map,
+	.free                   = vdpasim_free,
+};
+
 static int __init vdpasim_dev_init(void)
 {
 	vdpasim_dev = vdpasim_create();
-- 
2.26.0


  parent reply	other threads:[~2020-08-04 16:22 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-04 16:20 [PATCH V4 linux-next 00/12] VDPA support for Mellanox ConnectX devices Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 01/12] vhost-vdpa: refine ioctl pre-processing Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 02/12] vhost: generialize backend features setting/getting Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 03/12] vhost-vdpa: support get/set backend features Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 04/12] vhost-vdpa: support IOTLB batching hints Eli Cohen
2020-08-04 16:20 ` Eli Cohen [this message]
2020-08-04 16:20 ` [PATCH V4 linux-next 06/12] vdpa: remove hard coded virtq num Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 07/12] net/vdpa: Use struct for set/get vq state Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 08/12] vdpa: Modify get_vq_state() to return error code Eli Cohen
2020-08-05  8:10   ` Jason Wang
2020-08-04 16:20 ` [PATCH V4 linux-next 09/12] vdpa/mlx5: Add hardware descriptive header file Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 10/12] vdpa/mlx5: Add support library for mlx5 VDPA implementation Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 11/12] vdpa/mlx5: Add shared memory registration code Eli Cohen
2020-08-04 16:20 ` [PATCH V4 linux-next 12/12] vdpa/mlx5: Add VDPA driver for supported mlx5 devices Eli Cohen
2020-08-05  8:09   ` Jason Wang
2020-08-04 21:29 ` [PATCH V4 linux-next 00/12] VDPA support for Mellanox ConnectX devices Michael S. Tsirkin
2020-08-05  5:01   ` Eli Cohen
2020-08-05  8:12     ` Jason Wang
2020-08-05  8:18       ` Eli Cohen
2020-08-05  8:11 ` Jason Wang
2020-08-05 12:00 ` Michael S. Tsirkin
2020-08-05 12:40   ` Eli Cohen
2020-08-05 12:48     ` Michael S. Tsirkin
2020-08-05 13:01       ` Eli Cohen
2020-08-05 13:12         ` Michael S. Tsirkin
2020-08-05 19:01           ` Saeed Mahameed
2020-08-05 19:46             ` Jason Gunthorpe
2020-08-05 22:31               ` Michael S. Tsirkin

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=20200804162048.22587-6-eli@mellanox.com \
    --to=eli@mellanox.com \
    --cc=jasowang@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.com \
    --cc=saeedm@mellanox.com \
    --cc=shahafs@mellanox.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).