Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp454204pxa; Tue, 4 Aug 2020 09:24:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkKcCGrULEHSIW4AA7SQbVDhpaNCshR4KmIJ6QflZ+06sZanjG0UB/ufoiXcq63jsOVJF9 X-Received: by 2002:a17:906:46c6:: with SMTP id k6mr20970806ejs.230.1596558250030; Tue, 04 Aug 2020 09:24:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596558250; cv=none; d=google.com; s=arc-20160816; b=yiaVSFvwYKK5pIKrpFk1rEQKZQFnBstsfzQ4lrBIE9WTNzdHEN1N8Hz1dNnlcWdXHD beL5w9ebZYgz/APAynTDwVSfnXg7eim4euI/anaV11v6crYKJe+RFYIHjdht0PqjI6n0 k9z5jISmVMt4HL/81FvSnDbhDcuZxM8P7Tz7IsiWyPmLvdkqDiMBiZHu6/94GHA98zpj TppwEc+plbQxHlcjRwdKIdaxG0+EWaI8i/Xgb6kBlgEDC5+99eYFom/+afzJ4iFiMzRJ s+p18DwJ7zLZlIQ7d2Ys7eKWY8ltDfJxuPaEbBxTAolImrXL6ZCGcpMN/Tj6vqWgMjT0 pjHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=I7Q/ekyLlIDf26/NUgIbC9LCnp3Z195FZUYsIZhxMf8=; b=wRor1M5LbDTIsurVZvUwZwIoEQ0d4IhiBK7su/TjTau3YsdlI7vIAS60ruBrRdSQOJ yWX/xZeLorksj2fvPCIddZt4zFiyiGB6pK/Xil9vePpZ7o0Yv0Da+0dmyR58HlVM9w0T BzJ2TtiLP7UcoBxWFH2JDCwa4RiywCVfeIDbyqDHkIfslgFPF5V4bmTjHmS4ImNh/1N/ IVEHO3gtNHv2gupyvkFYoQQwW/kZ/YEsVTH5570MZJSBqiwVqGgpCPnImYodpIqseIJU m69n6ZtWpdCQGCpPI+SV8u9v8nfZ9eMxT8aJglFKBq+0y8ycYBDSo9U9wUIgYqaJwbvk XfTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r5si12138082edh.198.2020.08.04.09.23.47; Tue, 04 Aug 2020 09:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729801AbgHDQWn (ORCPT + 99 others); Tue, 4 Aug 2020 12:22:43 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:43896 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729632AbgHDQVA (ORCPT ); Tue, 4 Aug 2020 12:21:00 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 4 Aug 2020 19:20:53 +0300 Received: from nps-server-21.mtl.labs.mlnx (nps-server-21.mtl.labs.mlnx [10.237.240.120]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 074GKq9h024042; Tue, 4 Aug 2020 19:20:52 +0300 Received: from nps-server-21.mtl.labs.mlnx (localhost [127.0.0.1]) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 074GKq7r022643; Tue, 4 Aug 2020 19:20:52 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 074GKqgm022642; Tue, 4 Aug 2020 19:20:52 +0300 From: Eli Cohen 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 Message-Id: <20200804162048.22587-6-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200804162048.22587-1-eli@mellanox.com> References: <20200804162048.22587-1-eli@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Wang 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 --- 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