Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/cc/cc_hd.c
Show First 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | |||||
#include <netinet/khelp/h_ertt.h> | #include <netinet/khelp/h_ertt.h> | ||||
/* Largest possible number returned by random(). */ | /* Largest possible number returned by random(). */ | ||||
#define RANDOM_MAX INT_MAX | #define RANDOM_MAX INT_MAX | ||||
static void hd_ack_received(struct cc_var *ccv, uint16_t ack_type); | static void hd_ack_received(struct cc_var *ccv, uint16_t ack_type); | ||||
static int hd_mod_init(void); | static int hd_mod_init(void); | ||||
static size_t hd_data_sz(void); | |||||
static int ertt_id; | static int ertt_id; | ||||
VNET_DEFINE_STATIC(uint32_t, hd_qthresh) = 20; | VNET_DEFINE_STATIC(uint32_t, hd_qthresh) = 20; | ||||
VNET_DEFINE_STATIC(uint32_t, hd_qmin) = 5; | VNET_DEFINE_STATIC(uint32_t, hd_qmin) = 5; | ||||
VNET_DEFINE_STATIC(uint32_t, hd_pmax) = 5; | VNET_DEFINE_STATIC(uint32_t, hd_pmax) = 5; | ||||
#define V_hd_qthresh VNET(hd_qthresh) | #define V_hd_qthresh VNET(hd_qthresh) | ||||
#define V_hd_qmin VNET(hd_qmin) | #define V_hd_qmin VNET(hd_qmin) | ||||
#define V_hd_pmax VNET(hd_pmax) | #define V_hd_pmax VNET(hd_pmax) | ||||
struct cc_algo hd_cc_algo = { | struct cc_algo hd_cc_algo = { | ||||
.name = "hd", | .name = "hd", | ||||
.ack_received = hd_ack_received, | .ack_received = hd_ack_received, | ||||
.mod_init = hd_mod_init | .mod_init = hd_mod_init, | ||||
.cc_data_sz = hd_data_sz, | |||||
.after_idle = newreno_cc_after_idle, | |||||
.cong_signal = newreno_cc_cong_signal, | |||||
.post_recovery = newreno_cc_post_recovery, | |||||
}; | }; | ||||
static size_t | |||||
hd_data_sz(void) | |||||
{ | |||||
return (0); | |||||
} | |||||
/* | /* | ||||
* Hamilton backoff function. Returns 1 if we should backoff or 0 otherwise. | * Hamilton backoff function. Returns 1 if we should backoff or 0 otherwise. | ||||
*/ | */ | ||||
static __inline int | static __inline int | ||||
should_backoff(int qdly, int maxqdly) | should_backoff(int qdly, int maxqdly) | ||||
{ | { | ||||
unsigned long p; | unsigned long p; | ||||
Show All 34 Lines | if (e_t->rtt && e_t->minrtt && V_hd_qthresh > 0) { | ||||
/* Probabilistic backoff of cwnd. */ | /* Probabilistic backoff of cwnd. */ | ||||
if (should_backoff(qdly, | if (should_backoff(qdly, | ||||
e_t->maxrtt - e_t->minrtt)) { | e_t->maxrtt - e_t->minrtt)) { | ||||
/* | /* | ||||
* Update cwnd and ssthresh update to | * Update cwnd and ssthresh update to | ||||
* half cwnd and behave like an ECN (ie | * half cwnd and behave like an ECN (ie | ||||
* not a packet loss). | * not a packet loss). | ||||
*/ | */ | ||||
newreno_cc_algo.cong_signal(ccv, | newreno_cc_cong_signal(ccv, | ||||
CC_ECN); | CC_ECN); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
newreno_cc_algo.ack_received(ccv, ack_type); /* As for NewReno. */ | newreno_cc_ack_received(ccv, ack_type); | ||||
} | } | ||||
static int | static int | ||||
hd_mod_init(void) | hd_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); | ||||
} | } | ||||
hd_cc_algo.after_idle = newreno_cc_algo.after_idle; | |||||
hd_cc_algo.cong_signal = newreno_cc_algo.cong_signal; | |||||
hd_cc_algo.post_recovery = newreno_cc_algo.post_recovery; | |||||
return (0); | return (0); | ||||
} | } | ||||
static int | static int | ||||
hd_pmax_handler(SYSCTL_HANDLER_ARGS) | hd_pmax_handler(SYSCTL_HANDLER_ARGS) | ||||
{ | { | ||||
int error; | int error; | ||||
uint32_t new; | uint32_t new; | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | SYSCTL_PROC(_net_inet_tcp_cc_hd, OID_AUTO, pmax, | ||||
"per packet maximum backoff probability as a percentage"); | "per packet maximum backoff probability as a percentage"); | ||||
SYSCTL_PROC(_net_inet_tcp_cc_hd, OID_AUTO, queue_min, | SYSCTL_PROC(_net_inet_tcp_cc_hd, OID_AUTO, queue_min, | ||||
CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | CTLFLAG_VNET | CTLTYPE_UINT | CTLFLAG_RW | CTLFLAG_NEEDGIANT, | ||||
&VNET_NAME(hd_qmin), 5, &hd_qmin_handler, "IU", | &VNET_NAME(hd_qmin), 5, &hd_qmin_handler, "IU", | ||||
"minimum queueing delay threshold (qmin) in ticks"); | "minimum queueing delay threshold (qmin) in ticks"); | ||||
DECLARE_CC_MODULE(hd, &hd_cc_algo); | DECLARE_CC_MODULE(hd, &hd_cc_algo); | ||||
MODULE_VERSION(hd, 1); | MODULE_VERSION(hd, 2); | ||||
MODULE_DEPEND(hd, ertt, 1, 1, 1); | MODULE_DEPEND(hd, ertt, 1, 1, 1); |