FreeBSD kernel IPv4 code
cc_cdg.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/hhook.h>
#include <sys/kernel.h>
#include <sys/khelp.h>
#include <sys/limits.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/queue.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <net/vnet.h>
#include <net/route.h>
#include <net/route/nhop.h>
#include <netinet/in_pcb.h>
#include <netinet/tcp.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/cc/cc.h>
#include <netinet/cc/cc_module.h>
#include <netinet/khelp/h_ertt.h>
#include <vm/uma.h>
Include dependency graph for cc_cdg.c:

Go to the source code of this file.

Data Structures

struct  qdiff_sample
 
struct  cdg
 

Macros

#define CDG_VERSION   "0.1"
 
#define CC_CDG_DELAY   0x01000000
 
#define RENO_BETA   50
 
#define CDG_Q_EMPTY   1
 
#define CDG_Q_RISING   2
 
#define CDG_Q_FALLING   3
 
#define CDG_Q_FULL   4
 
#define CDG_Q_UNKNOWN   9999
 
#define EXP_PREC   15
 
#define MAXGRAD   5
 
#define D_P_E   7
 
#define V_cdg_alpha_inc   VNET(cdg_alpha_inc)
 
#define V_cdg_beta_delay   VNET(cdg_beta_delay)
 
#define V_cdg_beta_loss   VNET(cdg_beta_loss)
 
#define V_cdg_smoothing_factor   VNET(cdg_smoothing_factor)
 
#define V_cdg_exp_backoff_scale   VNET(cdg_exp_backoff_scale)
 
#define V_cdg_consec_cong   VNET(cdg_consec_cong)
 
#define V_cdg_hold_backoff   VNET(cdg_hold_backoff)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 VNET_DEFINE_STATIC (uint32_t, cdg_alpha_inc)
 
 VNET_DEFINE_STATIC (uint32_t, cdg_beta_delay)
 
 VNET_DEFINE_STATIC (uint32_t, cdg_beta_loss)
 
 VNET_DEFINE_STATIC (uint32_t, cdg_smoothing_factor)
 
 VNET_DEFINE_STATIC (uint32_t, cdg_exp_backoff_scale)
 
 VNET_DEFINE_STATIC (uint32_t, cdg_consec_cong)
 
 VNET_DEFINE_STATIC (uint32_t, cdg_hold_backoff)
 
static int cdg_mod_init (void)
 
static int cdg_mod_destroy (void)
 
static void cdg_conn_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_cong_signal (struct cc_var *ccv, uint32_t signal_type)
 
static void cdg_ack_received (struct cc_var *ccv, uint16_t ack_type)
 
static size_t cdg_data_sz (void)
 
static void cdg_init_vnet (const void *unused __unused)
 
static int cdg_beta_handler (SYSCTL_HANDLER_ARGS)
 
static int cdg_exp_backoff_scale_handler (SYSCTL_HANDLER_ARGS)
 
static uint32_t cdg_window_decrease (struct cc_var *ccv, unsigned long owin, unsigned int beta)
 
static void cdg_window_increase (struct cc_var *ccv, int new_measurement)
 
static int prob_backoff (long qtrend)
 
static void calc_moving_average (struct cdg *cdg_data, long qdiff_max, long qdiff_min)
 
 VNET_SYSINIT (cdg_init_vnet, SI_SUB_PROTO_BEGIN, SI_ORDER_FIRST, cdg_init_vnet, NULL)
 
 SYSCTL_DECL (_net_inet_tcp_cc_cdg)
 
 SYSCTL_NODE (_net_inet_tcp_cc, OID_AUTO, cdg, CTLFLAG_RW|CTLFLAG_MPSAFE, NULL, "CAIA delay-gradient congestion control related settings")
 
 SYSCTL_STRING (_net_inet_tcp_cc_cdg, OID_AUTO, version, CTLFLAG_RD, CDG_VERSION, sizeof(CDG_VERSION) - 1, "Current algorithm/implementation version number")
 
 SYSCTL_UINT (_net_inet_tcp_cc_cdg, OID_AUTO, alpha_inc, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(cdg_alpha_inc), 0, "Increment the window increase factor alpha by 1 MSS segment every " "alpha_inc RTTs during congestion avoidance mode.")
 
 SYSCTL_PROC (_net_inet_tcp_cc_cdg, OID_AUTO, beta_delay, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW|CTLFLAG_NEEDGIANT, &VNET_NAME(cdg_beta_delay), 70, &cdg_beta_handler, "IU", "Delay-based window decrease factor as a percentage " "(on delay-based backoff, w = w * beta_delay / 100)")
 
 SYSCTL_PROC (_net_inet_tcp_cc_cdg, OID_AUTO, beta_loss, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW|CTLFLAG_NEEDGIANT, &VNET_NAME(cdg_beta_loss), 50, &cdg_beta_handler, "IU", "Loss-based window decrease factor as a percentage " "(on loss-based backoff, w = w * beta_loss / 100)")
 
 SYSCTL_PROC (_net_inet_tcp_cc_cdg, OID_AUTO, exp_backoff_scale, CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW|CTLFLAG_NEEDGIANT, &VNET_NAME(cdg_exp_backoff_scale), 2, &cdg_exp_backoff_scale_handler, "IU", "Scaling parameter for the probabilistic exponential backoff")
 
 SYSCTL_UINT (_net_inet_tcp_cc_cdg, OID_AUTO, smoothing_factor, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(cdg_smoothing_factor), 8, "Number of samples used for moving average smoothing (0 = no smoothing)")
 
 SYSCTL_UINT (_net_inet_tcp_cc_cdg, OID_AUTO, loss_compete_consec_cong, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(cdg_consec_cong), 5, "Number of consecutive delay-gradient based congestion episodes which will " "trigger loss based CC compatibility")
 
 SYSCTL_UINT (_net_inet_tcp_cc_cdg, OID_AUTO, loss_compete_hold_backoff, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(cdg_hold_backoff), 5, "Number of consecutive delay-gradient based congestion episodes to hold " "the window backoff for loss based CC compatibility")
 
 DECLARE_CC_MODULE (cdg, &cdg_cc_algo)
 
 MODULE_VERSION (cdg, 2)
 
 MODULE_DEPEND (cdg, ertt, 1, 1, 1)
 

