diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-03-28 16:56:01 +0200 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-03-29 15:35:38 +0200 |
commit | 37c228ada88b7fa0001659b13c34a783ba75df83 (patch) | |
tree | 8322a8de553fdf30f89fed48e985547316a01964 /tcp.c | |
parent | 1f4b7fa0d75d25f518047e77c88718ec1cc3f5bb (diff) | |
download | passt-37c228ada88b7fa0001659b13c34a783ba75df83.tar passt-37c228ada88b7fa0001659b13c34a783ba75df83.tar.gz passt-37c228ada88b7fa0001659b13c34a783ba75df83.tar.bz2 passt-37c228ada88b7fa0001659b13c34a783ba75df83.tar.lz passt-37c228ada88b7fa0001659b13c34a783ba75df83.tar.xz passt-37c228ada88b7fa0001659b13c34a783ba75df83.tar.zst passt-37c228ada88b7fa0001659b13c34a783ba75df83.zip |
tap, tcp, udp, icmp: Cut down on some oversized buffers
The existing sizes provide no measurable differences in throughput
and packet rates at this point. They were probably needed as batched
implementations were not complete, but they can be decreased quite a
bit now.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tcp.c')
-rw-r--r-- | tcp.c | 51 |
1 files changed, 41 insertions, 10 deletions
@@ -70,9 +70,9 @@ * * Data needs to linger on sockets as long as it's not acknowledged by the * guest, and is read using MSG_PEEK into preallocated static buffers sized - * to the maximum supported window, 64MiB ("discard" buffer, for already-sent + * to the maximum supported window, 16 MiB ("discard" buffer, for already-sent * data) plus a number of maximum-MSS-sized buffers. This imposes a practical - * limitation on window scaling, that is, the maximum factor is 1024. Larger + * limitation on window scaling, that is, the maximum factor is 256. Larger * factors will be accepted, but resulting, larger values are never advertised * to the other side, and not used while queueing data. * @@ -299,7 +299,7 @@ #include "conf.h" #include "tcp_splice.h" -#define TCP_FRAMES_MEM 256 +#define TCP_FRAMES_MEM 128 #define TCP_FRAMES \ (c->mode == MODE_PASST ? TCP_FRAMES_MEM : 1) @@ -311,17 +311,48 @@ #define TCP_HASH_TABLE_SIZE (TCP_MAX_CONNS * 100 / \ TCP_HASH_TABLE_LOAD) -#define MAX_WS 10 +#define MAX_WS 8 #define MAX_WINDOW (1 << (16 + (MAX_WS))) /* MSS rounding: see SET_MSS() */ #define MSS_DEFAULT 536 -#define MSS4 ROUND_DOWN(USHRT_MAX - \ - sizeof(uint32_t) - sizeof(struct ethhdr) - \ - sizeof(struct iphdr) - sizeof(struct tcphdr), 4) -#define MSS6 ROUND_DOWN(USHRT_MAX - \ - sizeof(uint32_t) - sizeof(struct ethhdr) - \ - sizeof(struct ipv6hdr) - sizeof(struct tcphdr), 4) + +struct tcp4_l2_head { /* For MSS4 macro: keep in sync with tcp4_l2_buf_t */ + uint32_t psum; + uint32_t tsum; +#ifdef __AVX2__ + uint8_t pad[18]; +#else + uint8_t pad[2]; +#endif + uint32_t vnet_len; + struct ethhdr eh; + struct iphdr iph; + struct tcphdr th; +#ifdef __AVX2__ +} __attribute__ ((packed, aligned(32))); +#else +} __attribute__ ((packed, aligned(__alignof__(unsigned int)))); +#endif + +struct tcp6_l2_head { /* For MSS6 macro: keep in sync with tcp6_l2_buf_t */ +#ifdef __AVX2__ + uint8_t pad[14]; +#else + uint8_t pad[2]; +#endif + uint32_t vnet_len; + struct ethhdr eh; + struct ipv6hdr ip6h; + struct tcphdr th; +#ifdef __AVX2__ +} __attribute__ ((packed, aligned(32))); +#else +} __attribute__ ((packed, aligned(__alignof__(unsigned int)))); +#endif + +#define MSS4 ROUND_DOWN(USHRT_MAX - sizeof(struct tcp4_l2_head), 4) +#define MSS6 ROUND_DOWN(USHRT_MAX - sizeof(struct tcp6_l2_head), 4) #define WINDOW_DEFAULT 14600 /* RFC 6928 */ #ifdef HAS_SND_WND |