Unverified Commit 306b4220 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!326 vdpa: Add the vdpa device management mechanism and optimize the iotlb

Merge Pull Request from: @Zhao_Py 
 
Sync from https://gitee.com/openeuler/kernel/pulls/309

#I5WXCZ

[Description]​
1、add vdpa tool support in vp_vdpa 
2、multiple address spaces support in vdpa
3、support ASID based IOTLB API in vhost-vdpa
4、add suspend support vhost-vdpa

[Testing]
1. Environmental preparation
Server hardware: TaiShan 200
Network card: SmartNIC
Operating system: openEuler 22.03 LTS
2. Operation Procedure
Apply the relevant patches in the kernel and reinstall the kernel.
Enable the SmartNIC vf.
Insert the driver related to the vdpa:
```
        insmod drivers/vhost/vhost_iotlb.ko
        insmod drivers/vhost/vhost.ko
        insmod drivers/vdpa/vdpa.ko
        insmod drivers/vhost/vhost_vdpa.ko
        insmod drivers/vdpa/virtio_pci/vp_vdpa.ko
```
Run the following command to bind the VF to vp-vdpa:
```
        echo -n "1af4 1000" > /sys/bus/pci/drivers/vp-vdpa/new_id
        vdpa dev add name vdpa1 mgmtdev pci/0000:01:01.1
```
Start qemu with the following parameter to enable generic VDPA device:
```
        -device vhost-vdpa-device-pci,vhostdev=/dev/vhost-vdpa-0
```
Create a bridge on the host and add the VF to the bridge.
Configure the guest network adapter and the port on the host bridge to be in the same network segment.  
3. Expected results
The guest NIC and the port on the host bridge can be pinged.  
4. Actual results
Meets expectations
 
 
Link:https://gitee.com/openeuler/kernel/pulls/326

 
Reviewed-by: default avatarKevin Zhu <zhukeqian1@huawei.com>
Signed-off-by: default avatarXie XiuQi <xiexiuqi@huawei.com>
parents 1e0c4666 f65f986c
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
What:		/sys/bus/vdpa/driver_autoprobe
Date:		March 2020
Contact:	virtualization@lists.linux-foundation.org
Description:
		This file determines whether new devices are immediately bound
		to a driver after the creation. It initially contains 1, which
		means the kernel automatically binds devices to a compatible
		driver immediately after they are created.

		Writing "0" to this file disable this feature, any other string
		enable it.

What:		/sys/bus/vdpa/driver_probe
Date:		March 2020
Contact:	virtualization@lists.linux-foundation.org
Description:
		Writing a device name to this file will cause the kernel binds
		devices to a compatible driver.

		This can be useful when /sys/bus/vdpa/driver_autoprobe is
		disabled.

What:		/sys/bus/vdpa/drivers/.../bind
Date:		March 2020
Contact:	virtualization@lists.linux-foundation.org
Description:
		Writing a device name to this file will cause the driver to
		attempt to bind to the device. This is useful for overriding
		default bindings.

What:		/sys/bus/vdpa/drivers/.../unbind
Date:		March 2020
Contact:	virtualization@lists.linux-foundation.org
Description:
		Writing a device name to this file will cause the driver to
		attempt to unbind from the device. This may be useful when
		overriding default bindings.
+1 −0
Original line number Diff line number Diff line
@@ -18682,6 +18682,7 @@ M: "Michael S. Tsirkin" <mst@redhat.com>
M:	Jason Wang <jasowang@redhat.com>
L:	virtualization@lists.linux-foundation.org
S:	Maintained
F:	Documentation/ABI/testing/sysfs-bus-vdpa
F:	Documentation/devicetree/bindings/virtio/
F:	drivers/block/virtio_blk.c
F:	drivers/crypto/virtio/
+2 −2
Original line number Diff line number Diff line
@@ -933,7 +933,7 @@ static void virtblk_remove(struct virtio_device *vdev)
	mutex_lock(&vblk->vdev_mutex);

	/* Stop all the virtqueues. */
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);

	/* Virtqueues are stopped, nothing can use vblk->vdev anymore. */
	vblk->vdev = NULL;
@@ -953,7 +953,7 @@ static int virtblk_freeze(struct virtio_device *vdev)
	struct virtio_blk *vblk = vdev->priv;

	/* Ensure we don't receive any more interrupts */
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);

	/* Make sure no work handler is accessing the device. */
	flush_work(&vblk->config_work);
+1 −1
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ static void remove_common(struct virtio_device *vdev)
	vi->hwrng_removed = true;
	vi->data_avail = 0;
	complete(&vi->have_data);
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	vi->busy = false;
	if (vi->hwrng_register_done)
		hwrng_unregister(&vi->hwrng);
+2 −2
Original line number Diff line number Diff line
@@ -1967,7 +1967,7 @@ static void virtcons_remove(struct virtio_device *vdev)
		flush_work(&portdev->config_work);

	/* Disable interrupts for vqs */
	vdev->config->reset(vdev);
	virtio_reset_device(vdev);
	/* Finish up work that's lined up */
	if (use_multiport(portdev))
		cancel_work_sync(&portdev->control_work);
@@ -2149,7 +2149,7 @@ static int virtcons_freeze(struct virtio_device *vdev)

	portdev = vdev->priv;

	vdev->config->reset(vdev);
	virtio_reset_device(vdev);

	if (use_multiport(portdev))
		virtqueue_disable_cb(portdev->c_ivq);
Loading