From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F0E43C5475B for ; Fri, 1 Mar 2024 17:54:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 7475641C68; Fri, 1 Mar 2024 17:54:41 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id X6YaVuHqGiVG; Fri, 1 Mar 2024 17:54:40 +0000 (UTC) X-Comment: SPF check N/A for local connections - client-ip=140.211.166.34; helo=ash.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver= DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 514A941C6A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1709315680; bh=nTu8BntRycqg7yt21AHZn8UXSjkjplk0BJ11/qY4XBE=; h=Date:From:To:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=ysOCiv/EA46XYLlipwFrdZ+nJRGptEjAjeA6KXeuspwb2E0FYMvOwG3uvoKwJtqo0 TpHFFmWWTT0BZU+L7fw6VxWUllr5shBt6bqZa/vKODRp/Armz2xf0ZTdF3tWf+0Wht WqnpPV0NicRoHHMz28p7+Z7mAr3fqxzkO76RWb9Kims0eHN0zKt0nJe8owgGq3GOsM TrCXm0bQvZ87RxzfRuBS13c4+BcrgLZFdTO6oN6vrJwRMPPgWZRP36Oyg/Tw2RBLmc aIuHTeX5NZPa2orTOfYHuDpqCDn616ew0SnJqRkj+/eGBdFWrLkfSw1hXIOBuH1b4M QeQy6QZustyew== Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 514A941C6A; Fri, 1 Mar 2024 17:54:40 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id DC6B71BF2F7 for ; Fri, 1 Mar 2024 17:54:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C72D641C6A for ; Fri, 1 Mar 2024 17:54:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wuDN1J69zMf7 for ; Fri, 1 Mar 2024 17:54:37 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2607:f8b0:4864:20::633; helo=mail-pl1-x633.google.com; envelope-from=john.fastabend@gmail.com; receiver= DMARC-Filter: OpenDMARC Filter v1.4.2 smtp2.osuosl.org 9846241C68 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 9846241C68 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by smtp2.osuosl.org (Postfix) with ESMTPS id 9846241C68 for ; Fri, 1 Mar 2024 17:54:37 +0000 (UTC) Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1db6e0996ceso19671655ad.2 for ; Fri, 01 Mar 2024 09:54:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709315677; x=1709920477; 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=nTu8BntRycqg7yt21AHZn8UXSjkjplk0BJ11/qY4XBE=; b=Xx2TwTkfU6+O7z6dJLSsmJo8mGJDxtcBRsN7xSlfEnxesPbHZIiD7rf/l3bYi/UyxV LQbMr03LZI0fYvQGaEgLbRpBhtvZxYmHGCwT77CbZFdEGP7ka0xyi+KyQpWocnDHCfcQ Dno/vQOYLnlpu4p7ZyU4Ft4hz82kw0X0ng4lsZPinoBCzDO57lRw4yvGx18K+j2Zi5kS PHnJ9ZQvfi+xp4if0byiaJ3vzKGKsUUqbQ/YHzT80O28uhsI5zcVO3/CDkG0hncWAfk+ YURheNegBi8VLj/DwbA/rAQVtCdFRwneFGSWRNHKI+Nu8Xf8bpyPZbMhO1c8lOMLlDcP cXPw== X-Gm-Message-State: AOJu0Yxsx3PQoEhBSupSRHGeFEaZydqF1lfsijQuJ9SggAsjMFImWlAS X8iW+QKjk96iIRYoP5vEoJkj2xAAIIeNl27qk9aryms/VUXOHBO2 X-Google-Smtp-Source: AGHT+IE9csmqmhCHH7CB4+0CxfUKKrr/8xABmiG0iw4SYFgI5JFB+8TUoh0+dZcVBRLvK/L83PLtYQ== X-Received: by 2002:a17:903:8c6:b0:1dc:d515:79ca with SMTP id lk6-20020a17090308c600b001dcd51579camr2747683plb.5.1709315676554; Fri, 01 Mar 2024 09:54:36 -0800 (PST) Received: from localhost ([98.97.43.160]) by smtp.gmail.com with ESMTPSA id e8-20020a170902784800b001da001aed18sm3800862pln.54.2024.03.01.09.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:54:35 -0800 (PST) Date: Fri, 01 Mar 2024 09:54:34 -0800 From: John Fastabend To: Song Yoong Siang , Jesse Brandeburg , Tony Nguyen , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Richard Cochran , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Vinicius Costa Gomes , Florian Bezdeka , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Hao Luo , Jiri Olsa , Shuah Khan Message-ID: <65e2165a89ed0_5dcfe20823@john.notmuch> In-Reply-To: <20240301162348.898619-3-yoong.siang.song@intel.com> References: <20240301162348.898619-1-yoong.siang.song@intel.com> <20240301162348.898619-3-yoong.siang.song@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709315677; x=1709920477; darn=lists.osuosl.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=nTu8BntRycqg7yt21AHZn8UXSjkjplk0BJ11/qY4XBE=; b=VtDzG7oOYsEKMt1ee353+lv4Q7jLo8kP+vhgtqoPeOiDieSXnTuB5J1WUfiLTdnQxj HexlQHSbTRRWCycZlhvs0qolkiouWtZnq4j1XwBdHttYb7y+te7izPa0t63X1u0uhvpS CpE+iNIC30wUmAZ2+UafrfN3evy4xRBBHKgd9bB/h1uW2jI04vs8go25kdBEz7yBKdAL SrUpxzVQFhr1QUsg7irv+0+w7+iconpC/Izo57KYPvYargF8kkb/a5QIl0YGy+vpwrSS PEgOGRyXr5nyLqycQNy3cWr4r3wt2MjR7nlg1aD9Qa6mp4ilWZ833SzlVla8kFRVlPld znnQ== X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dmarc=pass (p=none dis=none) header.from=gmail.com X-Mailman-Original-Authentication-Results: smtp2.osuosl.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=VtDzG7oO Subject: Re: [Intel-wired-lan] [PATCH iwl-next, v2 2/2] igc: Add Tx hardware timestamp request for AF_XDP zero-copy packet X-BeenThere: intel-wired-lan@osuosl.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: xdp-hints@xdp-project.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Song Yoong Siang wrote: > This patch adds support to per-packet Tx hardware timestamp request to > AF_XDP zero-copy packet via XDP Tx metadata framework. Please note that > user needs to enable Tx HW timestamp capability via igc_ioctl() with > SIOCSHWTSTAMP cmd before sending xsk Tx hardware timestamp request. > > Same as implementation in RX timestamp XDP hints kfunc metadata, Timer 0 > (adjustable clock) is used in xsk Tx hardware timestamp. i225/i226 have > four sets of timestamping registers. Both *skb and *xsk_tx_buffer pointers > are used to indicate whether the timestamping register is already occupied. > > Furthermore, a boolean variable named xsk_pending_ts is used to hold the > transmit completion until the tx hardware timestamp is ready. This is > because, for i225/i226, the timestamp notification event comes some time > after the transmit completion event. The driver will retrigger hardware irq > to clean the packet after retrieve the tx hardware timestamp. > > Besides, xsk_meta is added into struct igc_tx_timestamp_request as a hook > to the metadata location of the transmit packet. When the Tx timestamp > interrupt is fired, the interrupt handler will copy the value of Tx hwts > into metadata location via xsk_tx_metadata_complete(). > > Co-developed-by: Lai Peter Jun Ann > Signed-off-by: Lai Peter Jun Ann > Signed-off-by: Song Yoong Siang > --- [...] > > +static void igc_xsk_request_timestamp(void *_priv) > +{ > + struct igc_metadata_request *meta_req = _priv; > + struct igc_ring *tx_ring = meta_req->tx_ring; > + struct igc_tx_timestamp_request *tstamp; > + u32 tx_flags = IGC_TX_FLAGS_TSTAMP; > + struct igc_adapter *adapter; > + unsigned long lock_flags; > + bool found = false; > + int i; > + > + if (test_bit(IGC_RING_FLAG_TX_HWTSTAMP, &tx_ring->flags)) { > + adapter = netdev_priv(tx_ring->netdev); > + > + spin_lock_irqsave(&adapter->ptp_tx_lock, lock_flags); > + > + /* Search for available tstamp regs */ > + for (i = 0; i < IGC_MAX_TX_TSTAMP_REGS; i++) { > + tstamp = &adapter->tx_tstamp[i]; > + > + if (tstamp->skb) > + continue; > + > + found = true; > + break; Not how I would have written this loop construct seems a bit odd to default break but it works. > + } > + > + /* Return if no available tstamp regs */ > + if (!found) { > + adapter->tx_hwtstamp_skipped++; > + spin_unlock_irqrestore(&adapter->ptp_tx_lock, > + lock_flags); > + return; > + } [...] > > +static void igc_ptp_free_tx_buffer(struct igc_adapter *adapter, > + struct igc_tx_timestamp_request *tstamp) > +{ > + if (tstamp->buffer_type == IGC_TX_BUFFER_TYPE_XSK) { > + /* Release the transmit completion */ > + tstamp->xsk_tx_buffer->xsk_pending_ts = false; > + tstamp->xsk_tx_buffer = NULL; > + tstamp->buffer_type = 0; > + > + /* Trigger txrx interrupt for transmit completion */ > + igc_xsk_wakeup(adapter->netdev, tstamp->xsk_queue_index, 0); Just curious because I didn't find it. Fairly sure I just need to look more, but don't you want to still 'tstamp->skb = NULL' in this path somewhere? It looks like triggering the tx interrupt again with buffer_type == 0 wouldn't do the null. I suspect I just missed it.