Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10471123rwr; Fri, 12 May 2023 08:32:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ci6IjWCTfCJAhbxYD6ckkNxORuS04+4jz56MpRNbkI9nen2lXuxn7Vyl+kuV3s2NZrvfL X-Received: by 2002:a17:903:245:b0:1aa:fbaa:ee10 with SMTP id j5-20020a170903024500b001aafbaaee10mr35559584plh.37.1683905553410; Fri, 12 May 2023 08:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683905553; cv=none; d=google.com; s=arc-20160816; b=T5MF0vGffya3tNCrGZ37EcSEPt5G0XR+54PKojh5rxqlk9tufxX90rRnReozRmE6GJ xSkcxmdbejxy5eMkTvv4EhtygP8KVE02pM/TRYW5kgMp9Rr8Rhi0CA0SGRmnwksojOHH ZjEGl4BBlyjwpaFzwufax8mqShjRoiJk8JGQeGznuQI2pLem6LSR42OUVDyNElf4oQrL OhgBaDBJfO2VfUoBrEUlHdfRoAtGNUltZTAHOhRSbehUpMOth6FeCHgG0e3JPrJAIZVf UaBsQnfQ8aQSR2ag4O0Txd0TUWuTaQgoPNErGdOG5bqBXVMp489iNRK+2jwFhtgQOOHd 2lRA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/M0wcWqFBEMlLrTYzoHRWm9LehBeHVi41H4kILv41UU=; b=BZPLx4EQz0Clx6Hu9GTCAI2wmtsiADPT8ywqgazWei+iwXYovpUzTPs0EbwYFMTuJK ujfcduxGzLPcWTZitWBjZ5t3/1xKtipYy3KWh+yJCyv+yFNZSSgUGIItNvgdEzcrigsE 9SA5CKXcTVWKvrL+nm/tk1I5vvM6m/iMmqoYNgOMtTcy67OArM8O+AJFboO7rqgn+DTT CIhQgogw6cF9pzFd+MC5NeeUQoA/Lj+yRXqpbIFs7VuLPtSd4V/DhA8WmF+BDNUN3k1D g/m2bOuCKr38cWgCuCnxfoOeciKr2O5z38whzWoKYsB3MF5Ap+YBxSXHf/kXqMj0vIA/ 8RDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nzbK6K2H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x18-20020a170902ec9200b001a647aadbe0si9272777plg.568.2023.05.12.08.32.21; Fri, 12 May 2023 08:32:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nzbK6K2H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241802AbjELPUN (ORCPT + 99 others); Fri, 12 May 2023 11:20:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241784AbjELPUJ (ORCPT ); Fri, 12 May 2023 11:20:09 -0400 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ED76213B; Fri, 12 May 2023 08:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683904804; x=1715440804; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5vB/mCJq56GY8l9CoZRfoaHhODKmcFLlsw3E4ilHnDM=; b=nzbK6K2HXGD5Jag3b6BK/LVHhQM7qk79XdRlJoR9Ii3C96I2j194zBLe tLbUhVuUgs6t7AumbNcgjVy/c0wEcBByEjNQ+LbQWEDGpb1/d05AAXFms +aOdOsDQk3fTLXTfx3uxAIZbFYkLpc6g55Utd8dbAnU3xFMOV8gWMzszB GQyaXNk8BF9R8+e8Z31gZX7IdR5Yo7xp9w8hYK8zQYrfRjBJ23UzdUgat DJpLqRwazutLb713Zgy0Gg9W/DlBi1tDXh4habGUL0hbgXLO0Tm7vAiLC oVYuBuNXnA/f3+pJN+v+AQq+xhgoor7KYzjhvUAPR9nblG5IqbNuIv9N1 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="331173771" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="331173771" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 08:20:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="765196584" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="765196584" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga008.fm.intel.com with ESMTP; 12 May 2023 08:19:59 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 7679B35FB9; Fri, 12 May 2023 16:19:57 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Cc: Larysa Zaremba , Stanislav Fomichev , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Jakub Kicinski , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Jiri Olsa , Jesse Brandeburg , Tony Nguyen , Anatoly Burakov , Jesper Dangaard Brouer , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/15] ice: make RX HW timestamp reading code more reusable Date: Fri, 12 May 2023 17:16:26 +0200 Message-Id: <20230512151639.992033-3-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230512151639.992033-1-larysa.zaremba@intel.com> References: <20230512151639.992033-1-larysa.zaremba@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, we only needed RX HW timestamp in skb path, hence all related code was written with skb in mind. But with the addition of XDP hints via kfuncs to the ice driver, the same logic will be needed in .xmo_() callbacks. Put generic process of reading RX HW timestamp from a descriptor into a separate function. Move skb-related code into another source file. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_ptp.c | 23 +++++++--------- drivers/net/ethernet/intel/ice/ice_ptp.h | 18 ++++++++----- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 27 ++++++++++++++++++- 3 files changed, 48 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index ac6f06f9a2ed..c90ce91f11ab 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2142,30 +2142,28 @@ int ice_ptp_set_ts_config(struct ice_pf *pf, struct ifreq *ifr) } /** - * ice_ptp_rx_hwtstamp - Check for an Rx timestamp + * ice_ptp_copy_rx_hwts_from_desc - Check for an Rx timestamp * @rx_ring: Ring to get the VSI info * @rx_desc: Receive descriptor - * @skb: Particular skb to send timestamp with + * @dst: Address to put RX timestamp to * - * The driver receives a notification in the receive descriptor with timestamp. - * The timestamp is in ns, so we must convert the result first. + * If function returns true, dst contains a valid RX timestamp in ns. */ -void -ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, - union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb) +bool ice_ptp_copy_rx_hwts_from_desc(struct ice_rx_ring *rx_ring, + union ice_32b_rx_flex_desc *rx_desc, + u64 *dst) { - struct skb_shared_hwtstamps *hwtstamps; u64 ts_ns, cached_time; u32 ts_high; if (!(rx_desc->wb.time_stamp_low & ICE_PTP_TS_VALID)) - return; + return false; cached_time = READ_ONCE(rx_ring->cached_phctime); /* Do not report a timestamp if we don't have a cached PHC time */ if (!cached_time) - return; + return false; /* Use ice_ptp_extend_32b_ts directly, using the ring-specific cached * PHC value, rather than accessing the PF. This also allows us to @@ -2176,9 +2174,8 @@ ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, ts_high = le32_to_cpu(rx_desc->wb.flex_ts.ts_high); ts_ns = ice_ptp_extend_32b_ts(cached_time, ts_high); - hwtstamps = skb_hwtstamps(skb); - memset(hwtstamps, 0, sizeof(*hwtstamps)); - hwtstamps->hwtstamp = ns_to_ktime(ts_ns); + *dst = ts_ns; + return true; } /** diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.h b/drivers/net/ethernet/intel/ice/ice_ptp.h index 9cda2f43e0e5..509ea9570276 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.h +++ b/drivers/net/ethernet/intel/ice/ice_ptp.h @@ -259,9 +259,9 @@ int ice_get_ptp_clock_index(struct ice_pf *pf); s8 ice_ptp_request_ts(struct ice_ptp_tx *tx, struct sk_buff *skb); bool ice_ptp_process_ts(struct ice_pf *pf); -void -ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, - union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb); +bool ice_ptp_copy_rx_hwts_from_desc(struct ice_rx_ring *rx_ring, + union ice_32b_rx_flex_desc *rx_desc, + u64 *dst); void ice_ptp_reset(struct ice_pf *pf); void ice_ptp_prepare_for_reset(struct ice_pf *pf); void ice_ptp_init(struct ice_pf *pf); @@ -294,9 +294,15 @@ static inline bool ice_ptp_process_ts(struct ice_pf *pf) { return true; } -static inline void -ice_ptp_rx_hwtstamp(struct ice_rx_ring *rx_ring, - union ice_32b_rx_flex_desc *rx_desc, struct sk_buff *skb) { } + +static inline bool +ice_ptp_copy_rx_hwts_from_desc(struct ice_rx_ring *rx_ring, + union ice_32b_rx_flex_desc *rx_desc, + u64 *dst) +{ + return false; +} + static inline void ice_ptp_reset(struct ice_pf *pf) { } static inline void ice_ptp_prepare_for_reset(struct ice_pf *pf) { } static inline void ice_ptp_init(struct ice_pf *pf) { } diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c index fc67bbf600af..1aab79dc8915 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c @@ -186,6 +186,31 @@ ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb, ring->vsi->back->hw_csum_rx_error++; } +/** + * ice_ptp_rx_hwts_to_skb - Put RX timestamp into skb, if available + * @rx_ring: Ring to get the VSI info + * @rx_desc: Receive descriptor + * @skb: Particular skb to send timestamp with + * + * The driver receives a notification in the receive descriptor with timestamp. + * The timestamp is in ns, so we must convert the result first. + */ +static void +ice_ptp_rx_hwts_to_skb(struct ice_rx_ring *rx_ring, + union ice_32b_rx_flex_desc *rx_desc, + struct sk_buff *skb) +{ + struct skb_shared_hwtstamps *hwtstamps; + u64 ts_ns; + + if (!ice_ptp_copy_rx_hwts_from_desc(rx_ring, rx_desc, &ts_ns)) + return; + + hwtstamps = skb_hwtstamps(skb); + memset(hwtstamps, 0, sizeof(*hwtstamps)); + hwtstamps->hwtstamp = ns_to_ktime(ts_ns); +} + /** * ice_process_skb_fields - Populate skb header fields from Rx descriptor * @rx_ring: Rx descriptor ring packet is being transacted on @@ -210,7 +235,7 @@ ice_process_skb_fields(struct ice_rx_ring *rx_ring, ice_rx_csum(rx_ring, skb, rx_desc, ptype); if (rx_ring->ptp_rx) - ice_ptp_rx_hwtstamp(rx_ring, rx_desc, skb); + ice_ptp_rx_hwts_to_skb(rx_ring, rx_desc, skb); } /** -- 2.35.3