13ae9bd97SShameer Kolothum=========================================================
23ae9bd97SShameer KolothumUser Space Accelerator Development Kit (UADK) Compression
33ae9bd97SShameer Kolothum=========================================================
43ae9bd97SShameer KolothumUADK is a general-purpose user space accelerator framework that uses shared
53ae9bd97SShameer Kolothumvirtual addressing (SVA) to provide a unified programming interface for
63ae9bd97SShameer Kolothumhardware acceleration of cryptographic and compression algorithms.
73ae9bd97SShameer Kolothum
83ae9bd97SShameer KolothumUADK includes Unified/User-space-access-intended Accelerator Framework (UACCE),
93ae9bd97SShameer Kolothumwhich enables hardware accelerators from different vendors that support SVA to
103ae9bd97SShameer Kolothumadapt to UADK.
113ae9bd97SShameer Kolothum
123ae9bd97SShameer KolothumCurrently, HiSilicon Kunpeng hardware accelerators have been registered with
133ae9bd97SShameer KolothumUACCE. Through the UADK framework, users can run cryptographic and compression
143ae9bd97SShameer Kolothumalgorithms using hardware accelerators instead of CPUs, freeing up CPU
153ae9bd97SShameer Kolothumcomputing power and improving computing performance.
163ae9bd97SShameer Kolothum
173ae9bd97SShameer Kolothumhttps://github.com/Linaro/uadk/tree/master/docs
183ae9bd97SShameer Kolothum
193ae9bd97SShameer KolothumUADK Framework
203ae9bd97SShameer Kolothum==============
213ae9bd97SShameer KolothumUADK consists of UACCE, vendors' drivers, and an algorithm layer. UADK requires
223ae9bd97SShameer Kolothumthe hardware accelerator to support SVA, and the operating system to support
233ae9bd97SShameer KolothumIOMMU and SVA. Hardware accelerators from different vendors are registered as
243ae9bd97SShameer Kolothumdifferent character devices with UACCE by using kernel-mode drivers of the
253ae9bd97SShameer Kolothumvendors. A user can access the hardware accelerators by performing user-mode
263ae9bd97SShameer Kolothumoperations on the character devices.
273ae9bd97SShameer Kolothum
283ae9bd97SShameer Kolothum::
293ae9bd97SShameer Kolothum
303ae9bd97SShameer Kolothum          +----------------------------------+
313ae9bd97SShameer Kolothum          |                apps              |
323ae9bd97SShameer Kolothum          +----+------------------------+----+
333ae9bd97SShameer Kolothum               |                        |
343ae9bd97SShameer Kolothum               |                        |
353ae9bd97SShameer Kolothum       +-------+--------+       +-------+-------+
363ae9bd97SShameer Kolothum       |   scheduler    |       | alg libraries |
373ae9bd97SShameer Kolothum       +-------+--------+       +-------+-------+
383ae9bd97SShameer Kolothum               |                         |
393ae9bd97SShameer Kolothum               |                         |
403ae9bd97SShameer Kolothum               |                         |
413ae9bd97SShameer Kolothum               |                +--------+------+
423ae9bd97SShameer Kolothum               |                | vendor drivers|
433ae9bd97SShameer Kolothum               |                +-+-------------+
443ae9bd97SShameer Kolothum               |                  |
453ae9bd97SShameer Kolothum               |                  |
463ae9bd97SShameer Kolothum            +--+------------------+--+
473ae9bd97SShameer Kolothum            |         libwd          |
483ae9bd97SShameer Kolothum    User    +----+-------------+-----+
493ae9bd97SShameer Kolothum    --------------------------------------------------
503ae9bd97SShameer Kolothum    Kernel    +--+-----+   +------+
513ae9bd97SShameer Kolothum              | uacce  |   | smmu |
523ae9bd97SShameer Kolothum              +---+----+   +------+
533ae9bd97SShameer Kolothum                  |
543ae9bd97SShameer Kolothum              +---+------------------+
553ae9bd97SShameer Kolothum              | vendor kernel driver |
563ae9bd97SShameer Kolothum              +----------------------+
573ae9bd97SShameer Kolothum    --------------------------------------------------
583ae9bd97SShameer Kolothum             +----------------------+
593ae9bd97SShameer Kolothum             |   HW Accelerators    |
603ae9bd97SShameer Kolothum             +----------------------+
613ae9bd97SShameer Kolothum
623ae9bd97SShameer KolothumUADK Installation
633ae9bd97SShameer Kolothum-----------------
643ae9bd97SShameer KolothumBuild UADK
653ae9bd97SShameer Kolothum^^^^^^^^^^
663ae9bd97SShameer Kolothum
673ae9bd97SShameer Kolothum.. code-block:: shell
683ae9bd97SShameer Kolothum
693ae9bd97SShameer Kolothum    git clone https://github.com/Linaro/uadk.git
703ae9bd97SShameer Kolothum    cd uadk
713ae9bd97SShameer Kolothum    mkdir build
723ae9bd97SShameer Kolothum    ./autogen.sh
733ae9bd97SShameer Kolothum    ./configure --prefix=$PWD/build
743ae9bd97SShameer Kolothum    make
753ae9bd97SShameer Kolothum    make install
763ae9bd97SShameer Kolothum
773ae9bd97SShameer KolothumWithout --prefix, UADK will be installed to /usr/local/lib by default.
783ae9bd97SShameer KolothumIf get error:"cannot find -lnuma", please install the libnuma-dev
793ae9bd97SShameer Kolothum
803ae9bd97SShameer KolothumRun pkg-config libwd to ensure env is setup correctly
813ae9bd97SShameer Kolothum^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
823ae9bd97SShameer Kolothum
833ae9bd97SShameer Kolothum* export PKG_CONFIG_PATH=$PWD/build/lib/pkgconfig
843ae9bd97SShameer Kolothum* pkg-config libwd --cflags --libs
853ae9bd97SShameer Kolothum  -I/usr/local/include -L/usr/local/lib -lwd
863ae9bd97SShameer Kolothum
873ae9bd97SShameer Kolothum* export PKG_CONFIG_PATH is required on demand.
883ae9bd97SShameer Kolothum  Not required if UADK is installed to /usr/local/lib
893ae9bd97SShameer Kolothum
903ae9bd97SShameer KolothumUADK Host Kernel Requirements
913ae9bd97SShameer Kolothum-----------------------------
923ae9bd97SShameer KolothumUser needs to make sure that ``UACCE`` is already supported in Linux kernel.
933ae9bd97SShameer KolothumThe kernel version should be at least v5.9 with SVA (Shared Virtual
943ae9bd97SShameer KolothumAddressing) enabled.
953ae9bd97SShameer Kolothum
963ae9bd97SShameer KolothumKernel Configuration
973ae9bd97SShameer Kolothum^^^^^^^^^^^^^^^^^^^^
983ae9bd97SShameer Kolothum
993ae9bd97SShameer Kolothum``UACCE`` could be built as module or built-in.
1003ae9bd97SShameer Kolothum
1013ae9bd97SShameer KolothumHere's an example to enable UACCE with hardware accelerator in HiSilicon
1023ae9bd97SShameer KolothumKunpeng platform.
1033ae9bd97SShameer Kolothum
1043ae9bd97SShameer Kolothum*    CONFIG_IOMMU_SVA_LIB=y
1053ae9bd97SShameer Kolothum*    CONFIG_ARM_SMMU=y
1063ae9bd97SShameer Kolothum*    CONFIG_ARM_SMMU_V3=y
1073ae9bd97SShameer Kolothum*    CONFIG_ARM_SMMU_V3_SVA=y
1083ae9bd97SShameer Kolothum*    CONFIG_PCI_PASID=y
1093ae9bd97SShameer Kolothum*    CONFIG_UACCE=y
1103ae9bd97SShameer Kolothum*    CONFIG_CRYPTO_DEV_HISI_QM=y
1113ae9bd97SShameer Kolothum*    CONFIG_CRYPTO_DEV_HISI_ZIP=y
1123ae9bd97SShameer Kolothum
1133ae9bd97SShameer KolothumMake sure all these above kernel configurations are selected.
1143ae9bd97SShameer Kolothum
1153ae9bd97SShameer KolothumAccelerator dev node permissions
1163ae9bd97SShameer Kolothum--------------------------------
117*24c32ed3SStefan WeilHardware accelerators (eg: HiSilicon Kunpeng Zip accelerator) gets registered to
1183ae9bd97SShameer KolothumUADK and char devices are created in dev directory. In order to access resources
1193ae9bd97SShameer Kolothumon hardware accelerator devices, write permission should be provided to user.
1203ae9bd97SShameer Kolothum
1213ae9bd97SShameer Kolothum.. code-block:: shell
1223ae9bd97SShameer Kolothum
1233ae9bd97SShameer Kolothum    $ sudo chmod 777 /dev/hisi_zip-*
1243ae9bd97SShameer Kolothum
1253ae9bd97SShameer KolothumHow To Use UADK Compression In QEMU Migration
1263ae9bd97SShameer Kolothum---------------------------------------------
1273ae9bd97SShameer Kolothum* Make sure UADK is installed as above
1283ae9bd97SShameer Kolothum* Build ``QEMU`` with ``--enable-uadk`` parameter
1293ae9bd97SShameer Kolothum
1303ae9bd97SShameer Kolothum  E.g. configure --target-list=aarch64-softmmu --enable-kvm ``--enable-uadk``
1313ae9bd97SShameer Kolothum
1323ae9bd97SShameer Kolothum* Enable ``UADK`` compression during migration
1333ae9bd97SShameer Kolothum
1343ae9bd97SShameer Kolothum  Set ``migrate_set_parameter multifd-compression uadk``
1353ae9bd97SShameer Kolothum
1363ae9bd97SShameer KolothumSince UADK uses Shared Virtual Addressing(SVA) and device access virtual memory
137*24c32ed3SStefan Weildirectly it is possible that SMMUv3 may encounter page faults while walking the
1383ae9bd97SShameer KolothumIO page tables. This may impact the performance. In order to mitigate this,
1393ae9bd97SShameer Kolothumplease make sure to specify ``-mem-prealloc`` parameter to the destination VM
1403ae9bd97SShameer Kolothumboot parameters.
1413ae9bd97SShameer Kolothum
1423ae9bd97SShameer KolothumThough both UADK and ZLIB are based on the deflate compression algorithm, UADK
1433ae9bd97SShameer Kolothumis not fully compatible with ZLIB. Hence, please make sure to use ``uadk`` on
1443ae9bd97SShameer Kolothumboth source and destination during migration.
145