lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201209143707.13503-4-erez.geva.ext@siemens.com>
Date:   Wed,  9 Dec 2020 15:37:06 +0100
From:   Erez Geva <erez.geva.ext@...mens.com>
To:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arch@...r.kernel.org,
        Alexey Kuznetsov <kuznet@....inr.ac.ru>,
        Arnd Bergmann <arnd@...db.de>,
        Cong Wang <xiyou.wangcong@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
        Jakub Kicinski <kuba@...nel.org>,
        Jamal Hadi Salim <jhs@...atatu.com>,
        Jiri Pirko <jiri@...nulli.us>,
        Alexei Starovoitov <ast@...nel.org>,
        Colin Ian King <colin.king@...onical.com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Eyal Birger <eyal.birger@...il.com>,
        "Gustavo A . R . Silva" <gustavoars@...nel.org>,
        Jakub Sitnicki <jakub@...udflare.com>,
        John Ogness <john.ogness@...utronix.de>,
        Jon Rosen <jrosen@...co.com>,
        Kees Cook <keescook@...omium.org>,
        Mao Wenan <maowenan@...wei.com>,
        Marc Kleine-Budde <mkl@...gutronix.de>,
        Martin KaFai Lau <kafai@...com>,
        Matthieu Baerts <matthieu.baerts@...sares.net>,
        Andrei Vagin <avagin@...il.com>,
        Dmitry Safonov <0x7f454c46@...il.com>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        Ingo Molnar <mingo@...nel.org>,
        John Stultz <john.stultz@...aro.org>,
        Miaohe Lin <linmiaohe@...wei.com>,
        Michal Kubecek <mkubecek@...e.cz>,
        Or Cohen <orcohen@...oaltonetworks.com>,
        Oleg Nesterov <oleg@...hat.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Richard Cochran <richardcochran@...il.com>,
        Stefan Schmidt <stefan@...enfreihafen.org>,
        Willem de Bruijn <willemb@...gle.com>,
        Xie He <xie.he.0141@...il.com>,
        Stephen Boyd <sboyd@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Vladis Dronov <vdronov@...hat.com>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
        Frederic Weisbecker <frederic@...nel.org>
Cc:     Vinicius Costa Gomes <vinicius.gomes@...el.com>,
        Vedang Patel <vedang.patel@...el.com>,
        Ines Molzahn <ines.molzahn@...mens.com>,
        Simon Sudler <simon.sudler@...mens.com>,
        Andreas Meisinger <andreas.meisinger@...mens.com>,
        Andreas Bucher <andreas.bucher@...mens.com>,
        Henning Schild <henning.schild@...mens.com>,
        Jan Kiszka <jan.kiszka@...mens.com>,
        Andreas Zirkler <andreas.zirkler@...mens.com>,
        Ermin Sakic <ermin.sakic@...mens.com>,
        An Ninh Nguyen <anninh.nguyen@...mens.com>,
        Michael Saenger <michael.saenger@...mens.com>,
        Bernd Maehringer <bernd.maehringer@...mens.com>,
        Gisela Greinert <gisela.greinert@...mens.com>,
        Erez Geva <erez.geva.ext@...mens.com>,
        Erez Geva <ErezGeva2@...il.com>
Subject: [PATCH 3/3] The TC ETF Qdisc pass the hardware timestamp to the interface driver.

The ETF pass the TX sending hardware timestamp to
 the network interface driver.

  - Add new flag to the ETF Qdisc setting that mandate
    the use of the hardware timestamp in a socket's buffer.
  - The ETF Qdisc pass the TX sending hardware timestamp to the
    network interface driver.

Signed-off-by: Erez Geva <erez.geva.ext@...mens.com>
---
 include/uapi/linux/pkt_sched.h |  1 +
 net/sched/sch_etf.c            | 59 +++++++++++++++++++++++++++-------
 2 files changed, 49 insertions(+), 11 deletions(-)

