Lines Matching refs:tp
53 void tcp_mstamp_refresh(struct tcp_sock *tp) in tcp_mstamp_refresh() argument
57 tp->tcp_clock_cache = val; in tcp_mstamp_refresh()
58 tp->tcp_mstamp = div_u64(val, NSEC_PER_USEC); in tcp_mstamp_refresh()
68 struct tcp_sock *tp = tcp_sk(sk); in tcp_event_new_data_sent() local
69 unsigned int prior_packets = tp->packets_out; in tcp_event_new_data_sent()
71 WRITE_ONCE(tp->snd_nxt, TCP_SKB_CB(skb)->end_seq); in tcp_event_new_data_sent()
76 if (tp->highest_sack == NULL) in tcp_event_new_data_sent()
77 tp->highest_sack = skb; in tcp_event_new_data_sent()
79 tp->packets_out += tcp_skb_pcount(skb); in tcp_event_new_data_sent()
97 const struct tcp_sock *tp = tcp_sk(sk); in tcp_acceptable_seq() local
99 if (!before(tcp_wnd_end(tp), tp->snd_nxt) || in tcp_acceptable_seq()
100 (tp->rx_opt.wscale_ok && in tcp_acceptable_seq()
101 ((tp->snd_nxt - tcp_wnd_end(tp)) < (1 << tp->rx_opt.rcv_wscale)))) in tcp_acceptable_seq()
102 return tp->snd_nxt; in tcp_acceptable_seq()
104 return tcp_wnd_end(tp); in tcp_acceptable_seq()
123 struct tcp_sock *tp = tcp_sk(sk); in tcp_advertise_mss() local
125 int mss = tp->advmss; in tcp_advertise_mss()
132 tp->advmss = mss; in tcp_advertise_mss()
144 struct tcp_sock *tp = tcp_sk(sk); in tcp_cwnd_restart() local
145 u32 restart_cwnd = tcp_init_cwnd(tp, __sk_dst_get(sk)); in tcp_cwnd_restart()
146 u32 cwnd = tcp_snd_cwnd(tp); in tcp_cwnd_restart()
150 tp->snd_ssthresh = tcp_current_ssthresh(sk); in tcp_cwnd_restart()
155 tcp_snd_cwnd_set(tp, max(cwnd, restart_cwnd)); in tcp_cwnd_restart()
156 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_cwnd_restart()
157 tp->snd_cwnd_used = 0; in tcp_cwnd_restart()
161 static void tcp_event_data_sent(struct tcp_sock *tp, in tcp_event_data_sent() argument
167 if (tcp_packets_in_flight(tp) == 0) in tcp_event_data_sent()
170 tp->lsndtime = now; in tcp_event_data_sent()
182 struct tcp_sock *tp = tcp_sk(sk); in tcp_event_ack_sent() local
184 if (unlikely(tp->compressed_ack)) { in tcp_event_ack_sent()
186 tp->compressed_ack); in tcp_event_ack_sent()
187 tp->compressed_ack = 0; in tcp_event_ack_sent()
188 if (hrtimer_try_to_cancel(&tp->compressed_ack_timer) == 1) in tcp_event_ack_sent()
192 if (unlikely(rcv_nxt != tp->rcv_nxt)) in tcp_event_ack_sent()
258 struct tcp_sock *tp = tcp_sk(sk); in tcp_select_window() local
259 u32 old_win = tp->rcv_wnd; in tcp_select_window()
260 u32 cur_win = tcp_receive_window(tp); in tcp_select_window()
275 new_win = ALIGN(cur_win, 1 << tp->rx_opt.rcv_wscale); in tcp_select_window()
277 tp->rcv_wnd = new_win; in tcp_select_window()
278 tp->rcv_wup = tp->rcv_nxt; in tcp_select_window()
283 if (!tp->rx_opt.rcv_wscale && in tcp_select_window()
287 new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale)); in tcp_select_window()
290 new_win >>= tp->rx_opt.rcv_wscale; in tcp_select_window()
294 tp->pred_flags = 0; in tcp_select_window()
308 const struct tcp_sock *tp = tcp_sk(sk); in tcp_ecn_send_synack() local
311 if (!(tp->ecn_flags & TCP_ECN_OK)) in tcp_ecn_send_synack()
321 struct tcp_sock *tp = tcp_sk(sk); in tcp_ecn_send_syn() local
333 tp->ecn_flags = 0; in tcp_ecn_send_syn()
337 tp->ecn_flags = TCP_ECN_OK; in tcp_ecn_send_syn()
365 struct tcp_sock *tp = tcp_sk(sk); in tcp_ecn_send() local
367 if (tp->ecn_flags & TCP_ECN_OK) { in tcp_ecn_send()
370 !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { in tcp_ecn_send()
372 if (tp->ecn_flags & TCP_ECN_QUEUE_CWR) { in tcp_ecn_send()
373 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; in tcp_ecn_send()
381 if (tp->ecn_flags & TCP_ECN_DEMAND_CWR) in tcp_ecn_send()
404 static inline bool tcp_urg_mode(const struct tcp_sock *tp) in tcp_urg_mode() argument
406 return tp->snd_una != tp->snd_up; in tcp_urg_mode()
445 static void mptcp_options_write(__be32 *ptr, const struct tcp_sock *tp, in mptcp_options_write() argument
450 mptcp_write_options(ptr, tp, &opts->mptcp); in mptcp_options_write()
606 static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp, in tcp_options_write() argument
657 struct tcp_sack_block *sp = tp->rx_opt.dsack ? in tcp_options_write()
658 tp->duplicate_sack : tp->selective_acks; in tcp_options_write()
673 tp->rx_opt.dsack = 0; in tcp_options_write()
702 mptcp_options_write(ptr, tp, opts); in tcp_options_write()
705 static void smc_set_option(const struct tcp_sock *tp, in smc_set_option() argument
711 if (tp->syn_smc) { in smc_set_option()
721 static void smc_set_option_cond(const struct tcp_sock *tp, in smc_set_option_cond() argument
728 if (tp->syn_smc && ireq->smc_ok) { in smc_set_option_cond()
761 struct tcp_sock *tp = tcp_sk(sk); in tcp_syn_options() local
763 struct tcp_fastopen_request *fastopen = tp->fastopen_req; in tcp_syn_options()
768 rcu_access_pointer(tp->md5sig_info)) { in tcp_syn_options()
769 *md5 = tp->af_specific->md5_lookup(sk, sk); in tcp_syn_options()
791 opts->tsval = tcp_skb_timestamp(skb) + tp->tsoffset; in tcp_syn_options()
792 opts->tsecr = tp->rx_opt.ts_recent; in tcp_syn_options()
796 opts->ws = tp->rx_opt.rcv_wscale; in tcp_syn_options()
816 tp->syn_fastopen = 1; in tcp_syn_options()
817 tp->syn_fastopen_exp = fastopen->cookie.exp ? 1 : 0; in tcp_syn_options()
821 smc_set_option(tp, opts, &remaining); in tcp_syn_options()
915 struct tcp_sock *tp = tcp_sk(sk); in tcp_established_options() local
924 rcu_access_pointer(tp->md5sig_info)) { in tcp_established_options()
925 *md5 = tp->af_specific->md5_lookup(sk, sk); in tcp_established_options()
933 if (likely(tp->rx_opt.tstamp_ok)) { in tcp_established_options()
935 opts->tsval = skb ? tcp_skb_timestamp(skb) + tp->tsoffset : 0; in tcp_established_options()
936 opts->tsecr = tp->rx_opt.ts_recent; in tcp_established_options()
957 eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack; in tcp_established_options()
973 if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp, in tcp_established_options()
1011 struct tcp_sock *tp = tcp_sk(sk); in tcp_tsq_write() local
1013 if (tp->lost_out > tp->retrans_out && in tcp_tsq_write()
1014 tcp_snd_cwnd(tp) > tcp_packets_in_flight(tp)) { in tcp_tsq_write()
1015 tcp_mstamp_refresh(tp); in tcp_tsq_write()
1019 tcp_write_xmit(sk, tcp_current_mss(sk), tp->nonagle, in tcp_tsq_write()
1045 struct tcp_sock *tp; in tcp_tasklet_func() local
1053 tp = list_entry(q, struct tcp_sock, tsq_node); in tcp_tasklet_func()
1054 list_del(&tp->tsq_node); in tcp_tasklet_func()
1056 sk = (struct sock *)tp; in tcp_tasklet_func()
1138 struct tcp_sock *tp = tcp_sk(sk); in tcp_wfree() local
1172 list_add(&tp->tsq_node, &tsq->head); in tcp_wfree()
1187 struct tcp_sock *tp = container_of(timer, struct tcp_sock, pacing_timer); in tcp_pace_kick() local
1188 struct sock *sk = (struct sock *)tp; in tcp_pace_kick()
1199 struct tcp_sock *tp = tcp_sk(sk); in tcp_update_skb_after_send() local
1208 if (rate != ~0UL && rate && tp->data_segs_out >= 10) { in tcp_update_skb_after_send()
1210 u64 credit = tp->tcp_wstamp_ns - prior_wstamp; in tcp_update_skb_after_send()
1214 tp->tcp_wstamp_ns += len_ns; in tcp_update_skb_after_send()
1217 list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue); in tcp_update_skb_after_send()
1240 struct tcp_sock *tp; in __tcp_transmit_skb() local
1251 tp = tcp_sk(sk); in __tcp_transmit_skb()
1252 prior_wstamp = tp->tcp_wstamp_ns; in __tcp_transmit_skb()
1253 tp->tcp_wstamp_ns = max(tp->tcp_wstamp_ns, tp->tcp_clock_cache); in __tcp_transmit_skb()
1254 skb->skb_mstamp_ns = tp->tcp_wstamp_ns; in __tcp_transmit_skb()
1257 - tp->snd_una; in __tcp_transmit_skb()
1336 if (unlikely(tcp_urg_mode(tp) && before(tcb->seq, tp->snd_up))) { in __tcp_transmit_skb()
1337 if (before(tp->snd_up, tcb->seq + 0x10000)) { in __tcp_transmit_skb()
1338 th->urg_ptr = htons(tp->snd_up - tcb->seq); in __tcp_transmit_skb()
1340 } else if (after(tcb->seq + 0xFFFF, tp->snd_nxt)) { in __tcp_transmit_skb()
1354 th->window = htons(min(tp->rcv_wnd, 65535U)); in __tcp_transmit_skb()
1357 tcp_options_write((__be32 *)(th + 1), tp, &opts); in __tcp_transmit_skb()
1363 tp->af_specific->calc_md5_hash(opts.hash_location, in __tcp_transmit_skb()
1379 tcp_event_data_sent(tp, sk); in __tcp_transmit_skb()
1380 tp->data_segs_out += tcp_skb_pcount(skb); in __tcp_transmit_skb()
1381 tp->bytes_sent += skb->len - tcp_header_size; in __tcp_transmit_skb()
1384 if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq) in __tcp_transmit_skb()
1388 tp->segs_out += tcp_skb_pcount(skb); in __tcp_transmit_skb()
1400 tcp_add_tx_delay(skb, tp); in __tcp_transmit_skb()
1431 struct tcp_sock *tp = tcp_sk(sk); in tcp_queue_skb() local
1434 WRITE_ONCE(tp->write_seq, TCP_SKB_CB(skb)->end_seq); in tcp_queue_skb()
1461 struct tcp_sock *tp = tcp_sk(sk); in tcp_adjust_pcount() local
1463 tp->packets_out -= decr; in tcp_adjust_pcount()
1466 tp->sacked_out -= decr; in tcp_adjust_pcount()
1468 tp->retrans_out -= decr; in tcp_adjust_pcount()
1470 tp->lost_out -= decr; in tcp_adjust_pcount()
1473 if (tcp_is_reno(tp) && decr > 0) in tcp_adjust_pcount()
1474 tp->sacked_out -= min_t(u32, tp->sacked_out, decr); in tcp_adjust_pcount()
1476 if (tp->lost_skb_hint && in tcp_adjust_pcount()
1477 before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(tp->lost_skb_hint)->seq) && in tcp_adjust_pcount()
1479 tp->lost_cnt_hint -= decr; in tcp_adjust_pcount()
1481 tcp_verify_left_out(tp); in tcp_adjust_pcount()
1534 struct tcp_sock *tp = tcp_sk(sk); in tcp_fragment() local
1609 if (!before(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) { in tcp_fragment()
1696 const struct tcp_sock *tp = tcp_sk(sk); in __tcp_mtu_to_mss() local
1714 if (mss_now > tp->rx_opt.mss_clamp) in __tcp_mtu_to_mss()
1715 mss_now = tp->rx_opt.mss_clamp; in __tcp_mtu_to_mss()
1738 const struct tcp_sock *tp = tcp_sk(sk); in tcp_mss_to_mtu() local
1743 tp->tcp_header_len + in tcp_mss_to_mtu()
1761 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtup_init() local
1766 icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) + in tcp_mtup_init()
1799 struct tcp_sock *tp = tcp_sk(sk); in tcp_sync_mss() local
1807 mss_now = tcp_bound_to_half_wnd(tp, mss_now); in tcp_sync_mss()
1813 tp->mss_cache = mss_now; in tcp_sync_mss()
1824 const struct tcp_sock *tp = tcp_sk(sk); in tcp_current_mss() local
1831 mss_now = tp->mss_cache; in tcp_current_mss()
1845 if (header_len != tp->tcp_header_len) { in tcp_current_mss()
1846 int delta = (int) header_len - tp->tcp_header_len; in tcp_current_mss()
1859 struct tcp_sock *tp = tcp_sk(sk); in tcp_cwnd_application_limited() local
1864 u32 init_win = tcp_init_cwnd(tp, __sk_dst_get(sk)); in tcp_cwnd_application_limited()
1865 u32 win_used = max(tp->snd_cwnd_used, init_win); in tcp_cwnd_application_limited()
1866 if (win_used < tcp_snd_cwnd(tp)) { in tcp_cwnd_application_limited()
1867 tp->snd_ssthresh = tcp_current_ssthresh(sk); in tcp_cwnd_application_limited()
1868 tcp_snd_cwnd_set(tp, (tcp_snd_cwnd(tp) + win_used) >> 1); in tcp_cwnd_application_limited()
1870 tp->snd_cwnd_used = 0; in tcp_cwnd_application_limited()
1872 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_cwnd_application_limited()
1878 struct tcp_sock *tp = tcp_sk(sk); in tcp_cwnd_validate() local
1887 if (!before(tp->snd_una, tp->max_packets_seq) || in tcp_cwnd_validate()
1889 (!tp->is_cwnd_limited && in tcp_cwnd_validate()
1890 tp->packets_out > tp->max_packets_out)) { in tcp_cwnd_validate()
1891 tp->is_cwnd_limited = is_cwnd_limited; in tcp_cwnd_validate()
1892 tp->max_packets_out = tp->packets_out; in tcp_cwnd_validate()
1893 tp->max_packets_seq= tp->snd_nxt; in tcp_cwnd_validate()
1898 tp->snd_cwnd_used = 0; in tcp_cwnd_validate()
1899 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_cwnd_validate()
1902 if (tp->packets_out > tp->snd_cwnd_used) in tcp_cwnd_validate()
1903 tp->snd_cwnd_used = tp->packets_out; in tcp_cwnd_validate()
1906 (s32)(tcp_jiffies32 - tp->snd_cwnd_stamp) >= inet_csk(sk)->icsk_rto && in tcp_cwnd_validate()
1925 static bool tcp_minshall_check(const struct tcp_sock *tp) in tcp_minshall_check() argument
1927 return after(tp->snd_sml, tp->snd_una) && in tcp_minshall_check()
1928 !after(tp->snd_sml, tp->snd_nxt); in tcp_minshall_check()
1939 static void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss_now, in tcp_minshall_update() argument
1943 tp->snd_sml = TCP_SKB_CB(skb)->end_seq; in tcp_minshall_update()
1953 static bool tcp_nagle_check(bool partial, const struct tcp_sock *tp, in tcp_nagle_check() argument
1958 (!nonagle && tp->packets_out && tcp_minshall_check(tp))); in tcp_nagle_check()
2006 const struct tcp_sock *tp = tcp_sk(sk); in tcp_mss_split_point() local
2009 window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in tcp_mss_split_point()
2025 if (tcp_nagle_check(partial != 0, tp, nonagle)) in tcp_mss_split_point()
2034 static inline unsigned int tcp_cwnd_test(const struct tcp_sock *tp, in tcp_cwnd_test() argument
2044 in_flight = tcp_packets_in_flight(tp); in tcp_cwnd_test()
2045 cwnd = tcp_snd_cwnd(tp); in tcp_cwnd_test()
2075 static inline bool tcp_nagle_test(const struct tcp_sock *tp, const struct sk_buff *skb, in tcp_nagle_test() argument
2088 if (tcp_urg_mode(tp) || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) in tcp_nagle_test()
2091 if (!tcp_nagle_check(skb->len < cur_mss, tp, nonagle)) in tcp_nagle_test()
2098 static bool tcp_snd_wnd_test(const struct tcp_sock *tp, in tcp_snd_wnd_test() argument
2107 return !after(end_seq, tcp_wnd_end(tp)); in tcp_snd_wnd_test()
2182 struct tcp_sock *tp = tcp_sk(sk); in tcp_tso_should_defer() local
2195 delta = tp->tcp_clock_cache - tp->tcp_wstamp_ns - NSEC_PER_MSEC; in tcp_tso_should_defer()
2199 in_flight = tcp_packets_in_flight(tp); in tcp_tso_should_defer()
2202 BUG_ON(tcp_snd_cwnd(tp) <= in_flight); in tcp_tso_should_defer()
2204 send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in tcp_tso_should_defer()
2207 cong_win = (tcp_snd_cwnd(tp) - in_flight) * tp->mss_cache; in tcp_tso_should_defer()
2212 if (limit >= max_segs * tp->mss_cache) in tcp_tso_should_defer()
2221 u32 chunk = min(tp->snd_wnd, tcp_snd_cwnd(tp) * tp->mss_cache); in tcp_tso_should_defer()
2235 if (limit > tcp_max_tso_deferred_mss(tp) * tp->mss_cache) in tcp_tso_should_defer()
2243 delta = tp->tcp_clock_cache - head->tstamp; in tcp_tso_should_defer()
2245 if ((s64)(delta - (u64)NSEC_PER_USEC * (tp->srtt_us >> 4)) < 0) in tcp_tso_should_defer()
2280 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtu_check_reprobe() local
2292 icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + in tcp_mtu_check_reprobe()
2332 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtu_probe() local
2349 tcp_snd_cwnd(tp) < 11 || in tcp_mtu_probe()
2350 tp->rx_opt.num_sacks || tp->rx_opt.dsack)) in tcp_mtu_probe()
2360 size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache; in tcp_mtu_probe()
2376 if (tp->write_seq - tp->snd_nxt < size_needed) in tcp_mtu_probe()
2379 if (tp->snd_wnd < size_needed) in tcp_mtu_probe()
2381 if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp))) in tcp_mtu_probe()
2385 if (tcp_packets_in_flight(tp) + 2 > tcp_snd_cwnd(tp)) { in tcp_mtu_probe()
2386 if (!tcp_packets_in_flight(tp)) in tcp_mtu_probe()
2457 tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) - 1); in tcp_mtu_probe()
2461 tp->mtu_probe.probe_seq_start = TCP_SKB_CB(nskb)->seq; in tcp_mtu_probe()
2462 tp->mtu_probe.probe_seq_end = TCP_SKB_CB(nskb)->end_seq; in tcp_mtu_probe()
2472 struct tcp_sock *tp = tcp_sk(sk); in tcp_pacing_check() local
2477 if (tp->tcp_wstamp_ns <= tp->tcp_clock_cache) in tcp_pacing_check()
2480 if (!hrtimer_is_queued(&tp->pacing_timer)) { in tcp_pacing_check()
2481 hrtimer_start(&tp->pacing_timer, in tcp_pacing_check()
2482 ns_to_ktime(tp->tcp_wstamp_ns), in tcp_pacing_check()
2558 static void tcp_chrono_set(struct tcp_sock *tp, const enum tcp_chrono new) in tcp_chrono_set() argument
2561 enum tcp_chrono old = tp->chrono_type; in tcp_chrono_set()
2564 tp->chrono_stat[old - 1] += now - tp->chrono_start; in tcp_chrono_set()
2565 tp->chrono_start = now; in tcp_chrono_set()
2566 tp->chrono_type = new; in tcp_chrono_set()
2571 struct tcp_sock *tp = tcp_sk(sk); in tcp_chrono_start() local
2578 if (type > tp->chrono_type) in tcp_chrono_start()
2579 tcp_chrono_set(tp, type); in tcp_chrono_start()
2584 struct tcp_sock *tp = tcp_sk(sk); in tcp_chrono_stop() local
2595 tcp_chrono_set(tp, TCP_CHRONO_UNSPEC); in tcp_chrono_stop()
2596 else if (type == tp->chrono_type) in tcp_chrono_stop()
2597 tcp_chrono_set(tp, TCP_CHRONO_BUSY); in tcp_chrono_stop()
2617 struct tcp_sock *tp = tcp_sk(sk); in tcp_write_xmit() local
2627 tcp_mstamp_refresh(tp); in tcp_write_xmit()
2642 if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE) { in tcp_write_xmit()
2644 skb->skb_mstamp_ns = tp->tcp_wstamp_ns = tp->tcp_clock_cache; in tcp_write_xmit()
2645 list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue); in tcp_write_xmit()
2656 cwnd_quota = tcp_cwnd_test(tp, skb); in tcp_write_xmit()
2665 if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now))) { in tcp_write_xmit()
2671 if (unlikely(!tcp_nagle_test(tp, skb, mss_now, in tcp_write_xmit()
2683 if (tso_segs > 1 && !tcp_urg_mode(tp)) in tcp_write_xmit()
2714 tcp_minshall_update(tp, mss_now, skb); in tcp_write_xmit()
2726 is_cwnd_limited |= (tcp_packets_in_flight(tp) >= tcp_snd_cwnd(tp)); in tcp_write_xmit()
2732 tp->prr_out += sent_pkts; in tcp_write_xmit()
2739 return !tp->packets_out && !tcp_write_queue_empty(sk); in tcp_write_xmit()
2745 struct tcp_sock *tp = tcp_sk(sk); in tcp_schedule_loss_probe() local
2752 if (rcu_access_pointer(tp->fastopen_rsk)) in tcp_schedule_loss_probe()
2760 !tp->packets_out || !tcp_is_sack(tp) || in tcp_schedule_loss_probe()
2769 if (tp->srtt_us) { in tcp_schedule_loss_probe()
2770 timeout_us = tp->srtt_us >> 2; in tcp_schedule_loss_probe()
2771 if (tp->packets_out == 1) in tcp_schedule_loss_probe()
2815 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_loss_probe() local
2821 if (tp->tlp_high_seq) in tcp_send_loss_probe()
2824 tp->tlp_retrans = 0; in tcp_send_loss_probe()
2826 if (skb && tcp_snd_wnd_test(tp, skb, mss)) { in tcp_send_loss_probe()
2827 pcount = tp->packets_out; in tcp_send_loss_probe()
2829 if (tp->packets_out > pcount) in tcp_send_loss_probe()
2835 WARN_ONCE(tp->packets_out, in tcp_send_loss_probe()
2837 tp->packets_out, sk->sk_state, tcp_snd_cwnd(tp), mss); in tcp_send_loss_probe()
2863 tp->tlp_retrans = 1; in tcp_send_loss_probe()
2867 tp->tlp_high_seq = tp->snd_nxt; in tcp_send_loss_probe()
2962 struct tcp_sock *tp = tcp_sk(sk); in __tcp_select_window() local
2977 full_space = min_t(int, tp->window_clamp, allowed_space); in __tcp_select_window()
2988 tp->rcv_ssthresh = min(tp->rcv_ssthresh, in __tcp_select_window()
2989 4U * tp->advmss); in __tcp_select_window()
2994 free_space = round_down(free_space, 1 << tp->rx_opt.rcv_wscale); in __tcp_select_window()
3007 if (free_space > tp->rcv_ssthresh) in __tcp_select_window()
3008 free_space = tp->rcv_ssthresh; in __tcp_select_window()
3013 if (tp->rx_opt.rcv_wscale) { in __tcp_select_window()
3020 window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale)); in __tcp_select_window()
3022 window = tp->rcv_wnd; in __tcp_select_window()
3059 struct tcp_sock *tp = tcp_sk(sk); in tcp_collapse_retrans() local
3089 tcp_clear_retrans_hints_partial(tp); in tcp_collapse_retrans()
3090 if (next_skb == tp->retransmit_skb_hint) in tcp_collapse_retrans()
3091 tp->retransmit_skb_hint = skb; in tcp_collapse_retrans()
3121 struct tcp_sock *tp = tcp_sk(sk); in tcp_retrans_try_collapse() local
3147 if (after(TCP_SKB_CB(skb)->end_seq, tcp_wnd_end(tp))) in tcp_retrans_try_collapse()
3162 struct tcp_sock *tp = tcp_sk(sk); in __tcp_retransmit_skb() local
3175 if (before(TCP_SKB_CB(skb)->seq, tp->snd_una)) { in __tcp_retransmit_skb()
3181 if (unlikely(before(TCP_SKB_CB(skb)->end_seq, tp->snd_una))) { in __tcp_retransmit_skb()
3185 if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq)) in __tcp_retransmit_skb()
3193 avail_wnd = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in __tcp_retransmit_skb()
3201 if (TCP_SKB_CB(skb)->seq != tp->snd_una) in __tcp_retransmit_skb()
3239 tp->total_retrans += segs; in __tcp_retransmit_skb()
3240 tp->bytes_retrans += skb->len; in __tcp_retransmit_skb()
3261 tcp_update_skb_after_send(sk, skb, tp->tcp_wstamp_ns); in __tcp_retransmit_skb()
3273 if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RETRANS_CB_FLAG)) in __tcp_retransmit_skb()
3287 struct tcp_sock *tp = tcp_sk(sk); in tcp_retransmit_skb() local
3297 tp->retrans_out += tcp_skb_pcount(skb); in tcp_retransmit_skb()
3301 if (!tp->retrans_stamp) in tcp_retransmit_skb()
3302 tp->retrans_stamp = tcp_skb_timestamp(skb); in tcp_retransmit_skb()
3304 if (tp->undo_retrans < 0) in tcp_retransmit_skb()
3305 tp->undo_retrans = 0; in tcp_retransmit_skb()
3306 tp->undo_retrans += tcp_skb_pcount(skb); in tcp_retransmit_skb()
3319 struct tcp_sock *tp = tcp_sk(sk); in tcp_xmit_retransmit_queue() local
3324 if (!tp->packets_out) in tcp_xmit_retransmit_queue()
3328 skb = tp->retransmit_skb_hint ?: rtx_head; in tcp_xmit_retransmit_queue()
3339 tp->retransmit_skb_hint = skb; in tcp_xmit_retransmit_queue()
3341 segs = tcp_snd_cwnd(tp) - tcp_packets_in_flight(tp); in tcp_xmit_retransmit_queue()
3350 if (tp->retrans_out >= tp->lost_out) { in tcp_xmit_retransmit_queue()
3376 tp->prr_out += tcp_skb_pcount(skb); in tcp_xmit_retransmit_queue()
3418 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_fin() local
3432 tp->write_seq++; in tcp_send_fin()
3440 WRITE_ONCE(tp->snd_nxt, tp->snd_nxt + 1); in tcp_send_fin()
3452 tcp_init_nondata_skb(skb, tp->write_seq, in tcp_send_fin()
3549 const struct tcp_sock *tp = tcp_sk(sk); in tcp_make_synack() local
3585 mss = tcp_mss_clamp(tp, dst_metric_advmss(dst)); in tcp_make_synack()
3645 tcp_add_tx_delay(skb, tp); in tcp_make_synack()
3674 struct tcp_sock *tp = tcp_sk(sk); in tcp_connect_init() local
3681 tp->tcp_header_len = sizeof(struct tcphdr); in tcp_connect_init()
3683 tp->tcp_header_len += TCPOLEN_TSTAMP_ALIGNED; in tcp_connect_init()
3686 if (tp->af_specific->md5_lookup(sk, sk)) in tcp_connect_init()
3687 tp->tcp_header_len += TCPOLEN_MD5SIG_ALIGNED; in tcp_connect_init()
3691 if (tp->rx_opt.user_mss) in tcp_connect_init()
3692 tp->rx_opt.mss_clamp = tp->rx_opt.user_mss; in tcp_connect_init()
3693 tp->max_window = 0; in tcp_connect_init()
3699 if (!tp->window_clamp) in tcp_connect_init()
3700 tp->window_clamp = dst_metric(dst, RTAX_WINDOW); in tcp_connect_init()
3701 tp->advmss = tcp_mss_clamp(tp, dst_metric_advmss(dst)); in tcp_connect_init()
3707 (tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0)) in tcp_connect_init()
3708 tp->window_clamp = tcp_full_space(sk); in tcp_connect_init()
3715 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), in tcp_connect_init()
3716 &tp->rcv_wnd, in tcp_connect_init()
3717 &tp->window_clamp, in tcp_connect_init()
3722 tp->rx_opt.rcv_wscale = rcv_wscale; in tcp_connect_init()
3723 tp->rcv_ssthresh = tp->rcv_wnd; in tcp_connect_init()
3727 tp->snd_wnd = 0; in tcp_connect_init()
3728 tcp_init_wl(tp, 0); in tcp_connect_init()
3730 tp->snd_una = tp->write_seq; in tcp_connect_init()
3731 tp->snd_sml = tp->write_seq; in tcp_connect_init()
3732 tp->snd_up = tp->write_seq; in tcp_connect_init()
3733 WRITE_ONCE(tp->snd_nxt, tp->write_seq); in tcp_connect_init()
3735 if (likely(!tp->repair)) in tcp_connect_init()
3736 tp->rcv_nxt = 0; in tcp_connect_init()
3738 tp->rcv_tstamp = tcp_jiffies32; in tcp_connect_init()
3739 tp->rcv_wup = tp->rcv_nxt; in tcp_connect_init()
3740 WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); in tcp_connect_init()
3744 tcp_clear_retrans(tp); in tcp_connect_init()
3749 struct tcp_sock *tp = tcp_sk(sk); in tcp_connect_queue_skb() local
3756 WRITE_ONCE(tp->write_seq, tcb->end_seq); in tcp_connect_queue_skb()
3757 tp->packets_out += tcp_skb_pcount(skb); in tcp_connect_queue_skb()
3770 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_syn_data() local
3771 struct tcp_fastopen_request *fo = tp->fastopen_req; in tcp_send_syn_data()
3775 tp->rx_opt.mss_clamp = tp->advmss; /* If MSS is not cached */ in tcp_send_syn_data()
3776 if (!tcp_fastopen_cookie_check(sk, &tp->rx_opt.mss_clamp, &fo->cookie)) in tcp_send_syn_data()
3783 tp->rx_opt.mss_clamp = tcp_mss_clamp(tp, tp->rx_opt.mss_clamp); in tcp_send_syn_data()
3835 tp->syn_data = (fo->copied > 0); in tcp_send_syn_data()
3843 tp->packets_out -= tcp_skb_pcount(syn_data); in tcp_send_syn_data()
3851 tp->syn_fastopen = 0; in tcp_send_syn_data()
3860 struct tcp_sock *tp = tcp_sk(sk); in tcp_connect() local
3871 if (unlikely(tp->repair)) { in tcp_connect()
3880 tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN); in tcp_connect()
3881 tcp_mstamp_refresh(tp); in tcp_connect()
3882 tp->retrans_stamp = tcp_time_stamp(tp); in tcp_connect()
3888 err = tp->fastopen_req ? tcp_send_syn_data(sk, buff) : in tcp_connect()
3896 WRITE_ONCE(tp->snd_nxt, tp->write_seq); in tcp_connect()
3897 tp->pushed_seq = tp->write_seq; in tcp_connect()
3900 WRITE_ONCE(tp->snd_nxt, TCP_SKB_CB(buff)->seq); in tcp_connect()
3901 tp->pushed_seq = TCP_SKB_CB(buff)->seq; in tcp_connect()
3923 const struct tcp_sock *tp = tcp_sk(sk); in tcp_send_delayed_ack() local
3936 if (tp->srtt_us) { in tcp_send_delayed_ack()
3937 int rtt = max_t(int, usecs_to_jiffies(tp->srtt_us >> 3), in tcp_send_delayed_ack()
4029 struct tcp_sock *tp = tcp_sk(sk); in tcp_xmit_probe_skb() local
4044 tcp_init_nondata_skb(skb, tp->snd_una - !urgent, TCPHDR_ACK); in tcp_xmit_probe_skb()
4062 struct tcp_sock *tp = tcp_sk(sk); in tcp_write_wakeup() local
4069 if (skb && before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) { in tcp_write_wakeup()
4072 unsigned int seg_size = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in tcp_write_wakeup()
4074 if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) in tcp_write_wakeup()
4075 tp->pushed_seq = TCP_SKB_CB(skb)->end_seq; in tcp_write_wakeup()
4097 if (between(tp->snd_up, tp->snd_una + 1, tp->snd_una + 0xFFFF)) in tcp_write_wakeup()
4109 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_probe0() local
4116 if (tp->packets_out || tcp_write_queue_empty(sk)) { in tcp_send_probe0()