FreeBSD kernel IPv4 code
cc.c File Reference
#include <sys/cdefs.h>
#include <opt_cc.h>
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/libkern.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
#include <sys/queue.h>
#include <sys/rwlock.h>
#include <sys/sbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_log_buf.h>
#include <netinet/tcp_hpts.h>
#include <netinet/cc/cc.h>
#include <netinet/cc/cc_module.h>
Include dependency graph for cc.c:

Go to the source code of this file.

Macros

#define CC_DEFAULT   "newreno"
 
#define V_newreno_beta   VNET(newreno_beta)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 MALLOC_DEFINE (M_CC_MEM, "CC Mem", "Congestion Control State memory")
 
 VNET_DEFINE (struct cc_algo *, default_cc_ptr)
 
 VNET_DEFINE (uint32_t, newreno_beta)
 
void cc_refer (struct cc_algo *algo)
 
void cc_release (struct cc_algo *algo)
 
void cc_attach (struct tcpcb *tp, struct cc_algo *algo)
 
void cc_detach (struct tcpcb *tp)
 
static int cc_default_algo (SYSCTL_HANDLER_ARGS)
 
static int cc_list_available (SYSCTL_HANDLER_ARGS)
 
static int cc_check_default (struct cc_algo *remove_cc)
 
static void cc_init (void)
 
int cc_deregister_algo (struct cc_algo *remove_cc)
 
int cc_register_algo (struct cc_algo *add_cc)
 
static void vnet_cc_sysinit (void *arg)
 
 VNET_SYSINIT (vnet_cc_sysinit, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY, vnet_cc_sysinit, NULL)
 
void newreno_cc_post_recovery (struct cc_var *ccv)
 
void newreno_cc_after_idle (struct cc_var *ccv)
 
void newreno_cc_cong_signal (struct cc_var *ccv, uint32_t type)
 
void newreno_cc_ack_received (struct cc_var *ccv, uint16_t type)
 
static int cc_stop_new_assignments (struct cc_algo *algo)
 
int cc_modevent (module_t mod, int event_type, void *data)
 
 SYSINIT (cc, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST, cc_init, NULL)
 
 SYSCTL_NODE (_net_inet_tcp, OID_AUTO, cc, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, "Congestion control related settings")
 
 SYSCTL_PROC (_net_inet_tcp_cc, OID_AUTO, algorithm, CTLFLAG_VNET|CTLTYPE_STRING|CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, 0, cc_default_algo, "A", "Default congestion control algorithm")
 
 SYSCTL_PROC (_net_inet_tcp_cc, OID_AUTO, available, CTLTYPE_STRING|CTLFLAG_RD|CTLFLAG_MPSAFE, NULL, 0, cc_list_available, "A", "List available congestion control algorithms")
 
 SYSCTL_NODE (_net_inet_tcp_cc, OID_AUTO, hystartplusplus, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, "New Reno related HyStart++ settings")
 
 SYSCTL_UINT (_net_inet_tcp_cc_hystartplusplus, OID_AUTO, minrtt_thresh, CTLFLAG_RW, &hystart_minrtt_thresh, 4000, "HyStarts++ minimum RTT thresh used in clamp (in microseconds)")
 
 SYSCTL_UINT (_net_inet_tcp_cc_hystartplusplus, OID_AUTO, maxrtt_thresh, CTLFLAG_RW, &hystart_maxrtt_thresh, 16000, "HyStarts++ maximum RTT thresh used in clamp (in microseconds)")
 
 SYSCTL_UINT (_net_inet_tcp_cc_hystartplusplus, OID_AUTO, n_rttsamples, CTLFLAG_RW, &hystart_n_rttsamples, 8, "The number of RTT samples that must be seen to consider HyStart++")
 
 SYSCTL_UINT (_net_inet_tcp_cc_hystartplusplus, OID_AUTO, css_growth_div, CTLFLAG_RW, &hystart_css_growth_div, 4, "The divisor to the growth when in Hystart++ CSS")
 
 SYSCTL_UINT (_net_inet_tcp_cc_hystartplusplus, OID_AUTO, css_rounds, CTLFLAG_RW, &hystart_css_rounds, 5, "The number of rounds HyStart++ lasts in CSS before falling to CA")
 
 SYSCTL_UINT (_net_inet_tcp_cc_hystartplusplus, OID_AUTO, bblogs, CTLFLAG_RW, &hystart_bblogs, 0, "Do we enable HyStart++ Black Box logs to be generated if BB logging is on")
 
 VNET_DEFINE (int, cc_do_abe)=0
 
 SYSCTL_INT (_net_inet_tcp_cc, OID_AUTO, abe, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(cc_do_abe), 0, "Enable draft-ietf-tcpm-alternativebackoff-ecn (TCP Alternative Backoff with ECN)")
 
 VNET_DEFINE (int, cc_abe_frlossreduce)=0
 
 SYSCTL_INT (_net_inet_tcp_cc, OID_AUTO, abe_frlossreduce, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(cc_abe_frlossreduce), 0, "Apply standard beta instead of ABE-beta during ECN-signalled congestion " "recovery episodes if loss also needs to be repaired")
 

