-
Notifications
You must be signed in to change notification settings - Fork 153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue: 1897191 Implement extra TCP statistics #870
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,51 @@ void stats_display_proto(struct stats_proto *proto, char *name); | |
#define stats_display_proto(proto, name) | ||
#endif /* LWIP_STATS_DISPLAY */ | ||
|
||
#ifdef DEFINED_EXTRA_STATS | ||
|
||
struct socket_tcp_stats { | ||
u32_t n_rto; /* number of RTO */ | ||
u32_t n_rtx_fast; /* fast retransmits */ | ||
u32_t n_rtx_rto; /* retransmits caused by RTO */ | ||
u32_t n_rtx_ss; /* retransmits in slow start phase */ | ||
u32_t n_rtx_spurious; /* number of segments removed from unsent queue */ | ||
u32_t n_recovered_fast; /* recovered after fast retransmit without RTO */ | ||
u32_t n_dupacks; /* duplicate ACKs */ | ||
u32_t n_ofo; /* out of order segments */ | ||
u32_t n_underruns; /* underruns (no segments to send) */ | ||
u32_t n_blocked_cwnd; /* sending blocked by cwnd */ | ||
u32_t n_blocked_rwnd; /* sending blocked by rwnd */ | ||
u32_t n_blocked_sndbuf; /* sending blocked by snd_buf */ | ||
u32_t n_updates_rtt; /* RTT measurements */ | ||
u32_t n_rst; /* RST segments */ | ||
|
||
u32_t n_rx_ignored; /* ignored incoming segments */ | ||
u32_t n_dropped; /* dropped segments due to an error */ | ||
u32_t n_memerr_pbuf; /* pbuf allocation errors */ | ||
u32_t n_memerr_seg; /* segment allocation errors */ | ||
|
||
u32_t n_mss; | ||
u32_t n_rto_timer; | ||
u32_t n_snd_wnd; | ||
u32_t n_cwnd; | ||
u32_t n_ssthresh; | ||
u32_t n_snd_nxt; | ||
u32_t n_lastack; | ||
u32_t n_unsent_q; | ||
u32_t n_unacked_q; | ||
u32_t n_ooseq_q; | ||
}; | ||
|
||
typedef struct socket_tcp_stats socket_tcp_stats_t; | ||
|
||
#define EXTRA_STATS_INC(x) ++x | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please consider |
||
|
||
#else /* DEFINED_EXTRA_STATS */ | ||
#define EXTRA_STATS_INC(x) do {} while (0) | ||
#endif /* DEFINED_EXTRA_STATS */ | ||
|
||
#define PCB_STATS_INC(x) EXTRA_STATS_INC(pcb->p_stats->x) | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,44 @@ const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 }; | |
/** Only used for temporary storage. */ | ||
struct tcp_pcb *tcp_tmp_pcb; | ||
|
||
#ifdef DEFINED_EXTRA_STATS | ||
void register_tcp_stats_instance(struct tcp_pcb *pcb, socket_tcp_stats_t *stats) | ||
{ | ||
pcb->p_stats = stats; | ||
} | ||
|
||
static void copy_tcp_metrics(struct tcp_pcb *pcb) | ||
{ | ||
struct tcp_seg *seg; | ||
socket_tcp_stats_t *stats = pcb->p_stats; | ||
u32_t n; | ||
|
||
if (stats == NULL) | ||
return; | ||
|
||
stats->n_mss = pcb->mss; | ||
stats->n_rto_timer = pcb->rto * slow_tmr_interval; | ||
stats->n_snd_wnd = pcb->snd_wnd; | ||
stats->n_cwnd = pcb->cwnd; | ||
stats->n_ssthresh = pcb->ssthresh; | ||
stats->n_snd_nxt = pcb->snd_nxt; | ||
stats->n_lastack = pcb->lastack; | ||
|
||
for (seg = pcb->unsent, n = 0; seg != NULL; seg = seg->next, ++n); | ||
stats->n_unsent_q = n; | ||
for (seg = pcb->unacked, n = 0; seg != NULL; seg = seg->next, ++n); | ||
stats->n_unacked_q = n; | ||
for (seg = pcb->ooseq, n = 0; seg != NULL; seg = seg->next, ++n); | ||
stats->n_ooseq_q = n; | ||
} | ||
#else /* DEFINED_EXTRA_STATS */ | ||
static void copy_tcp_metrics(struct tcp_pcb *pcb) | ||
{ | ||
/* Do nothing if extra statistics is off. */ | ||
(void)pcb; | ||
} | ||
#endif /* DEFINED_EXTRA_STATS */ | ||
|
||
/** | ||
* | ||
* @param v value to set | ||
|
@@ -132,6 +170,8 @@ tcp_tmr(struct tcp_pcb* pcb) | |
tcp_tmr() is called. */ | ||
tcp_slowtmr(pcb); | ||
} | ||
|
||
copy_tcp_metrics(pcb); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please consider
as is done in other places |
||
} | ||
|
||
/** | ||
|
@@ -1087,7 +1127,10 @@ tcp_tx_pbuf_alloc(struct tcp_pcb * pcb, u16_t length, pbuf_type type) | |
|
||
// pbuf_alloc is not valid, we should allocate a new pbuf. | ||
p = external_tcp_tx_pbuf_alloc(pcb); | ||
if (!p) return NULL; | ||
if (!p) { | ||
PCB_STATS_INC(n_memerr_pbuf); | ||
return NULL; | ||
} | ||
|
||
p->next = NULL; | ||
p->type = type; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
|
||
#include "vma/lwip/pbuf.h" | ||
#include "vma/lwip/ip.h" | ||
#include "vma/lwip/stats.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
|
@@ -298,6 +299,10 @@ struct tcp_pcb { | |
#define TF_NAGLEMEMERR ((u16_t)0x0080U) /* nagle enabled, memerr, try to output to prevent delayed ACK to happen */ | ||
#define TF_WND_SCALE ((u16_t)0x0100U) /* Window Scale option enabled */ | ||
|
||
#ifdef DEFINED_EXTRA_STATS | ||
socket_tcp_stats_t *p_stats; | ||
#endif /* DEFINED_EXTRA_STATS */ | ||
|
||
/* the rest of the fields are in host byte order | ||
as we have to do some math with them */ | ||
/* receiver variables */ | ||
|
@@ -483,6 +488,11 @@ err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb, | |
/*Initialization of tcp_pcb structure*/ | ||
void tcp_pcb_init (struct tcp_pcb* pcb, u8_t prio); | ||
|
||
#ifdef DEFINED_EXTRA_STATS | ||
/* Set pointer to extra TCP stats instance */ | ||
void register_tcp_stats_instance(struct tcp_pcb *pcb, socket_tcp_stats_t *stats); | ||
#endif /* DEFINED_EXTRA_STATS */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
void tcp_arg (struct tcp_pcb *pcb, void *arg); | ||
void tcp_ip_output (struct tcp_pcb *pcb, ip_output_fn ip_output); | ||
void tcp_accept (struct tcp_pcb *pcb, tcp_accept_fn accept); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please consider moving to
config\m4\opt.m4
.Look to implementation of otional log configure option at https://github.com/Mellanox/libvma/blob/master/config/m4/opt.m4
I would like to suggest
--enable-opt-stats
with following values:Probably it can be done w/o
none
at this pull request