Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: tcp: split ack slow/fast events from cwnd_event

The congestion control ops "cwnd_event" currently supports
CA_EVENT_FAST_ACK and CA_EVENT_SLOW_ACK events (among others).
Both FAST and SLOW_ACK are only used by Westwood congestion
control algorithm.

This removes both flags from cwnd_event and adds a new
in_ack_event callback for this. The goal is to be able to
provide more detailed information about ACKs, such as whether
ECE flag was set, or whether the ACK resulted in a window
update.

It is required for DataCenter TCP (DCTCP) congestion control
algorithm as it makes a different choice depending on ECE being
set or not.

Joint work with Daniel Borkmann and Glenn Judd.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Glenn Judd <glenn.judd@morganstanley.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Florian Westphal and committed by
David S. Miller
7354c8c3 30e502a3

+32 -16
+6 -2
include/net/tcp.h
··· 763 763 CA_EVENT_CWND_RESTART, /* congestion window restart */ 764 764 CA_EVENT_COMPLETE_CWR, /* end of congestion recovery */ 765 765 CA_EVENT_LOSS, /* loss timeout */ 766 - CA_EVENT_FAST_ACK, /* in sequence ack */ 767 - CA_EVENT_SLOW_ACK, /* other ack */ 766 + }; 767 + 768 + enum tcp_ca_ack_event_flags { 769 + CA_ACK_SLOWPATH = (1 << 0), 768 770 }; 769 771 770 772 /* ··· 798 796 void (*set_state)(struct sock *sk, u8 new_state); 799 797 /* call when cwnd event occurs (optional) */ 800 798 void (*cwnd_event)(struct sock *sk, enum tcp_ca_event ev); 799 + /* call when ack arrives (optional) */ 800 + void (*in_ack_event)(struct sock *sk, u32 flags); 801 801 /* new value of cwnd after loss (optional) */ 802 802 u32 (*undo_cwnd)(struct sock *sk); 803 803 /* hook for packet ack accounting (optional) */
+10 -2
net/ipv4/tcp_input.c
··· 3362 3362 } 3363 3363 } 3364 3364 3365 + static inline void tcp_in_ack_event(struct sock *sk, u32 flags) 3366 + { 3367 + const struct inet_connection_sock *icsk = inet_csk(sk); 3368 + 3369 + if (icsk->icsk_ca_ops->in_ack_event) 3370 + icsk->icsk_ca_ops->in_ack_event(sk, flags); 3371 + } 3372 + 3365 3373 /* This routine deals with incoming acks, but not outgoing ones. */ 3366 3374 static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) 3367 3375 { ··· 3429 3421 tp->snd_una = ack; 3430 3422 flag |= FLAG_WIN_UPDATE; 3431 3423 3432 - tcp_ca_event(sk, CA_EVENT_FAST_ACK); 3424 + tcp_in_ack_event(sk, 0); 3433 3425 3434 3426 NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPHPACKS); 3435 3427 } else { ··· 3447 3439 if (TCP_ECN_rcv_ecn_echo(tp, tcp_hdr(skb))) 3448 3440 flag |= FLAG_ECE; 3449 3441 3450 - tcp_ca_event(sk, CA_EVENT_SLOW_ACK); 3442 + tcp_in_ack_event(sk, CA_ACK_SLOWPATH); 3451 3443 } 3452 3444 3453 3445 /* We passed data and got it acked, remove any soft error
+16 -12
net/ipv4/tcp_westwood.c
··· 220 220 return max_t(u32, (w->bw_est * w->rtt_min) / tp->mss_cache, 2); 221 221 } 222 222 223 + static void tcp_westwood_ack(struct sock *sk, u32 ack_flags) 224 + { 225 + if (ack_flags & CA_ACK_SLOWPATH) { 226 + struct westwood *w = inet_csk_ca(sk); 227 + 228 + westwood_update_window(sk); 229 + w->bk += westwood_acked_count(sk); 230 + 231 + update_rtt_min(w); 232 + return; 233 + } 234 + 235 + westwood_fast_bw(sk); 236 + } 237 + 223 238 static void tcp_westwood_event(struct sock *sk, enum tcp_ca_event event) 224 239 { 225 240 struct tcp_sock *tp = tcp_sk(sk); 226 241 struct westwood *w = inet_csk_ca(sk); 227 242 228 243 switch (event) { 229 - case CA_EVENT_FAST_ACK: 230 - westwood_fast_bw(sk); 231 - break; 232 - 233 244 case CA_EVENT_COMPLETE_CWR: 234 245 tp->snd_cwnd = tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk); 235 246 break; 236 - 237 247 case CA_EVENT_LOSS: 238 248 tp->snd_ssthresh = tcp_westwood_bw_rttmin(sk); 239 249 /* Update RTT_min when next ack arrives */ 240 250 w->reset_rtt_min = 1; 241 251 break; 242 - 243 - case CA_EVENT_SLOW_ACK: 244 - westwood_update_window(sk); 245 - w->bk += westwood_acked_count(sk); 246 - update_rtt_min(w); 247 - break; 248 - 249 252 default: 250 253 /* don't care */ 251 254 break; ··· 277 274 .ssthresh = tcp_reno_ssthresh, 278 275 .cong_avoid = tcp_reno_cong_avoid, 279 276 .cwnd_event = tcp_westwood_event, 277 + .in_ack_event = tcp_westwood_ack, 280 278 .get_info = tcp_westwood_info, 281 279 .pkts_acked = tcp_westwood_pkts_acked, 282 280