aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/receive.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-06-16 04:52:35 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-06-17 19:36:37 +0200
commit6d7f0b0a746b06a903ec8e14fe14cd0605fb210f (patch)
treed5d8a55faba0202587877594622ec89e6cadcd04 /src/receive.c
parentqueueing: re-enable preemption periodically to lower latency (diff)
downloadwireguard-monolithic-historical-6d7f0b0a746b06a903ec8e14fe14cd0605fb210f.tar.xz
wireguard-monolithic-historical-6d7f0b0a746b06a903ec8e14fe14cd0605fb210f.zip
simd: encapsulate fpu amortization into nice functions
Diffstat (limited to 'src/receive.c')
-rw-r--r--src/receive.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/receive.c b/src/receive.c
index f33941b..c5062f8 100644
--- a/src/receive.c
+++ b/src/receive.c
@@ -10,6 +10,7 @@
#include "messages.h"
#include "cookie.h"
#include "socket.h"
+#include "crypto/simd.h"
#include <linux/ip.h>
#include <linux/ipv6.h>
@@ -418,21 +419,15 @@ void packet_decrypt_worker(struct work_struct *work)
{
struct crypt_queue *queue = container_of(work, struct multicore_worker, work)->ptr;
struct sk_buff *skb;
- bool have_simd = chacha20poly1305_init_simd();
+ bool have_simd = simd_get();
while ((skb = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state = likely(skb_decrypt(skb, &PACKET_CB(skb)->keypair->receiving, have_simd)) ? PACKET_STATE_CRYPTED : PACKET_STATE_DEAD;
-
queue_enqueue_per_peer(&PACKET_PEER(skb)->rx_queue, skb, state);
-
- /* Don't totally kill scheduling latency by keeping preemption disabled forever. */
- if (have_simd && need_resched()) {
- chacha20poly1305_deinit_simd(have_simd);
- have_simd = chacha20poly1305_init_simd();
- }
+ have_simd = simd_relax(have_simd);
}
- chacha20poly1305_deinit_simd(have_simd);
+ simd_put(have_simd);
}
static void packet_consume_data(struct wireguard_device *wg, struct sk_buff *skb)