···11+Subchannel passthrough via vfio-ccw
22+===================================
33+44+vfio-ccw (based upon the mediated vfio device infrastructure) allows to
55+make certain I/O subchannels and their devices available to a guest. The
66+host will not interact with those subchannels/devices any more.
77+88+Note that while vfio-ccw should work with most non-QDIO devices, only ECKD
99+DASDs have really been tested.
1010+1111+Example configuration
1212+---------------------
1313+1414+Step 1: configure the host device
1515+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1616+1717+As every mdev is identified by a uuid, the first step is to obtain one::
1818+1919+ [root@host ~]# uuidgen
2020+ 7e270a25-e163-4922-af60-757fc8ed48c6
2121+2222+Note: it is recommended to use the ``mdevctl`` tool for actually configuring
2323+the host device.
2424+2525+To define the same device as configured below to be started
2626+automatically, use
2727+2828+::
2929+3030+ [root@host ~]# driverctl -b css set-override 0.0.0313 vfio_ccw
3131+ [root@host ~]# mdevctl define -u 7e270a25-e163-4922-af60-757fc8ed48c6 \
3232+ -p 0.0.0313 -t vfio-ccw_io -a
3333+3434+If using ``mdevctl`` is not possible or wanted, follow the manual procedure
3535+below.
3636+3737+* Locate the subchannel for the device (in this example, ``0.0.2b09``)::
3838+3939+ [root@host ~]# lscss | grep 0.0.2b09 | awk '{print $2}'
4040+ 0.0.0313
4141+4242+* Unbind the subchannel (in this example, ``0.0.0313``) from the standard
4343+ I/O subchannel driver and bind it to the vfio-ccw driver::
4444+4545+ [root@host ~]# echo 0.0.0313 > /sys/bus/css/devices/0.0.0313/driver/unbind
4646+ [root@host ~]# echo 0.0.0313 > /sys/bus/css/drivers/vfio_ccw/bind
4747+4848+* Create the mediated device (identified by the uuid)::
4949+5050+ [root@host ~]# echo "7e270a25-e163-4922-af60-757fc8ed48c6" > \
5151+ /sys/bus/css/devices/0.0.0313/mdev_supported_types/vfio_ccw-io/create
5252+5353+Step 2: configure QEMU
5454+~~~~~~~~~~~~~~~~~~~~~~
5555+5656+* Reference the created mediated device and (optionally) pick a device id to
5757+ be presented in the guest (here, ``fe.0.1234``, which will end up visible
5858+ in the guest as ``0.0.1234``::
5959+6060+ -device vfio-ccw,devno=fe.0.1234,sysfsdev=\
6161+ /sys/bus/mdev/devices/7e270a25-e163-4922-af60-757fc8ed48c6
6262+6363+* Start the guest. The device (here, ``0.0.1234``) should now be usable::
6464+6565+ [root@guest ~]# lscss -d 0.0.1234
6666+ Device Subchan. DevType CU Type Use PIM PAM POM CHPID
6767+ ----------------------------------------------------------------------
6868+ 0.0.1234 0.0.0007 3390/0e 3990/e9 f0 f0 ff 1a2a3a0a 00000000
6969+ [root@guest ~]# chccwdev -e 0.0.1234
7070+ Setting device 0.0.1234 online
7171+ Done
7272+ [root@guest ~]# dmesg -t
7373+ (...)
7474+ dasd-eckd 0.0.1234: A channel path to the device has become operational
7575+ dasd-eckd 0.0.1234: New DASD 3390/0E (CU 3990/01) with 10017 cylinders, 15 heads, 224 sectors
7676+ dasd-eckd 0.0.1234: DASD with 4 KB/block, 7212240 KB total size, 48 KB/track, compatible disk layout
7777+ dasda:VOL1/ 0X2B09: dasda1