Variables

static const int probexp [641]
 
static uma_zone_t qdiffsample_zone
 
static int ertt_id
 
struct cc_algo cdg_cc_algo
 

Macro Definition Documentation

◆ CC_CDG_DELAY

#define CC_CDG_DELAY   0x01000000

Definition at line 88 of file cc_cdg.c.

◆ CDG_Q_EMPTY

#define CDG_Q_EMPTY   1

Definition at line 94 of file cc_cdg.c.

◆ CDG_Q_FALLING

#define CDG_Q_FALLING   3

Definition at line 96 of file cc_cdg.c.

◆ CDG_Q_FULL

#define CDG_Q_FULL   4

Definition at line 97 of file cc_cdg.c.

◆ CDG_Q_RISING

#define CDG_Q_RISING   2

Definition at line 95 of file cc_cdg.c.

◆ CDG_Q_UNKNOWN

#define CDG_Q_UNKNOWN   9999

Definition at line 98 of file cc_cdg.c.

◆ CDG_VERSION

#define CDG_VERSION   "0.1"

Definition at line 85 of file cc_cdg.c.

◆ D_P_E

#define D_P_E   7

Definition at line 110 of file cc_cdg.c.

◆ EXP_PREC

#define EXP_PREC   15

Definition at line 101 of file cc_cdg.c.

◆ MAXGRAD

#define MAXGRAD   5

Definition at line 104 of file cc_cdg.c.

◆ RENO_BETA

#define RENO_BETA   50

Definition at line 91 of file cc_cdg.c.

◆ V_cdg_alpha_inc

#define V_cdg_alpha_inc   VNET(cdg_alpha_inc)

Definition at line 213 of file cc_cdg.c.

◆ V_cdg_beta_delay

#define V_cdg_beta_delay   VNET(cdg_beta_delay)

Definition at line 214 of file cc_cdg.c.

◆ V_cdg_beta_loss

#define V_cdg_beta_loss   VNET(cdg_beta_loss)

Definition at line 215 of file cc_cdg.c.

◆ V_cdg_consec_cong

#define V_cdg_consec_cong   VNET(cdg_consec_cong)

Definition at line 218 of file cc_cdg.c.

◆ V_cdg_exp_backoff_scale

#define V_cdg_exp_backoff_scale   VNET(cdg_exp_backoff_scale)

Definition at line 217 of file cc_cdg.c.

◆ V_cdg_hold_backoff

#define V_cdg_hold_backoff   VNET(cdg_hold_backoff)

Definition at line 219 of file cc_cdg.c.

◆ V_cdg_smoothing_factor

#define V_cdg_smoothing_factor   VNET(cdg_smoothing_factor)

Definition at line 216 of file cc_cdg.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ calc_moving_average()

static void calc_moving_average ( struct cdg cdg_data,
long  qdiff_max,
long  qdiff_min 
)
inlinestatic

Definition at line 533 of file cc_cdg.c.

References cdg::max_qtrend, cdg::min_qtrend, qdiff_sample::qdiff, and qdiffsample_zone.

Referenced by cdg_ack_received().

Here is the caller graph for this function:

◆ cdg_ack_received()

◆ cdg_beta_handler()

static int cdg_beta_handler ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 367 of file cc_cdg.c.

