Q&A: Why is CAAM Driver Not Functioning in Linux for iMX6?

Document created by Yixing Kong Employee on Sep 17, 2013
Version 1Show Document
  • View in full screen mode

Question:

Using Linux SDK 4.1.0, with CAAM drivers enabled, there is little noticeable difference in the performance of openssd compared to a kernel without the CAAM drivers.

 

Tests were done using openssd.

 

Test image

AES-128 8192 byte block (M Bytes/sec)

“openssl speed –evp aes-128-cbc

AES-128 8192 byte block (M Bytes/sec)

With /dev/crypto

“openssl speed –evp aes-128-cbc -engine cryptodev” 

Ubuntu 11.04 Image

19.010

N/A

Timesys

20.518

N/A

SDK 4.1.0 LTIB

22.013

21.984 (errors reported)

 

One can see that with SDK 4.1.0, performance is worse with crypto enabled.  This is probably due to the overhead of a faulty driver or incorrect implementation.

 

The lowest number is for Ubuntu which could be attributed to the Unity GUI.

 

Conclusion: 

CAAM driver is not functional or I am using an improper testing procedure.

 

Test Procedure:

Board used is iMX6Q Sabre SDP

 

Openssl was used for testing.

Two command line commands were used, with and without the cryptodev engine.

 

openssl speed –evp aes-128-cbc

openssl speed –evp aes-128-cbc -engine cryptodev

 

Openssl versions used in each build are slightly different:

 

Ubuntu:              openssl 1.0.0e

Timesys:              openssl  1.0.1e

SDK 4.1.0:            openssl  1.0.1c

 

Three versions of Linux were tested.

  1. Default kernel  4.0.0 with Ubuntu rootfs form image tarballs.
  2. Timesys kernel and root file system
  3. Kernel built with SDK 4.1.0 using LTIB with hardware crypto enabled

 

Both 1 and 2 above did not have CRYPTODEV set in .config which contains the line

“# CONFIG_CRYPTO_CRYPTODEV is not set”

 

Option 3 had the line in .config as,

“CONFIG_CRYPTO_CRYPTODEV=y”

 

All three builds generate “/proc/crypto”  whose contents are attached.  A partial listing of /proc/crypto lists “caam” as a driver for all encryption methods supported.  Example printout for aes shown below:

ame         : cbc(aes)

driver       : cbc-aes-caam

module       : kernel

priority     : 3000

refcnt       : 1

selftest     : passed

type         : ablkcipher

async        : yes

blocksize    : 16

min keysize  : 16

max keysize  : 32

ivsize       : 16

geniv        : eseqiv

 

All three builds have “caam” and “enable_wait_mode=off” in the kernel command line in u-boot.

 

Only option #3 contains both device file in “/dev/crypto” and an entry in “/proc/crypto”

 

root@freescale ~$ cd /

root@freescale /$ ls /proc/cr*

/proc/crypto

root@freescale /$ ls /dev/cr*

/dev/crypto

root@freescale /$

 

Test #1—Kernel build 4.1.0 openssl speed test without caam engine

 

root@freescale ~$ openssl speed -evp aes-128-cbc                   

Doing aes-128-cbc for 3s on 16 size blocks: 3471184 aes-128-cbc's in 2.94s

Doing aes-128-cbc for 3s on 64 size blocks: 986286 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 256 size blocks: 249743 aes-128-cbc's in 2.93s

Doing aes-128-cbc for 3s on 1024 size blocks: 64343 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 8192 size blocks: 7954 aes-128-cbc's in 2.96s

OpenSSL 1.0.1c 10 May 2012

built on: Sat Sep 7 18:47:34 PDT 2013

options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) blowfish(ptr)

compiler: gcc -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall

The 'numbers' are in 1000s of bytes per second processed.

type 16 bytes     64 bytes    256 bytes 1024 bytes   8192 bytes

aes-128-cbc 18890.80k    21040.77k    21820.55k 21962.41k    22013.23k

root@freescale ~$

 

Test #2—Timesys kernel build of openssd without /dev/crypto

 

# openssl speed -evp aes-128-cbc

Doing aes-128-cbc for 3s on 16 size blocks: 3361305 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 64 size blocks: 924423 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 256 size blocks: 236623 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 1024 size blocks: 59967 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 8192 size blocks: 7514 aes-128-cbc's in 3.00s

