xref: /qemu/docs/system/s390x/vfio-ccw.rst (revision 9ece07d7)
18e75b835SCornelia HuckSubchannel passthrough via vfio-ccw
28e75b835SCornelia Huck===================================
38e75b835SCornelia Huck
48e75b835SCornelia Huckvfio-ccw (based upon the mediated vfio device infrastructure) allows to
58e75b835SCornelia Huckmake certain I/O subchannels and their devices available to a guest. The
68e75b835SCornelia Huckhost will not interact with those subchannels/devices any more.
78e75b835SCornelia Huck
88e75b835SCornelia HuckNote that while vfio-ccw should work with most non-QDIO devices, only ECKD
98e75b835SCornelia HuckDASDs have really been tested.
108e75b835SCornelia Huck
118e75b835SCornelia HuckExample configuration
128e75b835SCornelia Huck---------------------
138e75b835SCornelia Huck
148e75b835SCornelia HuckStep 1: configure the host device
158e75b835SCornelia Huck~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168e75b835SCornelia Huck
178e75b835SCornelia HuckAs every mdev is identified by a uuid, the first step is to obtain one::
188e75b835SCornelia Huck
198e75b835SCornelia Huck  [root@host ~]# uuidgen
208e75b835SCornelia Huck  7e270a25-e163-4922-af60-757fc8ed48c6
218e75b835SCornelia Huck
228e75b835SCornelia HuckNote: it is recommended to use the ``mdevctl`` tool for actually configuring
238e75b835SCornelia Huckthe host device.
248e75b835SCornelia Huck
258e75b835SCornelia HuckTo define the same device as configured below to be started
268e75b835SCornelia Huckautomatically, use
278e75b835SCornelia Huck
288e75b835SCornelia Huck::
298e75b835SCornelia Huck
308e75b835SCornelia Huck   [root@host ~]# driverctl -b css set-override 0.0.0313 vfio_ccw
318e75b835SCornelia Huck   [root@host ~]# mdevctl define -u 7e270a25-e163-4922-af60-757fc8ed48c6 \
32*9ece07d7SCornelia Huck                  -p 0.0.0313 -t vfio_ccw-io -a
338e75b835SCornelia Huck
348e75b835SCornelia HuckIf using ``mdevctl`` is not possible or wanted, follow the manual procedure
358e75b835SCornelia Huckbelow.
368e75b835SCornelia Huck
378e75b835SCornelia Huck* Locate the subchannel for the device (in this example, ``0.0.2b09``)::
388e75b835SCornelia Huck
398e75b835SCornelia Huck    [root@host ~]# lscss | grep 0.0.2b09 | awk '{print $2}'
408e75b835SCornelia Huck    0.0.0313
418e75b835SCornelia Huck
428e75b835SCornelia Huck* Unbind the subchannel (in this example, ``0.0.0313``) from the standard
438e75b835SCornelia Huck  I/O subchannel driver and bind it to the vfio-ccw driver::
448e75b835SCornelia Huck
458e75b835SCornelia Huck    [root@host ~]# echo 0.0.0313 > /sys/bus/css/devices/0.0.0313/driver/unbind
468e75b835SCornelia Huck    [root@host ~]# echo 0.0.0313 > /sys/bus/css/drivers/vfio_ccw/bind
478e75b835SCornelia Huck
488e75b835SCornelia Huck* Create the mediated device (identified by the uuid)::
498e75b835SCornelia Huck
508e75b835SCornelia Huck    [root@host ~]# echo "7e270a25-e163-4922-af60-757fc8ed48c6" > \
518e75b835SCornelia Huck    /sys/bus/css/devices/0.0.0313/mdev_supported_types/vfio_ccw-io/create
528e75b835SCornelia Huck
538e75b835SCornelia HuckStep 2: configure QEMU
548e75b835SCornelia Huck~~~~~~~~~~~~~~~~~~~~~~
558e75b835SCornelia Huck
568e75b835SCornelia Huck* Reference the created mediated device and (optionally) pick a device id to
578e75b835SCornelia Huck  be presented in the guest (here, ``fe.0.1234``, which will end up visible
588e75b835SCornelia Huck  in the guest as ``0.0.1234``::
598e75b835SCornelia Huck
608e75b835SCornelia Huck    -device vfio-ccw,devno=fe.0.1234,sysfsdev=\
618e75b835SCornelia Huck    /sys/bus/mdev/devices/7e270a25-e163-4922-af60-757fc8ed48c6
628e75b835SCornelia Huck
638e75b835SCornelia Huck* Start the guest. The device (here, ``0.0.1234``) should now be usable::
648e75b835SCornelia Huck
658e75b835SCornelia Huck    [root@guest ~]# lscss -d 0.0.1234
668e75b835SCornelia Huck    Device   Subchan.  DevType CU Type Use  PIM PAM POM  CHPID
678e75b835SCornelia Huck    ----------------------------------------------------------------------
688e75b835SCornelia Huck    0.0.1234 0.0.0007  3390/0e 3990/e9      f0  f0  ff   1a2a3a0a 00000000
698e75b835SCornelia Huck    [root@guest ~]# chccwdev -e 0.0.1234
708e75b835SCornelia Huck    Setting device 0.0.1234 online
718e75b835SCornelia Huck    Done
728e75b835SCornelia Huck    [root@guest ~]# dmesg -t
738e75b835SCornelia Huck    (...)
748e75b835SCornelia Huck    dasd-eckd 0.0.1234: A channel path to the device has become operational
758e75b835SCornelia Huck    dasd-eckd 0.0.1234: New DASD 3390/0E (CU 3990/01) with 10017 cylinders, 15 heads, 224 sectors
768e75b835SCornelia Huck    dasd-eckd 0.0.1234: DASD with 4 KB/block, 7212240 KB total size, 48 KB/track, compatible disk layout
778e75b835SCornelia Huck    dasda:VOL1/  0X2B09: dasda1
78