Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vdpa: introduce map ops

Virtio core allows the transport to provide device or transport
specific mapping functions. This patch adds this support to vDPA. We
can simply do this by allowing the vDPA parent to register a
virtio_map_ops.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Message-Id: <20250924070045.10361-2-jasowang@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eugenio Pérez <eperezma@redhat.com>

authored by

Jason Wang and committed by
Michael S. Tsirkin
0d16cc43 58aca3db

+29 -15
+2 -1
drivers/vdpa/alibaba/eni_vdpa.c
··· 478 478 return ret; 479 479 480 480 eni_vdpa = vdpa_alloc_device(struct eni_vdpa, vdpa, 481 - dev, &eni_vdpa_ops, 1, 1, NULL, false); 481 + dev, &eni_vdpa_ops, NULL, 482 + 1, 1, NULL, false); 482 483 if (IS_ERR(eni_vdpa)) { 483 484 ENI_ERR(pdev, "failed to allocate vDPA structure\n"); 484 485 return PTR_ERR(eni_vdpa);
+2 -1
drivers/vdpa/ifcvf/ifcvf_main.c
··· 705 705 vf = &ifcvf_mgmt_dev->vf; 706 706 pdev = vf->pdev; 707 707 adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa, 708 - &pdev->dev, &ifc_vdpa_ops, 1, 1, NULL, false); 708 + &pdev->dev, &ifc_vdpa_ops, 709 + NULL, 1, 1, NULL, false); 709 710 if (IS_ERR(adapter)) { 710 711 IFCVF_ERR(pdev, "Failed to allocate vDPA structure"); 711 712 return PTR_ERR(adapter);
+1 -1
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 3882 3882 } 3883 3883 3884 3884 ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mgtdev->vdpa_ops, 3885 - MLX5_VDPA_NUMVQ_GROUPS, MLX5_VDPA_NUM_AS, name, false); 3885 + NULL, MLX5_VDPA_NUMVQ_GROUPS, MLX5_VDPA_NUM_AS, name, false); 3886 3886 if (IS_ERR(ndev)) 3887 3887 return PTR_ERR(ndev); 3888 3888
+2 -2
drivers/vdpa/octeon_ep/octep_vdpa_main.c
··· 508 508 u64 device_features; 509 509 int ret; 510 510 511 - oct_vdpa = vdpa_alloc_device(struct octep_vdpa, vdpa, &pdev->dev, &octep_vdpa_ops, 1, 1, 512 - NULL, false); 511 + oct_vdpa = vdpa_alloc_device(struct octep_vdpa, vdpa, &pdev->dev, &octep_vdpa_ops, 512 + NULL, 1, 1, NULL, false); 513 513 if (IS_ERR(oct_vdpa)) { 514 514 dev_err(&pdev->dev, "Failed to allocate vDPA structure for octep vdpa device"); 515 515 return PTR_ERR(oct_vdpa);
+2 -1
drivers/vdpa/pds/vdpa_dev.c
··· 632 632 } 633 633 634 634 pdsv = vdpa_alloc_device(struct pds_vdpa_device, vdpa_dev, 635 - dev, &pds_vdpa_ops, 1, 1, name, false); 635 + dev, &pds_vdpa_ops, NULL, 636 + 1, 1, name, false); 636 637 if (IS_ERR(pdsv)) { 637 638 dev_err(dev, "Failed to allocate vDPA structure: %pe\n", pdsv); 638 639 return PTR_ERR(pdsv);
+2 -2
drivers/vdpa/solidrun/snet_main.c
··· 1008 1008 } 1009 1009 1010 1010 /* Allocate vdpa device */ 1011 - snet = vdpa_alloc_device(struct snet, vdpa, &pdev->dev, &snet_config_ops, 1, 1, NULL, 1012 - false); 1011 + snet = vdpa_alloc_device(struct snet, vdpa, &pdev->dev, &snet_config_ops, 1012 + NULL, 1, 1, NULL, false); 1013 1013 if (!snet) { 1014 1014 SNET_ERR(pdev, "Failed to allocate a vdpa device\n"); 1015 1015 ret = -ENOMEM;
+3
drivers/vdpa/vdpa.c
··· 142 142 * initialized but before registered. 143 143 * @parent: the parent device 144 144 * @config: the bus operations that is supported by this device 145 + * @map: the map operations that is supported by this device 145 146 * @ngroups: number of groups supported by this device 146 147 * @nas: number of address spaces supported by this device 147 148 * @size: size of the parent structure that contains private data ··· 157 156 */ 158 157 struct vdpa_device *__vdpa_alloc_device(struct device *parent, 159 158 const struct vdpa_config_ops *config, 159 + const struct virtio_map_ops *map, 160 160 unsigned int ngroups, unsigned int nas, 161 161 size_t size, const char *name, 162 162 bool use_va) ··· 189 187 vdev->dev.release = vdpa_release_dev; 190 188 vdev->index = err; 191 189 vdev->config = config; 190 + vdev->map = map; 192 191 vdev->features_valid = false; 193 192 vdev->use_va = use_va; 194 193 vdev->ngroups = ngroups;
+1 -1
drivers/vdpa/vdpa_sim/vdpa_sim.c
··· 215 215 else 216 216 ops = &vdpasim_config_ops; 217 217 218 - vdpa = __vdpa_alloc_device(NULL, ops, 218 + vdpa = __vdpa_alloc_device(NULL, ops, NULL, 219 219 dev_attr->ngroups, dev_attr->nas, 220 220 dev_attr->alloc_size, 221 221 dev_attr->name, use_va);
+2 -1
drivers/vdpa/vdpa_user/vduse_dev.c
··· 2009 2009 return -EEXIST; 2010 2010 2011 2011 vdev = vdpa_alloc_device(struct vduse_vdpa, vdpa, dev->dev, 2012 - &vduse_vdpa_config_ops, 1, 1, name, true); 2012 + &vduse_vdpa_config_ops, NULL, 2013 + 1, 1, name, true); 2013 2014 if (IS_ERR(vdev)) 2014 2015 return PTR_ERR(vdev); 2015 2016
+2 -1
drivers/vdpa/virtio_pci/vp_vdpa.c
··· 511 511 int ret, i; 512 512 513 513 vp_vdpa = vdpa_alloc_device(struct vp_vdpa, vdpa, 514 - dev, &vp_vdpa_ops, 1, 1, name, false); 514 + dev, &vp_vdpa_ops, NULL, 515 + 1, 1, name, false); 515 516 516 517 if (IS_ERR(vp_vdpa)) { 517 518 dev_err(dev, "vp_vdpa: Failed to allocate vDPA structure\n");
+3 -1
drivers/virtio/virtio_vdpa.c
··· 466 466 if (!vd_dev) 467 467 return -ENOMEM; 468 468 469 - vd_dev->vdev.dev.parent = vdpa_get_map(vdpa).dma_dev; 469 + vd_dev->vdev.dev.parent = vdpa->map ? &vdpa->dev : 470 + vdpa_get_map(vdpa).dma_dev; 470 471 vd_dev->vdev.dev.release = virtio_vdpa_release_dev; 471 472 vd_dev->vdev.config = &virtio_vdpa_config_ops; 473 + vd_dev->vdev.map = vdpa->map; 472 474 vd_dev->vdpa = vdpa; 473 475 474 476 vd_dev->vdev.id.device = ops->get_device_id(vdpa);
+7 -3
include/linux/vdpa.h
··· 76 76 * because core frees it; use driver_set_override() to 77 77 * set or clear it. 78 78 * @config: the configuration ops for this device. 79 + * @map: the map ops for this device 79 80 * @cf_lock: Protects get and set access to configuration layout. 80 81 * @index: device index 81 82 * @features_valid: were features initialized? for legacy guests ··· 92 91 union virtio_map vmap; 93 92 const char *driver_override; 94 93 const struct vdpa_config_ops *config; 94 + const struct virtio_map_ops *map; 95 95 struct rw_semaphore cf_lock; /* Protects get/set config */ 96 96 unsigned int index; 97 97 bool features_valid; ··· 449 447 450 448 struct vdpa_device *__vdpa_alloc_device(struct device *parent, 451 449 const struct vdpa_config_ops *config, 450 + const struct virtio_map_ops *map, 452 451 unsigned int ngroups, unsigned int nas, 453 452 size_t size, const char *name, 454 453 bool use_va); ··· 461 458 * @member: the name of struct vdpa_device within the @dev_struct 462 459 * @parent: the parent device 463 460 * @config: the bus operations that is supported by this device 461 + * @map: the map operations that is supported by this device 464 462 * @ngroups: the number of virtqueue groups supported by this device 465 463 * @nas: the number of address spaces 466 464 * @name: name of the vdpa device ··· 469 465 * 470 466 * Return allocated data structure or ERR_PTR upon error 471 467 */ 472 - #define vdpa_alloc_device(dev_struct, member, parent, config, ngroups, nas, \ 473 - name, use_va) \ 468 + #define vdpa_alloc_device(dev_struct, member, parent, config, map, \ 469 + ngroups, nas, name, use_va) \ 474 470 container_of((__vdpa_alloc_device( \ 475 - parent, config, ngroups, nas, \ 471 + parent, config, map, ngroups, nas, \ 476 472 (sizeof(dev_struct) + \ 477 473 BUILD_BUG_ON_ZERO(offsetof( \ 478 474 dev_struct, member))), name, use_va)), \