Rate This Document
Findability
Accuracy
Completeness
Readability

Installation Using RPM Packages (KAE 1.0)

KAE 1.0 RPM software packages include hisi_hpre, hisi_sec2, hisi_zip, libkaezip, libkae, UACCE, and libwd. UACCE and libwd are required, and the others are optional.

Prerequisites

  • You have downloaded the RPM packages matching the OS. For KAE 1.0, download RPM packages of version v1.x.x from https://gitee.com/kunpengcompute/KAE/releases.
  • The RPM 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/Tongsuo.
  • Set the OpenSSL environment variable OPENSSL_ENGINES to the directory where the KAE dynamic library is stored so that OpenSSL can find KAE.
    1
    export OPENSSL_ENGINES=/usr/local/lib/engines-1.1
    

Procedure

In KAE 1.0, the hisi_hpre and hisi_sec2 driver software packages depend on the UACCE software package, and the libkae engine software package 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.
  1. Use an SSH tool to remotely log in to the Linux CLI as the root user.
  2. Copy the KAE 1.0 RPM software packages to a custom directory.
  3. Install the accelerator driver software packages.
    • Method 1: If OpenSSL has been installed using the preceding default method, run the rpm -ivh *.rpm command to install all KAE RPM software packages.
      1
      rpm -ivh *.rpm
      
      If the following information is displayed, the installation is successful:
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      Preparing...                          ################################# [100%]
      checking installed modules
      Updating / installing...
         1:uacce-1.0.1-1.centos7.6         ################################# [ 14%]
      modules installed
         2:libwd-1.0.1-1.centos7.6         ################################# [ 29%]
         3:libkae-1.0.1-1.centos7.6        ################################# [ 43%]
      checking installed modules
         4:hisi_hpre-1.0.1-1.centos7.6     ################################# [ 57%]
      modules installed
      checking installed modules
         6:hisi_sec2-1.0.1-1.centos7.6     ################################# [ 86%]
      modules installed
      checking installed modules 
      
    • Method 2: Install the RPM packages in sequence. See the following example to install the uacce-1.0.1 software package.
      1
      rpm -ivh uacce-1.0.1-1.centos7.6.aarch64.rpm
      
      If the following information is displayed, the installation is successful:
      1
      2
      3
      4
      5
      Preparing...                          ################################# [100%]
      checking installed modules
      Updating / installing... 
      1:uacce-1.0.1-1.centos7.6             ################################# [100%]
      modules installed
      

      To install the hisi_hpre, hisi_sec2, and hisi_zip driver software packages and the libwd and libkae engine software packages, replace the RPM package name in the command with the actual one. When installing the libkae engine software package, use --prefix to specify the path of the OpenSSL engine. The command and command output are as follows:

      1
      rpm -ivh libkae-1.0.1-1.centos7.6.aarch64.rpm      --prefix=/usr/local/openssl/lib/engines-1.1 
      

      --prefix=/usr/local/openssl/lib/engines-1.1 indicates that the OpenSSL installation path is /usr/local/openssl.

  4. Check whether the RPM packages are installed in the system.
    1. Check whether UACCE is installed.
      1
      rpm -ql uacce
      
      Command output:
      1
      2
      /lib/modules/4.14.0-115.el7a.0.1.aarch64/extra/hisi_qm.ko
      /lib/modules/4.14.0-115.el7a.0.1.aarch64/extra/uacce.ko
      
    2. Check whether hisi_sec2 and hisi_hpre are installed.
      1
      rpm -ql hisi_sec2 hisi_hpre
      
      Command output:
      1
      2
      3
      4
      /lib/modules/4.14.0-115.el7a.0.1.aarch64/extra/hisi_sec2.ko
      /etc/modproe.d/hisi_sec2.conf
      /lib/modules/4.14.0-115.el7a.0.1.aarch64/extra/hisi_hpre.ko
      /etc/modproe.d/hisi_hpre.conf
      
    3. Check whether the corresponding modules are generated in the installation directory.
      1
      ls -al /lib/modules/`uname -r`/extra 
      
      Command output:
      1
      2
      3
      4
      5
      6
      7
      total 3672
      drwxr-xr-x. 2 root root    118 Nov 17 21:56 .
      drwxr-xr-x. 7 root root   4096 Nov 17 21:56 ..
      -rw-r--r--. 1 root root 681104 Nov 12 17:32 hisi_hpre.ko
      -rw-r--r--. 1 root root 618888 Nov 12 17:32 hisi_qm.ko
      -rw-r--r--. 1 root root 729304 Nov 12 17:32 hisi_sec2.ko
      -rw-r--r--. 1 root root 467160 Nov 12 17:32 uacce.ko
      
    4. Check whether the corresponding configuration files are generated in /etc/modprobe.d/.
      1
      ls -al /etc/modprobe.d/
      
      Command output:
      1
      2
      3
      4
      5
      6
      7
      total 36
      drwxr-xr-x.   2 root root  140 Nov 17 21:56 .
      drwxr-xr-x. 127 root root 8192 Nov 17 22:14 ..
      -rw-r--r--.   1 root root  166 Oct 30  2018 firewalld-sysctls.conf
      -rw-r--r--.   1 root root   44 Nov 17 21:56 hisi_hpre.conf
      -rw-r--r--.   1 root root   61 Nov 17 21:56 hisi_sec2.conf
      -rw-r--r--.   1 root root  674 Jul  4  2018 tuned.conf
      
  5. Optional: If a SUSE OS is used, set allow_unsupported_modules in the /etc/modprobe.d/10-unsupported-modules.conf file to 1 before loading external drivers.
  6. 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.
      1. Query UACCE driver modules that have been loaded to the kernel.
        1
        lsmod | grep uacce
        

        If no command output is displayed, perform 6.b to #EN-US_TOPIC_0000002173542086/li208411440133819 to load the corresponding modules to the kernel.

      2. Load the UACCE driver.
        1
        modprobe uacce
        
      3. Load the hisi_sec2 driver to the kernel based on the configuration file in /etc/modprobe.d/hisi_sec2.conf.
        1
        modprobe hisi_sec2
        
      4. Load the hisi_hpre driver to the kernel based on the configuration file in /etc/modprobe.d/hisi_hpre.conf.
        1
        modprobe hisi_hpre
        
      5. Query UACCE driver modules that have been loaded to the kernel again.
        1
        lsmod | grep uacce
        
        If the following information is displayed, the loading is successful:
        1
        uacce                36864  3 hisi_sec2,hisi_qm,hisi_hpre
        

Verifying the Installation

  1. Check KAE RPM software packages.
    1
    rpm -qa uacce hisi_sec2 hisi_hpre
    
    If the following information is displayed, the installation is successful:
    1
    2
    3
    hisi_sec2-1.0.1-1.centos7.6.aarch64
    uacce-1.0.1-1.centos7.6.aarch64
    hisi_hpre-1.0.1-1.centos7.6.aarch64
    
  2. Check the accelerator devices in the virtual file system.
    1
    ls -al /sys/class/uacce/
    
    Command output:
    1
    2
    3
    4
    5
    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 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
    
  3. 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.

    1
    cat /sys/class/uacce/hisi_hpre-*/attrs/available_instances
    
    You can also run the following command to refresh the hardware queue consumption of hisi_sec2 every 0.1 second:
    1
    watch -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.