6d3351
From 8c30b1e683b37d67d7fe827f6ab63174c596494e Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <8c30b1e683b37d67d7fe827f6ab63174c596494e@dist-git>
6d3351
From: Erik Skultety <eskultet@redhat.com>
6d3351
Date: Thu, 18 May 2017 14:02:49 +0200
6d3351
Subject: [PATCH] docs: Provide a nodedev driver stub documentation
6d3351
6d3351
There's lot more to document about the nodedev driver, besides PCI and
6d3351
SR-IOV (even this might need to be extended), but let's start small-ish
6d3351
and at least have a page for it linked from the drivers.html.
6d3351
6d3351
https://bugzilla.redhat.com/show_bug.cgi?id=1452072
6d3351
6d3351
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6d3351
(cherry picked from commit a94d431dc46070034de7798f572dc1d257542a50)
6d3351
Signed-off-by: Erik Skultety <eskultet@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 docs/drivers.html.in    |   6 +-
6d3351
 docs/drvnodedev.html.in | 189 ++++++++++++++++++++++++++++++++++++++++++++++++
6d3351
 2 files changed, 194 insertions(+), 1 deletion(-)
6d3351
 create mode 100644 docs/drvnodedev.html.in
6d3351
6d3351
diff --git a/docs/drivers.html.in b/docs/drivers.html.in
6d3351
index be7483b9b..61993861e 100644
6d3351
--- a/docs/drivers.html.in
6d3351
+++ b/docs/drivers.html.in
6d3351
@@ -4,7 +4,11 @@
6d3351
   <body>
6d3351
     

Internal drivers

6d3351
 
