openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Ask questions about Arch Linux ARM. Please search before making a new topic.

openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby swass » Mon Aug 11, 2014 3:55 pm

Perhaps someone can point me in the right direction here. I had followed the fairly simple instructions to get cryptodev up and running on my Pogoplug v4 with a Marvell Kirkwood 800MHz SoC. The SoC has a hardware encryption engine that should accelerate AES encryption.

My issue is that certain things like SHA1 are clearly showing hardware acceleration, while AES and DES are not. Looking at the kernel module, I cannot find any options to tinker with. So either openssl is avoiding using cryptodev for AES and DES, or cryptodev isn't seeming to work properly for them.

# openssl speed aes-256-cbc
Doing aes-256 cbc for 3s on 16 size blocks: 1407258 aes-256 cbc's in 2.93s
Doing aes-256 cbc for 3s on 64 size blocks: 394512 aes-256 cbc's in 2.94s
Doing aes-256 cbc for 3s on 256 size blocks: 101470 aes-256 cbc's in 2.93s
Doing aes-256 cbc for 3s on 1024 size blocks: 25620 aes-256 cbc's in 2.93s
Doing aes-256 cbc for 3s on 8192 size blocks: 3189 aes-256 cbc's in 2.91s
..nope...

# openssl speed aes-128-cbc
Doing aes-128 cbc for 3s on 16 size blocks: 1873074 aes-128 cbc's in 2.92s
Doing aes-128 cbc for 3s on 64 size blocks: 527350 aes-128 cbc's in 2.94s
Doing aes-128 cbc for 3s on 256 size blocks: 136055 aes-128 cbc's in 2.93s
Doing aes-128 cbc for 3s on 1024 size blocks: 34330 aes-128 cbc's in 2.94s
Doing aes-128 cbc for 3s on 8192 size blocks: 4300 aes-128 cbc's in 2.94s
..nope...

# openssl speed sha1
Doing sha1 for 3s on 16 size blocks: 15722 sha1's in 0.35s
Doing sha1 for 3s on 64 size blocks: 14877 sha1's in 0.27s
Doing sha1 for 3s on 256 size blocks: 14755 sha1's in 0.28s
Doing sha1 for 3s on 1024 size blocks: 12797 sha1's in 0.28s
Doing sha1 for 3s on 8192 size blocks: 6603 sha1's in 0.19s
..yep...

Do I need to modify the OpenSSL configuration for this?
swass
 
Posts: 27
Joined: Mon Aug 11, 2014 3:43 pm

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby pepedog » Mon Aug 11, 2014 4:08 pm

Where are the instructions you followed?
I thought it was install openssl-cryptodev and modprobe cryptodev
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby swass » Mon Aug 11, 2014 4:17 pm

Correct -- I followed the instructions in the forums here.

I did just realize that you need to specify to use the engine with openssl when "speed" testing AES. After using the -evp switch, it seems to have done what I expect.

This begs the question though: If it doesn't use hardware acceleration unless you tell it to, doesn't that mean that any program that uses openssl would then need to tell it to use the cryptodev also?

# openssl speed -evp aes-128-cbc
Doing aes-128-cbc for 3s on 16 size blocks: 47677 aes-128-cbc's in 0.06s
Doing aes-128-cbc for 3s on 64 size blocks: 46394 aes-128-cbc's in 0.04s
Doing aes-128-cbc for 3s on 256 size blocks: 38778 aes-128-cbc's in 0.07s
Doing aes-128-cbc for 3s on 1024 size blocks: 25603 aes-128-cbc's in 0.03s
Doing aes-128-cbc for 3s on 8192 size blocks: 5542 aes-128-cbc's in 0.02s
swass
 
Posts: 27
Joined: Mon Aug 11, 2014 3:43 pm

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby WarheadsSE » Mon Aug 11, 2014 4:36 pm

Which kernel was this on?
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby swass » Mon Aug 11, 2014 4:48 pm

linux-kirkwood
3.15.8-1-ARCH #1 PREEMPT Wed Aug 6 03:20:19 MDT 2014 armv5tel GNU/Linux

I'm thinking this has something to do with the way OpenSSL operates with the device. Ideally, I just want to make sure that anything that can use the hardware acceleration does.
swass
 
Posts: 27
Joined: Mon Aug 11, 2014 3:43 pm

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby moonman » Tue Aug 12, 2014 5:44 am

Just make a simple test with and without cryptodev module loaded. For me throughput and cpu load both drop with cryptodev. While I dont care that much about throughput because it's still better then my UP link capacity, i do want to unload the cpu a bit for other tasks.
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby pepedog » Wed Aug 13, 2014 1:37 pm

