Skip to content

Commit ed6e726

Browse files
nealcardwelldavem330
authored andcommitted
tcp: allow congestion control module to request TSO skb segment count
Add the tso_segs_goal() function in tcp_congestion_ops to allow the congestion control module to specify the number of segments that should be in a TSO skb sent by tcp_write_xmit() and tcp_xmit_retransmit_queue(). The congestion control module can either request a particular number of segments in TSO skb that we transmit, or return 0 if it doesn't care. This allows the upcoming BBR congestion control module to select small TSO skb sizes if the module detects that the bottleneck bandwidth is very low, or that the connection is policed to a low rate. 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 eb8329e commit ed6e726

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

include/net/tcp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,8 @@ struct tcp_congestion_ops {
913913
u32 (*undo_cwnd)(struct sock *sk);
914914
/* hook for packet ack accounting (optional) */
915915
void (*pkts_acked)(struct sock *sk, const struct ack_sample *sample);
916+
/* suggest number of segments for each skb to transmit (optional) */
917+
u32 (*tso_segs_goal)(struct sock *sk);
916918
/* get info for inet_diag (optional) */
917919
size_t (*get_info)(struct sock *sk, u32 ext, int *attr,
918920
union tcp_cc_info *info);

net/ipv4/tcp_output.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,6 +1566,17 @@ static u32 tcp_tso_autosize(const struct sock *sk, unsigned int mss_now)
15661566
return min_t(u32, segs, sk->sk_gso_max_segs);
15671567
}
15681568

1569+
/* Return the number of segments we want in the skb we are transmitting.
1570+
* See if congestion control module wants to decide; otherwise, autosize.
1571+
*/
1572+
static u32 tcp_tso_segs(struct sock *sk, unsigned int mss_now)
1573+
{
1574+
const struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;
1575+
u32 tso_segs = ca_ops->tso_segs_goal ? ca_ops->tso_segs_goal(sk) : 0;
1576+
1577+
return tso_segs ? : tcp_tso_autosize(sk, mss_now);
1578+
}
1579+
15691580
/* Returns the portion of skb which can be sent right away */
15701581
static unsigned int tcp_mss_split_point(const struct sock *sk,
15711582
const struct sk_buff *skb,
@@ -2061,7 +2072,7 @@ static bool tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle,
20612072
}
20622073
}
20632074

2064-
max_segs = tcp_tso_autosize(sk, mss_now);
2075+
max_segs = tcp_tso_segs(sk, mss_now);
20652076
while ((skb = tcp_send_head(sk))) {
20662077
unsigned int limit;
20672078

@@ -2778,7 +2789,7 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
27782789
last_lost = tp->snd_una;
27792790
}
27802791

2781-
max_segs = tcp_tso_autosize(sk, tcp_current_mss(sk));
2792+
max_segs = tcp_tso_segs(sk, tcp_current_mss(sk));
27822793
tcp_for_write_queue_from(skb, sk) {
27832794
__u8 sacked;
27842795
int segs;

0 commit comments

Comments
 (0)