Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_chd.c
Show First 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
#define CC_CHD_DELAY 0x02000000 | #define CC_CHD_DELAY 0x02000000 | ||||
/* Largest possible number returned by random(). */ | /* Largest possible number returned by random(). */ | ||||
#define RANDOM_MAX INT_MAX | #define RANDOM_MAX INT_MAX | ||||
static void chd_ack_received(struct cc_var *ccv, uint16_t ack_type); | static void chd_ack_received(struct cc_var *ccv, uint16_t ack_type); | ||||
static void chd_cb_destroy(struct cc_var *ccv); | static void chd_cb_destroy(struct cc_var *ccv); | ||||
static int chd_cb_init(struct cc_var *ccv); | static int chd_cb_init(struct cc_var *ccv, void *ptr); | ||||
static void chd_cong_signal(struct cc_var *ccv, uint32_t signal_type); | static void chd_cong_signal(struct cc_var *ccv, uint32_t signal_type); | ||||
static void chd_conn_init(struct cc_var *ccv); | static void chd_conn_init(struct cc_var *ccv); | ||||
static int chd_mod_init(void); | static int chd_mod_init(void); | ||||
static size_t chd_data_sz(void); | |||||
struct chd { | struct chd { | ||||
/* | /* | ||||
* Shadow window - keeps track of what the NewReno congestion window | * Shadow window - keeps track of what the NewReno congestion window | ||||
* would have been if delay-based cwnd backoffs had not been made. This | * would have been if delay-based cwnd backoffs had not been made. This | ||||
* functionality aids coexistence with loss-based TCP flows which may be | * functionality aids coexistence with loss-based TCP flows which may be | ||||
* sharing links along the path. | * sharing links along the path. | ||||
*/ | */ | ||||
Show All 17 Lines | |||||
VNET_DEFINE_STATIC(uint32_t, chd_use_max) = 1; | VNET_DEFINE_STATIC(uint32_t, chd_use_max) = 1; | ||||
VNET_DEFINE_STATIC(uint32_t, chd_qthresh) = 20; | VNET_DEFINE_STATIC(uint32_t, chd_qthresh) = 20; | ||||
#define V_chd_qthresh VNET(chd_qthresh) | #define V_chd_qthresh VNET(chd_qthresh) | ||||
#define V_chd_qmin VNET(chd_qmin) | #define V_chd_qmin VNET(chd_qmin) | ||||
#define V_chd_pmax VNET(chd_pmax) | #define V_chd_pmax VNET(chd_pmax) | ||||
#define V_chd_loss_fair VNET(chd_loss_fair) | #define V_chd_loss_fair VNET(chd_loss_fair) | ||||
#define V_chd_use_max VNET(chd_use_max) | #define V_chd_use_max VNET(chd_use_max) | ||||
static MALLOC_DEFINE(M_CHD, "chd data", | |||||
"Per connection data required for the CHD congestion control algorithm"); | |||||
struct cc_algo chd_cc_algo = { | struct cc_algo chd_cc_algo = { | ||||
.name = "chd", | .name = "chd", | ||||
.ack_received = chd_ack_received, | .ack_received = chd_ack_received, | ||||
.cb_destroy = chd_cb_destroy, | .cb_destroy = chd_cb_destroy, | ||||
.cb_init = chd_cb_init, | .cb_init = chd_cb_init, | ||||
.cong_signal = chd_cong_signal, | .cong_signal = chd_cong_signal, | ||||
.conn_init = chd_conn_init, | .conn_init = chd_conn_init, | ||||
.mod_init = chd_mod_init | .mod_init = chd_mod_init, | ||||
.cc_data_sz = chd_data_sz, | |||||
.after_idle = common_cc_after_idle, | |||||
.post_recovery = common_cc_post_recovery, | |||||
}; | }; | ||||
static __inline void | static __inline void | ||||
chd_window_decrease(struct cc_var *ccv) | chd_window_decrease(struct cc_var *ccv) | ||||
{ | { | ||||
unsigned long win; | unsigned long win; | ||||
win = min(CCV(ccv, snd_wnd), CCV(ccv, snd_cwnd)) / CCV(ccv, t_maxseg); | win = min(CCV(ccv, snd_wnd), CCV(ccv, snd_cwnd)) / CCV(ccv, t_maxseg); | ||||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | chd_ack_received(struct cc_var *ccv, uint16_t ack_type) | ||||
} else if (ack_type == CC_ACK) | } else if (ack_type == CC_ACK) | ||||
chd_window_increase(ccv, new_measurement); | chd_window_increase(ccv, new_measurement); | ||||
} | } | ||||
static void | static void | ||||
chd_cb_destroy(struct cc_var *ccv) | chd_cb_destroy(struct cc_var *ccv) | ||||
{ | { | ||||
free(ccv->cc_data, M_CC_MEM); | |||||
} | |||||
free(ccv->cc_data, M_CHD); | size_t | ||||
chd_data_sz(void) | |||||
{ | |||||
return (sizeof(struct chd)); | |||||
} | } | ||||
static int | static int | ||||
chd_cb_init(struct cc_var *ccv) | chd_cb_init(struct cc_var *ccv, void *ptr) | ||||
{ | { | ||||
struct chd *chd_data; | struct chd *chd_data; | ||||
chd_data = malloc(sizeof(struct chd), M_CHD, M_NOWAIT); | if (ptr == NULL) { | ||||
chd_data = malloc(sizeof(struct chd), M_CC_MEM, M_NOWAIT); | |||||
if (chd_data == NULL) | if (chd_data == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} else | |||||
chd_data = ptr; | |||||
chd_data->shadow_w = 0; | chd_data->shadow_w = 0; | ||||
ccv->cc_data = chd_data; | ccv->cc_data = chd_data; | ||||
return (0); | return (0); | ||||
} | } | ||||
static void | static void | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | case CC_NDUPACK: /* Packet loss. */ | ||||
if (chd_data->shadow_w > 0) { | if (chd_data->shadow_w > 0) { | ||||
chd_data->shadow_w = max(chd_data->shadow_w / | chd_data->shadow_w = max(chd_data->shadow_w / | ||||
CCV(ccv, t_maxseg) / 2, 2) * CCV(ccv, t_maxseg); | CCV(ccv, t_maxseg) / 2, 2) * CCV(ccv, t_maxseg); | ||||
} | } | ||||
ENTER_FASTRECOVERY(CCV(ccv, t_flags)); | ENTER_FASTRECOVERY(CCV(ccv, t_flags)); | ||||
break; | break; | ||||
default: | default: | ||||
newreno_cc_algo.cong_signal(ccv, signal_type); | common_cc_cong_signal(ccv, signal_type); | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
chd_conn_init(struct cc_var *ccv) | chd_conn_init(struct cc_var *ccv) | ||||
{ | { | ||||
struct chd *chd_data; | struct chd *chd_data; | ||||
Show All 12 Lines | |||||
chd_mod_init(void) | chd_mod_init(void) | ||||
{ | { | ||||
ertt_id = khelp_get_id("ertt"); | ertt_id = khelp_get_id("ertt"); | ||||
if (ertt_id <= 0) { | if (ertt_id <= 0) { | ||||
printf("%s: h_ertt module not found\n", __func__); | printf("%s: h_ertt module not found\n", __func__); | ||||
return (ENOENT); | return (ENOENT); | ||||
} | } | ||||
chd_cc_algo.after_idle = newreno_cc_algo.after_idle; | |||||
chd_cc_algo.post_recovery = newreno_cc_algo.post_recovery; | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
chd_loss_fair_handler(SYSCTL_HANDLER_ARGS) | chd_loss_fair_handler(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
int error; | int error; | ||||
uint32_t new; | uint32_t new; | ||||
▲ Show 20 Lines • Show All 80 Lines • Show Last 20 Lines |