+#define IS_TIMER_HZ_500MS(i) ((i) >= TCPT_PERSIST)
+#define IS_TIMER_HZ_100MS(i) ((i) >= TCPT_REXMT && (i) < TCPT_PERSIST)
+#define IS_TIMER_HZ_10MS(i) ((i) < TCPT_REXMT)
+
+struct tcptimerlist;
+
+struct tcptimerentry {
+ LIST_ENTRY(tcptimerentry) le; /* links for timer list */
+ uint32_t timer_start; /* tcp clock when the timer was started */
+ uint16_t index; /* index of lowest timer that needs to run first */
+ uint16_t mode; /* Bit-wise OR of timers that are active */
+ uint32_t runtime; /* deadline at which the first timer has to fire */
+};
+
+LIST_HEAD(timerlisthead, tcptimerentry);
+
+struct tcptimerlist {
+ struct timerlisthead lhead; /* head of the list */
+ lck_mtx_t *mtx; /* lock to protect the list */
+ lck_attr_t *mtx_attr; /* mutex attributes */
+ lck_grp_t *mtx_grp; /* mutex group definition */
+ lck_grp_attr_t *mtx_grp_attr; /* mutex group attributes */
+ thread_call_t call; /* call entry */
+ uint32_t runtime; /* time at which this list is going to run */
+ uint32_t entries; /* Number of entries on the list */
+ uint32_t maxentries; /* Max number of entries at any time */
+
+ /* Set desired mode when timer list running */
+ boolean_t running; /* Set when timer list is being processed */
+ boolean_t scheduled; /* set when the timer is scheduled */
+#define TCP_TIMERLIST_10MS_MODE 0x1
+#define TCP_TIMERLIST_100MS_MODE 0x2
+#define TCP_TIMERLIST_500MS_MODE 0x4
+ uint32_t mode; /* Current mode of the timer */
+ uint32_t pref_mode; /* Preferred mode set by a connection */
+ uint32_t pref_offset; /* Preferred offset set by a connection */
+ uint32_t idleruns; /* Number of times the list has been idle in fast mode */
+ struct tcptimerentry *next_te; /* next timer entry pointer to process */
+ u_int16_t probe_if_index; /* Interface index that needs to send probes */
+
+};
+
+/* number of idle runs allowed for TCP timer list in fast or quick modes */
+#define TCP_FASTMODE_IDLERUN_MAX 10
+
+/*
+ * Minimum retransmit timeout is set to 30ms. We add a slop of
+ * 200 ms to the retransmit value to account for processing
+ * variance and delayed ack. This extra 200ms will help to avoid
+ * spurious retransmits by taking into consideration the receivers
+ * that wait for delayed ack timer instead of generating an ack
+ * for every two packets.
+ *
+ * On a local link, the minimum retransmit timeout is 100ms and
+ * variance is set to 0. This will make the sender a little bit more
+ * aggressive on local link. When the connection is not established yet,
+ * there is no need to add an extra 200ms to retransmit timeout because
+ * the initial value is high (1s) and delayed ack is not a problem in
+ * that case.
+ */
+#define TCPTV_REXMTSLOP ( TCP_RETRANSHZ/5 ) /* extra 200 ms slop */
+
+/* macro to decide when retransmit slop (described above) should be added */
+#define TCP_ADD_REXMTSLOP(tp) (tp->t_state >= TCPS_ESTABLISHED)
+
+#define TCPT_RANGESET(tv, value, tvmin, tvmax, addslop) do { \
+ (tv) = ((addslop) ? tcp_rexmt_slop : 0) + (value); \