blob: f7168776f73be984dac89d7427034da86a5e0121 [file] [log] [blame]
Frédéric Lécaillea7e7ce92020-11-23 14:14:04 +01001/*
2 * Congestion controller handling.
3 *
4 * This file contains definitions for QUIC congestion control.
5 *
6 * Copyright 2019 HAProxy Technologies, Frédéric Lécaille <flecaille@haproxy.com>
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation, version 2.1
11 * exclusively.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#include <haproxy/buf.h>
24#include <haproxy/quic_cc-t.h>
25#include <haproxy/xprt_quic-t.h>
26
27
28struct quic_cc_algo *default_quic_cc_algo = &quic_cc_algo_nr;
29
30/*
31 * Initialize <cc> congestion control with <algo> as algorithm depending on <ipv4>
32 * a boolean which is true for an IPv4 path.
33 */
34void quic_cc_init(struct quic_cc *cc,
35 struct quic_cc_algo *algo, struct quic_conn *qc)
36{
37 cc->qc = qc;
38 cc->algo = algo;
39 if (cc->algo->init)
40 (cc->algo->init(cc));
41}
42
43/* Send <ev> event to <cc> congestion controller. */
44void quic_cc_event(struct quic_cc *cc, struct quic_cc_event *ev)
45{
46 cc->algo->event(cc, ev);
47}
48
49void quic_cc_state_trace(struct buffer *buf, const struct quic_cc *cc)
50{
51 cc->algo->state_trace(buf, cc);
52}