6d3351
-    
    6d3351
    +    
      6d3351
      +      
    • Hypervisor drivers
    • 6d3351
      +      
    • Storage drivers
    • 6d3351
      +      
    • Node device driver
    • 6d3351
      +    
      6d3351
       
      6d3351
           

      6d3351
             The libvirt public API delegates its implementation to one or
      6d3351
      diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in
      6d3351
      new file mode 100644
      6d3351
      index 000000000..0a3870343
      6d3351
      --- /dev/null
      6d3351
      +++ b/docs/drvnodedev.html.in
      6d3351
      @@ -0,0 +1,189 @@
      6d3351
      +
      6d3351
      +
      6d3351
      +<html xmlns="http://www.w3.org/1999/xhtml">
      6d3351
      +  <body>
      6d3351
      +    

      Host device management

      6d3351
      +
      6d3351
      +    

      6d3351
      +      Libvirt provides management of both physical and virtual host devices
      6d3351
      +      (historically also referred to as node devices) like USB, PCI, SCSI, and
      6d3351
      +      network devices. This also includes various virtualization capabilities
      6d3351
      +      which the aforementioned devices provide for utilization, for example
      6d3351
      +      SR-IOV, NPIV, DRM, etc.
      6d3351
      +    

      6d3351
      +
      6d3351
      +    

      6d3351
      +      The node device driver provides means to list and show details about host
      6d3351
      +      devices (virsh nodedev-list,
      6d3351
      +      virsh nodedev-dumpxml), which are generic and can be used
      6d3351
      +      with all devices. It also provides means to create and destroy devices
      6d3351
      +      (virsh nodedev-create, virsh nodedev-destroy)
      6d3351
      +      which are meant to be used to create virtual devices, currently only
      6d3351
      +      supported by NPIV
      6d3351
      +      (more info about NPIV)).
      6d3351
      +      Devices on the host system are arranged in a tree-like hierarchy, with
      6d3351
      +      the root node being called computer. The node device driver
      6d3351
      +      supports two backends to manage the devices, HAL and udev, with the former
      6d3351
      +      being deprecated in favour of the latter.
      6d3351
      +    

      6d3351
      +
      6d3351
      +    

      6d3351
      +      The generic format of a host device XML can be seen below.
      6d3351
      +      To identify a device both within the host and the device tree hierarchy,
      6d3351
      +      the following elements are used:
      6d3351
      +    

      6d3351
      +      
      6d3351
      +        
      name
      6d3351
      +        
      6d3351
      +          The device's name will be generated by libvirt using the subsystem,
      6d3351
      +          like pci and the device's sysfs basename.
      6d3351
      +        
      6d3351
      +        
      path
      6d3351
      +        
      6d3351
      +          Fully qualified sysfs path to the device.
      6d3351
      +        
      6d3351
      +        
      parent
      6d3351
      +        
      6d3351
      +          This element identifies the parent node in the device hierarchy. The
      6d3351
      +          value of the element will correspond with the device parent's
      6d3351
      +          name element or computer if the device does
      6d3351
      +          not have any parent.
      6d3351
      +        
      6d3351
      +        
      driver
      6d3351
      +        
      6d3351
      +          This elements reports the driver in use for this device. The presence
      6d3351
      +          of this element in the output XML depends on whether the underlying
      6d3351
      +          device manager (most likely udev) exposes information about the
      6d3351
      +          driver.
      6d3351
      +        
      6d3351
      +        
      capability
      6d3351
      +        
      6d3351
      +          Describes the device in terms of feature support. The element has one
      6d3351
      +          mandatory attribute type the value of which determines
      6d3351
      +          the type of the device. Currently recognized values for the attribute
      6d3351
      +          are:
      6d3351
      +          system,
      6d3351
      +          pci,
      6d3351
      +          usb,
      6d3351
      +          usb_device,
      6d3351
      +          net,
      6d3351
      +          scsi,
      6d3351
      +          scsi_host (Since 0.4.7),
      6d3351
      +          fc_host,
      6d3351
      +          vports,
      6d3351
      +          scsi_target (Since 0.7.3),
      6d3351
      +          storage (Since 1.0.4),
      6d3351
      +          scsi_generic (Since 1.0.7),
      6d3351
      +          drm (Since 3.1.0), and
      6d3351
      +          This element can be nested in which case it further specifies a
      6d3351
      +          device's capability. Refer to specific device types to see more values
      6d3351
      +          for the type attribute which are exclusive.
      6d3351
      +        
      6d3351
      +      
      6d3351
      +
      6d3351
      +    

      Basic structure of a node device

      6d3351
      +    
      6d3351
      +<device>
      6d3351
      +  <name>pci_0000_00_17_0</name>
      6d3351
      +  <path>/sys/devices/pci0000:00/0000:00:17.0</path>
      6d3351
      +  <parent>computer</parent>
      6d3351
      +  <driver>
      6d3351
      +    <name>ahci</name>
      6d3351
      +  </driver>
      6d3351
      +  <capability type='pci'>
      6d3351
      +...
      6d3351
      +  </capability>
      6d3351
      +</device>
      6d3351
      +
      6d3351
      +    
        6d3351
        +
        6d3351
        +    

        PCI host devices

        6d3351
        +    
        6d3351
        +      
        capability
        6d3351
        +      
        6d3351
        +        When used as top level element, the supported values for the
        6d3351
        +        type attribute are pci and
        6d3351
        +        phys_function (see SR-IOV below).
        6d3351
        +      
        6d3351
        +    
        6d3351
        +    
        6d3351
        +<device>
        6d3351
        +  <name>pci_0000_04_00_1</name>
        6d3351
        +  <path>/sys/devices/pci0000:00/0000:00:06.0/0000:04:00.1</path>
        6d3351
        +  <parent>pci_0000_00_06_0</parent>
        6d3351
        +  <driver>
        6d3351
        +    <name>igb</name>
        6d3351
        +  </driver>
        6d3351
        +  <capability type='pci'>
        6d3351
        +    <domain>0</domain>
        6d3351
        +    <bus>4</bus>
        6d3351
        +    <slot>0</slot>
        6d3351
        +    <function>1</function>
        6d3351
        +    <product id='0x10c9'>82576 Gigabit Network Connection</product>
        6d3351
        +    <vendor id='0x8086'>Intel Corporation</vendor>
        6d3351
        +    <iommuGroup number='15'>
        6d3351
        +      <address domain='0x0000' bus='0x04' slot='0x00' function='0x1'/>
        6d3351
        +    </iommuGroup>
        6d3351
        +    <numa node='0'/>
        6d3351
        +    <pci-express>
        6d3351
        +      <link validity='cap' port='1' speed='2.5' width='2'/>
        6d3351
        +      <link validity='sta' speed='2.5' width='2'/>
        6d3351
        +    </pci-express>
        6d3351
        +  </capability>
        6d3351
        +</device>
        6d3351
        +
        6d3351
        +    

        6d3351
        +      The XML format for a PCI device stays the same for any further
        6d3351
        +      capabilities it supports, a single nested <capability>
        6d3351
        +      element will be included for each capability the device supports.
        6d3351
        +    

        6d3351
        +
        6d3351
        +    

        SR-IOV capability

        6d3351
        +    

        6d3351
        +      Single root input/output virtualization (SR-IOV) allows sharing of the
        6d3351
        +      PCIe resources by multiple virtual environments. That is achieved by
        6d3351
        +      slicing up a single full-featured physical resource called physical
        6d3351
        +      function (PF) into multiple devices called virtual functions (VFs) sharing
        6d3351
        +      their configuration with the underlying PF. Despite the SR-IOV
        6d3351
        +      specification, the amount of VFs that can be created on a PF varies among
        6d3351
        +      manufacturers.
        6d3351
        +    

        6d3351
        +
        6d3351
        +    

        6d3351
        +      Suppose the NIC above was also SR-IOV capable, it would
        6d3351
        +      also include a nested
        6d3351
        +      <capability> element enumerating all virtual
        6d3351
        +      functions available on the physical device (physical port) like in the
        6d3351
        +      example below.
        6d3351
        +    

        6d3351
        +
        6d3351
        +    
        6d3351
        +<capability type='pci'>
        6d3351
        +...
        6d3351
        +  <capability type='virt_functions' maxCount='7'>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x10' function='0x1'/>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x10' function='0x3'/>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x10' function='0x5'/>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x10' function='0x7'/>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x11' function='0x1'/>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x11' function='0x3'/>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x11' function='0x5'/>
        6d3351
        +  </capability>
        6d3351
        +...
        6d3351
        +</capability>
        6d3351
        +    

        6d3351
        +      A SR-IOV child device on the other hand, would then report its top level
        6d3351
        +      capability type as a phys_function instead:
        6d3351
        +    

        6d3351
        +
        6d3351
        +    
        6d3351
        +<device>
        6d3351
        +...
        6d3351
        +  <capability type='phys_function'>
        6d3351
        +    <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
        6d3351
        +  </capability>
        6d3351
        +...
        6d3351
        +<device>
        6d3351
        +
        6d3351
        +  </body>
        6d3351
        +</html>
        6d3351
        -- 
        6d3351
        2.13.0
        6d3351