From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: [PATCH net-next] net: sk_pacing_shift_update() helper Date: Tue, 12 Dec 2017 06:34:19 -0800 Message-ID: <1513089259.25033.51.camel@gmail.com> References: <1510281664.2849.143.camel@edumazet-glaptop3.roam.corp.google.com> <1510444452.2849.149.camel@edumazet-glaptop3.roam.corp.google.com> <5cc376a2-895e-68f6-cddd-1011b0fc26bd@nbd.name> <1511890429.16595.20.camel@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit Cc: netdev , Johannes Berg , Toke =?ISO-8859-1?Q?H=F8iland-J=F8rgensen?= , Kir Kolyshkin To: Felix Fietkau , David Miller Return-path: Received: from mail-pf0-f195.google.com ([209.85.192.195]:38353 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750731AbdLLOeW (ORCPT ); Tue, 12 Dec 2017 09:34:22 -0500 Received: by mail-pf0-f195.google.com with SMTP id u25so14331659pfg.5 for ; Tue, 12 Dec 2017 06:34:22 -0800 (PST) In-Reply-To: <1511890429.16595.20.camel@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Eric Dumazet In commit 3a9b76fd0db9 ("tcp: allow drivers to tweak TSQ logic") I gave a code sample to set sk->sk_pacing_shift that was not complete. Better add a helper that can be used by drivers without worries, and maybe amended in the future. A wifi driver might use it from its ndo_start_xmit() Following call would setup TCP to allow up to ~8ms of queued data per flow. sk_pacing_shift_update(skb->sk, 7); Signed-off-by: Eric Dumazet ---  include/net/sock.h |   11 +++++++++++  1 file changed, 11 insertions(+) diff --git a/include/net/sock.h b/include/net/sock.h index 9155da42269208b358df8535b14dfd3dba509365..9a9047268d375496bccc954d03ec20baf4177fd3 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2407,4 +2407,15 @@ static inline int sk_get_rmem0(const struct sock *sk, const struct proto *proto) return *proto->sysctl_rmem; } +/* Default TCP Small queue budget is ~1 ms of data (1sec >> 10) + * Some wifi drivers need to tweak it to get more chunks. + * They can use this helper from their ndo_start_xmit() + */ +static inline void sk_pacing_shift_update(struct sock *sk, int val) +{ + if (!sk || !sk_fullsock(sk) || sk->sk_pacing_shift == val) + return; + sk->sk_pacing_shift = val; +} + #endif /* _SOCK_H */