◆ cdg_cb_destroy()

static void cdg_cb_destroy ( struct cc_var ccv)
static

Definition at line 342 of file cc_cdg.c.

References cc_var::cc_data, and qdiffsample_zone.

◆ cdg_cb_init()

static int cdg_cb_init ( struct cc_var ccv,
void *  ptr 
)
static

◆ cdg_cong_signal()

static void cdg_cong_signal ( struct cc_var ccv,
uint32_t  signal_type 
)
static

Definition at line 456 of file cc_cdg.c.

References CC_CDG_DELAY, cc_var::cc_data, CC_NDUPACK, CCV, CDG_Q_FULL, cdg_window_decrease(), ENTER_CONGRECOVERY, ENTER_RECOVERY, IN_CONGRECOVERY, newreno_cc_cong_signal(), RENO_BETA, V_cdg_beta_delay, and V_cdg_beta_loss.

Referenced by cdg_ack_received().

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

◆ cdg_conn_init()

static void cdg_conn_init ( struct cc_var ccv)
static

Definition at line 330 of file cc_cdg.c.

References cc_var::cc_data, and CCV.

◆ cdg_data_sz()

static size_t cdg_data_sz ( void  )
static

Definition at line 290 of file cc_cdg.c.

◆ cdg_exp_backoff_scale_handler()

static int cdg_exp_backoff_scale_handler ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 385 of file cc_cdg.c.

◆ cdg_init_vnet()

static void cdg_init_vnet ( const void *unused  __unused)
static

Definition at line 247 of file cc_cdg.c.

References V_cdg_alpha_inc, V_cdg_beta_delay, V_cdg_beta_loss, V_cdg_consec_cong, V_cdg_exp_backoff_scale, V_cdg_hold_backoff, and V_cdg_smoothing_factor.

Referenced by cdg_mod_init().

Here is the caller graph for this function:

◆ cdg_mod_destroy()

static int cdg_mod_destroy ( void  )
static

Definition at line 282 of file cc_cdg.c.

References qdiffsample_zone.

◆ cdg_mod_init()

static int cdg_mod_init ( void  )
static

Definition at line 260 of file cc_cdg.c.

References cdg_init_vnet(), ertt_id, and qdiffsample_zone.

Here is the call graph for this function:

◆ cdg_window_decrease()

static uint32_t cdg_window_decrease ( struct cc_var ccv,
unsigned long  owin,
unsigned int  beta 
)
inlinestatic

Definition at line 403 of file cc_cdg.c.

References CCV.

Referenced by cdg_cong_signal().

Here is the caller graph for this function:

◆ cdg_window_increase()

static void cdg_window_increase ( struct cc_var ccv,
int  new_measurement 
)
static

Definition at line 417 of file cc_cdg.c.

References cc_var::cc_data, CCV, and V_cdg_alpha_inc.

Referenced by cdg_ack_received().

Here is the caller graph for this function:

◆ DECLARE_CC_MODULE()

DECLARE_CC_MODULE ( cdg  ,
cdg_cc_algo 
)

◆ MODULE_DEPEND()

MODULE_DEPEND ( cdg  ,
ertt  ,
,
,
 
)

◆ MODULE_VERSION()

MODULE_VERSION ( cdg  ,
 
)

◆ prob_backoff()

static int prob_backoff ( long  qtrend)
inlinestatic

Definition at line 511 of file cc_cdg.c.

References D_P_E, EXP_PREC, MAXGRAD, probexp, and V_cdg_exp_backoff_scale.

Referenced by cdg_ack_received().

Here is the caller graph for this function:

◆ SYSCTL_DECL()

SYSCTL_DECL ( _net_inet_tcp_cc_cdg  )

◆ SYSCTL_NODE()

SYSCTL_NODE ( _net_inet_tcp_cc  ,
OID_AUTO  ,
cdg  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
NULL  ,
"CAIA delay-gradient congestion control related settings"   
)

◆ SYSCTL_PROC() [1/3]

SYSCTL_PROC ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
beta_delay  ,
CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW|  CTLFLAG_NEEDGIANT,
VNET_NAMEcdg_beta_delay,
70  ,
cdg_beta_handler,
"IU"  ,
"Delay-based window decrease factor as a percentage " "(on delay-based backoff, w = w * beta_delay / 100)"   
)

◆ SYSCTL_PROC() [2/3]

SYSCTL_PROC ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
beta_loss  ,
CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW|  CTLFLAG_NEEDGIANT,
VNET_NAMEcdg_beta_loss,
50  ,
cdg_beta_handler,
"IU"  ,
"Loss-based window decrease factor as a percentage " "(on loss-based backoff, w = w * beta_loss / 100)"   
)

◆ SYSCTL_PROC() [3/3]

