189e560f4SRandall Stewart #ifndef __pacer_timer_h__ 289e560f4SRandall Stewart #define __pacer_timer_h__ 389e560f4SRandall Stewart /*- 452467047SWarner Losh * Copyright (c) 2017 Netflix, Inc. 589e560f4SRandall Stewart * 689e560f4SRandall Stewart * Redistribution and use in source and binary forms, with or without 789e560f4SRandall Stewart * modification, are permitted provided that the following conditions 889e560f4SRandall Stewart * are met: 989e560f4SRandall Stewart * 1. Redistributions of source code must retain the above copyright 1089e560f4SRandall Stewart * notice, this list of conditions and the following disclaimer. 1189e560f4SRandall Stewart * 2. Redistributions in binary form must reproduce the above copyright 1289e560f4SRandall Stewart * notice, this list of conditions and the following disclaimer in the 1389e560f4SRandall Stewart * documentation and/or other materials provided with the distribution. 1489e560f4SRandall Stewart * 1589e560f4SRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 1689e560f4SRandall Stewart * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1789e560f4SRandall Stewart * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1889e560f4SRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 1989e560f4SRandall Stewart * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2089e560f4SRandall Stewart * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2189e560f4SRandall Stewart * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2289e560f4SRandall Stewart * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2389e560f4SRandall Stewart * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2489e560f4SRandall Stewart * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2589e560f4SRandall Stewart * SUCH DAMAGE. 2689e560f4SRandall Stewart * 2789e560f4SRandall Stewart * __FBSDID("$FreeBSD$"); 2889e560f4SRandall Stewart */ 2989e560f4SRandall Stewart /* Common defines and such used by both RACK and BBR */ 3089e560f4SRandall Stewart /* Special values for mss accounting array */ 3189e560f4SRandall Stewart #define TCP_MSS_ACCT_JUSTRET 0 3289e560f4SRandall Stewart #define TCP_MSS_ACCT_SNDACK 1 3389e560f4SRandall Stewart #define TCP_MSS_ACCT_PERSIST 2 3489e560f4SRandall Stewart #define TCP_MSS_ACCT_ATIMER 60 3589e560f4SRandall Stewart #define TCP_MSS_ACCT_INPACE 61 3689e560f4SRandall Stewart #define TCP_MSS_ACCT_LATE 62 3789e560f4SRandall Stewart #define TCP_MSS_SMALL_SIZE_OFF 63 /* Point where small sizes enter */ 3889e560f4SRandall Stewart #define TCP_MSS_ACCT_SIZE 70 3989e560f4SRandall Stewart #define TCP_MSS_SMALL_MAX_SIZE_DIV (TCP_MSS_ACCT_SIZE - TCP_MSS_SMALL_SIZE_OFF) 4089e560f4SRandall Stewart 41*3b0b41e6SRandall Stewart #define DUP_ACK_THRESHOLD 3 4289e560f4SRandall Stewart 4389e560f4SRandall Stewart /* Magic flags for tracing progress events */ 4489e560f4SRandall Stewart #define PROGRESS_DROP 1 4589e560f4SRandall Stewart #define PROGRESS_UPDATE 2 4689e560f4SRandall Stewart #define PROGRESS_CLEAR 3 4789e560f4SRandall Stewart #define PROGRESS_START 4 4889e560f4SRandall Stewart 4989e560f4SRandall Stewart 5089e560f4SRandall Stewart /* RTT sample methods */ 5189e560f4SRandall Stewart #define USE_RTT_HIGH 0 5289e560f4SRandall Stewart #define USE_RTT_LOW 1 5389e560f4SRandall Stewart #define USE_RTT_AVG 2 5489e560f4SRandall Stewart 55*3b0b41e6SRandall Stewart #define PACE_MAX_IP_BYTES 65536 56*3b0b41e6SRandall Stewart #define USECS_IN_SECOND 1000000 57*3b0b41e6SRandall Stewart #define MSEC_IN_SECOND 1000 58*3b0b41e6SRandall Stewart #define MS_IN_USEC 1000 59*3b0b41e6SRandall Stewart #define USEC_TO_MSEC(x) (x / MS_IN_USEC) 60*3b0b41e6SRandall Stewart #define TCP_TS_OVERHEAD 12 /* Overhead of having Timestamps on */ 61*3b0b41e6SRandall Stewart 6289e560f4SRandall Stewart #ifdef _KERNEL 6389e560f4SRandall Stewart /* We have only 7 bits in rack so assert its true */ 6489e560f4SRandall Stewart CTASSERT((PACE_TMR_MASK & 0x80) == 0); 65*3b0b41e6SRandall Stewart #ifdef KERN_TLS 66*3b0b41e6SRandall Stewart uint32_t ctf_get_opt_tls_size(struct socket *so, uint32_t rwnd); 67*3b0b41e6SRandall Stewart #endif 68*3b0b41e6SRandall Stewart int 69*3b0b41e6SRandall Stewart ctf_process_inbound_raw(struct tcpcb *tp, struct socket *so, 70*3b0b41e6SRandall Stewart struct mbuf *m, int has_pkt); 71*3b0b41e6SRandall Stewart int 72*3b0b41e6SRandall Stewart ctf_do_queued_segments(struct socket *so, struct tcpcb *tp, int have_pkt); 73*3b0b41e6SRandall Stewart uint32_t ctf_outstanding(struct tcpcb *tp); 74*3b0b41e6SRandall Stewart uint32_t ctf_flight_size(struct tcpcb *tp, uint32_t rc_sacked); 75*3b0b41e6SRandall Stewart int 76*3b0b41e6SRandall Stewart ctf_drop_checks(struct tcpopt *to, struct mbuf *m, 77*3b0b41e6SRandall Stewart struct tcphdr *th, struct tcpcb *tp, int32_t * tlenp, int32_t * thf, 78*3b0b41e6SRandall Stewart int32_t * drop_hdrlen, int32_t * ret_val); 79*3b0b41e6SRandall Stewart void 80*3b0b41e6SRandall Stewart ctf_do_dropafterack(struct mbuf *m, struct tcpcb *tp, 81*3b0b41e6SRandall Stewart struct tcphdr *th, int32_t thflags, int32_t tlen, int32_t * ret_val); 82*3b0b41e6SRandall Stewart void 83*3b0b41e6SRandall Stewart ctf_do_dropwithreset(struct mbuf *m, struct tcpcb *tp, 84*3b0b41e6SRandall Stewart struct tcphdr *th, int32_t rstreason, int32_t tlen); 85*3b0b41e6SRandall Stewart void 86*3b0b41e6SRandall Stewart ctf_do_drop(struct mbuf *m, struct tcpcb *tp); 87*3b0b41e6SRandall Stewart 88*3b0b41e6SRandall Stewart int 89*3b0b41e6SRandall Stewart ctf_process_rst(struct mbuf *m, struct tcphdr *th, 90*3b0b41e6SRandall Stewart struct socket *so, struct tcpcb *tp); 91*3b0b41e6SRandall Stewart 92*3b0b41e6SRandall Stewart void 93*3b0b41e6SRandall Stewart ctf_challenge_ack(struct mbuf *m, struct tcphdr *th, 94*3b0b41e6SRandall Stewart struct tcpcb *tp, int32_t * ret_val); 95*3b0b41e6SRandall Stewart 96*3b0b41e6SRandall Stewart int 97*3b0b41e6SRandall Stewart ctf_ts_check(struct mbuf *m, struct tcphdr *th, 98*3b0b41e6SRandall Stewart struct tcpcb *tp, int32_t tlen, int32_t thflags, int32_t * ret_val); 99*3b0b41e6SRandall Stewart 100*3b0b41e6SRandall Stewart void 101*3b0b41e6SRandall Stewart ctf_calc_rwin(struct socket *so, struct tcpcb *tp); 102*3b0b41e6SRandall Stewart 103*3b0b41e6SRandall Stewart void 104*3b0b41e6SRandall Stewart ctf_do_dropwithreset_conn(struct mbuf *m, struct tcpcb *tp, struct tcphdr *th, 105*3b0b41e6SRandall Stewart int32_t rstreason, int32_t tlen); 106*3b0b41e6SRandall Stewart 107*3b0b41e6SRandall Stewart uint32_t 108*3b0b41e6SRandall Stewart ctf_fixed_maxseg(struct tcpcb *tp); 109*3b0b41e6SRandall Stewart 110*3b0b41e6SRandall Stewart void 111*3b0b41e6SRandall Stewart ctf_log_sack_filter(struct tcpcb *tp, int num_sack_blks, struct sackblk *sack_blocks); 112*3b0b41e6SRandall Stewart 113*3b0b41e6SRandall Stewart uint32_t 114*3b0b41e6SRandall Stewart ctf_decay_count(uint32_t count, uint32_t decay_percentage); 115*3b0b41e6SRandall Stewart 11689e560f4SRandall Stewart #endif 11789e560f4SRandall Stewart #endif 118