NXP CAAM Hardware Offloading with OpenSSL in LS1046A

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

NXP CAAM Hardware Offloading with OpenSSL in LS1046A

794 Views
Sakthi
Contributor II

Hi 

I am working with LS1046ARDB Evaluation Board to develop a network based application. I have started my project with Flex-builder(flexbuild_lsdk2108), Flex-installer(version: 1.13.2108) and Codewarrior IDE. Now i want to develop OPENSSL application with NXP CAAM Hardware Offloading feature. I have followed the steps in this document https://www.nxp.com/docs/en/user-guide/LSDKUG_Rev21.08.pdf  -> 9.1.1.3 Hardware Offloading with OpenSSL section. But i can't load the CAAM into OPENSSL so can you guide me to load and use the OPENSSL hardware offloading feature. I have posted my work below.

I have download the images from https://lsdk.github.io/components.html

boot_LS -> wget https://www.nxp.com/lgfiles/sdk/lsdk2108/boot_LS_arm64_lts_5.10.tgz

firmware image -> wget https://www.nxp.com/lgfiles/sdk/lsdk2108/firmware_ls1046ardb_sdboot.img

Rootfs -> wget https://www.nxp.com/lgfiles/sdk/lsdk2108/rootfs_lsdk2108_ubuntu_main_arm64.tgz

I have depolyed the image's in SD card through flex-installer:

$ flex-installer -i pf -d /dev/sdx (partition and format the target storage device)

$ sudo flex-installer -b boot_LS_arm64_lts_5.10.tgz -r rootfs_lsdk2108_ubuntu_main_arm64.tgz -f firmware_ls1046ardb_sdboot.img -d /dev/sdx

I have booted the board using SD card, by default caam driver is not enabled in linux kernel it was builded as a module.

NXP LSDK 2108 main (custom based on ubuntu 20.04)
localhost login: root
Password: root

root@localhost:~# dmesg | grep -i caam

root@localhost:~# modinfo caam

filename: /lib/modules/5.10.35/kernel/drivers/crypto/caam/caam.ko
author: Freescale Semiconductor - NMG/STC
description: FSL CAAM request backend
license: GPL
alias: of:N*T*Cfsl,sec4.0C*
alias: of:N*T*Cfsl,sec4.0
alias: of:N*T*Cfsl,sec-v4.0C*
alias: of:N*T*Cfsl,sec-v4.0
depends: error
intree: Y
name: caam
vermagic: 5.10.35 SMP preempt mod_unload modversions aarch64

root@localhost:~# modinfo cryptodev

filename: /lib/modules/5.10.35/extra/cryptodev.ko
license: GPL
description: CryptoDev driver
author: Nikos Mavrogiannopoulos <nmav@gnutls.org>
depends:
name: cryptodev
vermagic: 5.10.35 SMP preempt mod_unload modversions aarch64
parm: cryptodev_verbosity:0: normal, 1: verbose, 2: debug (int)

Sakthi_1-1656658406618.png

but these drivers are not available as module. It was builded as build-in drivers in kernel.

root@localhost:~# modinfo caamalg
modinfo: ERROR: Module caamalg not found.

root@localhost:~# modinfo caamhash
modinfo: ERROR: Module caamhash not found.

root@localhost:~# modinfo caam_pkc
modinfo: ERROR: Module caam_pkc not found.

I have verfied the kernel drivers below:

root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM
CONFIG_CRYPTO_DEV_FSL_CAAM=m
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_JR
CONFIG_CRYPTO_DEV_FSL_CAAM_JR=m
SH_APIocalhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_AHA
CONFIG_CRYPTO_DEV_FSL_CAAM_AHASH_API=y
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_PKC_API
CONFIG_CRYPTO_DEV_FSL_CAAM_PKC_API=y
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API
CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_API=y
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_TK_API
CONFIG_CRYPTO_DEV_FSL_CAAM_TK_API=y
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_TEST
# CONFIG_CRYPTO_DEV_FSL_CAAM_RNG_TEST is not set
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_SM
CONFIG_CRYPTO_DEV_FSL_CAAM_SM=y
root@localhost:~# zcat /proc/config.gz | grep -iw CONFIG_CRYPTO_DEV_FSL_CAAM_JR_UIO
CONFIG_CRYPTO_DEV_FSL_CAAM_JR_UIO=m

root@localhost:~# openssl
openssl: symbol lookup error: openssl: undefined symbol: EVP_mdc2, version OPENSSL_1_1_0

By default openssl was throw an error, but if i run ./openssl in /usr/bin it was working

root@localhost:/usr/bin# ./openssl
OpenSSL> engine
(dynamic) Dynamic engine loading support
OpenSSL> version
OpenSSL 1.1.1f 31 Mar 2020
OpenSSL>

Now I load the caam module through modprobe, but it through error in caam_jr

root@localhost:~# modprobe -v caam
insmod /lib/modules/5.10.35/kernel/drivers/crypto/caam/error.ko
insmod /lib/modules/5.10.35/kernel/drivers/crypto/caam/caam.ko
root@localhost:~# [ 1790.786153] caam_jr 1730000.jr: failed to flush job ring 2

root@localhost:~# ls /dev/crypto
ls: cannot access '/dev/crypto': No such file or directory

root@localhost:~# cat /proc/interrupts | grep jr
78: 11 0 0 0 GICv2 103 Level 1710000.jr
79: 0 0 0 0 GICv2 104 Level 1720000.jr
80: 0 0 0 0 GICv2 105 Level fsl-jr0

root@localhost:/usr/bin# modprobe cryptodev

root@localhost:/usr/bin# ls /dev/crypto
/dev/crypto

root@localhost:/usr/bin# ./openssl engine
(dynamic) Dynamic engine loading support

root@localhost:/usr/bin# ./openssl engine
(dynamic) Dynamic engine loading support

I have faced few error in caam and cryptodev in dmesg after loading caam and cryptodev module, due to this may be CAAM offload is not happening or else, can you guide me to offload.

root@localhost:~# dmesg
[ 1790.522486] caam 1700000.crypto: Linux CAAM Queue I/F driver initialised
[ 1790.523182] caam 1700000.crypto: device ID = 0x0a11030100000000 (Era
[ 1790.523190] caam 1700000.crypto: job rings = 3, qi = 1
[ 1790.780457] caam algorithms registered in /proc/crypto
[ 1790.781646] caam 1700000.crypto: caam pkc algorithms registered in /proc/crypto
[ 1790.784495] caam 1700000.crypto: algorithms registered in /proc/crypto
[ 1790.784503] caam 1700000.crypto: registering rng-caam
[ 1790.784718] Device caam-keygen registered
[ 1790.786153] caam_jr 1730000.jr: failed to flush job ring 2
[ 1790.791749] caam_jr: probe of 1730000.jr failed with error -5
[ 1790.802356] fsl-jr-uio 1730000.jr: UIO device full name fsl-jr0 initialized
[ 1872.560845] cryptodev: loading out-of-tree module taints kernel.
[ 1872.562580] cryptodev: driver 1.12 loaded.

I am not getting the cryptodev engine in OPENSSL like below

Sakthi_2-1656659684914.png

Can you provide a neccessary details to fix this issue. Looking forward for your response.

Thanks in advance.

0 Kudos
0 Replies