virtualization-virtio-vdpa-hands-on

hands on with vDPA device simulator

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
The vdpa management tool(from iproute2) can be used to communicate with the vDPA framework in the kernel using netlink vDPA API. It allows to create and destroy new devices, and control their parameters.

An example using the in-kernel simulators:

# Load vDPA net and block simulators kernel modules
$ modprobe vdpa-sim-net
$ modprobe vdpa-sim-blk

# List vdpa management device attributes
$ vdpa mgmtdev show
vdpasim_blk:
supported_classes block
vdpasim_net:
supported_classes net

# Add `vdpa-net1` device through `vdpasim_net` management device
$ vdpa dev add name vdpa-net1 mgmtdev vdpasim_net

# Add `vdpa-blk1` device through `vdpasim_blk` management device
$ vdpa dev add name vdpa-blk1 mgmtdev vdpasim_blk

# List all vdpa devices on the system
$ vdpa dev show
vdpa-net1: type network mgmtdev vdpasim_net vendor_id 0 max_vqs 2 max_vq_size 256
vdpa-blk1: type block mgmtdev vdpasim_blk vendor_id 0 max_vqs 1 max_vq_size 256

# As above, but using pretty[-p] JSON[-j] output
$ vdpa dev show -jp
{
"dev": {
"vdpa-net1": {
"type": "network",
"mgmtdev": "vdpasim_net",
"vendor_id": 0,
"max_vqs": 2,
"max_vq_size": 256
},
"vdpa-blk1": {
"type": "block",
"mgmtdev": "vdpasim_blk",
"vendor_id": 0,
"max_vqs": 1,
"max_vq_size": 256
}
}
}

# check all vdpa device(each VF is an vdpa device)
$ ls /sys/bus/vdpa/devices
# check bus driver of a vdpa device
$ ls -l /sys/bus/vdpa/devices/vdpa0/driver

# switch bus driver
$ echo vdpa0 > /sys/bus/vdpa/drivers/vhost_vdpa/unbind
$ echo vdpa0 > /sys/bus/vdpa/drivers/virtio_vdpa/bind

# check all bus drivers(virtio, vhost)
$ ls /sys/bus/vdpa/drivers