summaryrefslogtreecommitdiffstats
path: root/src/quic_cc_nocc.c
blob: 6e5cff96b960022a405cfa48330a14123b81aef0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
 * Fake congestion control algorithm which does nothing except initializing
 * the congestion control window to a fixed value.
 *
 */

#include <haproxy/api-t.h>
#include <haproxy/quic_conn-t.h>
#include <haproxy/quic_trace.h>
#include <haproxy/trace.h>

static int quic_cc_nocc_init(struct quic_cc *cc)
{
	struct quic_cc_path *path;

	path = container_of(cc, struct quic_cc_path, cc);
	path->cwnd = path->max_cwnd;
	return 1;
}

static void quic_cc_nocc_slow_start(struct quic_cc *cc)
{
}

/* Slow start callback. */
static void quic_cc_nocc_ss_cb(struct quic_cc *cc, struct quic_cc_event *ev)
{
	TRACE_ENTER(QUIC_EV_CONN_CC, cc->qc);
	TRACE_PROTO("CC nocc", QUIC_EV_CONN_CC, cc->qc, ev, cc);
	TRACE_LEAVE(QUIC_EV_CONN_CC, cc->qc);
}

/* Congestion avoidance callback. */
static void quic_cc_nocc_ca_cb(struct quic_cc *cc, struct quic_cc_event *ev)
{
	TRACE_ENTER(QUIC_EV_CONN_CC, cc->qc);
	TRACE_PROTO("CC nocc", QUIC_EV_CONN_CC, cc->qc, ev, cc);
	TRACE_LEAVE(QUIC_EV_CONN_CC, cc->qc);
}

/*  Recovery period callback. */
static void quic_cc_nocc_rp_cb(struct quic_cc *cc, struct quic_cc_event *ev)
{
	TRACE_ENTER(QUIC_EV_CONN_CC, cc->qc);
	TRACE_PROTO("CC nocc", QUIC_EV_CONN_CC, cc->qc, ev, cc);
	TRACE_LEAVE(QUIC_EV_CONN_CC, cc->qc);
}

static void quic_cc_nocc_state_trace(struct buffer *buf, const struct quic_cc *cc)
{
	struct quic_cc_path *path;

	path = container_of(cc, struct quic_cc_path, cc);
	chunk_appendf(buf, " cwnd=%llu", (unsigned long long)path->cwnd);
}

static void (*quic_cc_nocc_state_cbs[])(struct quic_cc *cc,
                                      struct quic_cc_event *ev) = {
	[QUIC_CC_ST_SS] = quic_cc_nocc_ss_cb,
	[QUIC_CC_ST_CA] = quic_cc_nocc_ca_cb,
	[QUIC_CC_ST_RP] = quic_cc_nocc_rp_cb,
};

static void quic_cc_nocc_event(struct quic_cc *cc, struct quic_cc_event *ev)
{
	return quic_cc_nocc_state_cbs[QUIC_CC_ST_SS](cc, ev);
}

struct quic_cc_algo quic_cc_algo_nocc = {
	.type        = QUIC_CC_ALGO_TP_NOCC,
	.init        = quic_cc_nocc_init,
	.event       = quic_cc_nocc_event,
	.slow_start  = quic_cc_nocc_slow_start,
	.state_trace = quic_cc_nocc_state_trace,
};