Skip to content

Commit 1b3878c

Browse files
nealcardwelldavem330
authored andcommitted
tcp: export tcp_tso_autosize() and parameterize minimum number of TSO segments
To allow congestion control modules to use the default TSO auto-sizing algorithm as one of the ingredients in their own decision about TSO sizing: 1) Export tcp_tso_autosize() so that CC modules can use it. 2) Change tcp_tso_autosize() to allow callers to specify a minimum number of segments per TSO skb, in case the congestion control module has a different notion of the best floor for TSO skbs for the connection right now. For very low-rate paths or policed connections it can be appropriate to use smaller TSO skbs. Signed-off-by: Van Jacobson <[email protected]> Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: Yuchung Cheng <[email protected]> Signed-off-by: Nandita Dukkipati <[email protected]> Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: Soheil Hassas Yeganeh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ed6e726 commit 1b3878c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

include/net/tcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,8 @@ __u32 cookie_v6_init_sequence(const struct sk_buff *skb, __u16 *mss);
533533
#endif
534534
/* tcp_output.c */
535535

536+
u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
537+
int min_tso_segs);
536538
void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss,
537539
int nonagle);
538540
bool tcp_may_send_now(struct sock *sk);

net/ipv4/tcp_output.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,8 @@ static bool tcp_nagle_check(bool partial, const struct tcp_sock *tp,
15491549
/* Return how many segs we'd like on a TSO packet,
15501550
* to send one TSO packet per ms
15511551
*/
1552-
static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now)
1552+
u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now,
1553+
int min_tso_segs)
15531554
{
15541555
u32 bytes, segs;
15551556

@@ -1561,10 +1562,11 @@ static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now)
15611562
* This preserves ACK clocking and is consistent
15621563
* with tcp_tso_should_defer() heuristic.
15631564
*/
1564-
segs = max_t(u32, bytes / mss_now, sysctl_tcp_min_tso_segs);
1565+
segs = max_t(u32, bytes / mss_now, min_tso_segs);
15651566

15661567
return min_t(u32, segs, sk->sk_gso_max_segs);
15671568
}
1569+
EXPORT_SYMBOL(tcp_tso_autosize);
15681570

15691571
/* Return the number of segments we want in the skb we are transmitting.
15701572
* See if congestion control module wants to decide; otherwise, autosize.
@@ -1574,7 +1576,8 @@ static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now)
15741576
const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
15751577
u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0;
15761578

1577-
return tso_segs ? : tcp_tso_autosize(sk, mss_now);
1579+
return tso_segs ? :
1580+
tcp_tso_autosize(sk, mss_now, sysctl_tcp_min_tso_segs);
15781581
}
15791582

15801583
/* Returns the portion of skb which can be sent right away */

0 commit comments

Comments
 (0)