Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_dctcp.c
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Perform any necessary tasks before we enter congestion recovery. | * Perform any necessary tasks before we enter congestion recovery. | ||||
*/ | */ | ||||
static void | static void | ||||
dctcp_cong_signal(struct cc_var *ccv, uint32_t type) | dctcp_cong_signal(struct cc_var *ccv, uint32_t type) | ||||
{ | { | ||||
struct dctcp *dctcp_data; | struct dctcp *dctcp_data; | ||||
u_int win, mss; | uint32_t cwin; | ||||
u_int mss; | |||||
dctcp_data = ccv->cc_data; | dctcp_data = ccv->cc_data; | ||||
win = CCV(ccv, snd_cwnd); | cwin = CCV(ccv, snd_cwnd); | ||||
mss = CCV(ccv, t_maxseg); | mss = CCV(ccv, t_maxseg); | ||||
switch (type) { | switch (type) { | ||||
case CC_NDUPACK: | case CC_NDUPACK: | ||||
if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { | if (!IN_FASTRECOVERY(CCV(ccv, t_flags))) { | ||||
if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { | if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { | ||||
CCV(ccv, snd_ssthresh) = mss * | CCV(ccv, snd_ssthresh) = mss * | ||||
max(win / 2 / mss, 2); | max(cwin / 2 / mss, 2); | ||||
dctcp_data->num_cong_events++; | dctcp_data->num_cong_events++; | ||||
} else { | } else { | ||||
/* cwnd has already updated as congestion | /* cwnd has already updated as congestion | ||||
* recovery. Reverse cwnd value using | * recovery. Reverse cwnd value using | ||||
* snd_cwnd_prev and recalculate snd_ssthresh | * snd_cwnd_prev and recalculate snd_ssthresh | ||||
*/ | */ | ||||
win = CCV(ccv, snd_cwnd_prev); | cwin = CCV(ccv, snd_cwnd_prev); | ||||
CCV(ccv, snd_ssthresh) = | CCV(ccv, snd_ssthresh) = | ||||
max(win / 2 / mss, 2) * mss; | max(cwin / 2 / mss, 2) * mss; | ||||
} | } | ||||
ENTER_RECOVERY(CCV(ccv, t_flags)); | ENTER_RECOVERY(CCV(ccv, t_flags)); | ||||
} | } | ||||
break; | break; | ||||
case CC_ECN: | case CC_ECN: | ||||
/* | /* | ||||
* Save current snd_cwnd when the host encounters both | * Save current snd_cwnd when the host encounters both | ||||
* congestion recovery and fast recovery. | * congestion recovery and fast recovery. | ||||
*/ | */ | ||||
CCV(ccv, snd_cwnd_prev) = win; | CCV(ccv, snd_cwnd_prev) = cwin; | ||||
if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { | if (!IN_CONGRECOVERY(CCV(ccv, t_flags))) { | ||||
if (V_dctcp_slowstart && | if (V_dctcp_slowstart && | ||||
dctcp_data->num_cong_events++ == 0) { | dctcp_data->num_cong_events++ == 0) { | ||||
CCV(ccv, snd_ssthresh) = | CCV(ccv, snd_ssthresh) = | ||||
mss * max(win / 2 / mss, 2); | mss * max(cwin / 2 / mss, 2); | ||||
dctcp_data->alpha = MAX_ALPHA_VALUE; | dctcp_data->alpha = MAX_ALPHA_VALUE; | ||||
dctcp_data->bytes_ecn = 0; | dctcp_data->bytes_ecn = 0; | ||||
dctcp_data->bytes_total = 0; | dctcp_data->bytes_total = 0; | ||||
dctcp_data->save_sndnxt = CCV(ccv, snd_nxt); | dctcp_data->save_sndnxt = CCV(ccv, snd_nxt); | ||||
} else | } else | ||||
CCV(ccv, snd_ssthresh) = max((win - ((win * | CCV(ccv, snd_ssthresh) = max((cwin - ((cwin * | ||||
dctcp_data->alpha) >> 11)) / mss, 2) * mss; | dctcp_data->alpha) >> 11)) / mss, 2) * mss; | ||||
CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); | CCV(ccv, snd_cwnd) = CCV(ccv, snd_ssthresh); | ||||
ENTER_CONGRECOVERY(CCV(ccv, t_flags)); | ENTER_CONGRECOVERY(CCV(ccv, t_flags)); | ||||
} | } | ||||
dctcp_data->ece_curr = 1; | dctcp_data->ece_curr = 1; | ||||
break; | break; | ||||
case CC_RTO: | case CC_RTO: | ||||
if (CCV(ccv, t_flags) & TF_ECN_PERMIT) { | if (CCV(ccv, t_flags) & TF_ECN_PERMIT) { | ||||
CCV(ccv, t_flags) |= TF_ECN_SND_CWR; | CCV(ccv, t_flags) |= TF_ECN_SND_CWR; | ||||
dctcp_update_alpha(ccv); | dctcp_update_alpha(ccv); | ||||
dctcp_data->save_sndnxt += CCV(ccv, t_maxseg); | dctcp_data->save_sndnxt += CCV(ccv, t_maxseg); | ||||
dctcp_data->num_cong_events++; | dctcp_data->num_cong_events++; | ||||
CCV(ccv, snd_ssthresh) = max(2 * mss, cwin / 2); | |||||
CCV(ccv, snd_cwnd) = mss; | |||||
} | } | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
dctcp_conn_init(struct cc_var *ccv) | dctcp_conn_init(struct cc_var *ccv) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 178 Lines • Show Last 20 Lines |