summaryrefslogtreecommitdiff
path: root/drivers/net/wireguard/send.c
diff options
context:
space:
mode:
authorBruno Martins <bgcngm@gmail.com>2020-12-06 18:31:14 +0000
committerMichael Bestas <mkbestas@lineageos.org>2020-12-31 19:40:46 +0200
commit141849eac5defb4bb6cf6e6f1381cb24ffcfdba5 (patch)
tree991068d0b0e30be8ca5879ba6e2914b82eefd25b /drivers/net/wireguard/send.c
parent7d982ef6fe996f837d5c0c71feb2a3f3989deee7 (diff)
drivers: net: Modify WireGuard for backward compat
Change-Id: I1c8e130a514a7b0329f8df8099cc84f4cc8d5822
Diffstat (limited to 'drivers/net/wireguard/send.c')
-rw-r--r--drivers/net/wireguard/send.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/net/wireguard/send.c b/drivers/net/wireguard/send.c
index f74b9341ab0f..828b086abe31 100644
--- a/drivers/net/wireguard/send.c
+++ b/drivers/net/wireguard/send.c
@@ -11,6 +11,7 @@
#include "messages.h"
#include "cookie.h"
+#include <linux/simd.h>
#include <linux/uio.h>
#include <linux/inetdevice.h>
#include <linux/socket.h>
@@ -159,7 +160,8 @@ static unsigned int calculate_skb_padding(struct sk_buff *skb)
return padded_size - last_unit;
}
-static bool encrypt_packet(struct sk_buff *skb, struct noise_keypair *keypair)
+static bool encrypt_packet(struct sk_buff *skb, struct noise_keypair *keypair,
+ simd_context_t *simd_context)
{
unsigned int padding_len, plaintext_len, trailer_len;
struct scatterlist sg[MAX_SKB_FRAGS + 8];
@@ -215,7 +217,8 @@ static bool encrypt_packet(struct sk_buff *skb, struct noise_keypair *keypair)
return false;
return chacha20poly1305_encrypt_sg_inplace(sg, plaintext_len, NULL, 0,
PACKET_CB(skb)->nonce,
- keypair->sending.key);
+ keypair->sending.key,
+ simd_context);
}
void wg_packet_send_keepalive(struct wg_peer *peer)
@@ -293,13 +296,16 @@ void wg_packet_encrypt_worker(struct work_struct *work)
struct crypt_queue *queue = container_of(work, struct multicore_worker,
work)->ptr;
struct sk_buff *first, *skb, *next;
+ simd_context_t simd_context;
+ simd_get(&simd_context);
while ((first = ptr_ring_consume_bh(&queue->ring)) != NULL) {
enum packet_state state = PACKET_STATE_CRYPTED;
skb_list_walk_safe(first, skb, next) {
if (likely(encrypt_packet(skb,
- PACKET_CB(first)->keypair))) {
+ PACKET_CB(first)->keypair,
+ &simd_context))) {
wg_reset_packet(skb, true);
} else {
state = PACKET_STATE_DEAD;
@@ -308,9 +314,10 @@ void wg_packet_encrypt_worker(struct work_struct *work)
}
wg_queue_enqueue_per_peer(&PACKET_PEER(first)->tx_queue, first,
state);
- if (need_resched())
- cond_resched();
+
+ simd_relax(&simd_context);
}
+ simd_put(&simd_context);
}
static void wg_packet_create_data(struct sk_buff *first)