Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp337302rdb; Tue, 5 Dec 2023 06:56:09 -0800 (PST) X-Google-Smtp-Source: AGHT+IHK0srRxzIEnN2ZBqdR3CyrIEFz5978FWnIeHr7s6ZbGeNUapphJ8tDzcV5CiNUTKKBl69h X-Received: by 2002:a17:90b:1c06:b0:286:9cdc:c2cf with SMTP id oc6-20020a17090b1c0600b002869cdcc2cfmr1054105pjb.44.1701788169039; Tue, 05 Dec 2023 06:56:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701788169; cv=none; d=google.com; s=arc-20160816; b=j3Be9sBOaLfKEiAw7hD5EblxsCccXemEftnRrdQAsYlaaJbKVPBXjEB2E95dl9u83W nhBTTrPc2pkTBnF6hP0DBs2VZdv/Cp9YUZA41qHcEpZg1waqls3BqzG7lIYQoFFyJ0Co jzs/beTPoB+0r7pLuQEe6wcF271vM3urRHZEbWiJTkZK+LbSZH5g7bbO2D6953brQF9y V4ogu5F0yGCaRlDg/igkCqhCCYxdbXVIHhyq7oepLUghhyvZagB3cKDxkbOwunb/PSnG xcH3xOeavlU4Z2ZPjuwsvWr9VxVnKdrxu3BOJF6tv3mDT2AUZwP3a7sUFMk5nDvF3CCZ Qp3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version:subject :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=Vwn3+d55WIDQqPzaUZ6Y1euKtU0awuVxdMPC2F9sWJM=; fh=GOtUny2oW8a+OwZiCofPVokLDKreR5RNYbuuI4KXBgQ=; b=xoAfAqnHqIwEzolxVWndJ4UMrSMc2c8br5uN1sfyokHa3uwwhhXJv8DL27mQu3xEoC ocFHgFr+QUxls0oissKkJ1O995AqasC4jT441gTCN85MjILdecgnvkn/NQLrkEzfdJyC EHtH73daP+Rwx/OQ76fvJkp6v8h6H/7UrFDqMfKdzcL7V8j5HQdyJssK71+b4uoZQPVg oUpkkFgUrnSrgvwa4SFyWPYImKNMxZHkkeulJ7X7v2UN0kKcGrV896S7V9N6TuZHVKFY OxlWXi8ZDSsBKImdxwVcsDabBbT0/96gyAS0NVV3puSyYUgE2G1aYqNeRwAlWmAyWtZl PKMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=K77UUAzD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u24-20020a17090abb1800b00286aded8191si3517782pjr.122.2023.12.05.06.56.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:56:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=K77UUAzD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BF98A8076D08; Tue, 5 Dec 2023 06:55:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345780AbjLEOzP (ORCPT + 99 others); Tue, 5 Dec 2023 09:55:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345742AbjLEOzN (ORCPT ); Tue, 5 Dec 2023 09:55:13 -0500 Received: from mail-yb1-xb2c.google.com (mail-yb1-xb2c.google.com [IPv6:2607:f8b0:4864:20::b2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDC37CA; Tue, 5 Dec 2023 06:55:19 -0800 (PST) Received: by mail-yb1-xb2c.google.com with SMTP id 3f1490d57ef6-db632fef2dcso3931551276.1; Tue, 05 Dec 2023 06:55:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701788119; x=1702392919; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Vwn3+d55WIDQqPzaUZ6Y1euKtU0awuVxdMPC2F9sWJM=; b=K77UUAzD6OhhkG+OWSzsia81MDr+irPwylYgvVESqcPP3DbyYANi8CXFslT8kZ6GUm G3s474Jc8Q+PhAh/8XHwiZKK8mNLc34QMWy6RDyVeT9jInHhd1nKs0Vs68yV//VfeFtL Y2P1mCL9DsfSq3C8T1RGF+LN+vmE+7LnszSCZ592NfkbsADVkj5lm3tZwNcgL1QPL2vP zW7jDkLHIifI0zTGopHTjqJpEkuSzu7HjdJkF/OqrYlIgRZGgA1TgYXN6uAMHG9dT+wX tz0FXfvdNc3TzigRJv0iBjt2sabOlY8D3wJ2gUeHXUrCLFr1MLFaIhPgtji6pfBySIfH DqaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701788119; x=1702392919; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Vwn3+d55WIDQqPzaUZ6Y1euKtU0awuVxdMPC2F9sWJM=; b=HHxLaARF7YKT6gYDme+UBbNZn60kLpgZAPkd7kcC/gySQ+5xus2fNi4b4C45cOdh/7 VEjJ44EUPsPV118h4/aBSpECfy6ei+eNCMYEe7fsO5dbmugLGIhjreL1Hje2hur67UKT N66HCAcRALQdPQOU8mi9wEYszgMI3iG/pCQHjdokIfZEsIK7pAkB05RdBPTxNIhlkeLW 5AZh6Q/RfvSvbgL9y8CHZ4NgfajokbR0CusC1VZDmp95z/5fOsLuXuN0Xw4mA5r1U9Bi E+AkiomsBtw6kFGRy7NRxKiZJEjc7MeGbdlVd8oGrpUopRMtEMvfgn9QDrLkR9S/YaWu 8rBg== X-Gm-Message-State: AOJu0YzKVdvhNxUxe9649XPof0YypUzvzBxjwHnAmXSmar66WgL2Wc2u q7be7SnztKRD5l19L8xx+jc= X-Received: by 2002:a25:c50a:0:b0:db5:4d4b:d8a7 with SMTP id v10-20020a25c50a000000b00db54d4bd8a7mr4619822ybe.50.1701788119064; Tue, 05 Dec 2023 06:55:19 -0800 (PST) Received: from localhost (114.66.194.35.bc.googleusercontent.com. [35.194.66.114]) by smtp.gmail.com with ESMTPSA id ez16-20020ad45910000000b0067aa25438fdsm3832891qvb.40.2023.12.05.06.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 06:55:18 -0800 (PST) Date: Tue, 05 Dec 2023 09:55:18 -0500 From: Willem de Bruijn To: "Song, Yoong Siang" , Willem de Bruijn , Jesper Dangaard Brouer , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Bjorn Topel , "Karlsson, Magnus" , "Fijalkowski, Maciej" , Jonathan Lemon , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Stanislav Fomichev , Lorenzo Bianconi , Tariq Toukan , Willem de Bruijn , Maxime Coquelin , Andrii Nakryiko , Mykola Lysenko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , Shuah Khan , Alexandre Torgue , Jose Abreu Cc: "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , "bpf@vger.kernel.org" , "xdp-hints@xdp-project.net" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kselftest@vger.kernel.org" Message-ID: <656f39d668439_3dd6422949e@willemb.c.googlers.com.notmuch> In-Reply-To: References: <20231201062421.1074768-1-yoong.siang.song@intel.com> <20231201062421.1074768-3-yoong.siang.song@intel.com> <5a660c0f-d3ed-47a2-b9be-098a224b8a12@kernel.org> <656de8eb14c24_2e983e29435@willemb.c.googlers.com.notmuch> Subject: RE: [PATCH bpf-next v2 2/3] net: stmmac: Add txtime support to XDP ZC Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 05 Dec 2023 06:55:35 -0800 (PST) Song, Yoong Siang wrote: > On Monday, December 4, 2023 10:58 PM, Willem de Bruijn wrote: > >Song, Yoong Siang wrote: > >> On Friday, December 1, 2023 11:02 PM, Jesper Dangaard Brouer wrote: > >> >On 12/1/23 07:24, Song Yoong Siang wrote: > >> >> This patch enables txtime support to XDP zero copy via XDP Tx > >> >> metadata framework. > >> >> > >> >> Signed-off-by: Song Yoong Siang > >> >> --- > >> >> drivers/net/ethernet/stmicro/stmmac/stmmac.h | 2 ++ > >> >> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 13 +++++++++++++ > >> >> 2 files changed, 15 insertions(+) > >> > > >> >I think we need to see other drivers using this new feature to evaluate > >> >if API is sane. > >> > > >> >I suggest implementing this for igc driver (chip i225) and also for igb > >> >(i210 chip) that both support this kind of LaunchTime feature in HW. > >> > > >> >The API and stmmac driver takes a u64 as time. > >> >I'm wondering how this applies to i210 that[1] have 25-bit for > >> >LaunchTime (with 32 nanosec granularity) limiting LaunchTime max 0.5 > >> >second into the future. > >> >And i225 that [1] have 30-bit max 1 second into the future. > >> > > >> > > >> >[1] > >> >https://github.com/xdp-project/xdp- > >> >project/blob/master/areas/tsn/code01_follow_qdisc_TSN_offload.org > >> > >> I am using u64 for launch time because existing EDT framework is using it. > >> Refer to struct sk_buff below. Both u64 and ktime_t can be used as launch time. > >> I choose u64 because ktime_t often requires additional type conversion and > >> we didn't expect negative value of time. > >> > >> include/linux/skbuff.h-744- * @tstamp: Time we arrived/left > >> include/linux/skbuff.h:745- * @skb_mstamp_ns: (aka @tstamp) earliest departure > >time; start point > >> include/linux/skbuff.h-746- * for retransmit timer > >> -- > >> include/linux/skbuff.h-880- union { > >> include/linux/skbuff.h-881- ktime_t tstamp; > >> include/linux/skbuff.h:882- u64 skb_mstamp_ns; /* earliest departure > >time */ > >> include/linux/skbuff.h-883- }; > >> > >> tstamp/skb_mstamp_ns are used by various drivers for launch time support > >> on normal packet, so I think u64 should be "friendly" to all the drivers. For an > >> example, igc driver will take launch time from tstamp and recalculate it > >> accordingly (i225 expect user to program "delta time" instead of "time" into > >> HW register). > >> > >> drivers/net/ethernet/intel/igc/igc_main.c-1602- txtime = skb->tstamp; > >> drivers/net/ethernet/intel/igc/igc_main.c-1603- skb->tstamp = ktime_set(0, 0); > >> drivers/net/ethernet/intel/igc/igc_main.c:1604- launch_time = > >igc_tx_launchtime(tx_ring, txtime, &first_flag, &insert_empty); > >> > >> Do you think this is enough to say the API is sane? > > > >u64 nsec sounds sane to be. It must be made explicit with clock source > >it is against. > > > > The u64 launch time should base on NIC PTP hardware clock (PHC). > I will add documentation saying which clock source it is against It's not that obvious to me that that is the right and only choice. See below. > >Some applications could want to do the conversion from a clock source > >to raw NIC cycle counter in userspace or BPF and program the raw > >value. So it may be worthwhile to add an clock source argument -- even > >if initially only CLOCK_MONOTONIC is supported. > > Sorry, not so understand your suggestion on adding clock source argument. > Are you suggesting to add clock source for the selftest xdp_hw_metadata apps? > IMHO, no need to add clock source as the clock source for launch time > should always base on NIC PHC. This is not how FQ and ETF qdiscs pass timestamps to drivers today. Those are in CLOCK_MONOTONIC or CLOCK_TAI. The driver is expected to convert from that to its descriptor format, both to the reduced bit width and the NIC PHC. See also for instance how sch_etf has an explicit q->clock_id match, and SO_TXTIME added an sk_clock_id for the same purpose: to agree on which clock source is being used.