Variables

uint32_t hystart_minrtt_thresh = 4000
 
uint32_t hystart_maxrtt_thresh = 16000
 
uint32_t hystart_n_rttsamples = 8
 
uint32_t hystart_css_growth_div = 4
 
uint32_t hystart_css_rounds = 5
 
uint32_t hystart_bblogs = 0
 
struct cc_head cc_list = STAILQ_HEAD_INITIALIZER(cc_list)
 
struct rwlock cc_list_lock
 

Macro Definition Documentation

◆ CC_DEFAULT

#define CC_DEFAULT   "newreno"

Definition at line 84 of file cc.c.

◆ V_newreno_beta

#define V_newreno_beta   VNET(newreno_beta)

Definition at line 108 of file cc.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cc_attach()

void cc_attach ( struct tcpcb tp,
struct cc_algo algo 
)

Definition at line 126 of file cc.c.

References CC_ALGO, CC_LIST_RLOCK, CC_LIST_RUNLOCK, and cc_refer().

Referenced by tcp_newtcpcb(), and tcp_set_cc_mod().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cc_check_default()

static int cc_check_default ( struct cc_algo remove_cc)
static

Definition at line 248 of file cc.c.

References CC_DEFAULT_ALGO, CC_LIST_LOCK_ASSERT, and cc_algo::name.

Referenced by cc_deregister_algo(), cc_modevent(), and cc_stop_new_assignments().

Here is the caller graph for this function:

◆ cc_default_algo()

static int cc_default_algo ( SYSCTL_HANDLER_ARGS  )
static

◆ cc_deregister_algo()

int cc_deregister_algo ( struct cc_algo remove_cc)

Definition at line 284 of file cc.c.

References cc_check_default(), cc_list, CC_LIST_WLOCK, CC_LIST_WUNLOCK, CC_MODULE_BEING_REMOVED, cc_algo::cc_refcount, and cc_algo::flags.

Referenced by cc_modevent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cc_detach()

void cc_detach ( struct tcpcb tp)

Definition at line 138 of file cc.c.

References CC_ALGO, CC_LIST_RLOCK, CC_LIST_RUNLOCK, and cc_release().

Referenced by tcp_discardcb(), tcp_newtcpcb(), and tcp_set_cc_mod().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cc_init()

static void cc_init ( void  )
static

Definition at line 274 of file cc.c.

References cc_list, and CC_LIST_LOCK_INIT.

◆ cc_list_available()

static int cc_list_available ( SYSCTL_HANDLER_ARGS  )
static

◆ cc_modevent()

int cc_modevent ( module_t  mod,
int  event_type,
void *  data 
)

◆ cc_refer()

void cc_refer ( struct cc_algo algo)

Definition at line 111 of file cc.c.

References CC_LIST_LOCK_ASSERT, and cc_algo::cc_refcount.

Referenced by cc_attach(), and tcp_set_cc_mod().

Here is the caller graph for this function:

◆ cc_register_algo()

int cc_register_algo ( struct cc_algo add_cc)

Definition at line 322 of file cc.c.

References CC_DEFAULT, cc_list, CC_LIST_WLOCK, CC_LIST_WUNLOCK, cc_algo::cc_refcount, cc_algo::name, and V_default_cc_ptr.

Referenced by cc_modevent().

Here is the caller graph for this function:

◆ cc_release()

void cc_release ( struct cc_algo algo)

Definition at line 118 of file cc.c.