diff --git a/include/uapi/linux/pkt_sched.h b/include/uapi/linux/pkt_sched.h
index 9e7c2c607845..51e2b57bfa81 100644
--- a/include/uapi/linux/pkt_sched.h
+++ b/include/uapi/linux/pkt_sched.h
@@ -1056,6 +1056,7 @@ struct tc_etf_qopt {
 #define TC_ETF_DEADLINE_MODE_ON	_BITUL(0)
 #define TC_ETF_OFFLOAD_ON	_BITUL(1)
 #define TC_ETF_SKIP_SOCK_CHECK	_BITUL(2)
+#define TC_ETF_USE_HW_TIMESTAMP _BITUL(3)
 };
 
 enum {
diff --git a/net/sched/sch_etf.c b/net/sched/sch_etf.c
index c48f91075b5c..67eace3e180f 100644
--- a/net/sched/sch_etf.c
+++ b/net/sched/sch_etf.c
@@ -23,11 +23,13 @@
 #define DEADLINE_MODE_IS_ON(x) ((x)->flags & TC_ETF_DEADLINE_MODE_ON)
 #define OFFLOAD_IS_ON(x) ((x)->flags & TC_ETF_OFFLOAD_ON)
 #define SKIP_SOCK_CHECK_IS_SET(x) ((x)->flags & TC_ETF_SKIP_SOCK_CHECK)
+#define USE_HW_TIMESTAMP(x) ((x)->flags & TC_ETF_USE_HW_TIMESTAMP)
 
 struct etf_sched_data {
 	bool offload;
 	bool deadline_mode;
 	bool skip_sock_check;
+	bool use_hw_timestamp;
 	int clockid;
 	int queue;
 	s32 delta; /* in ns */
@@ -75,7 +77,7 @@ static inline int validate_input_params(struct tc_etf_qopt *qopt,
 static bool is_packet_valid(struct Qdisc *sch, struct sk_buff *nskb)
 {
 	struct etf_sched_data *q = qdisc_priv(sch);
-	ktime_t txtime = nskb->tstamp;
+	ktime_t hwtxtime, txtime = nskb->tstamp;
 	struct sock *sk = nskb->sk;
 	ktime_t now;
 
@@ -88,6 +90,9 @@ static bool is_packet_valid(struct Qdisc *sch, struct sk_buff *nskb)
 	if (!sock_flag(sk, SOCK_TXTIME))
 		return false;
 
+	if (!q->use_hw_timestamp != !sock_flag(sk, SOCK_HW_TXTIME))
+		return false;
+
 	/* We don't perform crosstimestamping.
 	 * Drop if packet's clockid differs from qdisc's.
 	 */
@@ -99,7 +104,11 @@ static bool is_packet_valid(struct Qdisc *sch, struct sk_buff *nskb)
 
 skip:
 	now = q->get_time();
-	if (ktime_before(txtime, now) || ktime_before(txtime, q->last))
+	if (q->use_hw_timestamp)
+		hwtxtime = skb_hwtstamps(nskb)->hwtstamp;
+	else
+		hwtxtime = txtime;
+	if (ktime_before(txtime, now) || ktime_before(hwtxtime, q->last))
 		return false;
 
 	return true;
@@ -173,16 +182,33 @@ static int etf_enqueue_timesortedlist(struct sk_buff *nskb, struct Qdisc *sch,
 		return qdisc_drop(nskb, sch, to_free);
 	}
 
-	while (*p) {
-		struct sk_buff *skb;
+	if (q->use_hw_timestamp) {
+		ktime_t hwtxtime = skb_hwtstamps(nskb)->hwtstamp;
+
+		while (*p) {
+			struct sk_buff *skb;
 
-		parent = *p;
-		skb = rb_to_skb(parent);
-		if (ktime_compare(txtime, skb->tstamp) >= 0) {
-			p = &parent->rb_right;
-			leftmost = false;
-		} else {
-			p = &parent->rb_left;
+			parent = *p;
+			skb = rb_to_skb(parent);
+			if (ktime_compare(hwtxtime, skb_hwtstamps(skb)->hwtstamp) >= 0) {
+				p = &parent->rb_right;
+				leftmost = false;
+			} else {
+				p = &parent->rb_left;
+			}
+		}
+	} else {
+		while (*p) {
+			struct sk_buff *skb;
+
+			parent = *p;
+			skb = rb_to_skb(parent);
+			if (ktime_compare(txtime, skb->tstamp) >= 0) {
+				p = &parent->rb_right;
+				leftmost = false;
+			} else {
+				p = &parent->rb_left;
+			}
 		}
 	}
 	rb_link_node(&nskb->rbnode, parent, p);
@@ -245,6 +271,10 @@ static void timesortedlist_remove(struct Qdisc *sch, struct sk_buff *skb)
 
 	qdisc_bstats_update(sch, skb);
 
+	/* Pass hardware time to driver and to last */
+	if (q->use_hw_timestamp)
+		skb->tstamp = skb_hwtstamps(skb)->hwtstamp;
+
 	q->last = skb->tstamp;
 
 	sch->q.qlen--;
@@ -393,6 +423,10 @@ static int etf_init(struct Qdisc *sch, struct nlattr *opt,
 	q->offload = OFFLOAD_IS_ON(qopt);
 	q->deadline_mode = DEADLINE_MODE_IS_ON(qopt);
 	q->skip_sock_check = SKIP_SOCK_CHECK_IS_SET(qopt);
+	q->use_hw_timestamp = USE_HW_TIMESTAMP(qopt);
+	/* deadline mode can not coexist with using hardware time */
+	if (q->use_hw_timestamp && q->deadline_mode)
+		return -EOPNOTSUPP;
 
 	switch (q->clockid) {
 	case CLOCK_REALTIME:
@@ -484,6 +518,9 @@ static int etf_dump(struct Qdisc *sch, struct sk_buff *skb)
 	if (q->skip_sock_check)
 		opt.flags |= TC_ETF_SKIP_SOCK_CHECK;
 
+	if (q->use_hw_timestamp)
+		opt.flags |= TC_ETF_USE_HW_TIMESTAMP;
+
 	if (nla_put(skb, TCA_ETF_PARMS, sizeof(opt), &opt))
 		goto nla_put_failure;
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