From nobody Wed Nov 27 00:30:04 2024 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0FA41D5146; Tue, 15 Oct 2024 13:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999428; cv=none; b=qWXW6TAmDpgu8FV0dtPlKUn7XAH09JSHOawrzh3hs8hp7qeiuqt9MwG8ZyBBxiDmoV5zE91a8q020vC4FR+Og6yYqrFEyWvG8M+YmPIUDgUDpqFvnl1NgdLmWeUP0CzXL8F+HzmQe1y0iwtFibyEc1EDNnOQYiVpkq/WMyG+E88= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999428; c=relaxed/simple; bh=qduMfvyPHe2PDaTlXTgdwzk4KaEENNuQxzLZoalphkI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FQciF8+ukybK1C7CV3TBzA+MXxyGV4/VWeyOfKNHtsAGbKep6a6879oiM5MeP/ytU/pbyOA4lz5tAJ4Hh5+x+vvtNHqZ90586AMnQZwyszhg3irYCmSibmnf0tSPSGH9D9gHsAouFQ7vGS6Znfmt5qt8LhmAe71tkPq2AIa6k0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com; spf=pass smtp.mailfrom=bp.renesas.com; arc=none smtp.client-ip=210.160.252.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bp.renesas.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bp.renesas.com X-IronPort-AV: E=Sophos;i="6.11,205,1725289200"; d="scan'208";a="225980126" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:04 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id E854F4007529; Tue, 15 Oct 2024 22:36:55 +0900 (JST) From: Paul Barker To: Sergey Shtylyov , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Paul Barker , Geert Uytterhoeven , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 02/10] net: ravb: Disable IP header RX checksum offloading Date: Tue, 15 Oct 2024 14:36:26 +0100 Message-Id: <20241015133634.193-3-paul.barker.ct@bp.renesas.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20241015133634.193-1-paul.barker.ct@bp.renesas.com> References: <20241015133634.193-1-paul.barker.ct@bp.renesas.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For IPv4 packets, the header checksum will always be checked in software in the RX path (inet_gro_receive() calls ip_fast_csum() unconditionally) so there is no advantage in asking the hardware to also calculate this checksum. Reviewed-by: Sergey Shtylyov Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/ren= esas/ravb.h index 4e1e0a754cd9..98496aa39f3d 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1014,7 +1014,7 @@ enum CSR2_BIT { CSR2_RDHD =3D 0x08000000, }; =20 -#define CSR2_CSUM_ENABLE (CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP= 4) +#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) =20 #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/etherne= t/renesas/ravb_main.c index c8988c0c85a1..43db69d03684 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -749,13 +749,18 @@ static void ravb_get_tx_tstamp(struct net_device *nde= v) static void ravb_rx_csum_gbeth(struct sk_buff *skb) { struct skb_shared_info *shinfo =3D skb_shinfo(skb); - __wsum csum_ip_hdr, csum_proto; + __wsum csum_proto; skb_frag_t *last_frag; u8 *hw_csum; =20 /* The hardware checksum status is contained in sizeof(__sum16) * 2 =3D 4 - * bytes appended to packet data. First 2 bytes is ip header checksum - * and last 2 bytes is protocol checksum. + * bytes appended to packet data. + * + * For ipv4, the first 2 bytes are the ip header checksum status. We can + * ignore this as it will always be re-checked in inet_gro_receive(). + * + * The last 2 bytes are the protocol checksum status which will be zero + * if the checksum has been validated. */ if (unlikely(skb->len < sizeof(__sum16) * 2)) return; @@ -771,16 +776,13 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) hw_csum -=3D sizeof(__sum16); csum_proto =3D csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); =20 - hw_csum -=3D sizeof(__sum16); - csum_ip_hdr =3D csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - if (skb_is_nonlinear(skb)) skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); else skb_trim(skb, skb->len - 2 * sizeof(__sum16)); =20 /* TODO: IPV6 Rx checksum */ - if (skb->protocol =3D=3D htons(ETH_P_IP) && !csum_ip_hdr && !csum_proto) + if (skb->protocol =3D=3D htons(ETH_P_IP) && !csum_proto) skb->ip_summed =3D CHECKSUM_UNNECESSARY; } =20 --=20 2.43.0