{"id":825814,"url":"http://patchwork.ozlabs.org/api/1.2/patches/825814/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20171014114714.3694-2-natale.patriciello@gmail.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/1.2/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20171014114714.3694-2-natale.patriciello@gmail.com>","list_archive_url":null,"date":"2017-10-14T11:47:10","name":"[RFC,v2,1/5] tcp: Added a function to retrieve pacing timer","commit_ref":null,"pull_url":null,"state":"rfc","archived":true,"hash":"43822bcf31332e6771a425742467ddcd8b1bed74","submitter":{"id":72063,"url":"http://patchwork.ozlabs.org/api/1.2/people/72063/?format=json","name":"Natale Patriciello","email":"natale.patriciello@gmail.com"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/1.2/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20171014114714.3694-2-natale.patriciello@gmail.com/mbox/","series":[{"id":8182,"url":"http://patchwork.ozlabs.org/api/1.2/series/8182/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=8182","date":"2017-10-14T11:47:09","name":"TCP Wave","version":2,"mbox":"http://patchwork.ozlabs.org/series/8182/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/825814/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/825814/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"gUEiiAAe\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3yDjZ13dL3z9sNx\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 14 Oct 2017 22:50:01 +1100 (AEDT)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1753262AbdJNLtu (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 14 Oct 2017 07:49:50 -0400","from mail-wm0-f68.google.com ([74.125.82.68]:44720 \"EHLO\n\tmail-wm0-f68.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1753178AbdJNLtt (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Sat, 14 Oct 2017 07:49:49 -0400","by mail-wm0-f68.google.com with SMTP id 196so30680966wma.1\n\tfor <netdev@vger.kernel.org>; Sat, 14 Oct 2017 04:49:48 -0700 (PDT)","from localhost.localdomain (62.57.152.197.dyn.user.ono.com.\n\t[62.57.152.197])\n\tby smtp.gmail.com with ESMTPSA id 4sm4560337wmm.1.2017.10.14.04.49.46\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tSat, 14 Oct 2017 04:49:47 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=eI/KE62jQ/z11el8pB0g0QaZCgdobugqujuoDDQwvnk=;\n\tb=gUEiiAAeCPvhoZVxPQxFrCAPwjPjgQjQY92DQFUZ6wKYzF6iq4du/T4i4eRixe26IU\n\teH4VdapSoPKBxXUWgzWMuOlNrbG7njqeE7HkAogZGVLhEGCYOjvDe8AfQ3JSulSkgTe3\n\tWj4xChi8fLTxzKEfohmhIrEO/vzVuP47iy50kIBxSU8hzIljCRbMVuIVlzAhsGXl8Rgp\n\tB7EJ+50yL525Z/NHjcDPQhABJI9E6l38ay5ukggtHv7QYayH2OdqsGRHfJISYWFJviGB\n\tNiMj9aqAhmJQpKPiZeiMG7dy7L+lRR7EkpGJH3GR1wehWdS+wmXMfSdlp88T3e1EVKa5\n\tOSUA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=eI/KE62jQ/z11el8pB0g0QaZCgdobugqujuoDDQwvnk=;\n\tb=F3saizIGwuZWeH8iEZsBCmAwmksIyiecI/vCTo+LALmsasNbW6ryDxqvJt5gi8T8iX\n\tW/2B8MmXMufJuDkBVsa4qEJGQtlSzYkjx7mRweqwR2v3LCqw7dOMAtK7d/Nj4l3E2aVj\n\tfuLDLKSXJNoUGF8vHKaszqbTlAk8PohJoQRi9Pg04IpNKp6Nk6nqFohJnLFYUS2l7/al\n\tUfhbxRFc/FjhBW9Er6YTCXLGp0YVGBPVF67C2AUgSbXkwP7k73Vu4rZV8oZM8106MzLu\n\t99CO1cckbBfKyvQrKTRJWBcrkH5TBFYkA4XjMZP5wlX7kwuhYasyguZy71/yHUWfhyKM\n\tc24Q==","X-Gm-Message-State":"AMCzsaXRAfDDp5UP36Ma311SGurVw6RQ0THJFAyPANFT0bNZ8z0hYVEs\n\ttd1StxjgYfP6UrTULk7j20M=","X-Google-Smtp-Source":"ABhQp+TZ7XvSOHNJNVU0n0rtSlkJO0KhLn77Nw5euofbZ/nd0KMjiwPpgB7s/5LbyswHeR9vlaUUkA==","X-Received":"by 10.28.146.20 with SMTP id u20mr3874771wmd.49.1507981787989;\n\tSat, 14 Oct 2017 04:49:47 -0700 (PDT)","From":"Natale Patriciello <natale.patriciello@gmail.com>","To":"\"David S . Miller\" <davem@davemloft.net>,\n\tEric Dumazet <eric.dumazet@gmail.com>","Cc":"netdev <netdev@vger.kernel.org>, Ahmed Said <ahmed.said@uniroma2.it>,\n\tNatale Patriciello <natale.patriciello@gmail.com>,\n\tFrancesco Zampognaro <zampognaro@ing.uniroma2.it>,\n\tCesare Roseti <roseti@ing.uniroma2.it>","Subject":"[RFC PATCH v2 1/5] tcp: Added a function to retrieve pacing timer","Date":"Sat, 14 Oct 2017 13:47:10 +0200","Message-Id":"<20171014114714.3694-2-natale.patriciello@gmail.com>","X-Mailer":"git-send-email 2.14.2","In-Reply-To":"<20171014114714.3694-1-natale.patriciello@gmail.com>","References":"<20171014114714.3694-1-natale.patriciello@gmail.com>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"Allow congestion control modules to set a custom pacing time between\nthe transmission of segments.\nMoreover, it is assumed that the time returned by the congestion module\nin the past is firm, until the timer expires; therefore, do not re-start\nthe timer if it is already active.\n\nSigned-off-by: Natale Patriciello <natale.patriciello@gmail.com>\n---\n include/net/tcp.h     |  2 ++\n net/ipv4/tcp_output.c | 36 +++++++++++++++++++++++++-----------\n 2 files changed, 27 insertions(+), 11 deletions(-)","diff":"diff --git a/include/net/tcp.h b/include/net/tcp.h\nindex 89974c5286d8..42c7aa96c4cf 100644\n--- a/include/net/tcp.h\n+++ b/include/net/tcp.h\n@@ -1015,6 +1015,8 @@ struct tcp_congestion_ops {\n \t/* get info for inet_diag (optional) */\n \tsize_t (*get_info)(struct sock *sk, u32 ext, int *attr,\n \t\t\t   union tcp_cc_info *info);\n+\t/* get the expiration time for the pacing timer (optional) */\n+\tu64 (*get_pacing_time)(struct sock *sk);\n \n \tchar \t\tname[TCP_CA_NAME_MAX];\n \tstruct module \t*owner;\ndiff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c\nindex 0bc9e46a5369..ec5977156c26 100644\n--- a/net/ipv4/tcp_output.c\n+++ b/net/ipv4/tcp_output.c\n@@ -950,22 +950,36 @@ static bool tcp_needs_internal_pacing(const struct sock *sk)\n \treturn smp_load_acquire(&sk->sk_pacing_status) == SK_PACING_NEEDED;\n }\n \n+static bool tcp_pacing_timer_check(const struct sock *sk)\n+{\n+\treturn hrtimer_active(&tcp_sk(sk)->pacing_timer);\n+}\n+\n static void tcp_internal_pacing(struct sock *sk, const struct sk_buff *skb)\n {\n+\tconst struct tcp_congestion_ops *ca_ops = inet_csk(sk)->icsk_ca_ops;\n \tu64 len_ns;\n-\tu32 rate;\n \n \tif (!tcp_needs_internal_pacing(sk))\n \t\treturn;\n-\trate = sk->sk_pacing_rate;\n-\tif (!rate || rate == ~0U)\n-\t\treturn;\n-\n-\t/* Should account for header sizes as sch_fq does,\n-\t * but lets make things simple.\n-\t */\n-\tlen_ns = (u64)skb->len * NSEC_PER_SEC;\n-\tdo_div(len_ns, rate);\n+\n+\tif (ca_ops && ca_ops->get_pacing_time) {\n+\t\tif (tcp_pacing_timer_check(sk))\n+\t\t\treturn;\n+\n+\t\tlen_ns = ca_ops->get_pacing_time(sk);\n+\t} else {\n+\t\tu32 rate = sk->sk_pacing_rate;\n+\n+\t\tif (!rate || rate == ~0U)\n+\t\t\treturn;\n+\n+\t\t/* Should account for header sizes as sch_fq does,\n+\t\t * but lets make things simple.\n+\t\t */\n+\t\tlen_ns = (u64)skb->len * NSEC_PER_SEC;\n+\t\tdo_div(len_ns, rate);\n+\t}\n \thrtimer_start(&tcp_sk(sk)->pacing_timer,\n \t\t      ktime_add_ns(ktime_get(), len_ns),\n \t\t      HRTIMER_MODE_ABS_PINNED);\n@@ -2123,7 +2137,7 @@ static int tcp_mtu_probe(struct sock *sk)\n static bool tcp_pacing_check(const struct sock *sk)\n {\n \treturn tcp_needs_internal_pacing(sk) &&\n-\t       hrtimer_active(&tcp_sk(sk)->pacing_timer);\n+\t\ttcp_pacing_timer_check(sk);\n }\n \n /* TCP Small Queues :\n","prefixes":["RFC","v2","1/5"]}