Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp10493360rwr; Fri, 12 May 2023 08:50:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5zH1//gZewsU3qmIU/9Su5s/Pde8RhV+hkCQWB0YJKIpPzr1CM3d5opNafXAtlPPaJ8bcG X-Received: by 2002:a17:903:4d5:b0:1ac:aac1:e344 with SMTP id jm21-20020a17090304d500b001acaac1e344mr12679774plb.36.1683906639533; Fri, 12 May 2023 08:50:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683906639; cv=none; d=google.com; s=arc-20160816; b=OeHFNAyrGJz6aZXffsQVYllTBIELn2HfC8EYBUhCT0CcoQiUhNF928HG7Q6+ef/rei kZLr+eu7fOkwKab4A2YpZNC5UEbR2r4F9W4TgCjb/k5ybGqdVaRIYXq6ApiWvCBhfIHg OAP06e407D7M/+rQkLWD72A24MbRxPCceGrylL27AaxUkT1cntd9gzQiu0epHxZTUBIx FAdRtE3n/avcUfVn75Ogn/M8yd4awcpW71rAbecugcqUEN+GTfby/ZaJs+h2vguhQXXY 54LZ/HGscwfnFdPcGx38ExVTEjPD8Hbk+jM4urdKv/q/tyQltGDYidEnW7RqFYgl12Dt +ZYg== 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=d/d4CQxRSHRZzSUCPPwv4DjMkkRdWTaItlqiAf4l8gY=; b=W2NZBOcrXUY+1QJJEe45h8hoRI3UKTtB+Cb9IaDqxDqsb8O8AhFPvaKBiFKInE1Ug4 uDBZ73bpkGLrIK6R0169ohiPjIBdvqzZvTuGYwYhSfMQCwsdURJwGKvDfxQXnTD1fz35 JieTcapuCIxjOYrltT6T0PloDXwcr66OyFz4AvWTks1JtftWgFprNizGFcxeiUAVPFnu avDtvXVCIJZQsSqvgi5ouA1ZjGnYkkS1EliP2fDtzWzqwJKF9K/4jlLgXpsGyKYBCfJB nEdIQ9z0aMzhB+nCYwDQ5XxEnBBt1VAnay069Kc3b6uTY3MwLoVBU4vjoN3ZKh4M3Q+v pFkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="Sfs7PH/M"; 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 z5-20020a170902834500b0019e9c8e51f4si8841912pln.165.2023.05.12.08.50.25; Fri, 12 May 2023 08:50:39 -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="Sfs7PH/M"; 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 S241947AbjELP3I (ORCPT + 99 others); Fri, 12 May 2023 11:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241880AbjELP3B (ORCPT ); Fri, 12 May 2023 11:29:01 -0400 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46A692D64; Fri, 12 May 2023 08:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683905329; x=1715441329; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cqKMx2oSgYgFjniI/xbMp1UqCMkQn2DYgiq9853O1hY=; b=Sfs7PH/MrYQXgCopvZzxr2OfSnFH2LOIfhDWP5JljiX9FikjfLzar3J6 F9mwbyEwuOVj/cqe0XgkW6Njypzwu5VnSxaw3DpOgf9e/xAG0Ci/bgvI0 zov2jvUq+7uG6ULlsECY/yPAyHLs6QJmmGzjpjwk5J4GPolMPvDdZ/dyX nVToJtV1Gf1sNr7do1vb8S7DhAx8Noy7C3ukgXc4jz43KVQkyk8eKnbsN cBV0cYwHeZNsJrJ3KUeJqG6XP/6egX0sVuFEUuuLpIt5lq6Nso+oU7hTq ts8l+QAN0XN3KeipveBxyF72BzEFDHeKV/CWN0KyA4ZBD9breylk8pi45 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349653320" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349653320" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2023 08:28:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="1030124517" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="1030124517" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga005.fm.intel.com with ESMTP; 12 May 2023 08:28:44 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 21092365B4; Fri, 12 May 2023 16:28:43 +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 RESEND bpf-next 06/15] ice: Support HW timestamp hint Date: Fri, 12 May 2023 17:25:58 +0200 Message-Id: <20230512152607.992209-7-larysa.zaremba@intel.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230512152607.992209-1-larysa.zaremba@intel.com> References: <20230512152607.992209-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 Use previously refactored code and create a function that allows XDP code to read HW timestamp. HW timestamp is the first supported hint in the driver, so also add xdp_metadata_ops. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice.h | 2 ++ drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index aa32111afd6e..ba1bb8392db1 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -962,4 +962,6 @@ static inline void ice_clear_rdma_cap(struct ice_pf *pf) set_bit(ICE_FLAG_UNPLUG_AUX_DEV, pf->flags); clear_bit(ICE_FLAG_RDMA_ENA, pf->flags); } + +extern const struct xdp_metadata_ops ice_xdp_md_ops; #endif /* _ICE_H_ */ diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index a1f7c8edc22f..cda6c4a80737 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -3378,6 +3378,7 @@ static void ice_set_ops(struct ice_vsi *vsi) netdev->netdev_ops = &ice_netdev_ops; netdev->udp_tunnel_nic_info = &pf->hw.udp_tunnel_nic; + netdev->xdp_metadata_ops = &ice_xdp_md_ops; ice_set_ethtool_ops(netdev); if (vsi->type != ICE_VSI_PF) diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c index 2515f5f7a2b6..e9589cadf811 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c @@ -537,3 +537,25 @@ void ice_finalize_xdp_rx(struct ice_tx_ring *xdp_ring, unsigned int xdp_res, spin_unlock(&xdp_ring->tx_lock); } } + +/** + * ice_xdp_rx_hw_ts - HW timestamp XDP hint handler + * @ctx: XDP buff pointer + * @ts_ns: destination address + * + * Copy HW timestamp (if available) to the destination address. + */ +static int ice_xdp_rx_hw_ts(const struct xdp_md *ctx, u64 *ts_ns) +{ + const struct ice_xdp_buff *xdp_ext = (void *)ctx; + + if (!ice_ptp_copy_rx_hwts_from_desc(xdp_ext->rx_ring, + xdp_ext->eop_desc, ts_ns)) + return -EOPNOTSUPP; + + return 0; +} + +const struct xdp_metadata_ops ice_xdp_md_ops = { + .xmo_rx_timestamp = ice_xdp_rx_hw_ts, +}; -- 2.35.3