References CC_LIST_LOCK_ASSERT, and cc_algo::cc_refcount.

Referenced by cc_detach(), and tcp_set_cc_mod().

Here is the caller graph for this function:

◆ cc_stop_new_assignments()

static int cc_stop_new_assignments ( struct cc_algo algo)
static

Definition at line 568 of file cc.c.

References cc_check_default(), CC_LIST_WLOCK, CC_LIST_WUNLOCK, CC_MODULE_BEING_REMOVED, and cc_algo::flags.

Referenced by cc_modevent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MALLOC_DEFINE()

MALLOC_DEFINE ( M_CC_MEM  ,
"CC Mem"  ,
"Congestion Control State memory"   
)

◆ newreno_cc_ack_received()

void newreno_cc_ack_received ( struct cc_var ccv,
uint16_t  type 
)

◆ newreno_cc_after_idle()

void newreno_cc_after_idle ( struct cc_var ccv)

Definition at line 415 of file cc.c.

References CCV, cc_var::ccvc, cc_var::ccv_container::tcp, tcp_compute_initwnd(), and tcp_maxseg().

Referenced by cubic_after_idle(), dctcp_after_idle(), and newreno_after_idle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newreno_cc_cong_signal()

void newreno_cc_cong_signal ( struct cc_var ccv,
uint32_t  type 
)

Definition at line 447 of file cc.c.

References CC_ECN, CC_NDUPACK, CC_RTO, CC_SIGPRIVMASK, CCV, cc_var::ccvc, ENTER_CONGRECOVERY, ENTER_RECOVERY, IN_CONGRECOVERY, IN_FASTRECOVERY, cc_var::ccv_container::tcp, tcp_fixed_maxseg(), and V_newreno_beta.

Referenced by cdg_cong_signal(), chd_cong_signal(), dctcp_cong_signal(), hd_ack_received(), and vegas_cong_signal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ newreno_cc_post_recovery()

void newreno_cc_post_recovery ( struct cc_var ccv)

Definition at line 384 of file cc.c.

References CCV, cc_var::ccvc, cc_var::curack, IN_FASTRECOVERY, cc_var::ccv_container::tcp, tcp_compute_pipe(), and V_tcp_do_newsack.

Referenced by dctcp_post_recovery().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SYSCTL_INT() [1/2]

SYSCTL_INT ( _net_inet_tcp_cc  ,
OID_AUTO  ,
abe  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcc_do_abe,
,
"Enable draft-ietf-tcpm-alternativebackoff-ecn (TCP Alternative Backoff with ECN)"   
)

◆ SYSCTL_INT() [2/2]

SYSCTL_INT ( _net_inet_tcp_cc  ,
OID_AUTO  ,
abe_frlossreduce  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcc_abe_frlossreduce,
,
"Apply standard beta instead of ABE-beta during ECN-signalled congestion " "recovery episodes if loss also needs to be repaired"   
)

◆ SYSCTL_NODE() [1/2]

SYSCTL_NODE ( _net_inet_tcp  ,
OID_AUTO  ,
cc  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
"Congestion control related settings"   
)

◆ SYSCTL_NODE() [2/2]

SYSCTL_NODE ( _net_inet_tcp_cc  ,
OID_AUTO  ,
hystartplusplus  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
"New Reno related HyStart++ settings"   
)

◆ SYSCTL_PROC() [1/2]

SYSCTL_PROC ( _net_inet_tcp_cc  ,
OID_AUTO  ,
algorithm  ,
CTLFLAG_VNET|CTLTYPE_STRING|CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
,
cc_default_algo  ,
"A"  ,
"Default congestion control algorithm"   
)

◆ SYSCTL_PROC() [2/2]

SYSCTL_PROC ( _net_inet_tcp_cc  ,
OID_AUTO  ,
available  ,
CTLTYPE_STRING|CTLFLAG_RD|  CTLFLAG_MPSAFE,
NULL  ,
,
cc_list_available  ,
"A"  ,
"List available congestion control algorithms"   
)

◆ SYSCTL_UINT() [1/6]

SYSCTL_UINT ( _net_inet_tcp_cc_hystartplusplus  ,
OID_AUTO  ,
bblogs  ,
CTLFLAG_RW  ,
hystart_bblogs,
,
"Do we enable HyStart++ Black Box logs to be generated if BB logging is on"   
)

