Installing KAE Using DEB Packages
The DEB software packages include hisi_hpre, hisi_sec2, hisi_rde, hisi_zip, libkaezip, libkae, UACCE, and libwd. UACCE and libwd are mandatory. The others can be installed as required. Currently, KAE 1.0 can be installed with DEB packages, while KAE 2.0 does not.
Prerequisites
- You have downloaded the DEB packages corresponding to the specified OS from https://gitee.com/kunpengcompute/KAE/releases.
- The dpkg tool is available.
- The OpenSSL version is 1.1.1x (run the openssl version command to query). If not, install OpenSSL based on Installing OpenSSL.
- The OpenSSL environment variable is configured as follows:
Run the following command to set the environment variable. If you specified the installation directory, use the actual installation directory instead of /usr/local/lib/engines-1.1. By default, this environment variable is mounted to the engine path of OpenSSL.
1export OPENSSL_ENGINES=/usr/local/lib/engines-1.1
Procedure
The hisi_hpre, hisi_sec2, hisi_rde, and hisi_zip driver software packages depend on the UACCE software package, and the libkae and libkaezip engine software packages depend on the libwd software package.
- If only the RSA and DH algorithms need to be accelerated, you are advised to install only the UACCE, hisi_hpre, libwd, and libkae software packages.
- If only AES, MD5, SM3, and SM4 need to be accelerated, you are advised to install only the UACCE, hisi_sec2, libwd, and libkae software packages.
- Use SSH to remotely log in to the Linux CLI as the root user.
- Copy the KAE DEB software packages to a custom directory.
- Install the accelerator driver software packages.
- Method 1: Run the dpkg -i *.deb command to install all KAE DEB software packages.
1dpkg -i *.deb
- Method 2: Install the software packages separately. The following example shows how to install the uacce-1.3.1 package.
1 2
dpkg -i uacce-1.3.1-1.ubuntu18.04.arm64.deb uacce modules installed
Install the hisi_hpre, hisi_sec2, and hisi_rde driver software packages and the libwd and libkae engine software packages in sequence. Install the libwd software package before installing the libkae engine package.
- Method 1: Run the dpkg -i *.deb command to install all KAE DEB software packages.
- Check whether the DEB packages are installed in the system.
- Check whether UACCE is installed.
1dpkg -L uacce
Command output:
1 2 3 4 5 6 7
/. /lib /lib/modules /lib/modules/4.15.0-70-generic /lib/modules/4.15.0-70-generic/extra /lib/modules/4.15.0-70-generic/extra/uacce.ko /lib/modules/4.15.0-70-generic/extra/hisi_qm.ko
- Check whether hisi_sec2, hisi_hpre, and hisi_rde are installed.
1dpkg -L hisi-sec2 hisi-hpre hisi-rde
Command output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/. /lib /lib/modules /lib/modules/4.15.0-70-generic /lib/modules/4.15.0-70-generic/extra /lib/modules/4.15.0-70-generic/extra/hisi_sec2.ko /etc /etc/modprobe.d /etc/modprobe.d/hisi_sec2.conf /. /lib /lib/modules /lib/modules/4.15.0-70-generic /lib/modules/4.15.0-70-generic/extra /lib/modules/4.15.0-70-generic/extra/hisi_hpre.ko /etc /etc/modprobe.d /etc/modprobe.d/hisi_hpre.conf /. /lib /lib/modules /lib/modules/4.15.0-70-generic /lib/modules/4.15.0-70-generic/extra /lib/modules/4.15.0-70-generic/extra/hisi_rde.ko /etc /etc/modprobe.d /etc/modprobe.d/hisi_rde.conf
- Check whether the corresponding modules are generated in the installation directory.
1ls -al /lib/modules/`uname -r`/extra
Command output:
1 2 3 4 5 6 7 8
total 348 drwxr-xr-x 2 root root 4096 Apr 15 17:12 . drwxr-xr-x 6 root root 4096 Apr 15 17:12 .. -rw-r--r-- 1 root root 49080 Apr 15 09:15 hisi_hpre.ko -rw-r--r-- 1 root root 85728 Apr 15 09:15 hisi_qm.ko -rw-r--r-- 1 root root 59720 Apr 15 09:15 hisi_rde.ko -rw-r--r-- 1 root root 65536 Apr 15 09:15 hisi_sec2.ko -rw-r--r-- 1 root root 40408 Apr 15 09:15 uacce.ko
- Check whether the corresponding configuration files are generated in /etc/modprobe.d/.
1ls -al /etc/modprobe.d/
Command output:
1 2 3 4 5 6 7 8 9 10 11 12 13
total 52 drwxr-xr-x 2 root root 4096 Apr 15 17:12 . drwxr-xr-x 94 root root 4096 Apr 15 09:15 .. -rw-r--r-- 1 root root 325 Jan 28 2018 blacklist-ath_pci.conf -rw-r--r-- 1 root root 1667 Nov 13 2018 blacklist.conf -rw-r--r-- 1 root root 210 Jan 28 2018 blacklist-firewire.conf -rw-r--r-- 1 root root 697 Jan 28 2018 blacklist-framebuffer.conf -rw-r--r-- 1 root root 583 Jan 28 2018 blacklist-rare-network.conf -rw-r--r-- 1 root root 45 Apr 15 09:15 hisi_hpre.conf -rw-r--r-- 1 root root 44 Apr 15 09:15 hisi_rde.conf -rw-r--r-- 1 root root 61 Apr 15 09:15 hisi_sec2.conf -rw-r--r-- 1 root root 347 Jan 28 2018 iwlwifi.conf -rw-r--r-- 1 root root 379 Jul 2 2018 mdadm.conf
- Check whether UACCE is installed.
- Load the accelerator drivers to the kernel.
- Method 1: Restart the system.
- Method 2: Manually load the drivers in sequence in the CLI and check whether the loading is successful.
- Query driver modules that have been loaded to the kernel.
1lsmod | grep uacce
If no command output is displayed, perform 5.b to 5.e to load the corresponding modules to the kernel.
- Load the UACCE driver.
1modprobe uacce - Load the hisi_sec2 driver to the kernel based on the configuration file in /etc/modprobe.d/hisi_sec2.conf.
1modprobe hisi_sec2 - Load the hisi_hpre driver to the kernel based on the configuration file in /etc/modprobe.d/hisi_hpre.conf.
1modprobe hisi_hpre - Load the hisi_rde driver to the kernel based on the configuration file in /etc/modprobe.d/hisi_rde.conf.
1modprobe hisi_rde - Query driver modules that have been loaded to the kernel again.
1 2
lsmod | grep uacce lsmod | grep hisi_qm
If the following information is displayed, the loading is successful:1uacce 28672 1 hisi_qm
1 2
hisi_qm 65536 4 hisi_sec2,hisi_hpre,hisi_rde uacce 28672 1 hisi_qm
- Query driver modules that have been loaded to the kernel.
Verifying the Installation
- Query KAE DEB software packages.
1dpkg -s uacce hisi-sec2 hisi-hpre hisi-rde
The query result is as follows:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
Package: uacce Status: install ok installed Priority: optional Section: utils Installed-Size: 512 Maintainer: HiSilicon Tech. Co., Ltd. Architecture: arm64 Version: 1.3.1 Description: This package contains the Unified/User-space-access-intended Accelerator Framework. URL: https://support.huawei.com Package: hisi-sec2 Status: install ok installed Priority: optional Section: utils Installed-Size: 512 Maintainer: HiSilicon Tech. Co., Ltd. Architecture: arm64 Version: 1.3.1 Description: This package contains the Huawei HiSilicon SEC Accelerator Driver. URL: https://support.huawei.com Package: hisi-hpre Status: install ok installed Priority: optional Section: utils Installed-Size: 512 Maintainer: HiSilicon Tech. Co., Ltd. Architecture: arm64 Version: 1.3.1 Description: This package contains the Huawei Hisilicon HPRE Accelerator Driver. URL: https://support.huawei.com Package: hisi-rde Status: install ok installed Priority: optional Section: utils Installed-Size: 512 Maintainer: HiSilicon Tech. Co., Ltd. Architecture: arm64 Version: 1.3.1 Description: This package contains the Huawei Hisilicon RDE Accelerator Driver. URL: https://support.huawei.com
- Check the accelerator devices in the virtual file system.
1ls -al /sys/class/uacce/
Command output:1 2 3 4 5 6 7
total 0 lrwxrwxrwx. 1 root root 0 Nov 14 03:45 hisi_hpre-2 -> ../../devices/pci0000:78/0000:78:00.0/0000:79:00.0/uacce/hisi_hpre-2 lrwxrwxrwx. 1 root root 0 Nov 14 03:45 hisi_hpre-3 -> ../../devices/pci0000:b8/0000:b8:00.0/0000:b9:00.0/uacce/hisi_hpre-3 lrwxrwxrwx. 1 root root 0 Nov 17 22:09 hisi_rde-4 -> ../../devices/pci0000:78/0000:78:01.0/uacce/hisi_rde-4 lrwxrwxrwx. 1 root root 0 Nov 17 22:09 hisi_rde-5 -> ../../devices/pci0000:b8/0000:b8:01.0/uacce/hisi_rde-5 lrwxrwxrwx. 1 root root 0 Nov 14 08:39 hisi_sec-0 -> ../../devices/pci0000:74/0000:74:01.0/0000:76:00.0/uacce/hisi_sec-0 lrwxrwxrwx. 1 root root 0 Nov 14 08:39 hisi_sec-1 -> ../../devices/pci0000:b4/0000:b4:01.0/0000:b6:00.0/uacce/hisi_sec-1
- Check whether KAEOpensslEngine takes effect.
The RSA performance is used as an example. For details about the verification procedure, see Testing the RSA Algorithm Performance in Synchronous Mode. The command output shows that the RSA performance is significantly improved after KAE is specified.
In addition, during the execution of the RSA performance verification command, you can view the hardware queue resource usage of the hisi_hpre device on a new terminal. Similarly, you can view the hardware queue resource usage of the hisi_sec2 device when verifying the SM3/SM4 algorithm performance.
1cat /sys/class/uacce/hisi_hpre-*/attrs/available_instancesYou can also run the following command to refresh the hardware queue consumption of hisi_sec2 every 0.1 second:1watch -n 0.1 cat /sys/class/uacce/hisi_hpre-*/attrs/available_instances
If the value changes from 256 to 255, the RSA algorithm consumes a hardware queue of the HPRE accelerator, indicating that KAEOpensslEngine has taken effect.