I just rebuilt linux-imx6-cubox-dt and cryptodev appears to working on that hardware helper too
$this->bbcode_second_pass_code('', '# openssl speed -evp aes-128-cbc
Doing aes-128-cbc for 3s on 16 size blocks: 5277076 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 64 size blocks: 1652760 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 256 size blocks: 434422 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 1024 size blocks: 110028 aes-128-cbc's in 3.00s
Doing aes-128-cbc for 3s on 8192 size blocks: 13799 aes-128-cbc's in 3.00s
OpenSSL 1.0.1i 6 Aug 2014
built on: Mon Aug 11 04:43:40 MDT 2014
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) blowfish(ptr)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS -DHASH_MAX_LEN=64 -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wl,-O1,--sort-common,--as-needed,-z,relro -DTERMIO -O3 -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DGHASH_ASM
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128-cbc 28144.41k 35258.88k 37070.68k 37556.22k 37680.47k
# modprobe cryptodev
# openssl speed -evp aes-128-cbc
Doing aes-128-cbc for 3s on 16 size blocks: 39961 aes-128-cbc's in 0.01s
Doing aes-128-cbc for 3s on 64 size blocks: 44458 aes-128-cbc's in 0.07s
Doing aes-128-cbc for 3s on 256 size blocks: 38341 aes-128-cbc's in 0.10s
Doing aes-128-cbc for 3s on 1024 size blocks: 29967 aes-128-cbc's in 0.04s
Doing aes-128-cbc for 3s on 8192 size blocks: 8184 aes-128-cbc's in 0.01s
OpenSSL 1.0.1i 6 Aug 2014
built on: Mon Aug 11 04:43:40 MDT 2014
options:bn(64,32) rc4(ptr,char) des(idx,cisc,16,long) aes(partial) idea(int) blowfish(ptr)
compiler: gcc -fPIC -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DHAVE_CRYPTODEV -DUSE_CRYPTODEV_DIGESTS -DHASH_MAX_LEN=64 -Wa,--noexecstack -D_FORTIFY_SOURCE=2 -march=armv7-a -mfloat-abi=hard -mfpu=vfpv3-d16 -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wl,-O1,--sort-common,--as-needed,-z,relro -DTERMIO -O3 -Wall -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DAES_ASM -DGHASH_ASM
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128-cbc 63937.60k 40647.31k 98152.96k 767155.20k 6704332.80k')
Maybe this might be a dkms candidate?
pepedog
Developer
 
Posts: 2431
Joined: Mon Jun 07, 2010 3:30 pm
Location: London UK

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby moonman » Wed Aug 13, 2014 8:44 pm

Why not include in the kernel itself like linux and linux-kirkwood? Shall I do it?
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby Geoff » Wed Aug 13, 2014 10:22 pm

$this->bbcode_second_pass_quote('pepedog', 'I') just rebuilt linux-imx6-cubox-dt and cryptodev appears to working on that hardware helper too

Thank you for doing this. I tried it out on my cubox-i4pro and got the same speeds as you did. Then I tried rsyncing a 2GB file to the cubox. The cpu load from sshd was slightly lower, but not enough to get excited about. However, I'm sad to say I started getting these errors on the sending side of rsync:

$this->bbcode_second_pass_code('', '
Received disconnect from 192.168.0.2: 2: Packet corrupt
rsync: [sender] write error: Broken pipe (32)
rsync error: unexplained error (code 255) at io.c(820) [sender=3.1.1]

...

Write failed: Broken pipe
rsync: [sender] write error: Broken pipe (32)
rsync error: error in socket IO (code 10) at io.c(820) [sender=3.1.1]
')
The errors went away when I reverted from openssl-cryptodev back to openssl.
Geoff
 
Posts: 231
Joined: Wed Mar 09, 2011 5:14 pm

Re: openssl-cryptodev on Kirkwood (Pogoplug v4) issue

Postby moonman » Thu Aug 14, 2014 12:20 am

Did you use latest git source for cryptodev module? I know they fixed some stuff since release
Pogoplug V4 | GoFlex Home | Raspberry Pi 4 4GB | CuBox-i4 Pro | ClearFog | BeagleBone Black | Odroid U2 | Odroid C1 | Odroid XU4
-----------------------------------------------------------------------------------------------------------------------
[armv5] Updated U-Boot | [armv5] NAND Rescue System
moonman
Developer
 
Posts: 3388
Joined: Sat Jan 15, 2011 3:36 am

Next

Return to User Questions

Who is online

Users browsing this forum: No registered users and 1 guest