◆ SYSCTL_UINT() [2/6]

SYSCTL_UINT ( _net_inet_tcp_cc_hystartplusplus  ,
OID_AUTO  ,
css_growth_div  ,
CTLFLAG_RW  ,
hystart_css_growth_div,
,
"The divisor to the growth when in Hystart++ CSS"   
)

◆ SYSCTL_UINT() [3/6]

SYSCTL_UINT ( _net_inet_tcp_cc_hystartplusplus  ,
OID_AUTO  ,
css_rounds  ,
CTLFLAG_RW  ,
hystart_css_rounds,
,
"The number of rounds HyStart++ lasts in CSS before falling to CA"   
)

◆ SYSCTL_UINT() [4/6]

SYSCTL_UINT ( _net_inet_tcp_cc_hystartplusplus  ,
OID_AUTO  ,
maxrtt_thresh  ,
CTLFLAG_RW  ,
hystart_maxrtt_thresh,
16000  ,
"HyStarts++ maximum RTT thresh used in clamp (in microseconds)"   
)

◆ SYSCTL_UINT() [5/6]

SYSCTL_UINT ( _net_inet_tcp_cc_hystartplusplus  ,
OID_AUTO  ,
minrtt_thresh  ,
CTLFLAG_RW  ,
hystart_minrtt_thresh,
4000  ,
"HyStarts++ minimum RTT thresh used in clamp (in microseconds)"   
)

◆ SYSCTL_UINT() [6/6]

SYSCTL_UINT ( _net_inet_tcp_cc_hystartplusplus  ,
OID_AUTO  ,
n_rttsamples  ,
CTLFLAG_RW  ,
hystart_n_rttsamples,
,
"The number of RTT samples that must be seen to consider HyStart++"   
)

◆ SYSINIT()

SYSINIT ( cc  ,
SI_SUB_PROTO_IFATTACHDOMAIN  ,
SI_ORDER_FIRST  ,
cc_init  ,
NULL   
)

◆ vnet_cc_sysinit()

static void vnet_cc_sysinit ( void *  arg)
static

Definition at line 364 of file cc.c.

References V_default_cc_ptr.

◆ VNET_DEFINE() [1/4]

VNET_DEFINE ( int  ,
cc_abe_frlossreduce   
)
pure virtual

◆ VNET_DEFINE() [2/4]

VNET_DEFINE ( int  ,
cc_do_abe   
)
pure virtual

◆ VNET_DEFINE() [3/4]

VNET_DEFINE ( struct cc_algo ,
default_cc_ptr   
)

◆ VNET_DEFINE() [4/4]

VNET_DEFINE ( uint32_t  ,
newreno_beta   
)

◆ VNET_SYSINIT()

VNET_SYSINIT ( vnet_cc_sysinit  ,
SI_SUB_PROTO_IFATTACHDOMAIN  ,
SI_ORDER_ANY  ,
vnet_cc_sysinit  ,
NULL   
)

Variable Documentation

◆ cc_list

struct cc_head cc_list = STAILQ_HEAD_INITIALIZER(cc_list)

◆ cc_list_lock

struct rwlock cc_list_lock

Definition at line 103 of file cc.c.

◆ hystart_bblogs

uint32_t hystart_bblogs = 0

Definition at line 92 of file cc.c.

Referenced by cubic_log_hystart_event(), and newreno_log_hystart_event().

◆ hystart_css_growth_div

uint32_t hystart_css_growth_div = 4

Definition at line 90 of file cc.c.

Referenced by cubic_does_slow_start(), and newreno_ack_received().

◆ hystart_css_rounds

uint32_t hystart_css_rounds = 5

Definition at line 91 of file cc.c.

Referenced by cubic_newround(), and newreno_newround().

◆ hystart_maxrtt_thresh

uint32_t hystart_maxrtt_thresh = 16000

Definition at line 88 of file cc.c.

Referenced by cubic_does_slow_start(), and newreno_ack_received().

◆ hystart_minrtt_thresh

uint32_t hystart_minrtt_thresh = 4000

Definition at line 87 of file cc.c.

Referenced by cubic_does_slow_start(), and newreno_ack_received().

◆ hystart_n_rttsamples

uint32_t hystart_n_rttsamples = 8