BPF List
 help / color / mirror / Atom feed
* [PATCH v4 net-next 1/1] tcp: allow congestion controls to override TSO autosizing
@ 2026-07-26 19:38 chia-yu.chang
  2026-07-27  8:02 ` Chia-Yu Chang (Nokia)
  2026-07-27 19:38 ` sashiko-bot
  0 siblings, 2 replies; 5+ messages in thread
From: chia-yu.chang @ 2026-07-26 19:38 UTC (permalink / raw)
  To: horms, dsahern, bpf, netdev, pabeni, jhs, kuba, stephen, davem,
	edumazet, andrew+netdev, donald.hunter, kuniyu, ij, ncardwell,
	koen.de_schepper, g.white, ingemar.s.johansson, mirja.kuehlewind,
	cheshire, rs.ietf, Jason_Livingood, vidhi_goel
  Cc: Chia-Yu Chang

From: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>

Today, congestion control algorithms influence TSO sizing through the
min_tso_segs() callback, which provides the minimum number of segments
used by tcp_tso_autosize(). However, Prague congestion control requires
finer control and needs to determine the final TSO segment count
directly rather than only providing a minimum bound.
 
This patch introduces TCP_CONG_EXACT_TSO_SEGS flag and extends
tcp_congestion_ops with an alternative tso_segs() callback. When the
flag is set, the congestion control algorithm supplies the final TSO
segment count directly and bypasses tcp_tso_autosize(). Otherwise, the
existing min_tso_segs() callback continues to provide the minimum
segment count used by tcp_tso_autosize().

This preserves the existing behavior of current congestion control
algorithms without introducing additional callbacks while enabling
future algorithms to implement custom TSO sizing policies.

Signed-off-by: Ilpo Järvinen <ij@kernel.org>
Signed-off-by: Chia-Yu Chang <chia-yu.chang@nokia-bell-labs.com>
---
 include/net/tcp.h     | 16 +++++++++++++---
 net/ipv4/tcp_output.c | 17 +++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index 2c5b889530b5..82cd82a19ff9 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1283,9 +1283,11 @@ enum tcp_ca_ack_event_flags {
 #define TCP_CONG_ECT_1_NEGOTIATION	BIT(3)
 /* Cannot fallback to RFC3168 during AccECN negotiation */
 #define TCP_CONG_NO_FALLBACK_RFC3168	BIT(4)
+/* Congestion cotnrol provides the exact TSO segment numbers  */
+#define TCP_CONG_EXACT_TSO_SEGS		BIT(5)
 #define TCP_CONG_MASK  (TCP_CONG_NON_RESTRICTED | TCP_CONG_NEEDS_ECN | \
 			TCP_CONG_NEEDS_ACCECN | TCP_CONG_ECT_1_NEGOTIATION | \
-			TCP_CONG_NO_FALLBACK_RFC3168)
+			TCP_CONG_NO_FALLBACK_RFC3168 | TCP_CONG_EXACT_TSO_SEGS)
 
 union tcp_cc_info;
 
@@ -1361,8 +1363,16 @@ struct tcp_congestion_ops {
 	/* hook for packet ack accounting (optional) */
 	void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
 
-	/* override sysctl_tcp_min_tso_segs (optional) */
-	u32 (*min_tso_segs)(struct sock *sk);
+	union {
+		/* Used when TCP_CONG_EXACT_TSO_SEGS is not set,
+		 * override sysctl_tcp_min_tso_segs (optional)
+		 */
+		u32 (*min_tso_segs)(struct sock *sk);
+		/* Used when TCP_CONG_EXACT_TSO_SEGS is set,
+		 * override tcp_tso_autosize (optional)
+		 */
+		u32 (*tso_segs)(struct sock *sk, u32 mss_now);
+	};
 
 	/* new value of cwnd after loss (required) */
 	u32  (*undo_cwnd)(struct sock *sk);
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index d7c1444b5e30..0de27a87c39e 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -2278,11 +2278,20 @@ static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now)
 	const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
 	u32 min_tso, tso_segs;
 
-	min_tso = ca_ops->min_tso_segs ?
-			ca_ops->min_tso_segs(sk) :
-			READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs);
+	min_tso = READ_ONCE(sock_net(sk)->ipv4.sysctl_tcp_min_tso_segs);
+
+	if (ca_ops->flags & TCP_CONG_EXACT_TSO_SEGS) {
+		if (WARN_ON_ONCE(!ca_ops->tso_segs))
+			tso_segs = tcp_tso_autosize(sk, mss_now, min_tso);
+		else
+			tso_segs = ca_ops->tso_segs(sk, mss_now);
+	} else {
+		if (ca_ops->min_tso_segs)
+			min_tso = ca_ops->min_tso_segs(sk);
+
+		tso_segs = tcp_tso_autosize(sk, mss_now, min_tso);
+	}
 
-	tso_segs = tcp_tso_autosize(sk, mss_now, min_tso);
 	return min_t(u32, tso_segs, sk->sk_gso_max_segs);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-27 23:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-26 19:38 [PATCH v4 net-next 1/1] tcp: allow congestion controls to override TSO autosizing chia-yu.chang
2026-07-27  8:02 ` Chia-Yu Chang (Nokia)
2026-07-27 23:08   ` Jakub Kicinski
2026-07-27 23:19   ` Emil Tsalapatis
2026-07-27 19:38 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox