• Ian Munsie's avatar
    cxl: Export optional AFU configuration record in sysfs · b087e619
    Ian Munsie authored
    An AFU may optionally contain one or more PCIe like configuration
    records, which can be used to identify the AFU.
    
    This patch adds support for exposing the raw config space and the
    vendor, device and class code under sysfs. These will appear in a
    subdirectory of the AFU device corresponding with the configuration
    record number, e.g.
    
    cat /sys/class/cxl/afu0.0/cr0/vendor
    0x1014
    
    cat /sys/class/cxl/afu0.0/cr0/device
    0x4350
    
    cat /sys/class/cxl/afu0.0/cr0/class
    0x120000
    
    hexdump -C /sys/class/cxl/afu0.0/cr0/config
    00000000  14 10 50 43 00 00 00 00  06 00 00 12 00 00 00 00  |..PC............|
    00000010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
    *
    00000100
    
    These files behave in much the same way as the equivalent files for PCI
    devices, with one exception being that the config file is currently
    read-only and restricted to the root user. It is not necessarily
    required to be this strict, but we currently do not have a compelling
    use-case to make it writable and/or world-readable, so I erred on the
    side of being restrictive.
    Signed-off-by: default avatarIan Munsie <imunsie@au1.ibm.com>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    b087e619
cxl.h 23.5 KB