forked from luck/tmp_suning_uos_patched
vdpasim: support batch updating
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> Link: https://lore.kernel.org/r/20200804162048.22587-6-eli@mellanox.com Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
25abc060d2
commit
de91a4d0e7
|
@ -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;
|
||||
|
||||
|
@ -643,12 +653,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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user