Commit 47585385 authored by Gautam Dawar's avatar Gautam Dawar Committed by Pengyuan Zhao
Browse files

vdpa: introduce virtqueue groups

mainline inclusion
from mainline-v5.19-rc1
commit d4821902
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WXCZ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d4821902e43453b85b31329441a9f6ac071228a8



----------------------------------------------------------------------

This patch introduces virtqueue groups to vDPA device. The virtqueue
group is the minimal set of virtqueues that must share an address
space. And the address space identifier could only be attached to
a specific virtqueue group.

Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarGautam Dawar <gdawar@xilinx.com>
Message-Id: <20220330180436.24644-6-gdawar@xilinx.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
[Changes to ifcvf and mlx5 are not included.]
Signed-off-by: default avatarPengyuan Zhao <zhaopengyuan@hisilicon.com>
parent e03b6f36
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -465,7 +465,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	}

	adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
				    dev, &ifc_vdpa_ops, NULL, false);
				    dev, &ifc_vdpa_ops, 1, NULL, false);
	if (adapter == NULL) {
		IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
		return -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -2014,7 +2014,7 @@ void *mlx5_vdpa_add_dev(struct mlx5_core_dev *mdev)
	max_vqs = min_t(u32, max_vqs, MLX5_MAX_SUPPORTED_VQS);

	ndev = vdpa_alloc_device(struct mlx5_vdpa_net, mvdev.vdev, mdev->device, &mlx5_vdpa_ops,
				 NULL, false);
				 1, NULL, false);
	if (IS_ERR(ndev))
		return ndev;

+3 −0
Original line number Diff line number Diff line
@@ -161,6 +161,7 @@ static void vdpa_release_dev(struct device *d)
 * initialized but before registered.
 * @parent: the parent device
 * @config: the bus operations that is supported by this device
 * @ngroups: number of groups supported by this device
 * @size: size of the parent structure that contains private data
 * @name: name of the vdpa device; optional.
 * @use_va: indicate whether virtual address must be used by this device
@@ -173,6 +174,7 @@ static void vdpa_release_dev(struct device *d)
 */
struct vdpa_device *__vdpa_alloc_device(struct device *parent,
					const struct vdpa_config_ops *config,
					unsigned int ngroups,
					size_t size, const char *name,
					bool use_va)
{
@@ -205,6 +207,7 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
	vdev->config = config;
	vdev->features_valid = false;
	vdev->use_va = use_va;
	vdev->ngroups = ngroups;

	if (name)
		err = dev_set_name(&vdev->dev, "%s", name);
+8 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
	else
		ops = &vdpasim_net_config_ops;

	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops,
	vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL, ops, 1,
				    dev_attr->name, false);
	if (!vdpasim)
		goto err_alloc;
@@ -363,6 +363,11 @@ static u32 vdpasim_get_vq_align(struct vdpa_device *vdpa)
	return VDPASIM_QUEUE_ALIGN;
}

static u32 vdpasim_get_vq_group(struct vdpa_device *vdpa, u16 idx)
{
	return 0;
}

static u64 vdpasim_get_device_features(struct vdpa_device *vdpa)
{
	struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
@@ -572,6 +577,7 @@ static const struct vdpa_config_ops vdpasim_net_config_ops = {
	.set_vq_state           = vdpasim_set_vq_state,
	.get_vq_state           = vdpasim_get_vq_state,
	.get_vq_align           = vdpasim_get_vq_align,
	.get_vq_group           = vdpasim_get_vq_group,
	.get_device_features    = vdpasim_get_device_features,
	.set_driver_features    = vdpasim_set_driver_features,
	.get_driver_features    = vdpasim_get_driver_features,
@@ -602,6 +608,7 @@ static const struct vdpa_config_ops vdpasim_net_batch_config_ops = {
	.set_vq_state           = vdpasim_set_vq_state,
	.get_vq_state           = vdpasim_get_vq_state,
	.get_vq_align           = vdpasim_get_vq_align,
	.get_vq_group           = vdpasim_get_vq_group,
	.get_device_features    = vdpasim_get_device_features,
	.set_driver_features    = vdpasim_set_driver_features,
	.get_driver_features    = vdpasim_get_driver_features,
+1 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ struct vdpasim {
	u32 status;
	u32 generation;
	u64 features;
	u32 groups;
	/* spinlock to synchronize iommu table */
	spinlock_t iommu_lock;
};
Loading