Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp448519lqg; Fri, 1 Mar 2024 09:54:54 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+QLZyzjk0RAae3ZfzcLzNYHT6jkciVDATYj0F40CvQEPmZG2foFokzUILJLcOt2IT+gN22deb/JmCf5KzWhzBr0ZLkDJSM0LR6kCPuA== X-Google-Smtp-Source: AGHT+IGEr4fdG8TD6Iep9PRpHO1aomlWnSnJzMUo3y2NRXJ0bGv3rpKBQUIUCdv5bbQVnNzR52uD X-Received: by 2002:a05:6870:23a9:b0:220:c50e:9133 with SMTP id e41-20020a05687023a900b00220c50e9133mr1752959oap.45.1709315693928; Fri, 01 Mar 2024 09:54:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709315693; cv=pass; d=google.com; s=arc-20160816; b=Q8YHQK0cQud/9bDGcd5zss8XPE2LY4aEyXLL6iGxNdynBiLTjeoUVCXzEpSu79LpgS 6Txu2pJmTCysf5BR0VXhZBjBNH3g//Yj37rhf+RpVolQ7q2ch8btcBao/ns2idzV2KmH Q/PH5Rd+LmilDffpVrucaFyzz72vh/hx9/TJ/ljfshSbqYxsnlO1hlZmUHoLoxreVLjm 9ZQbglWweHbrPVxIEu3nwdZwKUwDgq8++O2TDi/WryuAuOCs9gEf/JxEqEo2w1TkIbsC krbh6CXwvdvGShJTo0mN/NCCOW4AahnVqfupBdBTmkcthG5MKmu+JtggOask0VC32/1a KSoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:references:in-reply-to :message-id:cc:to:from:date:dkim-signature; bh=nTu8BntRycqg7yt21AHZn8UXSjkjplk0BJ11/qY4XBE=; fh=5hUoiWKFZEYYhVK4A95Kz73tz+t3VzNl0jCFbdYeG/k=; b=Po96z+1mZsWtrXO5v9WpzywZ2GSjX3jI/FW5ANLgpqPh936076N2AP4BMF3IqSYxP8 mQXQDh6904nFii63CF4yjuBnBx20OU3hWORBcI47qcXe6Z5STLZUhF6Rnb1BccJ2+j2+ 68o40gf2m0T0HSKxiaq8pavzZjfKcaXcb/RFKf/vMZZr9Kcjm2EPPadZrUvfsOdHynnu URDXHNwGXPJY3gqTm/oBzVtffJNURIG1N28hlGxM/LFlGwzcBVM7e5FPod1VUz2Yo8Dr y7iKqpR44dOqDvnT3DBnvKnxwqcwH6nCXOSCadI6TQ6OTQ9/dbBMOuUIrQqCdUNb8EsG 02AA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OYI2KflC; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88872-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88872-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u6-20020a05620a084600b00787761f6926si3972526qku.245.2024.03.01.09.54.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 09:54:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88872-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OYI2KflC; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-88872-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88872-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 856B11C22BBE for ; Fri, 1 Mar 2024 17:54:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B40D520DCD; Fri, 1 Mar 2024 17:54:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OYI2KflC" Received: from mail-pl1-f176.google.com (mail-pl1-f176.google.com [209.85.214.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B273848E; Fri, 1 Mar 2024 17:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709315678; cv=none; b=q7mHG0uh2wBkH49UFsc0RhSpyp44mNVf+QJeZIFb5kLAFj/TkbDHSe3RnYz2ASqVNA+JJFMQ+wdUM27H5ubmGcvdxsEueSVtx+VPnNfhRSGTV2SbJ/iMM1gGC+Hw8yV+tbhwZdeEft/SLrvMyRQ/EUUtAFVteJIKuhXhpIllwkE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709315678; c=relaxed/simple; bh=aqeIwwGa/fkHnXgNw3wwR4I8Nh8KUDC4YHT40u34iyA=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=E52AdwJUzG3Ym37M2varCH1ZjIe4Q7RKy0WxZ9kXFP10ReERLYns2IowaJKuHkcgbqbPomv/FXPebEpqXilRRzWADW7tS5IkNIWCyVNqmzF5H2xfhemb4zofe9oYv0vxL3J7pwqbbyI/cRpMrBhp0HOsfhlFzSUje+bWak4Pv0E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OYI2KflC; arc=none smtp.client-ip=209.85.214.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f176.google.com with SMTP id d9443c01a7336-1dccb2edc6dso22096815ad.3; Fri, 01 Mar 2024 09:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709315677; x=1709920477; 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=nTu8BntRycqg7yt21AHZn8UXSjkjplk0BJ11/qY4XBE=; b=OYI2KflC/BHZoPPAx+AtLH6bp56OD8ve8wV6+O0rPklItMqmbqVgihDSr5jQfbWQ44 EZJj4PnEigZ/S46/pvJtxTSzxqlqZ0hmi9UUB4uN2mzdu1U8b4A0A+467MkXymnfqmDv gw7g0JhbGqK+E+wu54Y4XN0WrEr6eFsaK0i8fS1rIhi+IA8EPnD2Ik1/g/jAuRkMewIy itJUlFbCaCznyla60T27UaV6YljTwLi/r9aOYg/FoIZEKcADn9yVndddIf6tnOz6RfAR i2l8brRKjIapJg27/0C/75hcxM0JpytYC67Jb8Org6JgVpztWqgGby7r1iGC4AGfRE1k 9tEA== 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=SmlQzAMB9eraWLDiQzmkj9cCGfwtUlinADdDdbfY8/Jso8hYrNiD5fletVDY74nebl oDAv8BmjPYx67UFNzjv2dkHmB+u3k5s0VSOh57+VOrAoMk/nosbyBupmTYTI0vScubjm Ua/FWr4q5cbPr7sB+GTfymI7NhvKp39APyAlkSi4I1aO30IsByCC+QTyc9b0bvXDJMRp Q6b4JdhgM/9ohcfdQs1bWmRAzN1gLf/IqX4Jiwt4MeoCICYgav2b/j/aX2g7JFGEStud Mdj9hTxT2Y8nsBQWNKGW/R03hsNcHcOvq4hwzpzL3mgxywRWIrMmU2PPZEsC+nWg+GXJ jdnA== X-Forwarded-Encrypted: i=1; AJvYcCVHEjst3RAt81fhtSbBWj5GTGAb/KHr7op+n7lcIfaJrG14W0eIvlJyC8ojZabbl0yyi7Xb/l9klnkNe+/edqrt6AFRfh/xTrIisBh6Iii1jVa30+eoHVYiAyQAHliL3SGrJMBTfB7nZ0b2HqENuEYME668Wo8tXN5tbI8aPAUyZrdm51VLGdzun3ZLbU4XwQ0KIkU0lE/CQQW+ X-Gm-Message-State: AOJu0YwewP5URYAQLD6UHCPJ5Hub0bDL6Y2W/PbrMfXvaDWnatVCvn/1 AWWUKZRak34aZIWttyPiR4m9GvhKvL25MWJh6FzYt5he3ku/2mCh 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 Cc: intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, xdp-hints@xdp-project.net 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> Subject: RE: [PATCH iwl-next,v2 2/2] igc: Add Tx hardware timestamp request for AF_XDP zero-copy packet Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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.