X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Ftcp%2Ftcp.h;h=52cc308871b320db66d2d89828aa8f26192f856a;hb=edf1da94dc099c6e2ab1d455ce8652fada3cdb04;hp=5e683f72dbd3f5291afa1c91fa0ca50d586402d5;hpb=c31dc31f84961033ecb6354811e0c360b6cf5f79;p=vpp.git diff --git a/src/vnet/tcp/tcp.h b/src/vnet/tcp/tcp.h index 5e683f72dbd..52cc308871b 100644 --- a/src/vnet/tcp/tcp.h +++ b/src/vnet/tcp/tcp.h @@ -82,7 +82,7 @@ typedef enum _tcp_timers TCP_N_TIMERS } tcp_timers_e; -typedef void (timer_expiration_handler) (u32 index); +typedef void (timer_expiration_handler) (u32 index, u32 thread_index); extern timer_expiration_handler tcp_timer_delack_handler; extern timer_expiration_handler tcp_timer_retransmit_handler; @@ -103,6 +103,29 @@ extern timer_expiration_handler tcp_timer_retransmit_syn_handler; #define TCP_RTO_BOFF_MAX 8 /* Max number of retries before reset */ #define TCP_ESTABLISH_TIME (60 * THZ) /* Connection establish timeout */ +/** Connection configuration flags */ +#define foreach_tcp_cfg_flag \ + _(RATE_SAMPLE, "Rate sampling") \ + _(NO_CSUM_OFFLOAD, "No csum offload") \ + _(NO_TSO, "TSO off") \ + _(TSO, "TSO") \ + +typedef enum tcp_cfg_flag_bits_ +{ +#define _(sym, str) TCP_CFG_F_##sym##_BIT, + foreach_tcp_cfg_flag +#undef _ + TCP_CFG_N_FLAG_BITS +} tcp_cfg_flag_bits_e; + +typedef enum tcp_cfg_flag_ +{ +#define _(sym, str) TCP_CFG_F_##sym = 1 << TCP_CFG_F_##sym##_BIT, + foreach_tcp_cfg_flag +#undef _ + TCP_CFG_N_FLAGS +} tcp_cfg_flags_e; + /** TCP connection flags */ #define foreach_tcp_connection_flag \ _(SNDACK, "Send ACK") \ @@ -113,16 +136,13 @@ extern timer_expiration_handler tcp_timer_retransmit_syn_handler; _(HALF_OPEN_DONE, "Half-open completed") \ _(FINPNDG, "FIN pending") \ _(RXT_PENDING, "Retransmit pending") \ - _(FRXT_FIRST, "Fast-retransmit first again") \ - _(DEQ_PENDING, "Pending dequeue acked") \ + _(FRXT_FIRST, "Retransmit first") \ + _(DEQ_PENDING, "Dequeue pending ") \ _(PSH_PENDING, "PSH pending") \ _(FINRCVD, "FIN received") \ - _(RATE_SAMPLE, "Conn does rate sampling") \ - _(TRACK_BURST, "Track burst") \ _(ZERO_RWND_SENT, "Zero RWND sent") \ - _(NO_CSUM_OFFLOAD, "No Checksum Offload") \ -typedef enum _tcp_connection_flag_bits +typedef enum tcp_connection_flag_bits_ { #define _(sym, str) TCP_CONN_##sym##_BIT, foreach_tcp_connection_flag @@ -130,7 +150,7 @@ typedef enum _tcp_connection_flag_bits TCP_CONN_N_FLAG_BITS } tcp_connection_flag_bits_e; -typedef enum _tcp_connection_flag +typedef enum tcp_connection_flag_ { #define _(sym, str) TCP_CONN_##sym = 1 << TCP_CONN_##sym##_BIT, foreach_tcp_connection_flag @@ -235,6 +255,8 @@ typedef enum tcp_bts_flags_ { TCP_BTS_IS_RXT = 1, TCP_BTS_IS_APP_LIMITED = 1 << 1, + TCP_BTS_IS_SACKED = 1 << 2, + TCP_BTS_IS_RXT_LOST = 1 << 3, } __clib_packed tcp_bts_flags_t; typedef struct tcp_bt_sample_ @@ -310,7 +332,7 @@ typedef struct _tcp_connection transport_connection_t connection; /**< Common transport data. First! */ u8 state; /**< TCP state as per tcp_state_t */ - u8 is_tso; /** is connection could use tso */ + u8 cfg_flags; /**< Connection configuration flags */ u16 flags; /**< Connection flags (see tcp_conn_flags_e) */ u32 timers[TCP_N_TIMERS]; /**< Timer handles into timer wheel */ @@ -372,7 +394,6 @@ typedef struct _tcp_connection u32 prr_start; /**< snd_una when prr starts */ u32 rxt_delivered; /**< Rxt bytes delivered during current cc event */ u32 rxt_head; /**< snd_una last time we re rxted the head */ - u32 prev_dsegs_out; /**< Number of dsegs after last ack */ u32 tsecr_last_ack; /**< Timestamp echoed to us in last healthy ACK */ u32 snd_congestion; /**< snd_una_max when congestion is detected */ u32 tx_fifo_size; /**< Tx fifo size. Used to constrain cwnd */ @@ -413,6 +434,7 @@ typedef struct _tcp_connection u32 last_fib_check; /**< Last time we checked fib route for peer */ u16 mss; /**< Our max seg size that includes options */ u32 timestamp_delta; /**< Offset for timestamp */ + u32 ipv6_flow_label; /**< flow label for ipv6 header */ } tcp_connection_t; /* *INDENT-OFF* */ @@ -451,6 +473,8 @@ struct _tcp_cc_algorithm #define tcp_in_cong_recovery(tc) ((tc)->flags & \ (TCP_CONN_FAST_RECOVERY | TCP_CONN_RECOVERY)) +#define tcp_csum_offload(tc) (!((tc)->cfg_flags & TCP_CFG_F_NO_CSUM_OFFLOAD)) + always_inline void tcp_cong_recovery_off (tcp_connection_t * tc) { @@ -487,9 +511,6 @@ typedef struct tcp_worker_ctx_ /** tx buffer free list */ u32 *tx_buffers; - /** tx frames for tcp 4/6 output nodes */ - vlib_frame_t *tx_frames[2]; - /** tx frames for ip 4/6 lookup nodes */ vlib_frame_t *ip_lookup_tx_frames[2]; @@ -534,6 +555,12 @@ typedef struct tcp_configuration_ /** Enable tx pacing for new connections */ u8 enable_tx_pacing; + /** Allow use of TSO whenever available */ + u8 allow_tso; + + /** Set if csum offloading is enabled */ + u8 csum_offload; + /** Default congestion control algorithm type */ tcp_cc_algorithm_type_e cc_algo; @@ -738,7 +765,10 @@ u8 *format_tcp_connection (u8 * s, va_list * args); always_inline tcp_connection_t * tcp_listener_get (u32 tli) { - return pool_elt_at_index (tcp_main.listener_pool, tli); + tcp_connection_t *tc = 0; + if (!pool_is_free_index (tcp_main.listener_pool, tli)) + tc = pool_elt_at_index (tcp_main.listener_pool, tli); + return tc; } always_inline tcp_connection_t * @@ -760,9 +790,9 @@ void tcp_send_reset (tcp_connection_t * tc); void tcp_send_syn (tcp_connection_t * tc); void tcp_send_synack (tcp_connection_t * tc); void tcp_send_fin (tcp_connection_t * tc); +void tcp_send_ack (tcp_connection_t * tc); void tcp_update_burst_snd_vars (tcp_connection_t * tc); void tcp_update_rto (tcp_connection_t * tc); -void tcp_flush_frame_to_output (tcp_worker_ctx_t * wrk, u8 is_ip4); void tcp_flush_frames_to_output (tcp_worker_ctx_t * wrk); void tcp_send_window_update_ack (tcp_connection_t * tc); @@ -798,7 +828,7 @@ void tcp_bt_flush_samples (tcp_connection_t * tc); * * @param tc tcp connection */ -void tcp_bt_track_tx (tcp_connection_t * tc); +void tcp_bt_track_tx (tcp_connection_t * tc, u32 len); /** * Track a tcp retransmission * @@ -829,6 +859,7 @@ void tcp_bt_check_app_limited (tcp_connection_t * tc); * @param bt byte tracker */ int tcp_bt_is_sane (tcp_byte_tracker_t * bt); +u8 *format_tcp_bt (u8 * s, va_list * args); always_inline u32 tcp_end_seq (tcp_header_t * th, u32 len) @@ -856,7 +887,8 @@ tcp_bytes_out (const tcp_connection_t * tc) if (tcp_opts_sack_permitted (&tc->rcv_opts)) return tc->sack_sb.sacked_bytes + tc->sack_sb.lost_bytes; else - return tc->rcv_dupacks * tc->snd_mss; + return clib_min (tc->rcv_dupacks * tc->snd_mss, + tc->snd_nxt - tc->snd_una); } /** @@ -1145,8 +1177,14 @@ tcp_persist_timer_set (tcp_connection_t * tc) always_inline void tcp_persist_timer_update (tcp_connection_t * tc) { - tcp_timer_update (tc, TCP_TIMER_PERSIST, - clib_max (tc->rto * TCP_TO_TIMER_TICK, 1)); + u32 interval; + + if (seq_leq (tc->snd_una, tc->snd_congestion + tc->burst_acked)) + interval = 1; + else + interval = clib_max (tc->rto * TCP_TO_TIMER_TICK, 1); + + tcp_timer_update (tc, TCP_TIMER_PERSIST, interval); } always_inline void