189e560f4SRandall Stewart /*-
2963fb2adSRandall Stewart * Copyright (c) 2016-2020 Netflix, Inc.
389e560f4SRandall Stewart *
489e560f4SRandall Stewart * Redistribution and use in source and binary forms, with or without
589e560f4SRandall Stewart * modification, are permitted provided that the following conditions
689e560f4SRandall Stewart * are met:
789e560f4SRandall Stewart * 1. Redistributions of source code must retain the above copyright
889e560f4SRandall Stewart * notice, this list of conditions and the following disclaimer.
989e560f4SRandall Stewart * 2. Redistributions in binary form must reproduce the above copyright
1089e560f4SRandall Stewart * notice, this list of conditions and the following disclaimer in the
1189e560f4SRandall Stewart * documentation and/or other materials provided with the distribution.
1289e560f4SRandall Stewart *
1389e560f4SRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1489e560f4SRandall Stewart * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1589e560f4SRandall Stewart * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1689e560f4SRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1789e560f4SRandall Stewart * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1889e560f4SRandall Stewart * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1989e560f4SRandall Stewart * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2089e560f4SRandall Stewart * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2189e560f4SRandall Stewart * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2289e560f4SRandall Stewart * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2389e560f4SRandall Stewart * SUCH DAMAGE.
2489e560f4SRandall Stewart */
2589e560f4SRandall Stewart
2689e560f4SRandall Stewart #ifndef _NETINET_TCP_RACK_H_
2789e560f4SRandall Stewart #define _NETINET_TCP_RACK_H_
2889e560f4SRandall Stewart
29141a53cdSRandall Stewart #define RACK_ACKED 0x000001/* The remote endpoint acked this */
30c3679af3SGordon Bergling #define RACK_TO_REXT 0x000002/* A timeout occurred on this sendmap entry */
31141a53cdSRandall Stewart #define RACK_DEFERRED 0x000004/* We can't use this for RTT calc - not used */
32141a53cdSRandall Stewart #define RACK_OVERMAX 0x000008/* We have more retran's then we can fit */
33141a53cdSRandall Stewart #define RACK_SACK_PASSED 0x000010/* A sack was done above this block */
34141a53cdSRandall Stewart #define RACK_WAS_SACKPASS 0x000020/* We retransmitted due to SACK pass */
35141a53cdSRandall Stewart #define RACK_HAS_FIN 0x000040/* segment is sent with fin */
36141a53cdSRandall Stewart #define RACK_TLP 0x000080/* segment sent as tail-loss-probe */
37141a53cdSRandall Stewart #define RACK_RWND_COLLAPSED 0x000100/* The peer collapsed the rwnd on the segment */
38141a53cdSRandall Stewart #define RACK_APP_LIMITED 0x000200/* We went app limited after this send */
39141a53cdSRandall Stewart #define RACK_WAS_ACKED 0x000400/* a RTO undid the ack, but it already had a rtt calc done */
40141a53cdSRandall Stewart #define RACK_HAS_SYN 0x000800/* SYN is on this guy */
41141a53cdSRandall Stewart #define RACK_SENT_W_DSACK 0x001000/* Sent with a dsack */
42141a53cdSRandall Stewart #define RACK_SENT_SP 0x002000/* sent in slow path */
43141a53cdSRandall Stewart #define RACK_SENT_FP 0x004000/* sent in fast path */
44141a53cdSRandall Stewart #define RACK_HAD_PUSH 0x008000/* Push was sent on original send */
45141a53cdSRandall Stewart #define RACK_MUST_RXT 0x010000/* We must retransmit this rsm (non-sack/mtu chg)*/
46030434acSRandall Stewart #define RACK_IN_GP_WIN 0x020000/* Send was in GP window when sent */
47030434acSRandall Stewart #define RACK_SHUFFLED 0x040000/* The RSM was shuffled some data from one to another */
48030434acSRandall Stewart #define RACK_MERGED 0x080000/* The RSM was merged */
49030434acSRandall Stewart #define RACK_PMTU_CHG 0x100000/* The path mtu changed on this guy */
50030434acSRandall Stewart #define RACK_STRADDLE 0x200000/* The seq straddles the bucket line */
51e18b97bdSRandall Stewart #define RACK_WAS_LOST 0x400000/* Is the rsm considered lost */
52e18b97bdSRandall Stewart #define RACK_IS_PCM 0x800000/* A PCM measurement is being taken */
5389e560f4SRandall Stewart #define RACK_NUM_OF_RETRANS 3
5489e560f4SRandall Stewart
555d8fd932SRandall Stewart #define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */
5689e560f4SRandall Stewart
575d8fd932SRandall Stewart #define RACK_REQ_AVG 3 /* Must be less than 256 */
58963fb2adSRandall Stewart
5989e560f4SRandall Stewart struct rack_sendmap {
60030434acSRandall Stewart TAILQ_ENTRY(rack_sendmap) next;
615d8fd932SRandall Stewart TAILQ_ENTRY(rack_sendmap) r_tnext; /* Time of transmit based next */
62030434acSRandall Stewart uint32_t bindex;
6389e560f4SRandall Stewart uint32_t r_start; /* Sequence number of the segment */
6489e560f4SRandall Stewart uint32_t r_end; /* End seq, this is 1 beyond actually */
6589e560f4SRandall Stewart uint32_t r_rtr_bytes; /* How many bytes have been retransmitted */
66141a53cdSRandall Stewart uint32_t r_flags : 24, /* Flags as defined above */
67141a53cdSRandall Stewart r_rtr_cnt : 8; /* Retran count, index this -1 to get time */
68e18b97bdSRandall Stewart uint32_t r_act_rxt_cnt; /* The actual total count of transmits */
695d8fd932SRandall Stewart struct mbuf *m;
705d8fd932SRandall Stewart uint32_t soff;
71030434acSRandall Stewart uint32_t orig_m_len; /* The original mbuf len when we sent (can update) */
72030434acSRandall Stewart uint32_t orig_t_space; /* The original trailing space when we sent (can update) */
73963fb2adSRandall Stewart uint32_t r_nseq_appl; /* If this one is app limited, this is the nxt seq limited */
7435c7bb34SRandall Stewart uint8_t r_dupack; /* Dup ack count */
7589e560f4SRandall Stewart uint8_t r_in_tmap; /* Flag to see if its in the r_tnext array */
765e02b277SJonathan T. Looney uint8_t r_limit_type; /* is this entry counted against a limit? */
77963fb2adSRandall Stewart uint8_t r_just_ret : 1, /* After sending, the next pkt was just returned, i.e. limited */
78963fb2adSRandall Stewart r_one_out_nr : 1, /* Special case 1 outstanding and not in recovery */
795d8fd932SRandall Stewart r_no_rtt_allowed : 1, /* No rtt measurement allowed */
809e4d9e4cSRandall Stewart r_hw_tls : 1,
819e4d9e4cSRandall Stewart r_avail : 4;
825d8fd932SRandall Stewart uint64_t r_tim_lastsent[RACK_NUM_OF_RETRANS];
835d8fd932SRandall Stewart uint64_t r_ack_arrival; /* This is the time of ack-arrival (if SACK'd) */
844e4c84f8SRandall Stewart uint32_t r_fas; /* Flight at send */
85030434acSRandall Stewart uint8_t r_bas; /* The burst size (burst at send = bas) */
8689e560f4SRandall Stewart };
8789e560f4SRandall Stewart
885d8fd932SRandall Stewart struct deferred_opt_list {
895d8fd932SRandall Stewart TAILQ_ENTRY(deferred_opt_list) next;
905d8fd932SRandall Stewart int optname;
915d8fd932SRandall Stewart uint64_t optval;
925d8fd932SRandall Stewart };
935d8fd932SRandall Stewart
945d8fd932SRandall Stewart /*
955d8fd932SRandall Stewart * Timestamps in the rack sendmap are now moving to be
965d8fd932SRandall Stewart * uint64_t's. This means that if you want a uint32_t
975d8fd932SRandall Stewart * usec timestamp (the old usecond timestamp) you simply have
985d8fd932SRandall Stewart * to cast it to uint32_t. The reason we do this is not for
995d8fd932SRandall Stewart * wrap, but we need to get back, at times, to the millisecond
1005d8fd932SRandall Stewart * timestamp that is used in the TSTMP option. To do this we
1015d8fd932SRandall Stewart * can use the rack_ts_to_msec() inline below which can take
1025d8fd932SRandall Stewart * the 64bit ts and make into the correct timestamp millisecond
1035d8fd932SRandall Stewart * wise. Thats not possible with the 32bit usecond timestamp since
1045d8fd932SRandall Stewart * the seconds wrap too quickly to cover all bases.
1055d8fd932SRandall Stewart *
1065d8fd932SRandall Stewart * There are quite a few places in rack where I simply cast
1075d8fd932SRandall Stewart * back to uint32_t and then end up using the TSTMP_XX()
1085d8fd932SRandall Stewart * macros. This is ok, but we could do simple compares if
1095d8fd932SRandall Stewart * we ever decided to move all of those variables to 64 bits
1105d8fd932SRandall Stewart * as well.
1115d8fd932SRandall Stewart */
1125d8fd932SRandall Stewart
1136eb2dbfaSGleb Smirnoff static inline uint64_t
rack_to_usec_ts(struct timeval * tv)1145d8fd932SRandall Stewart rack_to_usec_ts(struct timeval *tv)
1155d8fd932SRandall Stewart {
1165d8fd932SRandall Stewart return ((tv->tv_sec * HPTS_USEC_IN_SEC) + tv->tv_usec);
1175d8fd932SRandall Stewart }
1185d8fd932SRandall Stewart
1196eb2dbfaSGleb Smirnoff static inline uint32_t
rack_ts_to_msec(uint64_t ts)1205d8fd932SRandall Stewart rack_ts_to_msec(uint64_t ts)
1215d8fd932SRandall Stewart {
1225d8fd932SRandall Stewart return((uint32_t)(ts / HPTS_MSEC_IN_SEC));
1235d8fd932SRandall Stewart }
1245d8fd932SRandall Stewart
1255d8fd932SRandall Stewart
12689e560f4SRandall Stewart TAILQ_HEAD(rack_head, rack_sendmap);
1275d8fd932SRandall Stewart TAILQ_HEAD(def_opt_head, deferred_opt_list);
1285d8fd932SRandall Stewart
1295d8fd932SRandall Stewart /* Map change logging */
1305d8fd932SRandall Stewart #define MAP_MERGE 0x01
1315d8fd932SRandall Stewart #define MAP_SPLIT 0x02
1325d8fd932SRandall Stewart #define MAP_NEW 0x03
1335d8fd932SRandall Stewart #define MAP_SACK_M1 0x04
1345d8fd932SRandall Stewart #define MAP_SACK_M2 0x05
1355d8fd932SRandall Stewart #define MAP_SACK_M3 0x06
1365d8fd932SRandall Stewart #define MAP_SACK_M4 0x07
1375d8fd932SRandall Stewart #define MAP_SACK_M5 0x08
1385d8fd932SRandall Stewart #define MAP_FREE 0x09
1395d8fd932SRandall Stewart #define MAP_TRIM_HEAD 0x0a
14089e560f4SRandall Stewart
14135c7bb34SRandall Stewart #define RACK_LIMIT_TYPE_SPLIT 1
14289e560f4SRandall Stewart
14389e560f4SRandall Stewart /*
14489e560f4SRandall Stewart * We use the rate sample structure to
14589e560f4SRandall Stewart * assist in single sack/ack rate and rtt
14689e560f4SRandall Stewart * calculation. In the future we will expand
14789e560f4SRandall Stewart * this in BBR to do forward rate sample
14889e560f4SRandall Stewart * b/w estimation.
14989e560f4SRandall Stewart */
15089e560f4SRandall Stewart #define RACK_RTT_EMPTY 0x00000001 /* Nothing yet stored in RTT's */
15189e560f4SRandall Stewart #define RACK_RTT_VALID 0x00000002 /* We have at least one valid RTT */
15289e560f4SRandall Stewart struct rack_rtt_sample {
15389e560f4SRandall Stewart uint32_t rs_flags;
15489e560f4SRandall Stewart uint32_t rs_rtt_lowest;
15589e560f4SRandall Stewart uint32_t rs_rtt_highest;
15689e560f4SRandall Stewart uint32_t rs_rtt_cnt;
157963fb2adSRandall Stewart uint32_t rs_us_rtt;
158963fb2adSRandall Stewart int32_t confidence;
15989e560f4SRandall Stewart uint64_t rs_rtt_tot;
160963fb2adSRandall Stewart uint16_t rs_us_rtrcnt;
16189e560f4SRandall Stewart };
16289e560f4SRandall Stewart
16389e560f4SRandall Stewart #define RACK_LOG_TYPE_ACK 0x01
16489e560f4SRandall Stewart #define RACK_LOG_TYPE_OUT 0x02
16589e560f4SRandall Stewart #define RACK_LOG_TYPE_TO 0x03
16689e560f4SRandall Stewart #define RACK_LOG_TYPE_ALLOC 0x04
16789e560f4SRandall Stewart #define RACK_LOG_TYPE_FREE 0x05
16889e560f4SRandall Stewart
16989e560f4SRandall Stewart /*
17089e560f4SRandall Stewart * Magic numbers for logging timeout events if the
17189e560f4SRandall Stewart * logging is enabled.
17289e560f4SRandall Stewart */
17389e560f4SRandall Stewart #define RACK_TO_FRM_TMR 1
17489e560f4SRandall Stewart #define RACK_TO_FRM_TLP 2
17589e560f4SRandall Stewart #define RACK_TO_FRM_RACK 3
17689e560f4SRandall Stewart #define RACK_TO_FRM_KEEP 4
17789e560f4SRandall Stewart #define RACK_TO_FRM_PERSIST 5
17889e560f4SRandall Stewart #define RACK_TO_FRM_DELACK 6
17989e560f4SRandall Stewart
180e18b97bdSRandall Stewart #define RCV_PATH_RTT_MS 10 /* How many ms between recv path RTT's */
181e18b97bdSRandall Stewart
18289e560f4SRandall Stewart struct rack_opts_stats {
18389e560f4SRandall Stewart uint64_t tcp_rack_tlp_reduce;
18489e560f4SRandall Stewart uint64_t tcp_rack_pace_always;
18589e560f4SRandall Stewart uint64_t tcp_rack_pace_reduce;
18689e560f4SRandall Stewart uint64_t tcp_rack_max_seg;
18789e560f4SRandall Stewart uint64_t tcp_rack_prr_sendalot;
18889e560f4SRandall Stewart uint64_t tcp_rack_min_to;
18989e560f4SRandall Stewart uint64_t tcp_rack_early_seg;
19089e560f4SRandall Stewart uint64_t tcp_rack_reord_thresh;
19189e560f4SRandall Stewart uint64_t tcp_rack_reord_fade;
19289e560f4SRandall Stewart uint64_t tcp_rack_tlp_thresh;
19389e560f4SRandall Stewart uint64_t tcp_rack_pkt_delay;
19489e560f4SRandall Stewart uint64_t tcp_rack_tlp_inc_var;
19589e560f4SRandall Stewart uint64_t tcp_tlp_use;
19689e560f4SRandall Stewart uint64_t tcp_rack_idle_reduce;
19789e560f4SRandall Stewart uint64_t tcp_rack_idle_reduce_high;
19889e560f4SRandall Stewart uint64_t rack_no_timer_in_hpts;
19989e560f4SRandall Stewart uint64_t tcp_rack_min_pace_seg;
200963fb2adSRandall Stewart uint64_t tcp_rack_pace_rate_ca;
201963fb2adSRandall Stewart uint64_t tcp_rack_rr;
202963fb2adSRandall Stewart uint64_t tcp_rack_rrr_no_conf_rate;
203963fb2adSRandall Stewart uint64_t tcp_initial_rate;
204963fb2adSRandall Stewart uint64_t tcp_initial_win;
205963fb2adSRandall Stewart uint64_t tcp_hdwr_pacing;
206963fb2adSRandall Stewart uint64_t tcp_gp_inc_ss;
207963fb2adSRandall Stewart uint64_t tcp_gp_inc_ca;
208963fb2adSRandall Stewart uint64_t tcp_gp_inc_rec;
209963fb2adSRandall Stewart uint64_t tcp_rack_force_max_seg;
210963fb2adSRandall Stewart uint64_t tcp_rack_pace_rate_ss;
211963fb2adSRandall Stewart uint64_t tcp_rack_pace_rate_rec;
212963fb2adSRandall Stewart /* Temp counters for dsack */
213030434acSRandall Stewart uint64_t tcp_sack_path_1; /* not used */
214030434acSRandall Stewart uint64_t tcp_sack_path_2a; /* not used */
215030434acSRandall Stewart uint64_t tcp_sack_path_2b; /* not used */
216030434acSRandall Stewart uint64_t tcp_sack_path_3; /* not used */
217030434acSRandall Stewart uint64_t tcp_sack_path_4; /* not used */
218963fb2adSRandall Stewart /* non temp counters */
219963fb2adSRandall Stewart uint64_t tcp_rack_scwnd;
220963fb2adSRandall Stewart uint64_t tcp_rack_noprr;
221963fb2adSRandall Stewart uint64_t tcp_rack_cfg_rate;
222963fb2adSRandall Stewart uint64_t tcp_timely_dyn;
223963fb2adSRandall Stewart uint64_t tcp_rack_mbufq;
224963fb2adSRandall Stewart uint64_t tcp_fillcw;
225963fb2adSRandall Stewart uint64_t tcp_npush;
226963fb2adSRandall Stewart uint64_t tcp_lscwnd;
227963fb2adSRandall Stewart uint64_t tcp_profile;
2285d8fd932SRandall Stewart uint64_t tcp_hdwr_rate_cap;
2295d8fd932SRandall Stewart uint64_t tcp_pacing_rate_cap;
2305d8fd932SRandall Stewart uint64_t tcp_pacing_up_only;
2315d8fd932SRandall Stewart uint64_t tcp_use_cmp_acks;
2325d8fd932SRandall Stewart uint64_t tcp_rack_abc_val;
2335d8fd932SRandall Stewart uint64_t tcp_rec_abc_val;
2345d8fd932SRandall Stewart uint64_t tcp_rack_measure_cnt;
2355d8fd932SRandall Stewart uint64_t tcp_rack_delayed_ack;
2365d8fd932SRandall Stewart uint64_t tcp_rack_rtt_use;
2375d8fd932SRandall Stewart uint64_t tcp_data_after_close;
2385d8fd932SRandall Stewart uint64_t tcp_defer_opt;
239e18b97bdSRandall Stewart uint64_t tcp_pol_detect;
2405d8fd932SRandall Stewart uint64_t tcp_rack_beta;
2415d8fd932SRandall Stewart uint64_t tcp_rack_beta_ecn;
2424f3addd9SRandall Stewart uint64_t tcp_rack_timer_slop;
2435baf32c9SRandall Stewart uint64_t tcp_rack_dsack_opt;
244030434acSRandall Stewart uint64_t tcp_rack_hi_beta;
245030434acSRandall Stewart uint64_t tcp_split_limit;
246030434acSRandall Stewart uint64_t tcp_rack_pacing_divisor;
247030434acSRandall Stewart uint64_t tcp_rack_min_seg;
248030434acSRandall Stewart uint64_t tcp_dgp_in_rec;
249e18b97bdSRandall Stewart uint64_t tcp_notimely;
250e18b97bdSRandall Stewart uint64_t tcp_honor_hpts;
251e18b97bdSRandall Stewart uint64_t tcp_dyn_rec;
252e18b97bdSRandall Stewart uint64_t tcp_fillcw_rate_cap;
253e18b97bdSRandall Stewart uint64_t tcp_pol_mss;
25489e560f4SRandall Stewart };
25589e560f4SRandall Stewart
256963fb2adSRandall Stewart /* RTT shrink reasons */
257963fb2adSRandall Stewart #define RACK_RTTS_INIT 0
258963fb2adSRandall Stewart #define RACK_RTTS_NEWRTT 1
259963fb2adSRandall Stewart #define RACK_RTTS_EXITPROBE 2
260963fb2adSRandall Stewart #define RACK_RTTS_ENTERPROBE 3
261963fb2adSRandall Stewart #define RACK_RTTS_REACHTARGET 4
262963fb2adSRandall Stewart #define RACK_RTTS_SEEHBP 5
263963fb2adSRandall Stewart #define RACK_RTTS_NOBACKOFF 6
264963fb2adSRandall Stewart #define RACK_RTTS_SAFETY 7
265963fb2adSRandall Stewart
266963fb2adSRandall Stewart #define RACK_USE_BEG 1
267963fb2adSRandall Stewart #define RACK_USE_END 2
268963fb2adSRandall Stewart #define RACK_USE_END_OR_THACK 3
269963fb2adSRandall Stewart
27089e560f4SRandall Stewart #define TLP_USE_ID 1 /* Internet draft behavior */
27189e560f4SRandall Stewart #define TLP_USE_TWO_ONE 2 /* Use 2.1 behavior */
27289e560f4SRandall Stewart #define TLP_USE_TWO_TWO 3 /* Use 2.2 behavior */
273963fb2adSRandall Stewart #define RACK_MIN_BW 8000 /* 64kbps in Bps */
27489e560f4SRandall Stewart
275e18b97bdSRandall Stewart #define CCSP_DIS_MASK 0x0001
276e18b97bdSRandall Stewart #define HYBRID_DIS_MASK 0x0002
277e18b97bdSRandall Stewart
278e834f9a4SRandall Stewart /* Rack quality indicators for GPUT measurements */
279e834f9a4SRandall Stewart #define RACK_QUALITY_NONE 0 /* No quality stated */
280e834f9a4SRandall Stewart #define RACK_QUALITY_HIGH 1 /* A normal measurement of a GP RTT */
281e834f9a4SRandall Stewart #define RACK_QUALITY_APPLIMITED 2 /* An app limited case that may be of lower quality */
282e834f9a4SRandall Stewart #define RACK_QUALITY_PERSIST 3 /* A measurement where we went into persists */
283e834f9a4SRandall Stewart #define RACK_QUALITY_PROBERTT 4 /* A measurement where we went into or exited probe RTT */
284e834f9a4SRandall Stewart #define RACK_QUALITY_ALLACKED 5 /* All data is now acknowledged */
285e834f9a4SRandall Stewart
286963fb2adSRandall Stewart #define MIN_GP_WIN 6 /* We need at least 6 MSS in a GP measurement */
28789e560f4SRandall Stewart #ifdef _KERNEL
28889e560f4SRandall Stewart #define RACK_OPTS_SIZE (sizeof(struct rack_opts_stats)/sizeof(uint64_t))
28989e560f4SRandall Stewart extern counter_u64_t rack_opts_arry[RACK_OPTS_SIZE];
29089e560f4SRandall Stewart #define RACK_OPTS_ADD(name, amm) counter_u64_add(rack_opts_arry[(offsetof(struct rack_opts_stats, name)/sizeof(uint64_t))], (amm))
29189e560f4SRandall Stewart #define RACK_OPTS_INC(name) RACK_OPTS_ADD(name, 1)
29289e560f4SRandall Stewart #endif
29389e560f4SRandall Stewart /*
29489e560f4SRandall Stewart * As we get each SACK we wade through the
29589e560f4SRandall Stewart * rc_map and mark off what is acked.
29689e560f4SRandall Stewart * We also increment rc_sacked as well.
29789e560f4SRandall Stewart *
29889e560f4SRandall Stewart * We also pay attention to missing entries
29989e560f4SRandall Stewart * based on the time and possibly mark them
30089e560f4SRandall Stewart * for retransmit. If we do and we are not already
30189e560f4SRandall Stewart * in recovery we enter recovery. In doing
30289e560f4SRandall Stewart * so we claer prr_delivered/holes_rxt and prr_sent_dur_rec.
30389e560f4SRandall Stewart * We also setup rc_next/rc_snd_nxt/rc_send_end so
30489e560f4SRandall Stewart * we will know where to send from. When not in
30589e560f4SRandall Stewart * recovery rc_next will be NULL and rc_snd_nxt should
30689e560f4SRandall Stewart * equal snd_max.
30789e560f4SRandall Stewart *
30889e560f4SRandall Stewart * Whenever we retransmit from recovery we increment
30989e560f4SRandall Stewart * rc_holes_rxt as we retran a block and mark it as retransmitted
31089e560f4SRandall Stewart * with the time it was sent. During non-recovery sending we
31189e560f4SRandall Stewart * add to our map and note the time down of any send expanding
31289e560f4SRandall Stewart * the rc_map at the tail and moving rc_snd_nxt up with snd_max.
31389e560f4SRandall Stewart *
31489e560f4SRandall Stewart * In recovery during SACK/ACK processing if a chunk has
31589e560f4SRandall Stewart * been retransmitted and it is now acked, we decrement rc_holes_rxt.
31689e560f4SRandall Stewart * When we retransmit from the scoreboard we use
31789e560f4SRandall Stewart * rc_next and rc_snd_nxt/rc_send_end to help us
31889e560f4SRandall Stewart * find what needs to be retran.
31989e560f4SRandall Stewart *
32089e560f4SRandall Stewart * To calculate pipe we simply take (snd_max - snd_una) + rc_holes_rxt
32189e560f4SRandall Stewart * This gets us the effect of RFC6675 pipe, counting twice for
32289e560f4SRandall Stewart * bytes retransmitted.
32389e560f4SRandall Stewart */
32489e560f4SRandall Stewart
32589e560f4SRandall Stewart #define TT_RACK_FR_TMR 0x2000
32689e560f4SRandall Stewart
32789e560f4SRandall Stewart /*
32889e560f4SRandall Stewart * Locking for the rack control block.
32989e560f4SRandall Stewart * a) Locked by INP_WLOCK
33089e560f4SRandall Stewart * b) Locked by the hpts-mutex
33189e560f4SRandall Stewart *
33289e560f4SRandall Stewart */
33335c7bb34SRandall Stewart #define RACK_GP_HIST 4 /* How much goodput history do we maintain? */
334e18b97bdSRandall Stewart #define RETRAN_CNT_SIZE 16
33589e560f4SRandall Stewart
3365d8fd932SRandall Stewart #define RACK_NUM_FSB_DEBUG 16
337e834f9a4SRandall Stewart #ifdef _KERNEL
3385d8fd932SRandall Stewart struct rack_fast_send_blk {
3395d8fd932SRandall Stewart uint32_t left_to_send;
3405d8fd932SRandall Stewart uint16_t tcp_ip_hdr_len;
3415d8fd932SRandall Stewart uint8_t tcp_flags;
3425d8fd932SRandall Stewart uint8_t hoplimit;
3435d8fd932SRandall Stewart uint8_t *tcp_ip_hdr;
3445d8fd932SRandall Stewart uint32_t recwin;
3455d8fd932SRandall Stewart uint32_t off;
3465d8fd932SRandall Stewart struct tcphdr *th;
3475d8fd932SRandall Stewart struct udphdr *udp;
3485d8fd932SRandall Stewart struct mbuf *m;
3495d8fd932SRandall Stewart uint32_t o_m_len;
350030434acSRandall Stewart uint32_t o_t_len;
3515d8fd932SRandall Stewart uint32_t rfo_apply_push : 1,
3529e4d9e4cSRandall Stewart hw_tls : 1,
3539e4d9e4cSRandall Stewart unused : 30;
3545d8fd932SRandall Stewart };
3555d8fd932SRandall Stewart
356030434acSRandall Stewart struct tailq_hash;
357030434acSRandall Stewart
358e18b97bdSRandall Stewart struct rack_pcm_info {
359e18b97bdSRandall Stewart /* Base send time and s/e filled in by rack_log_output */
360e18b97bdSRandall Stewart uint64_t send_time;
361e18b97bdSRandall Stewart uint32_t sseq;
362e18b97bdSRandall Stewart uint32_t eseq;
363e18b97bdSRandall Stewart /* Ack's fill in the rest of the data */
364e18b97bdSRandall Stewart uint16_t cnt;
365e18b97bdSRandall Stewart /* Maximum acks present */
366e18b97bdSRandall Stewart uint16_t cnt_alloc;
367e18b97bdSRandall Stewart };
368e18b97bdSRandall Stewart
369e18b97bdSRandall Stewart #define RACK_DEFAULT_PCM_ARRAY 16
370e18b97bdSRandall Stewart
371e18b97bdSRandall Stewart struct rack_pcm_stats {
372e18b97bdSRandall Stewart uint32_t sseq;
373e18b97bdSRandall Stewart uint32_t eseq;
374e18b97bdSRandall Stewart uint64_t ack_time;
375e18b97bdSRandall Stewart };
376e18b97bdSRandall Stewart
377e18b97bdSRandall Stewart
37889e560f4SRandall Stewart struct rack_control {
37989e560f4SRandall Stewart /* Second cache line 0x40 from tcp_rack */
380030434acSRandall Stewart struct tailq_hash *tqh; /* Tree of all segments Lock(a) */
38189e560f4SRandall Stewart struct rack_head rc_tmap; /* List in transmit order Lock(a) */
38289e560f4SRandall Stewart struct rack_sendmap *rc_tlpsend; /* Remembered place for
38389e560f4SRandall Stewart * tlp_sending Lock(a) */
38489e560f4SRandall Stewart struct rack_sendmap *rc_resend; /* something we have been asked to
38589e560f4SRandall Stewart * resend */
3865d8fd932SRandall Stewart struct rack_fast_send_blk fsb; /* The fast-send block */
3874f3addd9SRandall Stewart uint32_t timer_slop;
388030434acSRandall Stewart uint16_t pace_len_divisor;
389030434acSRandall Stewart uint16_t rc_user_set_min_segs;
39089e560f4SRandall Stewart uint32_t rc_hpts_flags;
391963fb2adSRandall Stewart uint32_t rc_fixed_pacing_rate_ca;
392963fb2adSRandall Stewart uint32_t rc_fixed_pacing_rate_rec;
393963fb2adSRandall Stewart uint32_t rc_fixed_pacing_rate_ss;
394963fb2adSRandall Stewart uint32_t cwnd_to_use; /* The cwnd in use */
39589e560f4SRandall Stewart uint32_t rc_timer_exp; /* If a timer ticks of expiry */
39689e560f4SRandall Stewart uint32_t rc_rack_min_rtt; /* lowest RTT seen Lock(a) */
39789e560f4SRandall Stewart uint32_t rc_rack_largest_cwnd; /* Largest CWND we have seen Lock(a) */
39889e560f4SRandall Stewart
39989e560f4SRandall Stewart /* Third Cache line 0x80 */
40089e560f4SRandall Stewart struct rack_head rc_free; /* Allocation array */
4015d8fd932SRandall Stewart uint64_t last_hw_bw_req;
4025d8fd932SRandall Stewart uint64_t crte_prev_rate;
4035d8fd932SRandall Stewart uint64_t bw_rate_cap;
404030434acSRandall Stewart uint64_t last_cumack_advance; /* Last time cumack moved forward */
40589e560f4SRandall Stewart uint32_t rc_reorder_ts; /* Last time we saw reordering Lock(a) */
40689e560f4SRandall Stewart
40789e560f4SRandall Stewart uint32_t rc_tlp_new_data; /* we need to send new-data on a TLP
40889e560f4SRandall Stewart * Lock(a) */
40989e560f4SRandall Stewart uint32_t rc_prr_out; /* bytes sent during recovery Lock(a) */
41089e560f4SRandall Stewart
41189e560f4SRandall Stewart uint32_t rc_prr_recovery_fs; /* recovery fs point Lock(a) */
41289e560f4SRandall Stewart
41389e560f4SRandall Stewart uint32_t rc_prr_sndcnt; /* Prr sndcnt Lock(a) */
41489e560f4SRandall Stewart
41589e560f4SRandall Stewart uint32_t rc_sacked; /* Tot sacked on scoreboard Lock(a) */
4165baf32c9SRandall Stewart uint32_t last_sent_tlp_seq; /* Last tlp sequence that was retransmitted Lock(a) */
41789e560f4SRandall Stewart
41889e560f4SRandall Stewart uint32_t rc_prr_delivered; /* during recovery prr var Lock(a) */
419030434acSRandall Stewart
420963fb2adSRandall Stewart uint16_t rc_tlp_cnt_out; /* count of times we have sent a TLP without new data */
4215baf32c9SRandall Stewart uint16_t last_sent_tlp_len; /* Number of bytes in the last sent tlp */
42289e560f4SRandall Stewart
423963fb2adSRandall Stewart uint32_t rc_loss_count; /* How many bytes have been retransmitted
42489e560f4SRandall Stewart * Lock(a) */
42589e560f4SRandall Stewart uint32_t rc_reorder_fade; /* Socket option value Lock(a) */
42689e560f4SRandall Stewart
42789e560f4SRandall Stewart /* Forth cache line 0xc0 */
42889e560f4SRandall Stewart /* Times */
42989e560f4SRandall Stewart
43089e560f4SRandall Stewart uint32_t rc_rack_tmit_time; /* Rack transmit time Lock(a) */
43189e560f4SRandall Stewart uint32_t rc_holes_rxt; /* Tot retraned from scoreboard Lock(a) */
43289e560f4SRandall Stewart
43389e560f4SRandall Stewart uint32_t rc_num_maps_alloced; /* Number of map blocks (sacks) we
43489e560f4SRandall Stewart * have allocated */
43589e560f4SRandall Stewart uint32_t rc_rcvtime; /* When we last received data */
4365e02b277SJonathan T. Looney uint32_t rc_num_split_allocs; /* num split map entries allocated */
437030434acSRandall Stewart uint32_t rc_split_limit; /* Limit from control var can be set by socket opt */
43835c7bb34SRandall Stewart
43989e560f4SRandall Stewart uint32_t rc_last_output_to;
44089e560f4SRandall Stewart uint32_t rc_went_idle_time;
44189e560f4SRandall Stewart
44289e560f4SRandall Stewart struct rack_sendmap *rc_sacklast; /* sack remembered place
44389e560f4SRandall Stewart * Lock(a) */
44489e560f4SRandall Stewart
445963fb2adSRandall Stewart struct rack_sendmap *rc_first_appl; /* Pointer to first app limited */
446963fb2adSRandall Stewart struct rack_sendmap *rc_end_appl; /* Pointer to last app limited */
44789e560f4SRandall Stewart /* Cache line split 0x100 */
44889e560f4SRandall Stewart struct sack_filter rack_sf;
44989e560f4SRandall Stewart /* Cache line split 0x140 */
45089e560f4SRandall Stewart /* Flags for various things */
45135c7bb34SRandall Stewart uint32_t rc_pace_max_segs;
45235c7bb34SRandall Stewart uint32_t rc_pace_min_segs;
453963fb2adSRandall Stewart uint32_t rc_app_limited_cnt;
454963fb2adSRandall Stewart uint16_t rack_per_of_gp_ss; /* 100 = 100%, so from 65536 = 655 x bw */
455963fb2adSRandall Stewart uint16_t rack_per_of_gp_ca; /* 100 = 100%, so from 65536 = 655 x bw */
456963fb2adSRandall Stewart uint16_t rack_per_of_gp_rec; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
457963fb2adSRandall Stewart uint16_t rack_per_of_gp_probertt; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
45835c7bb34SRandall Stewart uint32_t rc_high_rwnd;
45989e560f4SRandall Stewart struct rack_rtt_sample rack_rs;
460963fb2adSRandall Stewart const struct tcp_hwrate_limit_table *crte;
461963fb2adSRandall Stewart uint32_t rc_agg_early;
462963fb2adSRandall Stewart uint32_t rc_agg_delayed;
46335c7bb34SRandall Stewart uint32_t rc_tlp_rxt_last_time;
4645d8fd932SRandall Stewart uint64_t rc_gp_output_ts; /* chg*/
4655d8fd932SRandall Stewart uint64_t rc_gp_cumack_ts; /* chg*/
466963fb2adSRandall Stewart struct timeval act_rcv_time;
467963fb2adSRandall Stewart struct timeval rc_last_time_decay; /* SAD time decay happened here */
468963fb2adSRandall Stewart uint64_t gp_bw;
469963fb2adSRandall Stewart uint64_t init_rate;
470963fb2adSRandall Stewart #ifdef NETFLIX_SHARED_CWND
471963fb2adSRandall Stewart struct shared_cwnd *rc_scw;
472963fb2adSRandall Stewart #endif
473963fb2adSRandall Stewart uint64_t last_gp_comp_bw;
474963fb2adSRandall Stewart uint64_t last_max_bw; /* Our calculated max b/w last */
475963fb2adSRandall Stewart struct time_filter_small rc_gp_min_rtt;
4765d8fd932SRandall Stewart struct def_opt_head opt_list;
477030434acSRandall Stewart uint64_t lt_bw_time; /* Total time with data outstanding (lt_bw = long term bandwidth) */
478030434acSRandall Stewart uint64_t lt_bw_bytes; /* Total bytes acked */
479030434acSRandall Stewart uint64_t lt_timemark; /* 64 bit timestamp when we started sending */
48057a3a161SRandall Stewart struct tcp_sendfile_track *rc_last_sft;
481030434acSRandall Stewart uint32_t lt_seq; /* Seq at start of lt_bw gauge */
482963fb2adSRandall Stewart int32_t rc_rtt_diff; /* Timely style rtt diff of our gp_srtt */
483e022f2b0SRandall Stewart uint64_t last_tmit_time_acked; /* Holds the last cumack point's last send time */
484e18b97bdSRandall Stewart /* Recovery stats */
485e18b97bdSRandall Stewart uint64_t last_sendtime;
486e18b97bdSRandall Stewart
487e18b97bdSRandall Stewart uint64_t last_gpest;
488e18b97bdSRandall Stewart uint64_t last_tm_mark; /* Last tm mark used */
489e18b97bdSRandall Stewart uint64_t fillcw_cap; /* B/W cap on fill cw */
490e18b97bdSRandall Stewart struct rack_pcm_info pcm_i;
491e18b97bdSRandall Stewart struct rack_pcm_stats *pcm_s;
492e18b97bdSRandall Stewart uint32_t gp_gain_req; /* Percent off gp gain req */
493e18b97bdSRandall Stewart uint32_t last_rnd_of_gp_rise;
494e18b97bdSRandall Stewart uint32_t gp_rnd_thresh;
495e18b97bdSRandall Stewart uint32_t ss_hi_fs;
496e18b97bdSRandall Stewart uint32_t gate_to_fs;
497e18b97bdSRandall Stewart uint32_t pcm_max_seg;
498e18b97bdSRandall Stewart uint32_t last_pcm_round;
499e18b97bdSRandall Stewart uint32_t pcm_idle_rounds;
500030434acSRandall Stewart
501963fb2adSRandall Stewart uint32_t rc_gp_srtt; /* Current GP srtt */
502963fb2adSRandall Stewart uint32_t rc_prev_gp_srtt; /* Previous RTT */
503963fb2adSRandall Stewart uint32_t rc_entry_gp_rtt; /* Entry to PRTT gp-rtt */
504963fb2adSRandall Stewart uint32_t rc_loss_at_start; /* At measurement window where was our lost value */
505e18b97bdSRandall Stewart uint32_t rc_considered_lost; /* Count in recovery of non-retransmitted bytes considered lost */
506963fb2adSRandall Stewart
5075baf32c9SRandall Stewart uint32_t dsack_round_end; /* In a round of seeing a DSACK */
5084e4c84f8SRandall Stewart uint32_t current_round; /* Starting at zero */
5094e4c84f8SRandall Stewart uint32_t roundends; /* acked value above which round ends */
5105baf32c9SRandall Stewart uint32_t num_dsack; /* Count of dsack's seen (1 per window)*/
511963fb2adSRandall Stewart uint32_t forced_ack_ts;
51262ce18fcSRandall Stewart uint32_t last_collapse_point; /* Last point peer collapsed too */
51362ce18fcSRandall Stewart uint32_t high_collapse_point;
514963fb2adSRandall Stewart uint32_t rc_lower_rtt_us_cts; /* Time our GP rtt was last lowered */
515963fb2adSRandall Stewart uint32_t rc_time_probertt_entered;
516963fb2adSRandall Stewart uint32_t rc_time_probertt_starts;
517963fb2adSRandall Stewart uint32_t rc_lowest_us_rtt;
518963fb2adSRandall Stewart uint32_t rc_highest_us_rtt;
519963fb2adSRandall Stewart uint32_t rc_last_us_rtt;
520963fb2adSRandall Stewart uint32_t rc_time_of_last_probertt;
521963fb2adSRandall Stewart uint32_t rc_target_probertt_flight;
522963fb2adSRandall Stewart uint32_t rc_probertt_sndmax_atexit; /* Highest sent to in probe-rtt */
5235d8fd932SRandall Stewart uint32_t rc_cwnd_at_erec;
5245d8fd932SRandall Stewart uint32_t rc_ssthresh_at_erec;
5255d8fd932SRandall Stewart uint32_t dsack_byte_cnt;
5265d8fd932SRandall Stewart uint32_t retran_during_recovery;
527963fb2adSRandall Stewart uint32_t rc_gp_lowrtt; /* Lowest rtt seen during GPUT measurement */
528963fb2adSRandall Stewart uint32_t rc_gp_high_rwnd; /* Highest rwnd seen during GPUT measurement */
529c3679af3SGordon Bergling uint32_t rc_snd_max_at_rto; /* For non-sack when the RTO occurred what was snd-max */
5305d8fd932SRandall Stewart uint32_t rc_out_at_rto;
531963fb2adSRandall Stewart int32_t rc_scw_index;
532e18b97bdSRandall Stewart uint32_t max_reduction;
533e18b97bdSRandall Stewart uint32_t side_chan_dis_mask; /* Bit mask of socket opt's disabled */
53489e560f4SRandall Stewart uint32_t rc_tlp_threshold; /* Socket option value Lock(a) */
5355d8fd932SRandall Stewart uint32_t rc_last_timeout_snduna;
5365baf32c9SRandall Stewart uint32_t last_tlp_acked_start;
5375baf32c9SRandall Stewart uint32_t last_tlp_acked_end;
5385d8fd932SRandall Stewart uint32_t rc_min_to; /* Socket option value Lock(a) */
5395d8fd932SRandall Stewart uint32_t rc_pkt_delay; /* Socket option value Lock(a) */
54026cbd002SRandall Stewart uint32_t persist_lost_ends;
541e18b97bdSRandall Stewart uint32_t cleared_app_ack_seq;
542e18b97bdSRandall Stewart uint32_t last_rcv_tstmp_for_rtt;
543e18b97bdSRandall Stewart uint32_t last_time_of_arm_rcv;
544e18b97bdSRandall Stewart uint32_t rto_ssthresh;
545*f6deb9eaSMichael Tuexen uint32_t rc_saved_beta;
546*f6deb9eaSMichael Tuexen uint32_t rc_saved_beta_ecn; /*
547*f6deb9eaSMichael Tuexen * For newreno cc: rc_saved_beta and
548*f6deb9eaSMichael Tuexen * rc_saved_beta_ecn are the values we have had
5495d8fd932SRandall Stewart * set by the user, if pacing is not happening
5505d8fd932SRandall Stewart * (i.e. its early and we have not turned on yet
5515d8fd932SRandall Stewart * or it was turned off). The minute pacing
5525d8fd932SRandall Stewart * is turned on we pull out the values currently
5535d8fd932SRandall Stewart * being used by newreno and replace them with
5545d8fd932SRandall Stewart * these values, then save off the old values here,
5555d8fd932SRandall Stewart * we also set the flag (if ecn_beta is set) to make
5565d8fd932SRandall Stewart * new_reno do less of a backoff for ecn (think abe).
5575d8fd932SRandall Stewart */
558e18b97bdSRandall Stewart uint16_t rc_cnt_of_retran[RETRAN_CNT_SIZE];
55989e560f4SRandall Stewart uint16_t rc_early_recovery_segs; /* Socket option value Lock(a) */
56089e560f4SRandall Stewart uint16_t rc_reorder_shift; /* Socket option value Lock(a) */
561030434acSRandall Stewart uint8_t rack_per_upper_bound_ss;
562030434acSRandall Stewart uint8_t rack_per_upper_bound_ca;
563e18b97bdSRandall Stewart uint8_t cleared_app_ack;
5645baf32c9SRandall Stewart uint8_t dsack_persist;
565963fb2adSRandall Stewart uint8_t rc_no_push_at_mrtt; /* No push when we exceed max rtt */
5665d8fd932SRandall Stewart uint8_t num_measurements; /* Number of measurements (up to 0xff, we freeze at 0xff) */
5675d8fd932SRandall Stewart uint8_t req_measurements; /* How many measurements are required? */
568e022f2b0SRandall Stewart uint8_t saved_hibeta;
56989e560f4SRandall Stewart uint8_t rc_tlp_cwnd_reduce; /* Socket option value Lock(a) */
57089e560f4SRandall Stewart uint8_t rc_prr_sendalot;/* Socket option value Lock(a) */
57189e560f4SRandall Stewart uint8_t rc_rate_sample_method;
572030434acSRandall Stewart uint8_t client_suggested_maxseg; /* Not sure what to do with this yet */
573e18b97bdSRandall Stewart uint8_t use_gp_not_last;
574e18b97bdSRandall Stewart uint8_t pacing_method; /* If pace_always, what type of pacing */
57589e560f4SRandall Stewart };
576e834f9a4SRandall Stewart #endif
57789e560f4SRandall Stewart
578e18b97bdSRandall Stewart #define RACK_PACING_NONE 0x00
579e18b97bdSRandall Stewart #define RACK_DGP_PACING 0x01
580e18b97bdSRandall Stewart #define RACK_REG_PACING 0x02
581e18b97bdSRandall Stewart
582030434acSRandall Stewart /* Hybrid pacing log defines */
583030434acSRandall Stewart #define HYBRID_LOG_NO_ROOM 0 /* No room for the clients request */
584030434acSRandall Stewart #define HYBRID_LOG_TURNED_OFF 1 /* Turned off hybrid pacing */
585030434acSRandall Stewart #define HYBRID_LOG_NO_PACING 2 /* Failed to set pacing on */
586030434acSRandall Stewart #define HYBRID_LOG_RULES_SET 3 /* Hybrid pacing for this chunk is set */
587030434acSRandall Stewart #define HYBRID_LOG_NO_RANGE 4 /* In DGP mode, no range found */
588030434acSRandall Stewart #define HYBRID_LOG_RULES_APP 5 /* The specified rules were applied */
589030434acSRandall Stewart #define HYBRID_LOG_REQ_COMP 6 /* The request completed */
590030434acSRandall Stewart #define HYBRID_LOG_BW_MEASURE 7 /* Follow up b/w measurements to the previous completed log */
591030434acSRandall Stewart #define HYBRID_LOG_RATE_CAP 8 /* We had a rate cap apply */
592030434acSRandall Stewart #define HYBRID_LOG_CAP_CALC 9 /* How we calculate the cap */
593030434acSRandall Stewart #define HYBRID_LOG_ISSAME 10 /* Same as before -- temp */
594030434acSRandall Stewart #define HYBRID_LOG_ALLSENT 11 /* We sent it all no more rate-cap */
595030434acSRandall Stewart #define HYBRID_LOG_OUTOFTIME 12 /* We are past the deadline DGP */
596030434acSRandall Stewart #define HYBRID_LOG_CAPERROR 13 /* Hit one of the TSNH cases */
597030434acSRandall Stewart #define HYBRID_LOG_EXTEND 14 /* We extended the end */
598e022f2b0SRandall Stewart #define HYBRID_LOG_SENT_LOST 15 /* A closing sent/lost report */
599030434acSRandall Stewart
600963fb2adSRandall Stewart #define RACK_TIMELY_CNT_BOOST 5 /* At 5th increase boost */
601963fb2adSRandall Stewart
602a9696510SRandall Stewart #define RACK_HYSTART_OFF 0
603a9696510SRandall Stewart #define RACK_HYSTART_ON 1 /* hystart++ on */
604a9696510SRandall Stewart #define RACK_HYSTART_ON_W_SC 2 /* hystart++ on +Slam Cwnd */
605a9696510SRandall Stewart #define RACK_HYSTART_ON_W_SC_C 3 /* hystart++ on,
606a9696510SRandall Stewart * Conservative ssthresh and
607a9696510SRandall Stewart * +Slam cwnd
608a9696510SRandall Stewart */
609a9696510SRandall Stewart
610e022f2b0SRandall Stewart #define MAX_USER_SET_SEG 0x3f /* The max we can set is 63 which is probably too many */
611e18b97bdSRandall Stewart #define RACK_FREE_CNT_MAX 0x2f /* Max our counter can do */
612e022f2b0SRandall Stewart
61389e560f4SRandall Stewart #ifdef _KERNEL
61489e560f4SRandall Stewart
61589e560f4SRandall Stewart struct tcp_rack {
61689e560f4SRandall Stewart /* First cache line 0x00 */
61789e560f4SRandall Stewart TAILQ_ENTRY(tcp_rack) r_hpts; /* hptsi queue next Lock(b) */
61889e560f4SRandall Stewart int32_t(*r_substate) (struct mbuf *, struct tcphdr *,
61989e560f4SRandall Stewart struct socket *, struct tcpcb *, struct tcpopt *,
6208df12ffcSMichael Tuexen int32_t, int32_t, uint32_t, int, int, uint8_t); /* Lock(a) */
62189e560f4SRandall Stewart struct tcpcb *rc_tp; /* The tcpcb Lock(a) */
62289e560f4SRandall Stewart struct inpcb *rc_inp; /* The inpcb Lock(a) */
623e18b97bdSRandall Stewart uint8_t rc_free_cnt : 6,
624e18b97bdSRandall Stewart rc_skip_timely : 1,
625e18b97bdSRandall Stewart pcm_enabled : 1; /* Is PCM enabled */
62681560c55SRandall Stewart uint8_t client_bufferlvl : 3, /* Expected range [0,5]: 0=unset, 1=low/empty */
62762ce18fcSRandall Stewart rack_deferred_inited : 1,
62862ce18fcSRandall Stewart /* ******************************************************************** */
62962ce18fcSRandall Stewart /* Note for details of next two fields see rack_init_retransmit_rate() */
63062ce18fcSRandall Stewart /* ******************************************************************** */
63162ce18fcSRandall Stewart full_size_rxt: 1,
63262ce18fcSRandall Stewart shape_rxt_to_pacing_min : 1,
63362ce18fcSRandall Stewart /* ******************************************************************** */
63481560c55SRandall Stewart rc_ack_required: 1,
635e18b97bdSRandall Stewart r_use_hpts_min : 1;
6365d8fd932SRandall Stewart uint8_t no_prr_addback : 1,
6375d8fd932SRandall Stewart gp_ready : 1,
6385d8fd932SRandall Stewart defer_options: 1,
639e18b97bdSRandall Stewart dis_lt_bw : 1,
6405d8fd932SRandall Stewart rc_ack_can_sendout_data: 1, /*
6415d8fd932SRandall Stewart * If set it will override pacing restrictions on not sending
6425d8fd932SRandall Stewart * data when the pacing timer is running. I.e. you set this
6435d8fd932SRandall Stewart * and an ACK will send data. Default is off and its only used
6445d8fd932SRandall Stewart * without pacing when we are doing 5G speed up for there
6455d8fd932SRandall Stewart * ack filtering.
6465d8fd932SRandall Stewart */
6475d8fd932SRandall Stewart rc_pacing_cc_set: 1, /*
6485d8fd932SRandall Stewart * If we are pacing (pace_always=1) and we have reached the
6495d8fd932SRandall Stewart * point where we start pacing (fixed or gp has reached its
6505d8fd932SRandall Stewart * magic gp_ready state) this flag indicates we have set in
6515d8fd932SRandall Stewart * values to effect CC's backoff's. If pacing is turned off
6525d8fd932SRandall Stewart * then we must restore the values saved in rc_saved_beta,
6535d8fd932SRandall Stewart * if its going to gp_ready we need to copy the values into
6545d8fd932SRandall Stewart * the CC module and set our flags.
6555d8fd932SRandall Stewart *
6565d8fd932SRandall Stewart * Note this only happens if the cc name is newreno (CCALGONAME_NEWRENO).
6575d8fd932SRandall Stewart */
6585d8fd932SRandall Stewart
6595baf32c9SRandall Stewart rc_rack_tmr_std_based :1,
6605baf32c9SRandall Stewart rc_rack_use_dsack: 1;
6615baf32c9SRandall Stewart uint8_t rc_dsack_round_seen: 1,
6625baf32c9SRandall Stewart rc_last_tlp_acked_set: 1,
6635baf32c9SRandall Stewart rc_last_tlp_past_cumack: 1,
6645baf32c9SRandall Stewart rc_last_sent_tlp_seq_valid: 1,
6655baf32c9SRandall Stewart rc_last_sent_tlp_past_cumack: 1,
66626cbd002SRandall Stewart probe_not_answered: 1,
667030434acSRandall Stewart rack_hibeta : 1,
668030434acSRandall Stewart lt_bw_up : 1;
66989e560f4SRandall Stewart uint32_t rc_rack_rtt; /* RACK-RTT Lock(a) */
670963fb2adSRandall Stewart uint16_t r_mbuf_queue : 1, /* Do we do mbuf queue for non-paced */
671963fb2adSRandall Stewart rtt_limit_mul : 4, /* muliply this by low rtt */
672963fb2adSRandall Stewart r_limit_scw : 1,
6735d8fd932SRandall Stewart r_must_retran : 1, /* For non-sack customers we hit an RTO and new data should be resends */
6745d8fd932SRandall Stewart r_use_cmp_ack: 1, /* Do we use compressed acks */
6755d8fd932SRandall Stewart r_ent_rec_ns: 1, /* We entered recovery and have not sent */
6765d8fd932SRandall Stewart r_might_revert: 1, /* Flag to find out if we might need to revert */
6775d8fd932SRandall Stewart r_fast_output: 1, /* Fast output is in progress we can skip the bulk of rack_output */
6785d8fd932SRandall Stewart r_fsb_inited: 1,
6795d8fd932SRandall Stewart r_rack_hw_rate_caps: 1,
6805d8fd932SRandall Stewart r_up_only: 1,
6815d8fd932SRandall Stewart r_via_fill_cw : 1,
682e18b97bdSRandall Stewart r_rcvpath_rtt_up : 1;
68389e560f4SRandall Stewart
684e022f2b0SRandall Stewart uint8_t rc_user_set_max_segs : 7, /* Socket option value Lock(a) */
685e022f2b0SRandall Stewart rc_fillcw_apply_discount;
6865d8fd932SRandall Stewart uint8_t rc_labc; /* Appropriate Byte Counting Value */
687963fb2adSRandall Stewart uint16_t forced_ack : 1,
688963fb2adSRandall Stewart rc_gp_incr : 1,
689963fb2adSRandall Stewart rc_gp_bwred : 1,
690963fb2adSRandall Stewart rc_gp_timely_inc_cnt : 3,
691963fb2adSRandall Stewart rc_gp_timely_dec_cnt : 3,
6925d8fd932SRandall Stewart r_use_labc_for_rec: 1,
693963fb2adSRandall Stewart rc_highly_buffered: 1, /* The path is highly buffered */
694963fb2adSRandall Stewart rc_dragged_bottom: 1,
695030434acSRandall Stewart rc_pace_dnd : 1, /* The pace do not disturb bit */
696e18b97bdSRandall Stewart rc_initial_ss_comp : 1,
6978d64b4b4SRandall Stewart rc_gp_filled : 1,
698030434acSRandall Stewart rc_hw_nobuf : 1;
699030434acSRandall Stewart uint8_t r_state : 4, /* Current rack state Lock(a) */
700030434acSRandall Stewart rc_catch_up : 1, /* catch up mode in dgp */
701030434acSRandall Stewart rc_hybrid_mode : 1, /* We are in hybrid mode */
702030434acSRandall Stewart rc_suspicious : 1, /* Suspect sacks have been given */
703030434acSRandall Stewart rc_new_rnd_needed: 1;
70489e560f4SRandall Stewart uint8_t rc_tmr_stopped : 7,
70589e560f4SRandall Stewart t_timers_stopped : 1;
706963fb2adSRandall Stewart uint8_t rc_enobuf : 7, /* count of enobufs on connection provides */
707963fb2adSRandall Stewart rc_on_min_to : 1;
70889e560f4SRandall Stewart uint8_t r_timer_override : 1, /* hpts override Lock(a) */
70989e560f4SRandall Stewart r_is_v6 : 1, /* V6 pcb Lock(a) */
71089e560f4SRandall Stewart rc_in_persist : 1,
71189e560f4SRandall Stewart rc_tlp_in_progress : 1,
71289e560f4SRandall Stewart rc_always_pace : 1, /* Socket option value Lock(a) */
713963fb2adSRandall Stewart rc_pace_to_cwnd : 1,
714963fb2adSRandall Stewart rc_pace_fill_if_rttin_range : 1,
7155d8fd932SRandall Stewart rc_srtt_measure_made : 1;
716963fb2adSRandall Stewart uint8_t app_limited_needs_set : 1,
717963fb2adSRandall Stewart use_fixed_rate : 1,
71835c7bb34SRandall Stewart rc_has_collapsed : 1,
719e18b97bdSRandall Stewart use_lesser_lt_bw : 1,
720e18b97bdSRandall Stewart cspr_is_fcc : 1,
721963fb2adSRandall Stewart rack_hdrw_pacing : 1, /* We are doing Hardware pacing */
722963fb2adSRandall Stewart rack_hdw_pace_ena : 1, /* Is hardware pacing enabled? */
723963fb2adSRandall Stewart rack_attempt_hdwr_pace : 1; /* Did we attempt hdwr pacing (if allowed) */
724963fb2adSRandall Stewart uint8_t rack_tlp_threshold_use : 3, /* only 1, 2 and 3 used so far */
725963fb2adSRandall Stewart rack_rec_nonrxt_use_cr : 1,
726963fb2adSRandall Stewart rack_enable_scwnd : 1,
727963fb2adSRandall Stewart rack_attempted_scwnd : 1,
728963fb2adSRandall Stewart rack_no_prr : 1,
729963fb2adSRandall Stewart rack_scwnd_is_idle : 1;
73089e560f4SRandall Stewart uint8_t rc_allow_data_af_clo: 1,
73189e560f4SRandall Stewart delayed_ack : 1,
73235c7bb34SRandall Stewart set_pacing_done_a_iw : 1,
733963fb2adSRandall Stewart use_rack_rr : 1,
7345e02b277SJonathan T. Looney alloc_limit_reported : 1,
735ea916b64SRandall Stewart rack_avail : 2,
736963fb2adSRandall Stewart rc_force_max_seg : 1;
7378d64b4b4SRandall Stewart uint8_t r_early : 1,
738963fb2adSRandall Stewart r_late : 1,
739963fb2adSRandall Stewart r_wanted_output: 1,
7408d64b4b4SRandall Stewart r_rr_config : 2,
74162ce18fcSRandall Stewart r_persist_lt_bw_off : 1,
74262ce18fcSRandall Stewart r_collapse_point_valid : 1,
743030434acSRandall Stewart dgp_on : 1;
744e18b97bdSRandall Stewart uint16_t rto_from_rec: 1,
745872164f5SRandall Stewart avail_bit: 4,
746e18b97bdSRandall Stewart pcm_in_progress: 1,
747e18b97bdSRandall Stewart pcm_needed: 1,
748e18b97bdSRandall Stewart rc_sendvars_notset : 1, /* Inside rack_init send variables (snd_max/una etc) were not set */
749963fb2adSRandall Stewart rc_gp_rtt_set : 1,
750963fb2adSRandall Stewart rc_gp_dyn_mul : 1,
751963fb2adSRandall Stewart rc_gp_saw_rec : 1,
752963fb2adSRandall Stewart rc_gp_saw_ca : 1,
753963fb2adSRandall Stewart rc_gp_saw_ss : 1,
754963fb2adSRandall Stewart rc_gp_no_rec_chg : 1,
755963fb2adSRandall Stewart in_probe_rtt : 1,
756963fb2adSRandall Stewart measure_saw_probe_rtt : 1;
75789e560f4SRandall Stewart /* Cache line 2 0x40 */
75889e560f4SRandall Stewart struct rack_control r_ctl;
75989e560f4SRandall Stewart } __aligned(CACHE_LINE_SIZE);
76089e560f4SRandall Stewart
761e18b97bdSRandall Stewart
762e18b97bdSRandall Stewart void rack_update_pcm_ack(struct tcp_rack *rack, int was_cumack,
763e18b97bdSRandall Stewart uint32_t ss, uint32_t es);
764e18b97bdSRandall Stewart
76589e560f4SRandall Stewart #endif
76689e560f4SRandall Stewart #endif
767