aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/compat
diff options
context:
space:
mode:
authorShawn Landden <shawn@git.icu>2019-05-10 19:02:36 -0300
committerShawn Landden <shawn@git.icu>2019-05-13 16:24:32 -0500
commit2b2e9c08b326409a28ef3d0237164e5ee67c7c6d (patch)
treed6ead58699723d4b42286696c18b42a14e832878 /src/compat
parentsocket: set ignore_df=1 on xmit (diff)
downloadwireguard-monolithic-historical-2b2e9c08b326409a28ef3d0237164e5ee67c7c6d.tar.xz
wireguard-monolithic-historical-2b2e9c08b326409a28ef3d0237164e5ee67c7c6d.zip
[Zinc] Add PowerPC chacha20 implementation from openssl/cryptograms
Only runs on the out-bound path, as the in-bound path is in an interrupt, but that can be fixed in Linux. Otherwise this is tested (with the VSX code enabled) on Power 9 (ppc64le). Without this I get 2GiB/s over the loopback (so 4 GiB/s), and with this I get 2.8 GiB/s (so 5.6 GiB/s), and more time is spent in poly1305 than chacha20. This is on a 4-thread VPS. Signed-off-by: Shawn Landden <shawn@git.icu> v2: more complete simd.h for PPC benchmarks whitespace issues v3: honor CONFIG_ALTIVEC (CONFIG_VSX has already honored)
Diffstat (limited to 'src/compat')
-rw-r--r--src/compat/simd/include/linux/simd.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/compat/simd/include/linux/simd.h b/src/compat/simd/include/linux/simd.h
index c75c724..44060a9 100644
--- a/src/compat/simd/include/linux/simd.h
+++ b/src/compat/simd/include/linux/simd.h
@@ -13,6 +13,9 @@
#include <asm/fpu/api.h>
#elif defined(CONFIG_KERNEL_MODE_NEON)
#include <asm/neon.h>
+#elif defined(CONFIG_ALTIVEC) || defined(CONFIG_VSX)
+#include <asm/switch_to.h>
+#include <asm/cputable.h>
#endif
typedef enum {
@@ -30,13 +33,24 @@ static inline void simd_get(simd_context_t *ctx)
static inline void simd_put(simd_context_t *ctx)
{
+ if (*ctx & HAVE_SIMD_IN_USE) {
#if defined(CONFIG_X86_64)
- if (*ctx & HAVE_SIMD_IN_USE)
kernel_fpu_end();
#elif defined(CONFIG_KERNEL_MODE_NEON)
- if (*ctx & HAVE_SIMD_IN_USE)
kernel_neon_end();
+#elif defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
+ if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
+ disable_kernel_vsx();
+ preempt_enable();
+ } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) {
+ disable_kernel_altivec();
+ preempt_enable();
+ } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) {
+ disable_kernel_fp();
+ preempt_enable();
+ }
#endif
+ }
*ctx = HAVE_NO_SIMD;
}
@@ -62,6 +76,17 @@ static __must_check inline bool simd_use(simd_context_t *ctx)
kernel_fpu_begin();
#elif defined(CONFIG_KERNEL_MODE_NEON)
kernel_neon_begin();
+#elif defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
+ if (cpu_has_feature(CPU_FTR_VSX_COMP)) {
+ preempt_disable();
+ enable_kernel_vsx();
+ } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) {
+ preempt_disable();
+ enable_kernel_altivec();
+ } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) {
+ preempt_disable();
+ enable_kernel_fp();
+ }
#endif
*ctx |= HAVE_SIMD_IN_USE;
return true;