Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_cdg.c
Show First 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | static const int probexp[641] = { | ||||
32374,32377,32381,32384,32387,32389,32392,32395,32398,32401,32404,32407,32410, | 32374,32377,32381,32384,32387,32389,32392,32395,32398,32401,32404,32407,32410, | ||||
32412,32415,32418,32421,32423,32426,32429,32431,32434,32437,32439,32442,32444, | 32412,32415,32418,32421,32423,32426,32429,32431,32434,32437,32439,32442,32444, | ||||
32447,32449,32452,32454,32457,32459,32461,32464,32466,32469,32471,32473,32476, | 32447,32449,32452,32454,32457,32459,32461,32464,32466,32469,32471,32473,32476, | ||||
32478,32480,32482,32485,32487,32489,32491,32493,32495,32497,32500,32502,32504, | 32478,32480,32482,32485,32487,32489,32491,32493,32495,32497,32500,32502,32504, | ||||
32506,32508,32510,32512,32514,32516,32518,32520,32522,32524,32526,32527,32529, | 32506,32508,32510,32512,32514,32516,32518,32520,32522,32524,32526,32527,32529, | ||||
32531,32533,32535,32537,32538,32540,32542,32544,32545,32547}; | 32531,32533,32535,32537,32538,32540,32542,32544,32545,32547}; | ||||
static uma_zone_t qdiffsample_zone; | static uma_zone_t qdiffsample_zone; | ||||
static MALLOC_DEFINE(M_CDG, "cdg data", | |||||
"Per connection data required for the CDG congestion control algorithm"); | |||||
static int ertt_id; | static int ertt_id; | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_alpha_inc); | VNET_DEFINE_STATIC(uint32_t, cdg_alpha_inc); | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_beta_delay); | VNET_DEFINE_STATIC(uint32_t, cdg_beta_delay); | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_beta_loss); | VNET_DEFINE_STATIC(uint32_t, cdg_beta_loss); | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_smoothing_factor); | VNET_DEFINE_STATIC(uint32_t, cdg_smoothing_factor); | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_exp_backoff_scale); | VNET_DEFINE_STATIC(uint32_t, cdg_exp_backoff_scale); | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_consec_cong); | VNET_DEFINE_STATIC(uint32_t, cdg_consec_cong); | ||||
VNET_DEFINE_STATIC(uint32_t, cdg_hold_backoff); | VNET_DEFINE_STATIC(uint32_t, cdg_hold_backoff); | ||||
#define V_cdg_alpha_inc VNET(cdg_alpha_inc) | #define V_cdg_alpha_inc VNET(cdg_alpha_inc) | ||||
#define V_cdg_beta_delay VNET(cdg_beta_delay) | #define V_cdg_beta_delay VNET(cdg_beta_delay) | ||||
#define V_cdg_beta_loss VNET(cdg_beta_loss) | #define V_cdg_beta_loss VNET(cdg_beta_loss) | ||||
#define V_cdg_smoothing_factor VNET(cdg_smoothing_factor) | #define V_cdg_smoothing_factor VNET(cdg_smoothing_factor) | ||||
#define V_cdg_exp_backoff_scale VNET(cdg_exp_backoff_scale) | #define V_cdg_exp_backoff_scale VNET(cdg_exp_backoff_scale) | ||||
#define V_cdg_consec_cong VNET(cdg_consec_cong) | #define V_cdg_consec_cong VNET(cdg_consec_cong) | ||||
#define V_cdg_hold_backoff VNET(cdg_hold_backoff) | #define V_cdg_hold_backoff VNET(cdg_hold_backoff) | ||||
/* Function prototypes. */ | /* Function prototypes. */ | ||||
static int cdg_mod_init(void); | static int cdg_mod_init(void); | ||||
static int cdg_mod_destroy(void); | static int cdg_mod_destroy(void); | ||||
static void cdg_conn_init(struct cc_var *ccv); | static void cdg_conn_init(struct cc_var *ccv); | ||||
static int cdg_cb_init(struct cc_var *ccv); | static int cdg_cb_init(struct cc_var *ccv, void *ptr); | ||||
static void cdg_cb_destroy(struct cc_var *ccv); | static void cdg_cb_destroy(struct cc_var *ccv); | ||||
static void cdg_cong_signal(struct cc_var *ccv, uint32_t signal_type); | static void cdg_cong_signal(struct cc_var *ccv, uint32_t signal_type); | ||||
static void cdg_ack_received(struct cc_var *ccv, uint16_t ack_type); | static void cdg_ack_received(struct cc_var *ccv, uint16_t ack_type); | ||||
static size_t cdg_data_sz(void); | |||||
struct cc_algo cdg_cc_algo = { | struct cc_algo cdg_cc_algo = { | ||||
.name = "cdg", | .name = "cdg", | ||||
.mod_init = cdg_mod_init, | .mod_init = cdg_mod_init, | ||||
.ack_received = cdg_ack_received, | .ack_received = cdg_ack_received, | ||||
.cb_destroy = cdg_cb_destroy, | .cb_destroy = cdg_cb_destroy, | ||||
.cb_init = cdg_cb_init, | .cb_init = cdg_cb_init, | ||||
.conn_init = cdg_conn_init, | .conn_init = cdg_conn_init, | ||||
.cong_signal = cdg_cong_signal, | .cong_signal = cdg_cong_signal, | ||||
.mod_destroy = cdg_mod_destroy | .mod_destroy = cdg_mod_destroy, | ||||
.cc_data_sz = cdg_data_sz | |||||
}; | }; | ||||
/* Vnet created and being initialised. */ | /* Vnet created and being initialised. */ | ||||
static void | static void | ||||
cdg_init_vnet(const void *unused __unused) | cdg_init_vnet(const void *unused __unused) | ||||
{ | { | ||||
V_cdg_alpha_inc = 0; | V_cdg_alpha_inc = 0; | ||||
Show All 20 Lines | cdg_mod_init(void) | ||||
VNET_LIST_RLOCK(); | VNET_LIST_RLOCK(); | ||||
VNET_FOREACH(v) { | VNET_FOREACH(v) { | ||||
CURVNET_SET(v); | CURVNET_SET(v); | ||||
cdg_init_vnet(NULL); | cdg_init_vnet(NULL); | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
} | } | ||||
VNET_LIST_RUNLOCK(); | VNET_LIST_RUNLOCK(); | ||||
cdg_cc_algo.post_recovery = newreno_cc_algo.post_recovery; | cdg_cc_algo.post_recovery = common_cc_post_recovery; | ||||
cdg_cc_algo.after_idle = newreno_cc_algo.after_idle; | cdg_cc_algo.after_idle = common_cc_after_idle; | ||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
cdg_mod_destroy(void) | cdg_mod_destroy(void) | ||||
{ | { | ||||
uma_zdestroy(qdiffsample_zone); | uma_zdestroy(qdiffsample_zone); | ||||
return (0); | return (0); | ||||
} | } | ||||
static size_t | |||||
cdg_data_sz(void) | |||||
{ | |||||
return (sizeof(struct cdg)); | |||||
} | |||||
static int | static int | ||||
cdg_cb_init(struct cc_var *ccv) | cdg_cb_init(struct cc_var *ccv, void *ptr) | ||||
{ | { | ||||
struct cdg *cdg_data; | struct cdg *cdg_data; | ||||
cdg_data = malloc(sizeof(struct cdg), M_CDG, M_NOWAIT); | if (ptr == NULL) { | ||||
cdg_data = malloc(sizeof(struct cdg), M_CC_MEM, M_NOWAIT); | |||||
if (cdg_data == NULL) | if (cdg_data == NULL) | ||||
return (ENOMEM); | return (ENOMEM); | ||||
} else { | |||||
cdg_data = ptr; | |||||
} | |||||
cdg_data->shadow_w = 0; | cdg_data->shadow_w = 0; | ||||
cdg_data->max_qtrend = 0; | cdg_data->max_qtrend = 0; | ||||
cdg_data->min_qtrend = 0; | cdg_data->min_qtrend = 0; | ||||
cdg_data->queue_state = CDG_Q_UNKNOWN; | cdg_data->queue_state = CDG_Q_UNKNOWN; | ||||
cdg_data->maxrtt_in_rtt = 0; | cdg_data->maxrtt_in_rtt = 0; | ||||
cdg_data->maxrtt_in_prevrtt = 0; | cdg_data->maxrtt_in_prevrtt = 0; | ||||
cdg_data->minrtt_in_rtt = INT_MAX; | cdg_data->minrtt_in_rtt = INT_MAX; | ||||
cdg_data->minrtt_in_prevrtt = 0; | cdg_data->minrtt_in_prevrtt = 0; | ||||
Show All 39 Lines | cdg_cb_destroy(struct cc_var *ccv) | ||||
qds = STAILQ_FIRST(&cdg_data->qdiffmax_q); | qds = STAILQ_FIRST(&cdg_data->qdiffmax_q); | ||||
while (qds != NULL) { | while (qds != NULL) { | ||||
qds_n = STAILQ_NEXT(qds, qdiff_lnk); | qds_n = STAILQ_NEXT(qds, qdiff_lnk); | ||||
uma_zfree(qdiffsample_zone,qds); | uma_zfree(qdiffsample_zone,qds); | ||||
qds = qds_n; | qds = qds_n; | ||||
} | } | ||||
free(ccv->cc_data, M_CDG); | free(ccv->cc_data, M_CC_MEM); | ||||
} | } | ||||
static int | static int | ||||
cdg_beta_handler(SYSCTL_HANDLER_ARGS) | cdg_beta_handler(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
int error; | int error; | ||||
uint32_t new; | uint32_t new; | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | if (IN_CONGRECOVERY(CCV(ccv, t_flags)) || | ||||
cdg_window_decrease(ccv, CCV(ccv, snd_cwnd), | cdg_window_decrease(ccv, CCV(ccv, snd_cwnd), | ||||
V_cdg_beta_loss)); | V_cdg_beta_loss)); | ||||
cdg_data->window_incr = cdg_data->rtt_count = 0; | cdg_data->window_incr = cdg_data->rtt_count = 0; | ||||
} | } | ||||
ENTER_RECOVERY(CCV(ccv, t_flags)); | ENTER_RECOVERY(CCV(ccv, t_flags)); | ||||
break; | break; | ||||
default: | default: | ||||
newreno_cc_algo.cong_signal(ccv, signal_type); | common_cc_cong_signal(ccv, signal_type); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Using a negative exponential probabilistic backoff so that sources with | * Using a negative exponential probabilistic backoff so that sources with | ||||
* varying RTTs which share the same link will, on average, have the same | * varying RTTs which share the same link will, on average, have the same | ||||
* probability of backoff over time. | * probability of backoff over time. | ||||
▲ Show 20 Lines • Show All 223 Lines • Show Last 20 Lines |