Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_stacks/rack.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 6,558 Lines • ▼ Show 20 Lines | #endif | ||||
rack->r_must_retran = 1; | rack->r_must_retran = 1; | ||||
rack->r_ctl.rc_out_at_rto = ctf_flight_size(rack->rc_tp, | rack->r_ctl.rc_out_at_rto = ctf_flight_size(rack->rc_tp, | ||||
rack->r_ctl.rc_sacked); | rack->r_ctl.rc_sacked); | ||||
} | } | ||||
rack->r_ctl.rc_snd_max_at_rto = tp->snd_max; | rack->r_ctl.rc_snd_max_at_rto = tp->snd_max; | ||||
} | } | ||||
static void | static void | ||||
rack_convert_rtts(struct tcpcb *tp) | |||||
{ | |||||
if (tp->t_srtt > 1) { | |||||
uint32_t val, frac; | |||||
val = tp->t_srtt >> TCP_RTT_SHIFT; | |||||
frac = tp->t_srtt & 0x1f; | |||||
tp->t_srtt = TICKS_2_USEC(val); | |||||
/* | |||||
* frac is the fractional part of the srtt (if any) | |||||
* but its in ticks and every bit represents | |||||
tuexen: You are definitely missing a ` tcp_hc_get()` call here.
General question: Can't you call… | |||||
Done Inline ActionsOpps yes I am :) rrs: Opps yes I am :) | |||||
* 1/32nd of a hz. | |||||
*/ | |||||
if (frac) { | |||||
if (hz == 1000) { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); | |||||
} else { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); | |||||
} | |||||
tp->t_srtt += frac; | |||||
} | |||||
} | |||||
if (tp->t_rttvar) { | |||||
uint32_t val, frac; | |||||
val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; | |||||
frac = tp->t_rttvar & 0x1f; | |||||
tp->t_rttvar = TICKS_2_USEC(val); | |||||
/* | |||||
* frac is the fractional part of the srtt (if any) | |||||
* but its in ticks and every bit represents | |||||
* 1/32nd of a hz. | |||||
*/ | |||||
if (frac) { | |||||
if (hz == 1000) { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); | |||||
} else { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); | |||||
} | |||||
tp->t_rttvar += frac; | |||||
} | |||||
} | |||||
RACK_TCPT_RANGESET(tp->t_rxtcur, RACK_REXMTVAL(tp), | |||||
rack_rto_min, rack_rto_max); | |||||
} | |||||
static void | |||||
rack_cc_conn_init(struct tcpcb *tp) | rack_cc_conn_init(struct tcpcb *tp) | ||||
{ | { | ||||
struct tcp_rack *rack; | struct tcp_rack *rack; | ||||
rack = (struct tcp_rack *)tp->t_fb_ptr; | rack = (struct tcp_rack *)tp->t_fb_ptr; | ||||
cc_conn_init(tp); | cc_conn_init(tp); | ||||
/* | /* | ||||
* Now convert to rack's internal format. | |||||
*/ | |||||
rack_convert_rtts(tp); | |||||
/* | |||||
* We want a chance to stay in slowstart as | * We want a chance to stay in slowstart as | ||||
* we create a connection. TCP spec says that | * we create a connection. TCP spec says that | ||||
* initially ssthresh is infinite. For our | * initially ssthresh is infinite. For our | ||||
* purposes that is the snd_wnd. | * purposes that is the snd_wnd. | ||||
*/ | */ | ||||
if (tp->snd_ssthresh < tp->snd_wnd) { | if (tp->snd_ssthresh < tp->snd_wnd) { | ||||
tp->snd_ssthresh = tp->snd_wnd; | tp->snd_ssthresh = tp->snd_wnd; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 5,329 Lines • ▼ Show 20 Lines | tcpip_fillheaders(rack->rc_inp, | ||||
ip, rack->r_ctl.fsb.th); | ip, rack->r_ctl.fsb.th); | ||||
} | } | ||||
rack->r_fsb_inited = 1; | rack->r_fsb_inited = 1; | ||||
} | } | ||||
static int | static int | ||||
rack_init_fsb(struct tcpcb *tp, struct tcp_rack *rack) | rack_init_fsb(struct tcpcb *tp, struct tcp_rack *rack) | ||||
{ | { | ||||
/* | /* | ||||
* Allocate the larger of spaces V6 if available else just | * Allocate the larger of spaces V6 if available else just | ||||
* V4 and include udphdr (overbook) | * V4 and include udphdr (overbook) | ||||
*/ | */ | ||||
#ifdef INET6 | #ifdef INET6 | ||||
rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr) + sizeof(struct udphdr); | rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct ip6_hdr) + sizeof(struct tcphdr) + sizeof(struct udphdr); | ||||
#else | #else | ||||
rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct tcpiphdr) + sizeof(struct udphdr); | rack->r_ctl.fsb.tcp_ip_hdr_len = sizeof(struct tcpiphdr) + sizeof(struct udphdr); | ||||
#endif | #endif | ||||
rack->r_ctl.fsb.tcp_ip_hdr = malloc(rack->r_ctl.fsb.tcp_ip_hdr_len, | rack->r_ctl.fsb.tcp_ip_hdr = malloc(rack->r_ctl.fsb.tcp_ip_hdr_len, | ||||
M_TCPFSB, M_NOWAIT|M_ZERO); | M_TCPFSB, M_NOWAIT|M_ZERO); | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | #endif | ||||
* Timers in Rack are kept in microseconds so lets | * Timers in Rack are kept in microseconds so lets | ||||
* convert any initial incoming variables | * convert any initial incoming variables | ||||
* from ticks into usecs. Note that we | * from ticks into usecs. Note that we | ||||
* also change the values of t_srtt and t_rttvar, if | * also change the values of t_srtt and t_rttvar, if | ||||
* they are non-zero. They are kept with a 5 | * they are non-zero. They are kept with a 5 | ||||
* bit decimal so we have to carefully convert | * bit decimal so we have to carefully convert | ||||
* these to get the full precision. | * these to get the full precision. | ||||
*/ | */ | ||||
if (tp->t_srtt > 1) { | rack_convert_rtts(tp); | ||||
uint32_t val, frac; | |||||
val = tp->t_srtt >> TCP_RTT_SHIFT; | |||||
frac = tp->t_srtt & 0x1f; | |||||
tp->t_srtt = TICKS_2_USEC(val); | |||||
/* | |||||
* frac is the fractional part of the srtt (if any) | |||||
* but its in ticks and every bit represents | |||||
* 1/32nd of a hz. | |||||
*/ | |||||
if (frac) { | |||||
if (hz == 1000) { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); | |||||
} else { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); | |||||
} | |||||
tp->t_srtt += frac; | |||||
} | |||||
} | |||||
if (tp->t_rttvar) { | |||||
uint32_t val, frac; | |||||
val = tp->t_rttvar >> TCP_RTTVAR_SHIFT; | |||||
frac = tp->t_rttvar & 0x1f; | |||||
tp->t_rttvar = TICKS_2_USEC(val); | |||||
/* | |||||
* frac is the fractional part of the srtt (if any) | |||||
* but its in ticks and every bit represents | |||||
* 1/32nd of a hz. | |||||
*/ | |||||
if (frac) { | |||||
if (hz == 1000) { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_MSEC) / (uint64_t)TCP_RTT_SCALE); | |||||
} else { | |||||
frac = (((uint64_t)frac * (uint64_t)HPTS_USEC_IN_SEC) / ((uint64_t)(hz) * (uint64_t)TCP_RTT_SCALE)); | |||||
} | |||||
tp->t_rttvar += frac; | |||||
} | |||||
} | |||||
tp->t_rxtcur = TICKS_2_USEC(tp->t_rxtcur); | |||||
tp->t_rttlow = TICKS_2_USEC(tp->t_rttlow); | tp->t_rttlow = TICKS_2_USEC(tp->t_rttlow); | ||||
if (rack_def_profile) | if (rack_def_profile) | ||||
rack_set_profile(rack, rack_def_profile); | rack_set_profile(rack, rack_def_profile); | ||||
/* Cancel the GP measurement in progress */ | /* Cancel the GP measurement in progress */ | ||||
tp->t_flags &= ~TF_GPUTINPROG; | tp->t_flags &= ~TF_GPUTINPROG; | ||||
if (SEQ_GT(tp->snd_max, tp->iss)) | if (SEQ_GT(tp->snd_max, tp->iss)) | ||||
snt = tp->snd_max - tp->iss; | snt = tp->snd_max - tp->iss; | ||||
else | else | ||||
Show All 26 Lines | if (snt < iwin) { | ||||
* It is highly unlikely that we will have had a loss | * It is highly unlikely that we will have had a loss | ||||
* before getting the IW out. | * before getting the IW out. | ||||
*/ | */ | ||||
tp->snd_ssthresh = 0xffffffff; | tp->snd_ssthresh = 0xffffffff; | ||||
} | } | ||||
rack_stop_all_timers(tp); | rack_stop_all_timers(tp); | ||||
/* Lets setup the fsb block */ | /* Lets setup the fsb block */ | ||||
rack_start_hpts_timer(rack, tp, tcp_get_usecs(NULL), 0, 0, 0); | rack_start_hpts_timer(rack, tp, tcp_get_usecs(NULL), 0, 0, 0); | ||||
rack_log_rtt_shrinks(rack, us_cts, 0, | rack_log_rtt_shrinks(rack, us_cts, tp->t_rxtcur, | ||||
__LINE__, RACK_RTTS_INIT); | __LINE__, RACK_RTTS_INIT); | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
rack_handoff_ok(struct tcpcb *tp) | rack_handoff_ok(struct tcpcb *tp) | ||||
{ | { | ||||
if ((tp->t_state == TCPS_CLOSED) || | if ((tp->t_state == TCPS_CLOSED) || | ||||
▲ Show 20 Lines • Show All 7,700 Lines • Show Last 20 Lines |
You are definitely missing a tcp_hc_get() call here.
General question: Can't you call cc_conn_init() here first and then do the conversion to the RACK internal format? This would reduce the code duplication...