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
260 u32 old_win = tp->rcv_wnd; in tcp_select_window()
270 cur_win = tcp_receive_window(tp); in tcp_select_window()
280 if (!READ_ONCE(net->ipv4.sysctl_tcp_shrink_window) || !tp->rx_opt.rcv_wscale) { in tcp_select_window()
284 new_win = ALIGN(cur_win, 1 << tp->rx_opt.rcv_wscale); in tcp_select_window()
288 tp->rcv_wnd = new_win; in tcp_select_window()
289 tp->rcv_wup = tp->rcv_nxt; in tcp_select_window()
294 if (!tp->rx_opt.rcv_wscale && in tcp_select_window()
298 new_win = min(new_win, (65535U << tp->rx_opt.rcv_wscale)); in tcp_select_window()
301 new_win >>= tp->rx_opt.rcv_wscale; in tcp_select_window()
305 tp->pred_flags = 0; in tcp_select_window()
318 const struct tcp_sock *tp = tcp_sk(sk); in tcp_ecn_send_synack() local
321 if (!(tp->ecn_flags & TCP_ECN_OK)) in tcp_ecn_send_synack()
331 struct tcp_sock *tp = tcp_sk(sk); in tcp_ecn_send_syn() local
343 tp->ecn_flags = 0; in tcp_ecn_send_syn()
347 tp->ecn_flags = TCP_ECN_OK; in tcp_ecn_send_syn()
375 struct tcp_sock *tp = tcp_sk(sk); in tcp_ecn_send() local
377 if (tp->ecn_flags & TCP_ECN_OK) { in tcp_ecn_send()
380 !before(TCP_SKB_CB(skb)->seq, tp->snd_nxt)) { in tcp_ecn_send()
382 if (tp->ecn_flags & TCP_ECN_QUEUE_CWR) { in tcp_ecn_send()
383 tp->ecn_flags &= ~TCP_ECN_QUEUE_CWR; in tcp_ecn_send()
391 if (tp->ecn_flags & TCP_ECN_DEMAND_CWR) in tcp_ecn_send()
413 static inline bool tcp_urg_mode(const struct tcp_sock *tp) in tcp_urg_mode() argument
415 return tp->snd_una != tp->snd_up; in tcp_urg_mode()
455 struct tcp_sock *tp, in mptcp_options_write() argument
460 mptcp_write_options(th, ptr, tp, &opts->mptcp); in mptcp_options_write()
616 static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp, in tcp_options_write() argument
668 struct tcp_sack_block *sp = tp->rx_opt.dsack ? in tcp_options_write()
669 tp->duplicate_sack : tp->selective_acks; in tcp_options_write()
684 tp->rx_opt.dsack = 0; in tcp_options_write()
713 mptcp_options_write(th, ptr, tp, opts); in tcp_options_write()
716 static void smc_set_option(const struct tcp_sock *tp, in smc_set_option() argument
722 if (tp->syn_smc) { in smc_set_option()
732 static void smc_set_option_cond(const struct tcp_sock *tp, in smc_set_option_cond() argument
739 if (tp->syn_smc && ireq->smc_ok) { in smc_set_option_cond()
772 struct tcp_sock *tp = tcp_sk(sk); in tcp_syn_options() local
774 struct tcp_fastopen_request *fastopen = tp->fastopen_req; in tcp_syn_options()
779 rcu_access_pointer(tp->md5sig_info)) { in tcp_syn_options()
780 *md5 = tp->af_specific->md5_lookup(sk, sk); in tcp_syn_options()
802 opts->tsval = tcp_skb_timestamp(skb) + tp->tsoffset; in tcp_syn_options()
803 opts->tsecr = tp->rx_opt.ts_recent; in tcp_syn_options()
807 opts->ws = tp->rx_opt.rcv_wscale; in tcp_syn_options()
827 tp->syn_fastopen = 1; in tcp_syn_options()
828 tp->syn_fastopen_exp = fastopen->cookie.exp ? 1 : 0; in tcp_syn_options()
832 smc_set_option(tp, opts, &remaining); in tcp_syn_options()
926 struct tcp_sock *tp = tcp_sk(sk); in tcp_established_options() local
935 rcu_access_pointer(tp->md5sig_info)) { in tcp_established_options()
936 *md5 = tp->af_specific->md5_lookup(sk, sk); in tcp_established_options()
944 if (likely(tp->rx_opt.tstamp_ok)) { in tcp_established_options()
946 opts->tsval = skb ? tcp_skb_timestamp(skb) + tp->tsoffset : 0; in tcp_established_options()
947 opts->tsecr = tp->rx_opt.ts_recent; in tcp_established_options()
968 eff_sacks = tp->rx_opt.num_sacks + tp->rx_opt.dsack; in tcp_established_options()
984 if (unlikely(BPF_SOCK_OPS_TEST_FLAG(tp, in tcp_established_options()
1022 struct tcp_sock *tp = tcp_sk(sk); in tcp_tsq_write() local
1024 if (tp->lost_out > tp->retrans_out && in tcp_tsq_write()
1025 tcp_snd_cwnd(tp) > tcp_packets_in_flight(tp)) { in tcp_tsq_write()
1026 tcp_mstamp_refresh(tp); in tcp_tsq_write()
1030 tcp_write_xmit(sk, tcp_current_mss(sk), tp->nonagle, in tcp_tsq_write()
1056 struct tcp_sock *tp; in tcp_tasklet_func() local
1064 tp = list_entry(q, struct tcp_sock, tsq_node); in tcp_tasklet_func()
1065 list_del(&tp->tsq_node); in tcp_tasklet_func()
1067 sk = (struct sock *)tp; in tcp_tasklet_func()
1149 struct tcp_sock *tp = tcp_sk(sk); in tcp_wfree() local
1181 list_add(&tp->tsq_node, &tsq->head); in tcp_wfree()
1195 struct tcp_sock *tp = container_of(timer, struct tcp_sock, pacing_timer); in tcp_pace_kick() local
1196 struct sock *sk = (struct sock *)tp; in tcp_pace_kick()
1207 struct tcp_sock *tp = tcp_sk(sk); in tcp_update_skb_after_send() local
1216 if (rate != ~0UL && rate && tp->data_segs_out >= 10) { in tcp_update_skb_after_send()
1218 u64 credit = tp->tcp_wstamp_ns - prior_wstamp; in tcp_update_skb_after_send()
1222 tp->tcp_wstamp_ns += len_ns; in tcp_update_skb_after_send()
1225 list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue); in tcp_update_skb_after_send()
1248 struct tcp_sock *tp; in __tcp_transmit_skb() local
1259 tp = tcp_sk(sk); in __tcp_transmit_skb()
1260 prior_wstamp = tp->tcp_wstamp_ns; in __tcp_transmit_skb()
1261 tp->tcp_wstamp_ns = max(tp->tcp_wstamp_ns, tp->tcp_clock_cache); in __tcp_transmit_skb()
1262 skb_set_delivery_time(skb, tp->tcp_wstamp_ns, true); in __tcp_transmit_skb()
1349 if (unlikely(tcp_urg_mode(tp) && before(tcb->seq, tp->snd_up))) { in __tcp_transmit_skb()
1350 if (before(tp->snd_up, tcb->seq + 0x10000)) { in __tcp_transmit_skb()
1351 th->urg_ptr = htons(tp->snd_up - tcb->seq); in __tcp_transmit_skb()
1353 } else if (after(tcb->seq + 0xFFFF, tp->snd_nxt)) { in __tcp_transmit_skb()
1367 th->window = htons(min(tp->rcv_wnd, 65535U)); in __tcp_transmit_skb()
1370 tcp_options_write(th, tp, &opts); in __tcp_transmit_skb()
1376 tp->af_specific->calc_md5_hash(opts.hash_location, in __tcp_transmit_skb()
1392 tcp_event_data_sent(tp, sk); in __tcp_transmit_skb()
1393 tp->data_segs_out += tcp_skb_pcount(skb); in __tcp_transmit_skb()
1394 tp->bytes_sent += skb->len - tcp_header_size; in __tcp_transmit_skb()
1397 if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq) in __tcp_transmit_skb()
1401 tp->segs_out += tcp_skb_pcount(skb); in __tcp_transmit_skb()
1413 tcp_add_tx_delay(skb, tp); in __tcp_transmit_skb()
1444 struct tcp_sock *tp = tcp_sk(sk); in tcp_queue_skb() local
1447 WRITE_ONCE(tp->write_seq, TCP_SKB_CB(skb)->end_seq); in tcp_queue_skb()
1474 struct tcp_sock *tp = tcp_sk(sk); in tcp_adjust_pcount() local
1476 tp->packets_out -= decr; in tcp_adjust_pcount()
1479 tp->sacked_out -= decr; in tcp_adjust_pcount()
1481 tp->retrans_out -= decr; in tcp_adjust_pcount()
1483 tp->lost_out -= decr; in tcp_adjust_pcount()
1486 if (tcp_is_reno(tp) && decr > 0) in tcp_adjust_pcount()
1487 tp->sacked_out -= min_t(u32, tp->sacked_out, decr); in tcp_adjust_pcount()
1489 if (tp->lost_skb_hint && in tcp_adjust_pcount()
1490 before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(tp->lost_skb_hint)->seq) && in tcp_adjust_pcount()
1492 tp->lost_cnt_hint -= decr; in tcp_adjust_pcount()
1494 tcp_verify_left_out(tp); in tcp_adjust_pcount()
1547 struct tcp_sock *tp = tcp_sk(sk); in tcp_fragment() local
1618 if (!before(tp->snd_nxt, TCP_SKB_CB(buff)->end_seq)) { in tcp_fragment()
1697 const struct tcp_sock *tp = tcp_sk(sk); in __tcp_mtu_to_mss() local
1715 if (mss_now > tp->rx_opt.mss_clamp) in __tcp_mtu_to_mss()
1716 mss_now = tp->rx_opt.mss_clamp; in __tcp_mtu_to_mss()
1739 const struct tcp_sock *tp = tcp_sk(sk); in tcp_mss_to_mtu() local
1744 tp->tcp_header_len + in tcp_mss_to_mtu()
1762 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtup_init() local
1767 icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + sizeof(struct tcphdr) + in tcp_mtup_init()
1800 struct tcp_sock *tp = tcp_sk(sk); in tcp_sync_mss() local
1808 mss_now = tcp_bound_to_half_wnd(tp, mss_now); in tcp_sync_mss()
1814 tp->mss_cache = mss_now; in tcp_sync_mss()
1825 const struct tcp_sock *tp = tcp_sk(sk); in tcp_current_mss() local
1832 mss_now = tp->mss_cache; in tcp_current_mss()
1846 if (header_len != tp->tcp_header_len) { in tcp_current_mss()
1847 int delta = (int) header_len - tp->tcp_header_len; in tcp_current_mss()
1860 struct tcp_sock *tp = tcp_sk(sk); in tcp_cwnd_application_limited() local
1865 u32 init_win = tcp_init_cwnd(tp, __sk_dst_get(sk)); in tcp_cwnd_application_limited()
1866 u32 win_used = max(tp->snd_cwnd_used, init_win); in tcp_cwnd_application_limited()
1867 if (win_used < tcp_snd_cwnd(tp)) { in tcp_cwnd_application_limited()
1868 tp->snd_ssthresh = tcp_current_ssthresh(sk); in tcp_cwnd_application_limited()
1869 tcp_snd_cwnd_set(tp, (tcp_snd_cwnd(tp) + win_used) >> 1); in tcp_cwnd_application_limited()
1871 tp->snd_cwnd_used = 0; in tcp_cwnd_application_limited()
1873 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_cwnd_application_limited()
1879 struct tcp_sock *tp = tcp_sk(sk); in tcp_cwnd_validate() local
1888 if (!before(tp->snd_una, tp->cwnd_usage_seq) || in tcp_cwnd_validate()
1890 (!tp->is_cwnd_limited && in tcp_cwnd_validate()
1891 tp->packets_out > tp->max_packets_out)) { in tcp_cwnd_validate()
1892 tp->is_cwnd_limited = is_cwnd_limited; in tcp_cwnd_validate()
1893 tp->max_packets_out = tp->packets_out; in tcp_cwnd_validate()
1894 tp->cwnd_usage_seq = tp->snd_nxt; in tcp_cwnd_validate()
1899 tp->snd_cwnd_used = 0; in tcp_cwnd_validate()
1900 tp->snd_cwnd_stamp = tcp_jiffies32; in tcp_cwnd_validate()
1903 if (tp->packets_out > tp->snd_cwnd_used) in tcp_cwnd_validate()
1904 tp->snd_cwnd_used = tp->packets_out; in tcp_cwnd_validate()
1907 (s32)(tcp_jiffies32 - tp->snd_cwnd_stamp) >= inet_csk(sk)->icsk_rto && in tcp_cwnd_validate()
1926 static bool tcp_minshall_check(const struct tcp_sock *tp) in tcp_minshall_check() argument
1928 return after(tp->snd_sml, tp->snd_una) && in tcp_minshall_check()
1929 !after(tp->snd_sml, tp->snd_nxt); in tcp_minshall_check()
1940 static void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss_now, in tcp_minshall_update() argument
1944 tp->snd_sml = TCP_SKB_CB(skb)->end_seq; in tcp_minshall_update()
1954 static bool tcp_nagle_check(bool partial, const struct tcp_sock *tp, in tcp_nagle_check() argument
1959 (!nonagle && tp->packets_out && tcp_minshall_check(tp))); in tcp_nagle_check()
2016 const struct tcp_sock *tp = tcp_sk(sk); in tcp_mss_split_point() local
2019 window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in tcp_mss_split_point()
2035 if (tcp_nagle_check(partial != 0, tp, nonagle)) in tcp_mss_split_point()
2044 static inline unsigned int tcp_cwnd_test(const struct tcp_sock *tp, in tcp_cwnd_test() argument
2054 in_flight = tcp_packets_in_flight(tp); in tcp_cwnd_test()
2055 cwnd = tcp_snd_cwnd(tp); in tcp_cwnd_test()
2085 static inline bool tcp_nagle_test(const struct tcp_sock *tp, const struct sk_buff *skb, in tcp_nagle_test() argument
2098 if (tcp_urg_mode(tp) || (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) in tcp_nagle_test()
2101 if (!tcp_nagle_check(skb->len < cur_mss, tp, nonagle)) in tcp_nagle_test()
2108 static bool tcp_snd_wnd_test(const struct tcp_sock *tp, in tcp_snd_wnd_test() argument
2117 return !after(end_seq, tcp_wnd_end(tp)); in tcp_snd_wnd_test()
2186 struct tcp_sock *tp = tcp_sk(sk); in tcp_tso_should_defer() local
2199 delta = tp->tcp_clock_cache - tp->tcp_wstamp_ns - NSEC_PER_MSEC; in tcp_tso_should_defer()
2203 in_flight = tcp_packets_in_flight(tp); in tcp_tso_should_defer()
2206 BUG_ON(tcp_snd_cwnd(tp) <= in_flight); in tcp_tso_should_defer()
2208 send_win = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in tcp_tso_should_defer()
2211 cong_win = (tcp_snd_cwnd(tp) - in_flight) * tp->mss_cache; in tcp_tso_should_defer()
2216 if (limit >= max_segs * tp->mss_cache) in tcp_tso_should_defer()
2225 u32 chunk = min(tp->snd_wnd, tcp_snd_cwnd(tp) * tp->mss_cache); in tcp_tso_should_defer()
2239 if (limit > tcp_max_tso_deferred_mss(tp) * tp->mss_cache) in tcp_tso_should_defer()
2247 delta = tp->tcp_clock_cache - head->tstamp; in tcp_tso_should_defer()
2249 if ((s64)(delta - (u64)NSEC_PER_USEC * (tp->srtt_us >> 4)) < 0) in tcp_tso_should_defer()
2284 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtu_check_reprobe() local
2296 icsk->icsk_mtup.search_high = tp->rx_opt.mss_clamp + in tcp_mtu_check_reprobe()
2389 struct tcp_sock *tp = tcp_sk(sk); in tcp_mtu_probe() local
2406 tcp_snd_cwnd(tp) < 11 || in tcp_mtu_probe()
2407 tp->rx_opt.num_sacks || tp->rx_opt.dsack)) in tcp_mtu_probe()
2417 size_needed = probe_size + (tp->reordering + 1) * tp->mss_cache; in tcp_mtu_probe()
2433 if (tp->write_seq - tp->snd_nxt < size_needed) in tcp_mtu_probe()
2436 if (tp->snd_wnd < size_needed) in tcp_mtu_probe()
2438 if (after(tp->snd_nxt + size_needed, tcp_wnd_end(tp))) in tcp_mtu_probe()
2442 if (tcp_packets_in_flight(tp) + 2 > tcp_snd_cwnd(tp)) { in tcp_mtu_probe()
2443 if (!tcp_packets_in_flight(tp)) in tcp_mtu_probe()
2513 tcp_snd_cwnd_set(tp, tcp_snd_cwnd(tp) - 1); in tcp_mtu_probe()
2517 tp->mtu_probe.probe_seq_start = TCP_SKB_CB(nskb)->seq; in tcp_mtu_probe()
2518 tp->mtu_probe.probe_seq_end = TCP_SKB_CB(nskb)->end_seq; in tcp_mtu_probe()
2528 struct tcp_sock *tp = tcp_sk(sk); in tcp_pacing_check() local
2533 if (tp->tcp_wstamp_ns <= tp->tcp_clock_cache) in tcp_pacing_check()
2536 if (!hrtimer_is_queued(&tp->pacing_timer)) { in tcp_pacing_check()
2537 hrtimer_start(&tp->pacing_timer, in tcp_pacing_check()
2538 ns_to_ktime(tp->tcp_wstamp_ns), in tcp_pacing_check()
2614 static void tcp_chrono_set(struct tcp_sock *tp, const enum tcp_chrono new) in tcp_chrono_set() argument
2617 enum tcp_chrono old = tp->chrono_type; in tcp_chrono_set()
2620 tp->chrono_stat[old - 1] += now - tp->chrono_start; in tcp_chrono_set()
2621 tp->chrono_start = now; in tcp_chrono_set()
2622 tp->chrono_type = new; in tcp_chrono_set()
2627 struct tcp_sock *tp = tcp_sk(sk); in tcp_chrono_start() local
2634 if (type > tp->chrono_type) in tcp_chrono_start()
2635 tcp_chrono_set(tp, type); in tcp_chrono_start()
2640 struct tcp_sock *tp = tcp_sk(sk); in tcp_chrono_stop() local
2651 tcp_chrono_set(tp, TCP_CHRONO_UNSPEC); in tcp_chrono_stop()
2652 else if (type == tp->chrono_type) in tcp_chrono_stop()
2653 tcp_chrono_set(tp, TCP_CHRONO_BUSY); in tcp_chrono_stop()
2673 struct tcp_sock *tp = tcp_sk(sk); in tcp_write_xmit() local
2683 tcp_mstamp_refresh(tp); in tcp_write_xmit()
2698 if (unlikely(tp->repair) && tp->repair_queue == TCP_SEND_QUEUE) { in tcp_write_xmit()
2700 tp->tcp_wstamp_ns = tp->tcp_clock_cache; in tcp_write_xmit()
2701 skb_set_delivery_time(skb, tp->tcp_wstamp_ns, true); in tcp_write_xmit()
2702 list_move_tail(&skb->tcp_tsorted_anchor, &tp->tsorted_sent_queue); in tcp_write_xmit()
2713 cwnd_quota = tcp_cwnd_test(tp, skb); in tcp_write_xmit()
2722 if (unlikely(!tcp_snd_wnd_test(tp, skb, mss_now))) { in tcp_write_xmit()
2728 if (unlikely(!tcp_nagle_test(tp, skb, mss_now, in tcp_write_xmit()
2740 if (tso_segs > 1 && !tcp_urg_mode(tp)) in tcp_write_xmit()
2771 tcp_minshall_update(tp, mss_now, skb); in tcp_write_xmit()
2783 is_cwnd_limited |= (tcp_packets_in_flight(tp) >= tcp_snd_cwnd(tp)); in tcp_write_xmit()
2789 tp->prr_out += sent_pkts; in tcp_write_xmit()
2796 return !tp->packets_out && !tcp_write_queue_empty(sk); in tcp_write_xmit()
2802 struct tcp_sock *tp = tcp_sk(sk); in tcp_schedule_loss_probe() local
2809 if (rcu_access_pointer(tp->fastopen_rsk)) in tcp_schedule_loss_probe()
2817 !tp->packets_out || !tcp_is_sack(tp) || in tcp_schedule_loss_probe()
2826 if (tp->srtt_us) { in tcp_schedule_loss_probe()
2827 timeout_us = tp->srtt_us >> 2; in tcp_schedule_loss_probe()
2828 if (tp->packets_out == 1) in tcp_schedule_loss_probe()
2872 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_loss_probe() local
2878 if (tp->tlp_high_seq) in tcp_send_loss_probe()
2881 tp->tlp_retrans = 0; in tcp_send_loss_probe()
2883 if (skb && tcp_snd_wnd_test(tp, skb, mss)) { in tcp_send_loss_probe()
2884 pcount = tp->packets_out; in tcp_send_loss_probe()
2886 if (tp->packets_out > pcount) in tcp_send_loss_probe()
2892 WARN_ONCE(tp->packets_out, in tcp_send_loss_probe()
2894 tp->packets_out, sk->sk_state, tcp_snd_cwnd(tp), mss); in tcp_send_loss_probe()
2920 tp->tlp_retrans = 1; in tcp_send_loss_probe()
2924 tp->tlp_high_seq = tp->snd_nxt; in tcp_send_loss_probe()
3019 struct tcp_sock *tp = tcp_sk(sk); in __tcp_select_window() local
3035 full_space = min_t(int, tp->window_clamp, allowed_space); in __tcp_select_window()
3046 if (READ_ONCE(net->ipv4.sysctl_tcp_shrink_window) && tp->rx_opt.rcv_wscale) in __tcp_select_window()
3060 free_space = round_down(free_space, 1 << tp->rx_opt.rcv_wscale); in __tcp_select_window()
3073 if (free_space > tp->rcv_ssthresh) in __tcp_select_window()
3074 free_space = tp->rcv_ssthresh; in __tcp_select_window()
3079 if (tp->rx_opt.rcv_wscale) { in __tcp_select_window()
3086 window = ALIGN(window, (1 << tp->rx_opt.rcv_wscale)); in __tcp_select_window()
3088 window = tp->rcv_wnd; in __tcp_select_window()
3108 free_space = round_down(free_space, 1 << tp->rx_opt.rcv_wscale); in __tcp_select_window()
3118 free_space < (1 << tp->rx_opt.rcv_wscale)) in __tcp_select_window()
3122 if (free_space > tp->rcv_ssthresh) { in __tcp_select_window()
3123 free_space = tp->rcv_ssthresh; in __tcp_select_window()
3131 free_space = ALIGN(free_space, (1 << tp->rx_opt.rcv_wscale)); in __tcp_select_window()
3155 struct tcp_sock *tp = tcp_sk(sk); in tcp_collapse_retrans() local
3181 tcp_clear_retrans_hints_partial(tp); in tcp_collapse_retrans()
3182 if (next_skb == tp->retransmit_skb_hint) in tcp_collapse_retrans()
3183 tp->retransmit_skb_hint = skb; in tcp_collapse_retrans()
3213 struct tcp_sock *tp = tcp_sk(sk); in tcp_retrans_try_collapse() local
3239 if (after(TCP_SKB_CB(skb)->end_seq, tcp_wnd_end(tp))) in tcp_retrans_try_collapse()
3254 struct tcp_sock *tp = tcp_sk(sk); in __tcp_retransmit_skb() local
3267 if (before(TCP_SKB_CB(skb)->seq, tp->snd_una)) { in __tcp_retransmit_skb()
3273 if (unlikely(before(TCP_SKB_CB(skb)->end_seq, tp->snd_una))) { in __tcp_retransmit_skb()
3277 if (tcp_trim_head(sk, skb, tp->snd_una - TCP_SKB_CB(skb)->seq)) in __tcp_retransmit_skb()
3285 avail_wnd = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in __tcp_retransmit_skb()
3293 if (TCP_SKB_CB(skb)->seq != tp->snd_una) in __tcp_retransmit_skb()
3331 tp->total_retrans += segs; in __tcp_retransmit_skb()
3332 tp->bytes_retrans += skb->len; in __tcp_retransmit_skb()
3353 tcp_update_skb_after_send(sk, skb, tp->tcp_wstamp_ns); in __tcp_retransmit_skb()
3365 if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RETRANS_CB_FLAG)) in __tcp_retransmit_skb()
3379 struct tcp_sock *tp = tcp_sk(sk); in tcp_retransmit_skb() local
3389 tp->retrans_out += tcp_skb_pcount(skb); in tcp_retransmit_skb()
3393 if (!tp->retrans_stamp) in tcp_retransmit_skb()
3394 tp->retrans_stamp = tcp_skb_timestamp(skb); in tcp_retransmit_skb()
3396 if (tp->undo_retrans < 0) in tcp_retransmit_skb()
3397 tp->undo_retrans = 0; in tcp_retransmit_skb()
3398 tp->undo_retrans += tcp_skb_pcount(skb); in tcp_retransmit_skb()
3411 struct tcp_sock *tp = tcp_sk(sk); in tcp_xmit_retransmit_queue() local
3416 if (!tp->packets_out) in tcp_xmit_retransmit_queue()
3420 skb = tp->retransmit_skb_hint ?: rtx_head; in tcp_xmit_retransmit_queue()
3431 tp->retransmit_skb_hint = skb; in tcp_xmit_retransmit_queue()
3433 segs = tcp_snd_cwnd(tp) - tcp_packets_in_flight(tp); in tcp_xmit_retransmit_queue()
3442 if (tp->retrans_out >= tp->lost_out) { in tcp_xmit_retransmit_queue()
3468 tp->prr_out += tcp_skb_pcount(skb); in tcp_xmit_retransmit_queue()
3510 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_fin() local
3524 tp->write_seq++; in tcp_send_fin()
3532 WRITE_ONCE(tp->snd_nxt, tp->snd_nxt + 1); in tcp_send_fin()
3544 tcp_init_nondata_skb(skb, tp->write_seq, in tcp_send_fin()
3641 const struct tcp_sock *tp = tcp_sk(sk); in tcp_make_synack() local
3677 mss = tcp_mss_clamp(tp, dst_metric_advmss(dst)); in tcp_make_synack()
3738 tcp_add_tx_delay(skb, tp); in tcp_make_synack()
3767 struct tcp_sock *tp = tcp_sk(sk); in tcp_connect_init() local
3774 tp->tcp_header_len = sizeof(struct tcphdr); in tcp_connect_init()
3776 tp->tcp_header_len += TCPOLEN_TSTAMP_ALIGNED; in tcp_connect_init()
3779 if (tp->rx_opt.user_mss) in tcp_connect_init()
3780 tp->rx_opt.mss_clamp = tp->rx_opt.user_mss; in tcp_connect_init()
3781 tp->max_window = 0; in tcp_connect_init()
3787 if (!tp->window_clamp) in tcp_connect_init()
3788 tp->window_clamp = dst_metric(dst, RTAX_WINDOW); in tcp_connect_init()
3789 tp->advmss = tcp_mss_clamp(tp, dst_metric_advmss(dst)); in tcp_connect_init()
3795 (tp->window_clamp > tcp_full_space(sk) || tp->window_clamp == 0)) in tcp_connect_init()
3796 tp->window_clamp = tcp_full_space(sk); in tcp_connect_init()
3803 tp->advmss - (tp->rx_opt.ts_recent_stamp ? tp->tcp_header_len - sizeof(struct tcphdr) : 0), in tcp_connect_init()
3804 &tp->rcv_wnd, in tcp_connect_init()
3805 &tp->window_clamp, in tcp_connect_init()
3810 tp->rx_opt.rcv_wscale = rcv_wscale; in tcp_connect_init()
3811 tp->rcv_ssthresh = tp->rcv_wnd; in tcp_connect_init()
3815 tp->snd_wnd = 0; in tcp_connect_init()
3816 tcp_init_wl(tp, 0); in tcp_connect_init()
3818 tp->snd_una = tp->write_seq; in tcp_connect_init()
3819 tp->snd_sml = tp->write_seq; in tcp_connect_init()
3820 tp->snd_up = tp->write_seq; in tcp_connect_init()
3821 WRITE_ONCE(tp->snd_nxt, tp->write_seq); in tcp_connect_init()
3823 if (likely(!tp->repair)) in tcp_connect_init()
3824 tp->rcv_nxt = 0; in tcp_connect_init()
3826 tp->rcv_tstamp = tcp_jiffies32; in tcp_connect_init()
3827 tp->rcv_wup = tp->rcv_nxt; in tcp_connect_init()
3828 WRITE_ONCE(tp->copied_seq, tp->rcv_nxt); in tcp_connect_init()
3832 tcp_clear_retrans(tp); in tcp_connect_init()
3837 struct tcp_sock *tp = tcp_sk(sk); in tcp_connect_queue_skb() local
3844 WRITE_ONCE(tp->write_seq, tcb->end_seq); in tcp_connect_queue_skb()
3845 tp->packets_out += tcp_skb_pcount(skb); in tcp_connect_queue_skb()
3858 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_syn_data() local
3859 struct tcp_fastopen_request *fo = tp->fastopen_req; in tcp_send_syn_data()
3864 tp->rx_opt.mss_clamp = tp->advmss; /* If MSS is not cached */ in tcp_send_syn_data()
3865 if (!tcp_fastopen_cookie_check(sk, &tp->rx_opt.mss_clamp, &fo->cookie)) in tcp_send_syn_data()
3872 tp->rx_opt.mss_clamp = tcp_mss_clamp(tp, tp->rx_opt.mss_clamp); in tcp_send_syn_data()
3929 tp->syn_data = (fo->copied > 0); in tcp_send_syn_data()
3937 tp->packets_out -= tcp_skb_pcount(syn_data); in tcp_send_syn_data()
3945 tp->syn_fastopen = 0; in tcp_send_syn_data()
3954 struct tcp_sock *tp = tcp_sk(sk); in tcp_connect() local
3965 if (unlikely(tp->repair)) { in tcp_connect()
3974 tcp_init_nondata_skb(buff, tp->write_seq++, TCPHDR_SYN); in tcp_connect()
3975 tcp_mstamp_refresh(tp); in tcp_connect()
3976 tp->retrans_stamp = tcp_time_stamp(tp); in tcp_connect()
3982 err = tp->fastopen_req ? tcp_send_syn_data(sk, buff) : in tcp_connect()
3990 WRITE_ONCE(tp->snd_nxt, tp->write_seq); in tcp_connect()
3991 tp->pushed_seq = tp->write_seq; in tcp_connect()
3994 WRITE_ONCE(tp->snd_nxt, TCP_SKB_CB(buff)->seq); in tcp_connect()
3995 tp->pushed_seq = TCP_SKB_CB(buff)->seq; in tcp_connect()
4031 const struct tcp_sock *tp = tcp_sk(sk); in tcp_send_delayed_ack() local
4044 if (tp->srtt_us) { in tcp_send_delayed_ack()
4045 int rtt = max_t(int, usecs_to_jiffies(tp->srtt_us >> 3), in tcp_send_delayed_ack()
4137 struct tcp_sock *tp = tcp_sk(sk); in tcp_xmit_probe_skb() local
4152 tcp_init_nondata_skb(skb, tp->snd_una - !urgent, TCPHDR_ACK); in tcp_xmit_probe_skb()
4170 struct tcp_sock *tp = tcp_sk(sk); in tcp_write_wakeup() local
4177 if (skb && before(TCP_SKB_CB(skb)->seq, tcp_wnd_end(tp))) { in tcp_write_wakeup()
4180 unsigned int seg_size = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; in tcp_write_wakeup()
4182 if (before(tp->pushed_seq, TCP_SKB_CB(skb)->end_seq)) in tcp_write_wakeup()
4183 tp->pushed_seq = TCP_SKB_CB(skb)->end_seq; in tcp_write_wakeup()
4205 if (between(tp->snd_up, tp->snd_una + 1, tp->snd_una + 0xFFFF)) in tcp_write_wakeup()
4217 struct tcp_sock *tp = tcp_sk(sk); in tcp_send_probe0() local
4224 if (tp->packets_out || tcp_write_queue_empty(sk)) { in tcp_send_probe0()