From 6d18efb46ac07ce85d61e51af3e92e375778457b Mon Sep 17 00:00:00 2001 From: lstewart Date: Thu, 2 Dec 2010 02:32:46 +0000 Subject: General cleanup of the NewReno CC module (no functional changes): - Remove superfluous includes and unhelpful comments. - Alphabetically order functions. - Make functions static. Sponsored by: FreeBSD Foundation MFC after: 9 weeks X-MFC with: r215166 --- sys/netinet/cc/cc_newreno.c | 92 ++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/sys/netinet/cc/cc_newreno.c b/sys/netinet/cc/cc_newreno.c index 511186a..c095540 100644 --- a/sys/netinet/cc/cc_newreno.c +++ b/sys/netinet/cc/cc_newreno.c @@ -52,41 +52,35 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include #include #include +#include -#include -#include +#include #include -#include -#include #include #include #include -void newreno_ack_received(struct cc_var *ccv, uint16_t type); -void newreno_cong_signal(struct cc_var *ccv, uint32_t type); -void newreno_post_recovery(struct cc_var *ccv); -void newreno_after_idle(struct cc_var *ccv); +static void newreno_ack_received(struct cc_var *ccv, uint16_t type); +static void newreno_after_idle(struct cc_var *ccv); +static void newreno_cong_signal(struct cc_var *ccv, uint32_t type); +static void newreno_post_recovery(struct cc_var *ccv); struct cc_algo newreno_cc_algo = { .name = "newreno", .ack_received = newreno_ack_received, + .after_idle = newreno_after_idle, .cong_signal = newreno_cong_signal, .post_recovery = newreno_post_recovery, - .after_idle = newreno_after_idle }; -/* - * Increase cwnd on receipt of a successful ACK: - * if cwnd <= ssthresh, increases by 1 MSS per ACK - * if cwnd > ssthresh, increase by ~1 MSS per RTT - */ -void +static void newreno_ack_received(struct cc_var *ccv, uint16_t type) { if (type == CC_ACK && !IN_RECOVERY(CCV(ccv, t_flags)) && @@ -153,10 +147,37 @@ newreno_ack_received(struct cc_var *ccv, uint16_t type) } } +static void +newreno_after_idle(struct cc_var *ccv) +{ + int rw; + + /* + * If we've been idle for more than one retransmit timeout the old + * congestion window is no longer current and we have to reduce it to + * the restart window before we can transmit again. + * + * The restart window is the initial window or the last CWND, whichever + * is smaller. + * + * This is done to prevent us from flooding the path with a full CWND at + * wirespeed, overloading router and switch buffers along the way. + * + * See RFC5681 Section 4.1. "Restarting Idle Connections". + */ + if (V_tcp_do_rfc3390) + rw = min(4 * CCV(ccv, t_maxseg), + max(2 * CCV(ccv, t_maxseg), 4380)); + else + rw = CCV(ccv, t_maxseg) * 2; + + CCV(ccv, snd_cwnd) = min(rw, CCV(ccv, snd_cwnd)); +} + /* - * manage congestion signals + * Perform any necessary tasks before we enter congestion recovery. */ -void +static void newreno_cong_signal(struct cc_var *ccv, uint32_t type) { u_int win; @@ -183,11 +204,9 @@ newreno_cong_signal(struct cc_var *ccv, uint32_t type) } /* - * decrease the cwnd in response to packet loss or a transmit timeout. - * th can be null, in which case cwnd will be set according to reno instead - * of new reno. + * Perform any necessary tasks before we exit congestion recovery. */ -void +static void newreno_post_recovery(struct cc_var *ccv) { if (IN_FASTRECOVERY(CCV(ccv, t_flags))) { @@ -209,36 +228,5 @@ newreno_post_recovery(struct cc_var *ccv) } } -/* - * if a connection has been idle for a while and more data is ready to be sent, - * reset cwnd - */ -void -newreno_after_idle(struct cc_var *ccv) -{ - int rw; - - /* - * If we've been idle for more than one retransmit timeout the old - * congestion window is no longer current and we have to reduce it to - * the restart window before we can transmit again. - * - * The restart window is the initial window or the last CWND, whichever - * is smaller. - * - * This is done to prevent us from flooding the path with a full CWND at - * wirespeed, overloading router and switch buffers along the way. - * - * See RFC5681 Section 4.1. "Restarting Idle Connections". - */ - if (V_tcp_do_rfc3390) - rw = min(4 * CCV(ccv, t_maxseg), - max(2 * CCV(ccv, t_maxseg), 4380)); - else - rw = CCV(ccv, t_maxseg) * 2; - - CCV(ccv, snd_cwnd) = min(rw, CCV(ccv, snd_cwnd)); -} - DECLARE_CC_MODULE(newreno, &newreno_cc_algo); -- cgit v1.1