OpenSSL 1.0.1e 11 Feb 2013

built on: Thu Sep 5 21:54:37 EDT 2013

options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) blowfish(ptr)

compiler: armv7l-timesys-linux-gnueabi-gcc -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -I/here/workdir/factory/build_armv7l-times

ys-linux-gnueabi/toolchain/usr/include -DL_ENDIAN -DTERMIO -DOPENSSL_NO_KRB5 -DOPENSSL_NO_IDEA -DOPENSSL_NO_MDC2 -DOPENSSL_NO_RC5 -Os -pipe -Wa,--noexecstack -Wall

The 'numbers' are in 1000s of bytes per second processed.

type 16 bytes     64 bytes    256 bytes 1024 bytes   8192 bytes

aes-128-cbc 17926.96k    19721.02k    20191.83k 20468.74k    20518.23k

 

Test #3—Ubuntu rootfs and kernel image

 

root@linaro-ubuntu-desktop:/# openssl speed -evp aes-128-cbc

Doing aes-128-cbc for 3s on 16 size blocks: 3030128 aes-128-cbc's in 2.98s

Doing aes-128-cbc for 3s on 64 size blocks: 852897 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 256 size blocks: 220572 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 1024 size blocks: 55534 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 8192 size blocks: 6846 aes-128-cbc's in 2.95s

OpenSSL 1.0.0e 6 Sep 2011

built on: Wed Oct 5 01:45:02 UTC 2011

options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) blowfish(ptr)

compiler: cc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DTERMIO -O2 -Wa,--noexecstack -g -Wall

The 'numbers' are in 1000s of bytes per second processed.

type             16 bytes     64 bytes 256 bytes   1024 bytes   8192 bytes

aes-128-cbc 16269.14k    18195.14k    18822.14k 18955.61k    19010.99k

root@linaro-ubuntu-desktop:/#

 

 

Test #4—SDK 4.1.0 openssl speed test with “/dev/crypto” .  Note errors.

 

root@freescale ~$ openssl speed -evp aes-128-cbc -engine cryptodev 

invalid engine "cryptodev"

716715216:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:187:filename(/usr/lib/engines/libcryptodev.so): /usr/lib/eng

ines/libcryptodev.so: cannot open shared object file: No such file or directory

716715216:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:

716715216:error:260B6084:engine routines:DYNAMIC_LOAD:dso not found:eng_dyn.c:450:

716715216:error:2606A074:engine routines:ENGINE_by_id:no such engine:eng_list.c:417:id=cryptodev

716715216:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:187:filename(libcryptodev.so): libcryptodev.so: cannot open

shared object file: No such file or directory

716715216:error:25070067:DSO support routines:DSO_load:could not load the shared library:dso_lib.c:244:

716715216:error:260B6084:engine routines:DYNAMIC_LOAD:dso not found:eng_dyn.c:450:

Doing aes-128-cbc for 3s on 16 size blocks: 3572980 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 64 size blocks: 966002 aes-128-cbc's in 2.94s

Doing aes-128-cbc for 3s on 256 size blocks: 255307 aes-128-cbc's in 3.00s

Doing aes-128-cbc for 3s on 1024 size blocks: 62967 aes-128-cbc's in 2.93s

Doing aes-128-cbc for 3s on 8192 size blocks: 7890 aes-128-cbc's in 2.94s

OpenSSL 1.0.1c 10 May 2012

built on: Sat Sep 7 18:47:34 PDT 2013

options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) blowfish(ptr)

compiler: gcc -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall

The 'numbers' are in 1000s of bytes per second processed.

type 16 bytes     64 bytes    256 bytes 1024 bytes   8192 bytes

aes-128-cbc 19055.89k    21028.61k    21786.20k 22006.21k    21984.65k

root@freescale ~$

 

Answer:

I do not know what is recent state of official Freescale BSP regarding CAAM, but to get OpenSSL working under CAAM support with reasonable acceleration  :

 

https://community.freescale.com/message/318188#318188

 

The patches was used below :

http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/log/?h=imx_3.0.35_4.0.0

 

Direct link to the patches:

http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/commit/?h=imx_3.0.35_4.0.0&id=6068d7a77b2101c172fc2f003f90b1febbf99505

http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git/commit/?h=imx_3.0.35_4.0.0&id=b30237c79003223c6e8035d5be183cd4f0b469f9

2 people found this helpful

Outcomes