Repository navigation
ramips: add support for mtk eip93 crypto engine - #10042
Conversation
|
Please use your real email address for Signed-off-by line in the commit message instead of GitHub's address. |
|
I remember running this a long time ago with cryptsetup's benchmark. While there was a speedup with AES and such, it wasn't that dramatic. I also don't remember if openssl was faster. Should be slower for lower block sizes. ping @cotequeiroz since he deals with this stuff. |
|
No offense, but this looks like a copy of immortalwrt/immortalwrt@7fc2fd7 with author info stripped. |
|
@AmadeusGhost I have not seen it before the notification therefore I reinvented the wheel🌚 |
I've had some disappointing experiences with hw crypto, so my comments are probably discouraging. There are several drivers already included in openwrt, so I'm not going to be picky about adding another one. However, this driver does not appear to be ready for inclusion in the kernel. Just skimming through the code, I found some places needing changes. For example, the AES skcipher algos are registering themselves with I would strongly suggest that the driver be tested with the kernel self-test, and also speed tested. A friend has a device that I could try to install the module to do speed tests, but it is used in production, so I probably won't be able to install an image there. I'll post the results if able. Running the kernel self-testsOpenwrt disables the crypto self-tests to save space. To be able to run them, one must enable the self-tests in the kernel config: The self-tests will run upon loading the
Running the kernel speed testsSpeed testing can be done without the above change, by installing the
At least on arm, using hw-crypto to perform AES on network packets is not worth it. There is a large latency to set up the hw crypto operation. For networking with MTU=1500, take a look at the speed of block size=1472. On mvebu, the CESA beats the arm-asm driver (regular arm, not the neon version), but not by much (128-bits AES: 23560 vs 26607 CPU cycles). Then the acks will kill most/all of the gain: for CESA, using 128-bit AES on a 1472B packet plus a 64B ack: 23560 + 9469 = 33029 CPU cycles; arm-asm: 26607 + 1355 = 27962 cycles, a 15% penalty. I hope things on mips are different, and my expectations are just wrong. |
|
@cotequeiroz IIRC the mvebu hardware stuff was created when the core clock was closer to 1.2ghz for the original WRT1900. It makes a little more sense there. |
|
It makes sense. With CBC pretty much out of the picture, and CESA not supporting CTR, I had 0 |
I was just illustrating how it was not being used in the kernel. I don't run or recommend running openssl or wolfssl with cryptodev or afalg, even if it works faster. Most user space programs are not aware of how openssl processes its requests--internal or using an engine. Cryptodev file descriptors must not be shared across processes, which happens when you call Thanks for the tests: The speed tests indicate that it may speedup regular network encryption, which is good. The bad news is that the self tests showed one error that raised concern: 77 is The fact that it happened only in test vector 7 indicates it worked for vectors 0 through 6. 7 is the first vector without associated data--i.e. data not to be encrypted/decrypted, but that must be authenticated.
This should be investigated further. I would not trade reliability for speed. At the moment, this is a NAK for me. |
|
I think it is relevant to https://github.com/vschagen/mtk-eip93/blob/ca08387bf8352652129019bb19e2423ab313d5cb/crypto/mtk-eip93/eip93-main.c#L165 . |
|
I would use an async crypto fallback for requests smaller than, say 512 bytes. I've done it with qce in torvalds/linux@ce163ba, although later with torvalds/linux@25b71d6, it was inadvertently? limited to XTS only. After you do this, the self tests should pass, but beware that they will fall under the 512-byte threshold, so see if you can test it with other data. |
I applied similar changes in my stage tree. It works like a charm. |
|
please post your TEST method (test command or other) this is my test log : engine "devcrypto" set. |
|
|
i have tested . very great. EIP-93 work fine |
|
@cotequeiroz I implemented fallback in the driver. Therefore I saw a great speedup with small packets and the self tests passed. |
I did see the same test result as yours, but i note the CPU load is very high: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND Is it ok? |
It is the expected behaviour because there is a high overhead submitting data to the engine and getting it back. |
Nice job! You've managed to get the best of both worlds with this:
In the table above, I've averaged your test results, considering both encryption and decryption numbers (in counter-mode, they are the same operation). TLDR: The following is just a nitpick. If you're happy with what you've got, leave it alone. If you want to tweak the results for extra efficiency, read on. The mean absolute deviation of the block sizes <= 256 was quite large (34% of the avg for AES-256). Try to test this with If these numbers are indeed consistent with what you get with I used this to get a table from the logs that I could just copy and paste to a spreadsheet: Of course, using |
|
Well thing is that this is a whole new feature that would be added after
the branching and in theory backported should be max fixes or trivial new
device.
About having this as a patch, the idea was to use the upstream series with
a few fixup instead of raw files to make it easier to upstream, but it was
just created a diff patch. But this has been here for a long time and I
didn't want to delay this further so I preferred to just merge and see what
happen.
Il Mar 12 Set 2023, 15:59 rany2 ***@***.***> ha scritto:
… @Ansuel <https://github.com/Ansuel> It would have been easier to backport
to 23.05 if it was a separate package like it was in this iteration of this
PR: 53bdd30
<53bdd30>
Don't get why it was turned into a kernel patch, just adds to overhead IMO
—
Reply to this email directly, view it on GitHub
<#10042 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE2ZMQU3YLUNTUALVXIY3OLX2BTCRANCNFSM5YRV4WKA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Yeah. It would be nice to have this in 23.05 and even 22.03. Fix for the insufficient ikev2 performance. :) |
We would wait a point release for the revert to be applied that is the main problem. It's ok for RC but if we don't catch any problem in RC stage then it will be problematic in the future |
1. Fixes CPU and regulator boot problems 2. Enable CPUFREQ, I2C, RTC and THERMAL support 3. Disabled annoying debug logs, refresh kconfig 4. Fix compilation failure due to wrong kconfig Fixes: openwrt#10042 Signed-off-by: AmadeusGhost <[email protected]>
|
don't think libustream-mbedtls uses this engine even when included: (at least for gcm in tls) is there something more need to be done? |
|
mbedtls does not support hardware offload |
|
https://mbed-tls.readthedocs.io/en/latest/kb/development/hw_acc_guidelines/ |
|
If anyone wants to waste some time... I'm working on upstreaming it but it's for a different SoC so the register are a bit different. There is plenty of documentation around and I can help with some thing... Code is here and currently RFC upstream Would be good to check what is actually missing to make this core work on mips.... The main (and only) difference I notice were on the endian regs and ring configuration... Would be interesting if anyone can try it on some ramips device and see if it works right away... |
|
Should probably make a commit doing so. I tried and failed. It's not probing and dmesg shows nothing. |
|
@neheb what do you mean not probing? No log at all? Not even an error? |
|
Nope. I couldn’t replace the driver properly I guess. |
|
@neheb what version di you use? Maybe I know the problem... In latest version I'm pushing upstream I dropped the mtk compatible so that needs to be changed... Can you try to use the airoha one or check the main file what are supported? |
Like I said, I messed something up. |
|
@Ansuel @neheb It works on MT7621 or not? I'm trying to get this running on OpenWrt 23.05 with some changes (corrected spinlock code for linux 5.15) |
|
What revision are you using? Also what is the kernel crash? |
|
@Ansuel this openwrt version https://github.com/Linaro1985/openwrt/commits/23.05.5_eip93 P.S. I'll try to provide the log tomorrow. I don't have that opportunity now. Thanks! |
|
I'm running this module on self-compiled 23.05.4 with this commit cherrypicked on D-Link DIR-860L B1 Both D-Links have MediaTek MT7621AT, no apparent issues for me. |
|
@Ansuel I ported v5 driver to openwrt-24.10. All crypto tests enabled in kernel. Crash log:
Should I try this version? How can I help? |
|
@Linaro1985 can you try v7? Eventually we need to add some debug log to understand where is the unaligned error. |
|
@Ansuel I tried v7 version. No more crash, but there are still errors. Installed crypto kernel modules: |
|
@Linaro1985 can you make changes to the code? There are 2-3 things where we swap bits maybe they are not endian dependent and needs to be always swapped... |
|
@Ansuel no problem. What changes need to be made? |
|
actually are you sure all the crypto module are installed? Can you post output of /proc/crypto ? |
|
btw the driver is now upstream... I think we should put some effort in making this work on mt7622... the upstream version doesn't have the software fallback but that can be added with a downstream patch eventually. |
@skbeh Do you remember why you excluded AES (RFC3686) from the software fallback? The topic came up during the transition to the upstream driver. Benchmarks indicate that it should also use the fallback together with DES :) |
@abajk Not really. The reason might be that I didn't test RFC3686, and I was not sure about whether it can be used with the same fallback. |

Mediatek EIP93 Crypto engine is a crypto accelerator which
is available in the Mediatek MT7621 SoC.
Althrough it was submitted to upstream kernel, it is far away from being accepted by the upstream. To make it available in openwrt as soon as possible, I ported the package from immortalwrt with some adjustment to make it possible to be built with 5.10 kernel.
Thanks:
mtk-eip93
immortalwrt