From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mail.toke.dk (Postfix) with ESMTPS id B0BDAA0644D for ; Fri, 12 May 2023 17:29:04 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=JnATgzUr DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683905344; x=1715441344; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lKsK28rErg60/rNwLMPgryg9t46tucLmP+/ktIgM2XM=; b=JnATgzUrbtYHLkZ4bqfs6RUOaFF9vKI8HToB1ur4egD5Yo+RY29o+UZ/ 49OG9hYnPiZVl1dsvgW5tU9Z193vUElkyhA4fjJp3VyCEvka1xYHeLNhQ OJwMlQZtjwlFQBDGdl+GobLZeLVg1N0UXYkaENgLsX/2BOtYLn+aKcwRi c7dmceDnM8tWDi3ayI0YCD/5Vd2uwHJI/pANIJPywgfXxLppI96x+yM4Z qjCXG4J1P7q/0cXU9v7K+6IUaNCd9vzRyqE2mVXzqws04/K4FCKSwIiU1 3BpkfAGeKdEZOV1UHgsOtnwnaZKvvD1eW1qvzAj38kAp8hjs16tAlD+kI g==; X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349653448" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349653448" 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:29:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="1030124591" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="1030124591" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga005.fm.intel.com with ESMTP; 12 May 2023 08:29:00 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id A719B35FB9; Fri, 12 May 2023 16:28:58 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Fri, 12 May 2023 17:26:04 +0200 Message-Id: <20230512152607.992209-13-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 Message-ID-Hash: 7P4OP6FLKTXFD3LN5MKF4VDRMWR7F2CC X-Message-ID-Hash: 7P4OP6FLKTXFD3LN5MKF4VDRMWR7F2CC X-MailFrom: larysa.zaremba@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header 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 X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] [PATCH RESEND bpf-next 12/15] ice: Implement checksum level hint List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Implement .xmo_rx_csum_lvl callback to allow XDP code to determine, whether checksum was checked by hardware and on what level. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c index 39547feb6106..6a3ec925f20d 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c @@ -161,6 +161,8 @@ ice_rx_csum_checked(union ice_32b_rx_flex_desc *rx_desc, u16 ptype, */ if (decoded.tunnel_type >= ICE_RX_PTYPE_TUNNEL_IP_GRENAT) *csum_lvl_dst = 1; + else + *csum_lvl_dst = 0; /* Only report checksum unnecessary for TCP, UDP, or SCTP */ switch (decoded.inner_prot) { @@ -190,7 +192,7 @@ static void ice_rx_csum_into_skb(struct ice_rx_ring *ring, struct sk_buff *skb, union ice_32b_rx_flex_desc *rx_desc, u16 ptype) { - u8 csum_level = 0; + u8 csum_level; /* Start with CHECKSUM_NONE and by default csum_level = 0 */ skb->ip_summed = CHECKSUM_NONE; @@ -669,9 +671,29 @@ static int ice_xdp_rx_stag(const struct xdp_md *ctx, u16 *vlan_tag) return 0; } +/** + * ice_xdp_rx_csum_lvl - Get level, at which HW has checked the checksum + * @ctx: XDP buff pointer + * @csum_lvl: destination address + * + * Copy HW checksum level (if was checked) to the destination address. + */ +static int ice_xdp_rx_csum_lvl(const struct xdp_md *ctx, u8 *csum_lvl) +{ + const struct ice_xdp_buff *xdp_ext = (void *)ctx; + u16 ptype = ice_get_ptype(xdp_ext->eop_desc); + + if (!ice_rx_csum_checked(xdp_ext->eop_desc, ptype, csum_lvl, + xdp_ext->rx_ring)) + return -EOPNOTSUPP; + + return 0; +} + const struct xdp_metadata_ops ice_xdp_md_ops = { .xmo_rx_timestamp = ice_xdp_rx_hw_ts, .xmo_rx_hash = ice_xdp_rx_hash, .xmo_rx_ctag = ice_xdp_rx_ctag, .xmo_rx_stag = ice_xdp_rx_stag, + .xmo_rx_csum_lvl = ice_xdp_rx_csum_lvl, }; -- 2.35.3