xref: /freebsd/sys/netinet/tcp_stacks/tcp_rack.h (revision 82ea1a07b4894bea20c61afbf702cc46f0711ead)
1 /*-
2  * Copyright (c) 2016-2020 Netflix, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  *
25  * $FreeBSD$
26  */
27 
28 #ifndef _NETINET_TCP_RACK_H_
29 #define _NETINET_TCP_RACK_H_
30 
31 #define RACK_ACKED	    0x0001/* The remote endpoint acked this */
32 #define RACK_TO_REXT	    0x0002/* A timeout occured on this sendmap entry */
33 #define RACK_DEFERRED	    0x0004/* We can't use this for RTT calc - not used */
34 #define RACK_OVERMAX	    0x0008/* We have more retran's then we can fit */
35 #define RACK_SACK_PASSED    0x0010/* A sack was done above this block */
36 #define RACK_WAS_SACKPASS   0x0020/* We retransmitted due to SACK pass */
37 #define RACK_HAS_FIN	    0x0040/* segment is sent with fin */
38 #define RACK_TLP	    0x0080/* segment sent as tail-loss-probe */
39 #define RACK_RWND_COLLAPSED 0x0100/* The peer collapsed the rwnd on the segment */
40 #define RACK_APP_LIMITED    0x0200/* We went app limited after this send */
41 #define RACK_WAS_ACKED	    0x0400/* a RTO undid the ack, but it already had a rtt calc done */
42 #define RACK_HAS_SYN	    0x0800/* SYN is on this guy */
43 #define RACK_SENT_W_DSACK   0x1000/* Sent with a dsack */
44 #define RACK_SENT_SP	    0x2000/* sent in slow path */
45 #define RACK_SENT_FP        0x4000/* sent in fast path */
46 #define RACK_HAD_PUSH	    0x8000/* Push was sent on original send */
47 #define RACK_NUM_OF_RETRANS 3
48 
49 #define RACK_INITIAL_RTO 1000000 /* 1 second in microseconds */
50 
51 #define RACK_REQ_AVG 3 	/* Must be less than 256 */
52 
53 struct rack_sendmap {
54 	TAILQ_ENTRY(rack_sendmap) r_tnext;	/* Time of transmit based next */
55 	uint32_t r_start;	/* Sequence number of the segment */
56 	uint32_t r_end;		/* End seq, this is 1 beyond actually */
57 	uint32_t r_rtr_bytes;	/* How many bytes have been retransmitted */
58 	uint16_t r_rtr_cnt;	/* Retran count, index this -1 to get time
59 				 * sent */
60 	uint16_t r_flags;	/* Flags as defined above */
61 	struct mbuf *m;
62 	uint32_t soff;
63 	uint32_t orig_m_len;
64 	uint32_t r_nseq_appl;	/* If this one is app limited, this is the nxt seq limited */
65 	uint8_t r_dupack;	/* Dup ack count */
66 	uint8_t r_in_tmap;	/* Flag to see if its in the r_tnext array */
67 	uint8_t r_limit_type;	/* is this entry counted against a limit? */
68 	uint8_t r_just_ret : 1, /* After sending, the next pkt was just returned, i.e. limited  */
69 		r_one_out_nr : 1,	/* Special case 1 outstanding and not in recovery */
70 		r_no_rtt_allowed : 1, /* No rtt measurement allowed */
71 		r_hw_tls : 1,
72 		r_avail : 4;
73 	uint64_t r_tim_lastsent[RACK_NUM_OF_RETRANS];
74 	uint64_t r_ack_arrival;	/* This is the time of ack-arrival (if SACK'd) */
75 	RB_ENTRY(rack_sendmap) r_next;		/* RB Tree next */
76 };
77 
78 struct deferred_opt_list {
79 	TAILQ_ENTRY(deferred_opt_list) next;
80 	int optname;
81 	uint64_t optval;
82 };
83 
84 /*
85  * Timestamps in the rack sendmap are now moving to be
86  * uint64_t's. This means that if you want a uint32_t
87  * usec timestamp (the old usecond timestamp) you simply have
88  * to cast it to uint32_t. The reason we do this is not for
89  * wrap, but we need to get back, at times, to the millisecond
90  * timestamp that is used in the TSTMP option. To do this we
91  * can use the rack_ts_to_msec() inline below which can take
92  * the 64bit ts and make into the correct timestamp millisecond
93  * wise. Thats not possible with the 32bit usecond timestamp since
94  * the seconds wrap too quickly to cover all bases.
95  *
96  * There are quite a few places in rack where I simply cast
97  * back to uint32_t and then end up using the TSTMP_XX()
98  * macros. This is ok, but we could do simple compares if
99  * we ever decided to move all of those variables to 64 bits
100  * as well.
101  */
102 
103 inline uint64_t
104 rack_to_usec_ts(struct timeval *tv)
105 {
106 	return ((tv->tv_sec * HPTS_USEC_IN_SEC) + tv->tv_usec);
107 }
108 
109 inline uint32_t
110 rack_ts_to_msec(uint64_t ts)
111 {
112 	return((uint32_t)(ts / HPTS_MSEC_IN_SEC));
113 }
114 
115 
116 RB_HEAD(rack_rb_tree_head, rack_sendmap);
117 TAILQ_HEAD(rack_head, rack_sendmap);
118 TAILQ_HEAD(def_opt_head, deferred_opt_list);
119 
120 /* Map change logging */
121 #define MAP_MERGE	0x01
122 #define MAP_SPLIT	0x02
123 #define MAP_NEW		0x03
124 #define MAP_SACK_M1	0x04
125 #define MAP_SACK_M2	0x05
126 #define MAP_SACK_M3	0x06
127 #define MAP_SACK_M4	0x07
128 #define MAP_SACK_M5	0x08
129 #define MAP_FREE	0x09
130 #define MAP_TRIM_HEAD	0x0a
131 
132 #define RACK_LIMIT_TYPE_SPLIT	1
133 
134 /*
135  * We use the rate sample structure to
136  * assist in single sack/ack rate and rtt
137  * calculation. In the future we will expand
138  * this in BBR to do forward rate sample
139  * b/w estimation.
140  */
141 #define RACK_RTT_EMPTY 0x00000001	/* Nothing yet stored in RTT's */
142 #define RACK_RTT_VALID 0x00000002	/* We have at least one valid RTT */
143 struct rack_rtt_sample {
144 	uint32_t rs_flags;
145 	uint32_t rs_rtt_lowest;
146 	uint32_t rs_rtt_highest;
147 	uint32_t rs_rtt_cnt;
148 	uint32_t rs_us_rtt;
149 	int32_t  confidence;
150 	uint64_t rs_rtt_tot;
151 	uint16_t rs_us_rtrcnt;
152 };
153 
154 #define RACK_LOG_TYPE_ACK	0x01
155 #define RACK_LOG_TYPE_OUT	0x02
156 #define RACK_LOG_TYPE_TO	0x03
157 #define RACK_LOG_TYPE_ALLOC     0x04
158 #define RACK_LOG_TYPE_FREE      0x05
159 
160 struct rack_log {
161 	union {
162 		struct rack_sendmap *rsm;	/* For alloc/free */
163 		uint64_t sb_acc;/* For out/ack or t-o */
164 	};
165 	uint32_t th_seq;
166 	uint32_t th_ack;
167 	uint32_t snd_una;
168 	uint32_t snd_nxt;	/* th_win for TYPE_ACK */
169 	uint32_t snd_max;
170 	uint32_t blk_start[4];
171 	uint32_t blk_end[4];
172 	uint8_t type;
173 	uint8_t n_sackblks;
174 	uint16_t len;		/* Timeout T3=1, TLP=2, RACK=3 */
175 };
176 
177 /*
178  * Magic numbers for logging timeout events if the
179  * logging is enabled.
180  */
181 #define RACK_TO_FRM_TMR  1
182 #define RACK_TO_FRM_TLP  2
183 #define RACK_TO_FRM_RACK 3
184 #define RACK_TO_FRM_KEEP 4
185 #define RACK_TO_FRM_PERSIST 5
186 #define RACK_TO_FRM_DELACK 6
187 
188 struct rack_opts_stats {
189 	uint64_t tcp_rack_tlp_reduce;
190 	uint64_t tcp_rack_pace_always;
191 	uint64_t tcp_rack_pace_reduce;
192 	uint64_t tcp_rack_max_seg;
193 	uint64_t tcp_rack_prr_sendalot;
194 	uint64_t tcp_rack_min_to;
195 	uint64_t tcp_rack_early_seg;
196 	uint64_t tcp_rack_reord_thresh;
197 	uint64_t tcp_rack_reord_fade;
198 	uint64_t tcp_rack_tlp_thresh;
199 	uint64_t tcp_rack_pkt_delay;
200 	uint64_t tcp_rack_tlp_inc_var;
201 	uint64_t tcp_tlp_use;
202 	uint64_t tcp_rack_idle_reduce;
203 	uint64_t tcp_rack_idle_reduce_high;
204 	uint64_t rack_no_timer_in_hpts;
205 	uint64_t tcp_rack_min_pace_seg;
206 	uint64_t tcp_rack_pace_rate_ca;
207 	uint64_t tcp_rack_rr;
208 	uint64_t tcp_rack_do_detection;
209 	uint64_t tcp_rack_rrr_no_conf_rate;
210 	uint64_t tcp_initial_rate;
211 	uint64_t tcp_initial_win;
212 	uint64_t tcp_hdwr_pacing;
213 	uint64_t tcp_gp_inc_ss;
214 	uint64_t tcp_gp_inc_ca;
215 	uint64_t tcp_gp_inc_rec;
216 	uint64_t tcp_rack_force_max_seg;
217 	uint64_t tcp_rack_pace_rate_ss;
218 	uint64_t tcp_rack_pace_rate_rec;
219 	/* Temp counters for dsack */
220 	uint64_t tcp_sack_path_1;
221 	uint64_t tcp_sack_path_2a;
222 	uint64_t tcp_sack_path_2b;
223 	uint64_t tcp_sack_path_3;
224 	uint64_t tcp_sack_path_4;
225 	/* non temp counters */
226 	uint64_t tcp_rack_scwnd;
227 	uint64_t tcp_rack_noprr;
228 	uint64_t tcp_rack_cfg_rate;
229 	uint64_t tcp_timely_dyn;
230 	uint64_t tcp_rack_mbufq;
231 	uint64_t tcp_fillcw;
232 	uint64_t tcp_npush;
233 	uint64_t tcp_lscwnd;
234 	uint64_t tcp_profile;
235 	uint64_t tcp_hdwr_rate_cap;
236 	uint64_t tcp_pacing_rate_cap;
237 	uint64_t tcp_pacing_up_only;
238 	uint64_t tcp_use_cmp_acks;
239 	uint64_t tcp_rack_abc_val;
240 	uint64_t tcp_rec_abc_val;
241 	uint64_t tcp_rack_measure_cnt;
242 	uint64_t tcp_rack_delayed_ack;
243 	uint64_t tcp_rack_rtt_use;
244 	uint64_t tcp_data_after_close;
245 	uint64_t tcp_defer_opt;
246 	uint64_t tcp_rack_fastrsm_hack;
247 	uint64_t tcp_rack_beta;
248 	uint64_t tcp_rack_beta_ecn;
249 	uint64_t tcp_rack_timer_slop;
250 };
251 
252 /* RTT shrink reasons */
253 #define RACK_RTTS_INIT     0
254 #define RACK_RTTS_NEWRTT   1
255 #define RACK_RTTS_EXITPROBE 2
256 #define RACK_RTTS_ENTERPROBE 3
257 #define RACK_RTTS_REACHTARGET 4
258 #define RACK_RTTS_SEEHBP 5
259 #define RACK_RTTS_NOBACKOFF 6
260 #define RACK_RTTS_SAFETY 7
261 
262 #define RACK_USE_BEG 1
263 #define RACK_USE_END 2
264 #define RACK_USE_END_OR_THACK 3
265 
266 #define TLP_USE_ID	1	/* Internet draft behavior */
267 #define TLP_USE_TWO_ONE 2	/* Use 2.1 behavior */
268 #define TLP_USE_TWO_TWO 3	/* Use 2.2 behavior */
269 #define RACK_MIN_BW 8000	/* 64kbps in Bps */
270 
271 #define MIN_GP_WIN 6	/* We need at least 6 MSS in a GP measurement */
272 #ifdef _KERNEL
273 #define RACK_OPTS_SIZE (sizeof(struct rack_opts_stats)/sizeof(uint64_t))
274 extern counter_u64_t rack_opts_arry[RACK_OPTS_SIZE];
275 #define RACK_OPTS_ADD(name, amm) counter_u64_add(rack_opts_arry[(offsetof(struct rack_opts_stats, name)/sizeof(uint64_t))], (amm))
276 #define RACK_OPTS_INC(name) RACK_OPTS_ADD(name, 1)
277 #endif
278 /*
279  * As we get each SACK we wade through the
280  * rc_map and mark off what is acked.
281  * We also increment rc_sacked as well.
282  *
283  * We also pay attention to missing entries
284  * based on the time and possibly mark them
285  * for retransmit. If we do and we are not already
286  * in recovery we enter recovery. In doing
287  * so we claer prr_delivered/holes_rxt and prr_sent_dur_rec.
288  * We also setup rc_next/rc_snd_nxt/rc_send_end so
289  * we will know where to send from. When not in
290  * recovery rc_next will be NULL and rc_snd_nxt should
291  * equal snd_max.
292  *
293  * Whenever we retransmit from recovery we increment
294  * rc_holes_rxt as we retran a block and mark it as retransmitted
295  * with the time it was sent. During non-recovery sending we
296  * add to our map and note the time down of any send expanding
297  * the rc_map at the tail and moving rc_snd_nxt up with snd_max.
298  *
299  * In recovery during SACK/ACK processing if a chunk has
300  * been retransmitted and it is now acked, we decrement rc_holes_rxt.
301  * When we retransmit from the scoreboard we use
302  * rc_next and rc_snd_nxt/rc_send_end to help us
303  * find what needs to be retran.
304  *
305  * To calculate pipe we simply take (snd_max - snd_una) + rc_holes_rxt
306  * This gets us the effect of RFC6675 pipe, counting twice for
307  * bytes retransmitted.
308  */
309 
310 #define TT_RACK_FR_TMR	0x2000
311 
312 /*
313  * Locking for the rack control block.
314  * a) Locked by INP_WLOCK
315  * b) Locked by the hpts-mutex
316  *
317  */
318 #define RACK_GP_HIST 4	/* How much goodput history do we maintain? */
319 
320 #define RACK_NUM_FSB_DEBUG 16
321 struct rack_fast_send_blk {
322 	uint32_t left_to_send;
323 	uint16_t tcp_ip_hdr_len;
324 	uint8_t tcp_flags;
325 	uint8_t hoplimit;
326 	uint8_t *tcp_ip_hdr;
327 	uint32_t recwin;
328 	uint32_t off;
329 	struct tcphdr *th;
330 	struct udphdr *udp;
331 	struct mbuf *m;
332 	uint32_t o_m_len;
333 	uint32_t rfo_apply_push : 1,
334 		hw_tls : 1,
335 		unused : 30;
336 };
337 
338 struct rack_control {
339 	/* Second cache line 0x40 from tcp_rack */
340 	struct rack_rb_tree_head rc_mtree; /* Tree of all segments Lock(a) */
341 	struct rack_head rc_tmap;	/* List in transmit order Lock(a) */
342 	struct rack_sendmap *rc_tlpsend;	/* Remembered place for
343 						 * tlp_sending Lock(a) */
344 	struct rack_sendmap *rc_resend;	/* something we have been asked to
345 					 * resend */
346 	struct rack_fast_send_blk fsb;	/* The fast-send block */
347 	uint32_t timer_slop;
348 	uint32_t input_pkt;
349 	uint32_t saved_input_pkt;
350 	uint32_t rc_hpts_flags;
351 	uint32_t rc_fixed_pacing_rate_ca;
352 	uint32_t rc_fixed_pacing_rate_rec;
353 	uint32_t rc_fixed_pacing_rate_ss;
354 	uint32_t cwnd_to_use;	/* The cwnd in use */
355 	uint32_t rc_timer_exp;	/* If a timer ticks of expiry */
356 	uint32_t rc_rack_min_rtt;	/* lowest RTT seen Lock(a) */
357 	uint32_t rc_rack_largest_cwnd;	/* Largest CWND we have seen Lock(a) */
358 
359 	/* Third Cache line 0x80 */
360 	struct rack_head rc_free;	/* Allocation array */
361 	uint64_t last_hw_bw_req;
362 	uint64_t crte_prev_rate;
363 	uint64_t bw_rate_cap;
364 	uint32_t rc_time_last_sent;	/* Time we last sent some data and
365 					 * logged it Lock(a). */
366 	uint32_t rc_reorder_ts;	/* Last time we saw reordering Lock(a) */
367 
368 	uint32_t rc_tlp_new_data;	/* we need to send new-data on a TLP
369 					 * Lock(a) */
370 	uint32_t rc_prr_out;	/* bytes sent during recovery Lock(a) */
371 
372 	uint32_t rc_prr_recovery_fs;	/* recovery fs point Lock(a) */
373 
374 	uint32_t rc_prr_sndcnt;	/* Prr sndcnt Lock(a) */
375 
376 	uint32_t rc_sacked;	/* Tot sacked on scoreboard Lock(a) */
377 	uint32_t xxx_rc_last_tlp_seq;	/* Last tlp sequence Lock(a) */
378 
379 	uint32_t rc_prr_delivered;	/* during recovery prr var Lock(a) */
380 	uint16_t rc_tlp_cnt_out;	/* count of times we have sent a TLP without new data */
381 	uint16_t xxx_rc_tlp_seg_send_cnt;	/* Number of times we have TLP sent
382 					 * rc_last_tlp_seq Lock(a) */
383 
384 	uint32_t rc_loss_count;	/* How many bytes have been retransmitted
385 				 * Lock(a) */
386 	uint32_t rc_reorder_fade;	/* Socket option value Lock(a) */
387 
388 	/* Forth cache line 0xc0  */
389 	/* Times */
390 
391 	uint32_t rc_rack_tmit_time;	/* Rack transmit time Lock(a) */
392 	uint32_t rc_holes_rxt;	/* Tot retraned from scoreboard Lock(a) */
393 
394 	/* Variables to track bad retransmits and recover */
395 	uint32_t rc_rsm_start;	/* RSM seq number we retransmitted Lock(a) */
396 	uint32_t rc_cwnd_at;	/* cwnd at the retransmit Lock(a) */
397 
398 	uint32_t rc_ssthresh_at;/* ssthresh at the retransmit Lock(a) */
399 	uint32_t rc_num_maps_alloced;	/* Number of map blocks (sacks) we
400 					 * have allocated */
401 	uint32_t rc_rcvtime;	/* When we last received data */
402 	uint32_t rc_num_split_allocs;	/* num split map entries allocated */
403 
404 	uint32_t rc_last_output_to;
405 	uint32_t rc_went_idle_time;
406 
407 	struct rack_sendmap *rc_sacklast;	/* sack remembered place
408 						 * Lock(a) */
409 
410 	struct rack_sendmap *rc_rsm_at_retran;	/* Debug variable kept for
411 						 * cache line alignment
412 						 * Lock(a) */
413 	struct rack_sendmap *rc_first_appl;	/* Pointer to first app limited */
414 	struct rack_sendmap *rc_end_appl;	/* Pointer to last app limited */
415 	/* Cache line split 0x100 */
416 	struct sack_filter rack_sf;
417 	/* Cache line split 0x140 */
418 	/* Flags for various things */
419 	uint32_t last_pacing_time;
420 	uint32_t rc_pace_max_segs;
421 	uint32_t rc_pace_min_segs;
422 	uint32_t rc_app_limited_cnt;
423 	uint16_t rack_per_of_gp_ss; /* 100 = 100%, so from 65536 = 655 x bw  */
424 	uint16_t rack_per_of_gp_ca; /* 100 = 100%, so from 65536 = 655 x bw  */
425 	uint16_t rack_per_of_gp_rec; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
426 	uint16_t rack_per_of_gp_probertt; /* 100 = 100%, so from 65536 = 655 x bw, 0=off */
427 	uint32_t rc_high_rwnd;
428 	uint32_t ack_count;
429 	uint32_t sack_count;
430 	uint32_t sack_noextra_move;
431 	uint32_t sack_moved_extra;
432 	struct rack_rtt_sample rack_rs;
433 	const struct tcp_hwrate_limit_table *crte;
434 	uint32_t rc_agg_early;
435 	uint32_t rc_agg_delayed;
436 	uint32_t rc_tlp_rxt_last_time;
437 	uint32_t rc_saved_cwnd;
438 	uint64_t rc_gp_output_ts; /* chg*/
439 	uint64_t rc_gp_cumack_ts; /* chg*/
440 	struct timeval act_rcv_time;
441 	struct timeval rc_last_time_decay;	/* SAD time decay happened here */
442 	uint64_t gp_bw;
443 	uint64_t init_rate;
444 #ifdef NETFLIX_SHARED_CWND
445 	struct shared_cwnd *rc_scw;
446 #endif
447 	uint64_t last_gp_comp_bw;
448 	uint64_t last_max_bw;	/* Our calculated max b/w last */
449 	struct time_filter_small rc_gp_min_rtt;
450 	struct def_opt_head opt_list;
451 	int32_t rc_rtt_diff;		/* Timely style rtt diff of our gp_srtt */
452 	uint32_t rc_gp_srtt;		/* Current GP srtt */
453 	uint32_t rc_prev_gp_srtt;	/* Previous RTT */
454 	uint32_t rc_entry_gp_rtt;	/* Entry to PRTT gp-rtt */
455 	uint32_t rc_loss_at_start;	/* At measurement window where was our lost value */
456 
457 	uint32_t forced_ack_ts;
458 	uint32_t rc_lower_rtt_us_cts;	/* Time our GP rtt was last lowered */
459 	uint32_t rc_time_probertt_entered;
460 	uint32_t rc_time_probertt_starts;
461 	uint32_t rc_lowest_us_rtt;
462 	uint32_t rc_highest_us_rtt;
463 	uint32_t rc_last_us_rtt;
464 	uint32_t rc_time_of_last_probertt;
465 	uint32_t rc_target_probertt_flight;
466 	uint32_t rc_probertt_sndmax_atexit;	/* Highest sent to in probe-rtt */
467 	uint32_t rc_cwnd_at_erec;
468 	uint32_t rc_ssthresh_at_erec;
469 	uint32_t dsack_byte_cnt;
470 	uint32_t retran_during_recovery;
471 	uint32_t rc_gp_lowrtt;			/* Lowest rtt seen during GPUT measurement */
472 	uint32_t rc_gp_high_rwnd;		/* Highest rwnd seen during GPUT measurement */
473 	uint32_t rc_snd_max_at_rto;	/* For non-sack when the RTO occured what was snd-max */
474 	uint32_t rc_out_at_rto;
475 	int32_t rc_scw_index;
476 	uint32_t rc_tlp_threshold;	/* Socket option value Lock(a) */
477 	uint32_t rc_last_timeout_snduna;
478 	uint32_t challenge_ack_ts;
479 	uint32_t challenge_ack_cnt;
480 	uint32_t rc_min_to;	/* Socket option value Lock(a) */
481 	uint32_t rc_pkt_delay;	/* Socket option value Lock(a) */
482 	struct newreno rc_saved_beta;	/*
483 					 * For newreno cc:
484 					 * rc_saved_cc are the values we have had
485 					 * set by the user, if pacing is not happening
486 					 * (i.e. its early and we have not turned on yet
487 					 *  or it was turned off). The minute pacing
488 					 * is turned on we pull out the values currently
489 					 * being used by newreno and replace them with
490 					 * these values, then save off the old values here,
491 					 * we also set the flag (if ecn_beta is set) to make
492 					 * new_reno do less of a backoff for ecn (think abe).
493 					 */
494 	uint16_t rc_early_recovery_segs;	/* Socket option value Lock(a) */
495 	uint16_t rc_reorder_shift;	/* Socket option value Lock(a) */
496 	uint8_t rc_no_push_at_mrtt;	/* No push when we exceed max rtt */
497 	uint8_t num_measurements;	/* Number of measurements (up to 0xff, we freeze at 0xff)  */
498 	uint8_t req_measurements;	/* How many measurements are required? */
499 	uint8_t rc_tlp_cwnd_reduce;	/* Socket option value Lock(a) */
500 	uint8_t rc_prr_sendalot;/* Socket option value Lock(a) */
501 	uint8_t rc_rate_sample_method;
502 	uint8_t rc_gp_hist_idx;
503 };
504 
505 #define RACK_TIMELY_CNT_BOOST 5	/* At 5th increase boost */
506 #define RACK_MINRTT_FILTER_TIM 10 /* Seconds */
507 
508 #ifdef _KERNEL
509 
510 struct tcp_rack {
511 	/* First cache line 0x00 */
512 	TAILQ_ENTRY(tcp_rack) r_hpts;	/* hptsi queue next Lock(b) */
513 	int32_t(*r_substate) (struct mbuf *, struct tcphdr *,
514 	    struct socket *, struct tcpcb *, struct tcpopt *,
515 	    int32_t, int32_t, uint32_t, int, int, uint8_t);	/* Lock(a) */
516 	struct tcpcb *rc_tp;	/* The tcpcb Lock(a) */
517 	struct inpcb *rc_inp;	/* The inpcb Lock(a) */
518 	uint8_t rc_free_cnt;	/* Number of free entries on the rc_free list
519 				 * Lock(a) */
520 	uint8_t client_bufferlvl;	/* 0 - 5 normaly, less than or at 2 means its real low */
521 	uint8_t no_prr_addback : 1,
522 		gp_ready : 1,
523 		defer_options: 1,
524 		fast_rsm_hack: 1,
525 		rc_ack_can_sendout_data: 1, /*
526 					     * If set it will override pacing restrictions on not sending
527 					     * data when the pacing timer is running. I.e. you set this
528 					     * and an ACK will send data. Default is off and its only used
529 					     * without pacing when we are doing 5G speed up for there
530 					     * ack filtering.
531 					     */
532 		rc_pacing_cc_set: 1,	     /*
533 					      * If we are pacing (pace_always=1) and we have reached the
534 					      * point where we start pacing (fixed or gp has reached its
535 					      * magic gp_ready state) this flag indicates we have set in
536 					      * values to effect CC's backoff's. If pacing is turned off
537 					      * then we must restore the values saved in rc_saved_beta,
538 					      * if its going to gp_ready we need to copy the values into
539 					      * the CC module and set our flags.
540 					      *
541 					      * Note this only happens if the cc name is newreno (CCALGONAME_NEWRENO).
542 					      */
543 
544 		avail :2;
545 	uint8_t avail_bytes;
546 	uint32_t rc_rack_rtt;	/* RACK-RTT Lock(a) */
547 	uint16_t r_mbuf_queue : 1,	/* Do we do mbuf queue for non-paced */
548 		 rtt_limit_mul : 4,	/* muliply this by low rtt */
549 		 r_limit_scw : 1,
550 		 r_must_retran : 1,	/* For non-sack customers we hit an RTO and new data should be resends */
551 		 r_use_cmp_ack: 1,	/* Do we use compressed acks */
552 		 r_ent_rec_ns: 1,	/* We entered recovery and have not sent */
553 		 r_might_revert: 1,	/* Flag to find out if we might need to revert */
554 		 r_fast_output: 1, 	/* Fast output is in progress we can skip the bulk of rack_output */
555 		 r_fsb_inited: 1,
556 		 r_rack_hw_rate_caps: 1,
557 		 r_up_only: 1,
558 		 r_via_fill_cw : 1,
559 		 r_fill_less_agg : 1;
560 
561 	uint8_t rc_user_set_max_segs;	/* Socket option value Lock(a) */
562 	uint8_t rc_labc;		/* Appropriate Byte Counting Value */
563 	uint16_t forced_ack : 1,
564 		rc_gp_incr : 1,
565 		rc_gp_bwred : 1,
566 		rc_gp_timely_inc_cnt : 3,
567 		rc_gp_timely_dec_cnt : 3,
568 		r_use_labc_for_rec: 1,
569 		rc_highly_buffered: 1,		/* The path is highly buffered */
570 		rc_dragged_bottom: 1,
571 		rc_dack_mode : 1,		/* Mac O/S emulation of d-ack */
572 		rc_dack_toggle : 1,		/* For Mac O/S emulation of d-ack */
573 		pacing_longer_than_rtt : 1,
574 		rc_gp_filled : 1;
575 	uint8_t r_state;	/* Current rack state Lock(a) */
576 	uint8_t rc_tmr_stopped : 7,
577 		t_timers_stopped : 1;
578 	uint8_t rc_enobuf : 7,	/* count of enobufs on connection provides */
579 		rc_on_min_to : 1;
580 	uint8_t r_timer_override : 1,	/* hpts override Lock(a) */
581 		r_is_v6 : 1,	/* V6 pcb Lock(a)  */
582 		rc_in_persist : 1,
583 		rc_tlp_in_progress : 1,
584 		rc_always_pace : 1,	/* Socket option value Lock(a) */
585 		rc_pace_to_cwnd : 1,
586 		rc_pace_fill_if_rttin_range : 1,
587 		rc_srtt_measure_made : 1;
588 	uint8_t app_limited_needs_set : 1,
589 		use_fixed_rate : 1,
590 		rc_has_collapsed : 1,
591 		r_rep_attack : 1,
592 		r_rep_reverse : 1,
593 		rack_hdrw_pacing : 1,  /* We are doing Hardware pacing */
594 		rack_hdw_pace_ena : 1, /* Is hardware pacing enabled? */
595 		rack_attempt_hdwr_pace : 1; /* Did we attempt hdwr pacing (if allowed) */
596 	uint8_t rack_tlp_threshold_use : 3,	/* only 1, 2 and 3 used so far */
597 		rack_rec_nonrxt_use_cr : 1,
598 		rack_enable_scwnd : 1,
599 		rack_attempted_scwnd : 1,
600 		rack_no_prr : 1,
601 		rack_scwnd_is_idle : 1;
602 	uint8_t rc_allow_data_af_clo: 1,
603 		delayed_ack : 1,
604 		set_pacing_done_a_iw : 1,
605 		use_rack_rr : 1,
606 		alloc_limit_reported : 1,
607 		sack_attack_disable : 1,
608 		do_detection : 1,
609 		rc_force_max_seg : 1;
610 	uint8_t rack_cwnd_limited : 1,
611 		r_early : 1,
612 		r_late : 1,
613 		r_running_early : 1,
614 		r_running_late : 1,
615 		r_wanted_output: 1,
616 		r_rr_config : 2;
617 	uint16_t rc_init_win : 8,
618 		rc_gp_rtt_set : 1,
619 		rc_gp_dyn_mul : 1,
620 		rc_gp_saw_rec : 1,
621 		rc_gp_saw_ca : 1,
622 		rc_gp_saw_ss : 1,
623 		rc_gp_no_rec_chg : 1,
624 		in_probe_rtt : 1,
625 		measure_saw_probe_rtt : 1;
626 	/* Cache line 2 0x40 */
627 	struct rack_control r_ctl;
628 }        __aligned(CACHE_LINE_SIZE);
629 
630 #endif
631 #endif
632