haproxy/include/haproxy/quic_tx-t.h
Frederic Lecaille f8b697c19b BUG/MINOR: improve BBR throughput on very fast links
This patch fixes the loss of information when computing the delivery rate
(quic_cc_drs.c) on links with very low latency due to usage of 32bits
variables with the millisecond as precision.

Initialize the quic_conn task with TASK_F_WANTS_TIME flag ask it to ask
the scheduler to update the call date of this task. This allows this task to get
a nanosecond resolution on the call date calling task_mono_time(). This is enabled
only for congestion control algorithms with delivery rate estimation support
(BBR only at this time).

Store the send date with nanosecond precision of each TX packet into
->time_sent_ns new quic_tx_packet struct member to store the date a packet was
sent in nanoseconds thanks to task_mono_time().

Make use of this new timestamp by the delivery rate estimation algorithm (quic_cc_drs.c).

Rename current ->time_sent member from quic_tx_packet struct to ->time_sent_ms to
distinguish the unit used by this variable (millisecond) and update the code which
uses this variable. The logic found in quic_loss.c is not modified at all.

Must be backported to 3.1.
2024-11-28 21:39:05 +01:00

96 lines
3.2 KiB
C

#ifndef _HAPROXY_TX_T_H
#define _HAPROXY_TX_T_H
#define QUIC_MIN_CC_PKTSIZE 128
#define QUIC_DGRAM_HEADLEN (sizeof(uint16_t) + sizeof(void *))
#define QUIC_MAX_CC_BUFSIZE (2 * (QUIC_MIN_CC_PKTSIZE + QUIC_DGRAM_HEADLEN))
/* Sendmsg input buffer cannot be bigger than 65535 bytes. This comes from UDP
* header which uses a 2-bytes length field. QUIC datagrams are limited to 1252
* bytes for now so this does not cause any issue for serialized emission.
*
* However when using GSO large buffer can be transferred. By default, no more
* than 64 datagrams can be emitted via a single GSO call (man 7 udp). This is
* still too much with 1252 bytes datagram. Use a 52 datagrams max value, which
* ensures sendmsg input will be limited to 65104 bytes.
*/
#define QUIC_MAX_GSO_DGRAMS 52
#include <import/eb64tree.h>
#include <haproxy/list-t.h>
extern struct pool_head *pool_head_quic_tx_packet;
extern struct pool_head *pool_head_quic_cc_buf;
/* Flag a sent packet as being an ack-eliciting packet. */
#define QUIC_FL_TX_PACKET_ACK_ELICITING (1UL << 0)
/* Flag a sent packet as containing a PADDING frame. */
#define QUIC_FL_TX_PACKET_PADDING (1UL << 1)
/* Flag a sent packet as being in flight. */
#define QUIC_FL_TX_PACKET_IN_FLIGHT (QUIC_FL_TX_PACKET_ACK_ELICITING | QUIC_FL_TX_PACKET_PADDING)
/* Flag a sent packet as containing a CONNECTION_CLOSE frame */
#define QUIC_FL_TX_PACKET_CC (1UL << 2)
/* Flag a sent packet as containing an ACK frame */
#define QUIC_FL_TX_PACKET_ACK (1UL << 3)
/* Flag a sent packet as being coalesced to another one in the same datagram */
#define QUIC_FL_TX_PACKET_COALESCED (1UL << 4)
/* Flag a sent packet as being probing with old data */
#define QUIC_FL_TX_PACKET_PROBE_WITH_OLD_DATA (1UL << 5)
/* Structure to store enough information about TX QUIC packets. */
struct quic_tx_packet {
/* List entry point. */
struct list list;
/* Packet length */
size_t len;
/* This is not the packet length but the length of outstanding data
* for in flight TX packet.
*/
size_t in_flight_len;
struct eb64_node pn_node;
/* The list of frames of this packet. */
struct list frms;
/* The time this packet was sent (ms). */
unsigned int time_sent_ms;
uint64_t time_sent_ns;
/* Packet number spakce. */
struct quic_pktns *pktns;
/* Flags. */
unsigned int flags;
/* Reference counter */
int refcnt;
/* Next packet in the same datagram */
struct quic_tx_packet *next;
/* Previous packet in the same datagram */
struct quic_tx_packet *prev;
/* Largest acknowledged packet number if this packet contains an ACK frame */
int64_t largest_acked_pn;
/* Delivery rate sampling information */
struct {
uint64_t delivered;
uint64_t tx_in_flight;
uint64_t lost;
int64_t end_seq;
uint64_t delivered_time_ns;
uint64_t first_sent_time_ns;
int is_app_limited;
} rs;
unsigned char type;
};
/* Return value for qc_build_pkt(). */
enum qc_build_pkt_err {
QC_BUILD_PKT_ERR_NONE = 0,
QC_BUILD_PKT_ERR_ALLOC, /* memory allocation failure */
QC_BUILD_PKT_ERR_ENCRYPT, /* error during encryption operation */
QC_BUILD_PKT_ERR_BUFROOM, /* no more room in input buf or congestion window */
};
enum quic_tx_err {
QUIC_TX_ERR_NONE,
QUIC_TX_ERR_FATAL,
QUIC_TX_ERR_PACING,
};
#endif /* _HAPROXY_TX_T_H */