]> git.ipfire.org Git - thirdparty/openssl.git/blame - include/internal/quic_txpim.h
QUIC CFQ Fixes
[thirdparty/openssl.git] / include / internal / quic_txpim.h
CommitLineData
d77aea59
HL
1/*
2 * Copyright 2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10#ifndef OSSL_QUIC_TXPIM_H
11# define OSSL_QUIC_TXPIM_H
12
13# include <openssl/ssl.h>
14# include "internal/quic_types.h"
15# include "internal/quic_cfq.h"
16# include "internal/quic_ackm.h"
17
18/*
19 * QUIC Transmitted Packet Information Manager
20 * ===========================================
21 */
22typedef struct quic_txpim_st QUIC_TXPIM;
23typedef struct quic_fifd_st QUIC_FIFD;
24
25typedef struct quic_txpim_pkt_st {
26 /* ACKM-specific data. Caller should fill this. */
27 OSSL_ACKM_TX_PKT ackm_pkt;
28
29 /* Linked list of CFQ items in this packet. */
30 QUIC_CFQ_ITEM *retx_head;
31
32 /* Reserved for FIFD use. */
33 QUIC_FIFD *fifd;
34
35 /* Regenerate-strategy frames. */
36 unsigned int had_handshake_done_frame : 1;
37 unsigned int had_max_data_frame : 1;
0ede517c
HL
38 unsigned int had_max_streams_bidi_frame : 1;
39 unsigned int had_max_streams_uni_frame : 1;
d77aea59
HL
40 unsigned int had_ack_frame : 1;
41
42 /* Private data follows. */
43} QUIC_TXPIM_PKT;
44
45/* Represents a range of bytes in an application or CRYPTO stream. */
46typedef struct quic_txpim_chunk_st {
47 /* The stream ID, or UINT64_MAX for the CRYPTO stream. */
48 uint64_t stream_id;
49 /*
50 * The inclusive range of bytes in the stream. Exceptionally, if end <
51 * start, designates a frame of zero length (used for FIN-only frames).
52 */
53 uint64_t start, end;
54 /*
55 * Whether a FIN was sent for this stream in the packet. Not valid for
56 * CRYPTO stream.
57 */
58 unsigned int has_fin : 1;
59} QUIC_TXPIM_CHUNK;
60
61QUIC_TXPIM *ossl_quic_txpim_new(void);
62
63/*
64 * Frees the TXPIM. All QUIC_TXPIM_PKTs which have been handed out by the TXPIM
65 * must be released via a call to ossl_quic_txpim_pkt_release() before calling
66 * this function.
67 */
68void ossl_quic_txpim_free(QUIC_TXPIM *txpim);
69
70/*
71 * Allocates a new QUIC_TXPIM_PKT structure from the pool. Returns NULL on
72 * failure. The returned structure is cleared of all data and is in a fresh
73 * initial state.
74 */
75QUIC_TXPIM_PKT *ossl_quic_txpim_pkt_alloc(QUIC_TXPIM *txpim);
76
77/*
78 * Releases the TXPIM packet, returning it to the pool.
79 */
80void ossl_quic_txpim_pkt_release(QUIC_TXPIM *txpim, QUIC_TXPIM_PKT *fpkt);
81
82/* Clears the chunk list of the packet, removing all entries. */
83void ossl_quic_txpim_pkt_clear_chunks(QUIC_TXPIM_PKT *fpkt);
84
85/* Appends a chunk to the packet. The structure is copied. */
86int ossl_quic_txpim_pkt_append_chunk(QUIC_TXPIM_PKT *fpkt,
87 const QUIC_TXPIM_CHUNK *chunk);
88
89/* Adds a CFQ item to the packet by prepending it to the retx_head list. */
90void ossl_quic_txpim_pkt_add_cfq_item(QUIC_TXPIM_PKT *fpkt,
91 QUIC_CFQ_ITEM *item);
92
93/*
94 * Returns a pointer to an array of stream chunk information structures for the
95 * given packet. The caller must call ossl_quic_txpim_pkt_get_num_chunks() to
96 * determine the length of this array. The returned pointer is invalidated
97 * if the chunk list is mutated, for example via a call to
98 * ossl_quic_txpim_pkt_append_chunk() or ossl_quic_txpim_pkt_clear_chunks().
99 *
100 * The chunks are sorted by (stream_id, start) in ascending order.
101 */
6db5cb84 102const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(const QUIC_TXPIM_PKT *fpkt);
d77aea59
HL
103
104/*
105 * Returns the number of entries in the array returned by
106 * ossl_quic_txpim_pkt_get_chunks().
107 */
6db5cb84 108size_t ossl_quic_txpim_pkt_get_num_chunks(const QUIC_TXPIM_PKT *fpkt);
d77aea59 109
0ede517c
HL
110/*
111 * Returns the number of QUIC_TXPIM_PKTs allocated by the given TXPIM that have
112 * yet to be returned to the TXPIM.
113 */
6db5cb84 114size_t ossl_quic_txpim_get_in_use(const QUIC_TXPIM *txpim);
0ede517c 115
d77aea59 116#endif