blob: 16555e008212ac9da6395a12da1c017bcdd2db06 [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 *
Willy Tarreau3dfb7da2022-03-02 22:33:39 +01006 * Copyright 2019 HAProxy Technologies, Frederic Lecaille <flecaille@haproxy.com>
Frédéric Lécaillea7e7ce92020-11-23 14:14:04 +01007 *
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
Frédéric Lécaille1c9c2f62022-06-01 15:06:58 +020028struct quic_cc_algo *default_quic_cc_algo = &quic_cc_algo_cubic;
Frédéric Lécaillea7e7ce92020-11-23 14:14:04 +010029
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}