From patchwork Fri May 12 15:25:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larysa Zaremba X-Patchwork-Id: 1780687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=osuosl.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=intel-wired-lan-bounces@osuosl.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=osuosl.org header.i=@osuosl.org header.a=rsa-sha256 header.s=default header.b=eKWTft5k; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QHt2r0z7tz20KD for ; Sat, 13 May 2023 01:28:52 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 5450E4287F; Fri, 12 May 2023 15:28:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5450E4287F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osuosl.org; s=default; t=1683905330; bh=yqw4rpQl/JvDl60SdMbYq/fc4fPp4qeHv1TiZx3Reaw=; h=From:To:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=eKWTft5kz1TuE3fAqQadxn6LV0D09VbDJ6H8adm8w6//CbEMUhaltTW7bi6vo3CRz L3QCSs6Ow5JaRM/1RVX82BZc07ucXKvfYjErEQO9R4R7GSMTjELpJEJgzoWLKcQDkU Vzz8EF3NIWpqjum6/UqP1i2kZWqaiph0gYocW83nyGYHUqUNKYM8T2mM6maOYqx3vq GIB14eFK+tW30h9Q9A/hNtFideXyD350gbl7/+B78a+HPEA/dfiBYqs6R743Cc4K7T q9L7sSszBv4YwlMKY9mfxmBHeD8Pkif9Dk8zwUlOymG8fOZ+LVp6zT9ZttRH8YN7h4 8u7vKUyHg+9cg== X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j7aZd94BiQjP; Fri, 12 May 2023 15:28:49 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id BA8BE428D7; Fri, 12 May 2023 15:28:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org BA8BE428D7 X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id F13E61BF2CB for ; Fri, 12 May 2023 15:28:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id CACE781FDE for ; Fri, 12 May 2023 15:28:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org CACE781FDE X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AOkQIysVUeRD for ; Fri, 12 May 2023 15:28:43 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1B1A881F86 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1B1A881F86 for ; Fri, 12 May 2023 15:28:43 +0000 (UTC) X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="349653267" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="349653267" 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:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10708"; a="1030124454" X-IronPort-AV: E=Sophos;i="5.99,269,1677571200"; d="scan'208";a="1030124454" Received: from irvmail002.ir.intel.com ([10.43.11.120]) by fmsmga005.fm.intel.com with ESMTP; 12 May 2023 08:28:38 -0700 Received: from lincoln.igk.intel.com (lincoln.igk.intel.com [10.102.21.235]) by irvmail002.ir.intel.com (Postfix) with ESMTP id 5490935FB9; Fri, 12 May 2023 16:28:36 +0100 (IST) From: Larysa Zaremba To: bpf@vger.kernel.org Date: Fri, 12 May 2023 17:25:55 +0200 Message-Id: <20230512152607.992209-4-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 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683905323; x=1715441323; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wWhxMWiLcPZY9NZb4EwY/NQl1nkjgZ1XPyV3TLzPC7M=; b=LHX8gHNUygvHdzOzEl1dkyX+JqWMg14fqk5z4SCGD3zuhn81ut93VzUg LQ2DkaF+kCr/spt8RTlhDOKbXSQcFjJcvUwzxGYTOZB3coMufOCqrSA3f ZmEtqhJ8z0S3L0iDmqGfmzJFd6C4LGf23BlDyj1on/OHmHT60ZOLj5Uu/ Z992dO4cFfwFajGJtVKEy2jH4xBlYiMUAn2IDhkK6yIkqx7QRQLvTWok8 eXEe89HOBJRWqRBvHAqc0Cl7t8HiBm+UyZp1hvLURotblwAXjKcE27Iu0 NI8F/jxy/8EM13gp44+SanZUAHo2pk+Hlbjph39oExOHlJeqd6eb1pKfo w==; X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=LHX8gHNU Subject: [Intel-wired-lan] [PATCH RESEND bpf-next 03/15] ice: make RX checksum checking code more reusable 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: Anatoly Burakov , Alexei Starovoitov , Andrii Nakryiko , Song Liu , Tony Nguyen , Stanislav Fomichev , Maryam Tahhan , xdp-hints@xdp-project.net, Daniel Borkmann , John Fastabend , Jesse Brandeburg , intel-wired-lan@lists.osuosl.org, Jesper Dangaard Brouer , Yonghong Song , Larysa Zaremba , KP Singh , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jiri Olsa , Martin KaFai Lau Errors-To: intel-wired-lan-bounces@osuosl.org Sender: "Intel-wired-lan" Previously, we only needed RX checksum flags 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 determining checksum status into a separate function. Signed-off-by: Larysa Zaremba --- drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 71 ++++++++++++------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c index 1aab79dc8915..6a4fd3f3fc0a 100644 --- a/drivers/net/ethernet/intel/ice/ice_txrx_lib.c +++ b/drivers/net/ethernet/intel/ice/ice_txrx_lib.c @@ -104,17 +104,17 @@ ice_rx_hash_to_skb(struct ice_rx_ring *rx_ring, } /** - * ice_rx_csum - Indicate in skb if checksum is good - * @ring: the ring we care about - * @skb: skb currently being received and modified + * ice_rx_csum_checked - Indicates, whether hardware has checked the checksum * @rx_desc: the receive descriptor * @ptype: the packet type decoded by hardware + * @csum_lvl_dst: address to put checksum level into + * @ring: ring for error stats, can be NULL * - * skb->protocol must be set before this function is called + * Returns true, if hardware has checked the checksum. */ -static void -ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb, - union ice_32b_rx_flex_desc *rx_desc, u16 ptype) +static bool +ice_rx_csum_checked(union ice_32b_rx_flex_desc *rx_desc, u16 ptype, + u8 *csum_lvl_dst, struct ice_rx_ring *ring) { struct ice_rx_ptype_decoded decoded; u16 rx_status0, rx_status1; @@ -125,20 +125,12 @@ ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb, decoded = ice_decode_rx_desc_ptype(ptype); - /* Start with CHECKSUM_NONE and by default csum_level = 0 */ - skb->ip_summed = CHECKSUM_NONE; - skb_checksum_none_assert(skb); - - /* check if Rx checksum is enabled */ - if (!(ring->netdev->features & NETIF_F_RXCSUM)) - return; - /* check if HW has decoded the packet and checksum */ if (!(rx_status0 & BIT(ICE_RX_FLEX_DESC_STATUS0_L3L4P_S))) - return; + return false; if (!(decoded.known && decoded.outer_ip)) - return; + return false; ipv4 = (decoded.outer_ip == ICE_RX_PTYPE_OUTER_IP) && (decoded.outer_ip_ver == ICE_RX_PTYPE_OUTER_IPV4); @@ -168,22 +160,51 @@ ice_rx_csum(struct ice_rx_ring *ring, struct sk_buff *skb, * we are indicating we validated the inner checksum. */ if (decoded.tunnel_type >= ICE_RX_PTYPE_TUNNEL_IP_GRENAT) - skb->csum_level = 1; + *csum_lvl_dst = 1; /* Only report checksum unnecessary for TCP, UDP, or SCTP */ switch (decoded.inner_prot) { case ICE_RX_PTYPE_INNER_PROT_TCP: case ICE_RX_PTYPE_INNER_PROT_UDP: case ICE_RX_PTYPE_INNER_PROT_SCTP: - skb->ip_summed = CHECKSUM_UNNECESSARY; - break; - default: - break; + return true; } - return; + + return false; checksum_fail: - ring->vsi->back->hw_csum_rx_error++; + if (ring) + ring->vsi->back->hw_csum_rx_error++; + + return false; +} + +/** + * ice_rx_csum_into_skb - Indicate in skb if checksum is good + * @ring: the ring we care about + * @skb: skb currently being received and modified + * @rx_desc: the receive descriptor + * @ptype: the packet type decoded by hardware + */ +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; + + /* Start with CHECKSUM_NONE and by default csum_level = 0 */ + skb->ip_summed = CHECKSUM_NONE; + skb_checksum_none_assert(skb); + + /* check if Rx checksum is enabled */ + if (!(ring->netdev->features & NETIF_F_RXCSUM)) + return; + + if (!ice_rx_csum_checked(rx_desc, ptype, &csum_level, ring)) + return; + + skb->ip_summed = CHECKSUM_UNNECESSARY; + skb->csum_level = csum_level; } /** @@ -232,7 +253,7 @@ ice_process_skb_fields(struct ice_rx_ring *rx_ring, /* modifies the skb - consumes the enet header */ skb->protocol = eth_type_trans(skb, rx_ring->netdev); - ice_rx_csum(rx_ring, skb, rx_desc, ptype); + ice_rx_csum_into_skb(rx_ring, skb, rx_desc, ptype); if (rx_ring->ptp_rx) ice_ptp_rx_hwts_to_skb(rx_ring, rx_desc, skb);