linux/net/ipv4/tcp_cubic.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * TCP CUBIC: Binary Increase Congestion control for TCP v2.3
 * Home page:
 *      http://netsrv.csc.ncsu.edu/twiki/bin/view/Main/BIC
 * This is from the implementation of CUBIC TCP in
 * Sangtae Ha, Injong Rhee and Lisong Xu,
 *  "CUBIC: A New TCP-Friendly High-Speed TCP Variant"
 *  in ACM SIGOPS Operating System Review, July 2008.
 * Available from:
 *  http://netsrv.csc.ncsu.edu/export/cubic_a_new_tcp_2008.pdf
 *
 * CUBIC integrates a new slow start algorithm, called HyStart.
 * The details of HyStart are presented in
 *  Sangtae Ha and Injong Rhee,
 *  "Taming the Elephants: New TCP Slow Start", NCSU TechReport 2008.
 * Available from:
 *  http://netsrv.csc.ncsu.edu/export/hystart_techreport_2008.pdf
 *
 * All testing results are available from:
 * http://netsrv.csc.ncsu.edu/wiki/index.php/TCP_Testing
 *
 * Unless CUBIC is enabled and congestion window is large
 * this behaves the same as the original Reno.
 */

#include <linux/mm.h>
#include <linux/btf.h>
#include <linux/btf_ids.h>
#include <linux/module.h>
#include <linux/math64.h>
#include <net/tcp.h>

#define BICTCP_BETA_SCALE
#define BICTCP_HZ

/* Two methods of hybrid slow start */
#define HYSTART_ACK_TRAIN
#define HYSTART_DELAY

/* Number of delay samples for detecting the increase of delay */
#define HYSTART_MIN_SAMPLES
#define HYSTART_DELAY_MIN
#define HYSTART_DELAY_MAX
#define HYSTART_DELAY_THRESH(x)

static int fast_convergence __read_mostly =;
static int beta __read_mostly =;	/* = 717/1024 (BICTCP_BETA_SCALE) */
static int initial_ssthresh __read_mostly;
static int bic_scale __read_mostly =;
static int tcp_friendliness __read_mostly =;

static int hystart __read_mostly =;
static int hystart_detect __read_mostly =;
static int hystart_low_window __read_mostly =;
static int hystart_ack_delta_us __read_mostly =;

static u32 cube_rtt_scale __read_mostly;
static u32 beta_scale __read_mostly;
static u64 cube_factor __read_mostly;

/* Note parameters that are used for precomputing scale factors are read-only */
module_param(fast_convergence, int, 0644);
MODULE_PARM_DESC();
module_param(beta, int, 0644);
MODULE_PARM_DESC();
module_param(initial_ssthresh, int, 0644);
MODULE_PARM_DESC();
module_param(bic_scale, int, 0444);
MODULE_PARM_DESC();
module_param(tcp_friendliness, int, 0644);
MODULE_PARM_DESC();
module_param(hystart, int, 0644);
MODULE_PARM_DESC();
module_param(hystart_detect, int, 0644);
MODULE_PARM_DESC();
module_param(hystart_low_window, int, 0644);
MODULE_PARM_DESC();
module_param(hystart_ack_delta_us, int, 0644);
MODULE_PARM_DESC();

/* BIC TCP Parameters */
struct bictcp {};

static inline void bictcp_reset(struct bictcp *ca)
{}

static inline u32 bictcp_clock_us(const struct sock *sk)
{}

static inline void bictcp_hystart_reset(struct sock *sk)
{}

__bpf_kfunc static void cubictcp_init(struct sock *sk)
{}

__bpf_kfunc static void cubictcp_cwnd_event(struct sock *sk, enum tcp_ca_event event)
{}

/* calculate the cubic root of x using a table lookup followed by one
 * Newton-Raphson iteration.
 * Avg err ~= 0.195%
 */
static u32 cubic_root(u64 a)
{}

/*
 * Compute congestion window to use.
 */
static inline void bictcp_update(struct bictcp *ca, u32 cwnd, u32 acked)
{}

__bpf_kfunc static void cubictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
{}

__bpf_kfunc static u32 cubictcp_recalc_ssthresh(struct sock *sk)
{}

__bpf_kfunc static void cubictcp_state(struct sock *sk, u8 new_state)
{}

/* Account for TSO/GRO delays.
 * Otherwise short RTT flows could get too small ssthresh, since during
 * slow start we begin with small TSO packets and ca->delay_min would
 * not account for long aggregation delay when TSO packets get bigger.
 * Ideally even with a very small RTT we would like to have at least one
 * TSO packet being sent and received by GRO, and another one in qdisc layer.
 * We apply another 100% factor because @rate is doubled at this point.
 * We cap the cushion to 1ms.
 */
static u32 hystart_ack_delay(const struct sock *sk)
{}

static void hystart_update(struct sock *sk, u32 delay)
{}

__bpf_kfunc static void cubictcp_acked(struct sock *sk, const struct ack_sample *sample)
{}

static struct tcp_congestion_ops cubictcp __read_mostly =;

BTF_KFUNCS_START(tcp_cubic_check_kfunc_ids)
BTF_ID_FLAGS()
BTF_ID_FLAGS()
BTF_ID_FLAGS()
BTF_ID_FLAGS()
BTF_ID_FLAGS()
BTF_ID_FLAGS()
BTF_KFUNCS_END()

static const struct btf_kfunc_id_set tcp_cubic_kfunc_set =;

static int __init cubictcp_register(void)
{}

static void __exit cubictcp_unregister(void)
{}

module_init();
module_exit(cubictcp_unregister);

MODULE_AUTHOR();
MODULE_LICENSE();
MODULE_DESCRIPTION();
MODULE_VERSION();