SYSCTL_PROC ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
exp_backoff_scale  ,
CTLFLAG_VNET|CTLTYPE_UINT|CTLFLAG_RW|  CTLFLAG_NEEDGIANT,
VNET_NAMEcdg_exp_backoff_scale,
,
cdg_exp_backoff_scale_handler,
"IU"  ,
"Scaling parameter for the probabilistic exponential backoff"   
)

◆ SYSCTL_STRING()

SYSCTL_STRING ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
version  ,
CTLFLAG_RD  ,
CDG_VERSION  ,
sizeof(CDG_VERSION) -  1,
"Current algorithm/implementation version number"   
)

◆ SYSCTL_UINT() [1/4]

SYSCTL_UINT ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
alpha_inc  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcdg_alpha_inc,
,
"Increment the window increase factor alpha by 1 MSS segment every " "alpha_inc RTTs during congestion avoidance mode."   
)

◆ SYSCTL_UINT() [2/4]

SYSCTL_UINT ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
loss_compete_consec_cong  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcdg_consec_cong,
,
"Number of consecutive delay-gradient based congestion episodes which will " "trigger loss based CC compatibility"   
)

◆ SYSCTL_UINT() [3/4]

SYSCTL_UINT ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
loss_compete_hold_backoff  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcdg_hold_backoff,
,
"Number of consecutive delay-gradient based congestion episodes to hold " "the window backoff for loss based CC compatibility"   
)

◆ SYSCTL_UINT() [4/4]

SYSCTL_UINT ( _net_inet_tcp_cc_cdg  ,
OID_AUTO  ,
smoothing_factor  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEcdg_smoothing_factor,
,
"Number of samples used for moving average smoothing (0 = no smoothing)"   
)

◆ VNET_DEFINE_STATIC() [1/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_alpha_inc   
)

◆ VNET_DEFINE_STATIC() [2/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_beta_delay   
)

◆ VNET_DEFINE_STATIC() [3/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_beta_loss   
)

◆ VNET_DEFINE_STATIC() [4/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_consec_cong   
)

◆ VNET_DEFINE_STATIC() [5/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_exp_backoff_scale   
)

◆ VNET_DEFINE_STATIC() [6/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_hold_backoff   
)

◆ VNET_DEFINE_STATIC() [7/7]

VNET_DEFINE_STATIC ( uint32_t  ,
cdg_smoothing_factor   
)

◆ VNET_SYSINIT()

VNET_SYSINIT ( cdg_init_vnet  ,
SI_SUB_PROTO_BEGIN  ,
SI_ORDER_FIRST  ,
cdg_init_vnet  ,
NULL   
)

Variable Documentation

◆ cdg_cc_algo

struct cc_algo cdg_cc_algo
Initial value:
= {
.name = "cdg",
.mod_init = cdg_mod_init,
.ack_received = cdg_ack_received,
.cb_destroy = cdg_cb_destroy,
.cb_init = cdg_cb_init,
.conn_init = cdg_conn_init,
.cong_signal = cdg_cong_signal,
.mod_destroy = cdg_mod_destroy,
.cc_data_sz = cdg_data_sz,
.post_recovery = newreno_cc_post_recovery,
.after_idle = newreno_cc_after_idle,
}
void newreno_cc_post_recovery(struct cc_var *ccv)
Definition: cc.c:384
void newreno_cc_after_idle(struct cc_var *ccv)
Definition: cc.c:415
static size_t cdg_data_sz(void)
Definition: cc_cdg.c:290
static void cdg_conn_init(struct cc_var *ccv)
Definition: cc_cdg.c:330
static int cdg_mod_destroy(void)
Definition: cc_cdg.c:282
static int cdg_mod_init(void)
Definition: cc_cdg.c:260
static void cdg_ack_received(struct cc_var *ccv, uint16_t ack_type)
Definition: cc_cdg.c:577
static int cdg_cb_init(struct cc_var *ccv, void *ptr)
Definition: cc_cdg.c:296
static void cdg_cb_destroy(struct cc_var *ccv)
Definition: cc_cdg.c:342
static void cdg_cong_signal(struct cc_var *ccv, uint32_t signal_type)
Definition: cc_cdg.c:456

Definition at line 231 of file cc_cdg.c.

◆ ertt_id

int ertt_id
static

Definition at line 204 of file cc_cdg.c.

Referenced by cdg_ack_received(), and cdg_mod_init().

◆ probexp

const int probexp[641]
static

Definition at line 152 of file cc_cdg.c.

Referenced by prob_backoff().

◆ qdiffsample_zone

uma_zone_t qdiffsample_zone
static

Definition at line 203 of file cc_cdg.c.

Referenced by calc_moving_average(), cdg_cb_destroy(), cdg_mod_destroy(), and cdg_mod_init().