mbox series

[v3,0/6] crypto/realtek: add new driver

Message ID 20221231162525.416709-1-markus.stockhausen@gmx.de
Headers show
Series crypto/realtek: add new driver | expand

Message

Markus Stockhausen Dec. 31, 2022, 4:25 p.m. UTC
This driver adds support for the Realtek crypto engine. It provides hardware
accelerated AES, SHA1 & MD5 algorithms. It is included in SoCs of the RTL838x
series, such as RTL8380, RTL8381, RTL8382, as well as SoCs from the RTL930x
series, such as RTL9301, RTL9302 and RTL9303. Some little endian and ARM based
Realtek SoCs seem to have this engine too. Nevertheless this patch was only
developed and verified on MIPS big endian devices.

Changes since v2:
- Use dma_map_single() & dma_unmap_single() calls
- Add missing dma_unmap_sg() calls
- Use dma_sync_single_for_device() only for mapped regions

Changes since v1:
- use macros to allow unaligned access during hash state import/export

Module has been successfully tested with
- lots of module loads/unloads with crypto manager extra tests enabled.
- openssl devcrypto benchmarking
- tcrypt.ko benchmarking

Benchmarks from tcrypt.ko mode=600, 402, 403 sec=5 on a 800 MHz RTL9301 SoC can
be summed up as follows:
- with smallest block sizes the engine is 8-10 times slower than software
- sweet spot (harware speed = software speed) starts at 256 byte blocks
- With large blocks the engine is round about 2 times faster than software
- md5 performance is always worse than software

op/s with default software algorithms:
                              16 B    64 B   256 B  1024 B  1472 B  8192 B
ecb(aes) 128 bit encrypt    513593  165651   44233   11264    7846    1411
ecb(aes) 128 bit decrypt    514819  165792   44259   11268    7851    1411
ecb(aes) 192 bit encrypt    455136  142680   37761    9579    6673    1198
ecb(aes) 192 bit decrypt    456524  142836   37790    9584    6675    1200
ecb(aes) 256 bit encrypt    412102  125771   33038    8361    5825    1048
ecb(aes) 256 bit decrypt    412321  125800   33056    8368    5827    1048
                              16 B    64 B   256 B  1024 B  1472 B  8192 B
cbc(aes) 128 bit encrypt    476081  154228   41307   10520    7331    1318
cbc(aes) 128 bit decrypt    462068  152934   41228   10516    7326    1315
cbc(aes) 192 bit encrypt    426126  133894   35598    9041    6297    1132
cbc(aes) 192 bit decrypt    416446  133116   35542    9040    6296    1131
cbc(aes) 256 bit encrypt    386841  118950   31382    7953    5539     996
cbc(aes) 256 bit decrypt    379032  118209   31324    7952    5537     995
                              16 B    64 B   256 B  1024 B  1472 B  8192 B
ctr(aes) 128 bit encrypt    475435  152852   40825   10372    7225    1299
ctr(aes) 128 bit decrypt    475804  152852   40862   10374    7227    1299
ctr(aes) 192 bit encrypt    426900  133025   35230    8940    6228    1120
ctr(aes) 192 bit decrypt    427377  133030   35235    8942    6228    1120
ctr(aes) 256 bit encrypt    388872  118259   31086    7875    5484     985
ctr(aes) 256 bit decrypt    388862  118260   31100    7875    5483     985
                      16 B    64 B   256 B  1024 B  2048 B  4096 B  8192 B
md5                 600185  365210  166293   52399   27389   14011    7068
sha1                230154  124734   52979   16055    8322    4237    2137

op/s with module and hardware offloading enabled:
                              16 B    64 B   256 B  1024 B  1472 B  8192 B
ecb(aes) 128 bit encrypt     65062   58964   41380   19433   14884    2712
ecb(aes) 128 bit decrypt     65288   58507   40417   18854   14400    2627
ecb(aes) 192 bit encrypt     65233   57798   39236   17849   13534    2468
ecb(aes) 192 bit decrypt     65377   57100   38444   17336   13147    2406
ecb(aes) 256 bit encrypt     65064   56928   37400   16496   12432    2270
ecb(aes) 256 bit decrypt     64932   56115   36833   16064   12097    2219
                              16 B    64 B   256 B  1024 B  1472 B  8192 B
cbc(aes) 128 bit encrypt     64246   58073   40720   19361   14878    2718
cbc(aes) 128 bit decrypt     60969   55128   38904   18630   14184    2614
cbc(aes) 192 bit encrypt     64211   56854   38787   17793   13571    2468
cbc(aes) 192 bit decrypt     60948   53947   37209   17097   12955    2390
cbc(aes) 256 bit encrypt     63920   55889   37128   16502   12430    2267
cbc(aes) 256 bit decrypt     60680   53174   35787   15819   11961    2200
                              16 B    64 B   256 B  1024 B  1472 B  8192 B
ctr(aes) 128 bit encrypt     64452   58387   40897   19401   14921    2710
ctr(aes) 128 bit decrypt     64425   58244   41016   19433   14747    2710
ctr(aes) 192 bit encrypt     64513   57115   38884   17860   13547    2468
ctr(aes) 192 bit decrypt     64531   57116   39088   17785   13510    2468
ctr(aes) 256 bit encrypt     64284   56094   37254   16524   12411    2267
ctr(aes) 256 bit decrypt     64272   56321   37296   16436   12411    2265
                      16 B    64 B   256 B  1024 B  2048 B  4096 B  8192 B
md5                  47224   44513   39175   25264   17199   10548    5874
sha1                 46389   43578   36878   22501   14890    8796    4835

Markus Stockhausen (6)
  crypto/realtek: header definitions
  crypto/realtek: core functions
  crypto/realtek: hash algorithms
  crypto/realtek: skcipher algorithms
  crypto/realtek: enable module
  crypto/realtek: add devicetree documentation

/devicetree/bindings/crypto/realtek,realtek-crypto.yaml|   51 +
drivers/crypto/Kconfig                                 |   13
drivers/crypto/Makefile                                |    1
drivers/crypto/realtek/Makefile                        |    5
drivers/crypto/realtek/realtek_crypto.c                |  475 ++++++++++
drivers/crypto/realtek/realtek_crypto.h                |  328 ++++++
drivers/crypto/realtek/realtek_crypto_ahash.c          |  412 ++++++++
drivers/crypto/realtek/realtek_crypto_skcipher.c       |  376 +++++++
8 files changed, 1661 insertions(+)