Skip to content

Commit

Permalink
[rx] increase defrag buffers to be handle network jitter
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Aug 5, 2021
1 parent 3901924 commit 1f1e9e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 3 additions & 3 deletions libknet/host.c
Expand Up @@ -535,7 +535,7 @@ static void _clear_cbuffers(struct knet_host *host, seq_num_t rx_seq_num)

memset(host->circular_buffer_defrag, 0, KNET_CBUFFER_SIZE);

for (i = 0; i < KNET_MAX_LINK; i++) {
for (i = 0; i < KNET_DEFRAG_BUFFERS; i++) {
memset(&host->defrag_buf[i], 0, sizeof(struct knet_host_defrag_buf));
}
}
Expand All @@ -546,12 +546,12 @@ static void _reclaim_old_defrag_bufs(struct knet_host *host, seq_num_t seq_num)
int i;

head = seq_num + 1;
tail = seq_num - (KNET_MAX_LINK + 1);
tail = seq_num - (KNET_DEFRAG_BUFFERS + 1);

/*
* expire old defrag buffers
*/
for (i = 0; i < KNET_MAX_LINK; i++) {
for (i = 0; i < KNET_DEFRAG_BUFFERS; i++) {
if (host->defrag_buf[i].in_use) {
/*
* head has done a rollover to 0+
Expand Down
3 changes: 2 additions & 1 deletion libknet/internals.h
Expand Up @@ -95,6 +95,7 @@ struct knet_link {
uint8_t has_valid_mtu;
};

#define KNET_DEFRAG_BUFFERS 128
#define KNET_CBUFFER_SIZE 4096

struct knet_host_defrag_buf {
Expand Down Expand Up @@ -129,7 +130,7 @@ struct knet_host {
seq_num_t timed_rx_seq_num;
uint8_t got_data;
/* defrag/reassembly buffers */
struct knet_host_defrag_buf defrag_buf[KNET_MAX_LINK];
struct knet_host_defrag_buf defrag_buf[KNET_DEFRAG_BUFFERS];
char circular_buffer_defrag[KNET_CBUFFER_SIZE];
/* link stuff */
struct knet_link link[KNET_MAX_LINK];
Expand Down
6 changes: 3 additions & 3 deletions libknet/threads_rx.c
Expand Up @@ -71,7 +71,7 @@ static int _find_pckt_defrag_buf(knet_handle_t knet_h, struct knet_host *src_hos
/*
* check if there is a buffer already in use handling the same seq_num
*/
for (i = 0; i < KNET_MAX_LINK; i++) {
for (i = 0; i < KNET_DEFRAG_BUFFERS; i++) {
if (src_host->defrag_buf[i].in_use) {
if (src_host->defrag_buf[i].pckt_seq == seq_num) {
return i;
Expand Down Expand Up @@ -99,7 +99,7 @@ static int _find_pckt_defrag_buf(knet_handle_t knet_h, struct knet_host *src_hos
/*
* see if there is a free buffer
*/
for (i = 0; i < KNET_MAX_LINK; i++) {
for (i = 0; i < KNET_DEFRAG_BUFFERS; i++) {
if (!src_host->defrag_buf[i].in_use) {
return i;
}
Expand All @@ -113,7 +113,7 @@ static int _find_pckt_defrag_buf(knet_handle_t knet_h, struct knet_host *src_hos

oldest = 0;

for (i = 0; i < KNET_MAX_LINK; i++) {
for (i = 0; i < KNET_DEFRAG_BUFFERS; i++) {
if (_timecmp(src_host->defrag_buf[i].last_update, src_host->defrag_buf[oldest].last_update) < 0) {
oldest = i;
}
Expand Down

0 comments on commit 1f1e9e4

Please sign in to comment.