From patchwork Tue Oct 15 13:36:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836438 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C5781B2186; 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=1728999427; cv=none; b=bC8a7b/2s6DCeUOFXkJTO4zZIZ+S4KYAwdoUR20nnZaoIqTV2ubzQsb2M5sgN2h/KAHOyJli2h1ltjlj4+mkc27GHhFAKAG1LUtm7EElb7GiPLOlV/fjcfhlAvsQD8mMkdug0gOtV+8SOQ81aEDOIUMCaNeDk8sMFRh2s8B1idI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999427; c=relaxed/simple; bh=cIPF8O6w578TCBywYCIAJCizeQZcSmWc+2nIE5wE4G4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uXwJzmT316tuTbNiZaNi2yfrivc6M9nL1qq9NKcE4hyGfXAXltxF5XXw3JV4nJKvb0ZVAIjcq3e8ESaWHtBh1W/sjsd2Qn0vcjiUkdQtXR/oqUod4T/aIke+XF+yMxqMR5u8TXxQC6Rik5psHACU91prm/lbSaujr055aIqIe+8= 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="225980124" 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 361FC400755A; Tue, 15 Oct 2024 22:36:50 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 01/10] net: ravb: Factor out checksum offload enable bits Date: Tue, 15 Oct 2024 14:36:25 +0100 Message-Id: <20241015133634.193-2-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce new constants for the CSR1 (TX) and CSR2 (RX) checksum enable bits, removing the risk of inconsistency when we change which flags we enable. Reviewed-by: Sergey Shtylyov Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb.h | 4 ++++ drivers/net/ethernet/renesas/ravb_main.c | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index a7de5cf6b317..4e1e0a754cd9 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,6 +998,8 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; +#define CSR1_CSUM_ENABLE (CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4) + enum CSR2_BIT { CSR2_RIP4 = 0x00000001, CSR2_RTCP4 = 0x00000010, @@ -1012,6 +1014,8 @@ enum CSR2_BIT { CSR2_RDHD = 0x08000000, }; +#define CSR2_CSUM_ENABLE (CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) + #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 #define NUM_RX_QUEUE 2 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 41f88f8836f8..c8988c0c85a1 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -504,11 +504,10 @@ static void ravb_csum_init_gbeth(struct net_device *ndev) ndev->features &= ~NETIF_F_RXCSUM; } else { if (tx_enable) - ravb_write(ndev, CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4, CSR1); + ravb_write(ndev, CSR1_CSUM_ENABLE, CSR1); if (rx_enable) - ravb_write(ndev, CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4, - CSR2); + ravb_write(ndev, CSR2_CSUM_ENABLE, CSR2); } done: @@ -2531,7 +2530,7 @@ static int ravb_set_features_gbeth(struct net_device *ndev, spin_lock_irqsave(&priv->lock, flags); if (changed & NETIF_F_RXCSUM) { if (features & NETIF_F_RXCSUM) - val = CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4; + val = CSR2_CSUM_ENABLE; else val = 0; @@ -2542,7 +2541,7 @@ static int ravb_set_features_gbeth(struct net_device *ndev, if (changed & NETIF_F_HW_CSUM) { if (features & NETIF_F_HW_CSUM) - val = CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4; + val = CSR1_CSUM_ENABLE; else val = 0; From patchwork Tue Oct 15 13:36:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836439 X-Patchwork-Delegate: geert@linux-m68k.org 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_S=C3=B6derlu?= =?utf-8?q?nd?= , 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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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/renesas/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 = 0x08000000, }; -#define CSR2_CSUM_ENABLE (CSR2_RIP4 | CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) +#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/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 *ndev) static void ravb_rx_csum_gbeth(struct sk_buff *skb) { struct skb_shared_info *shinfo = skb_shinfo(skb); - __wsum csum_ip_hdr, csum_proto; + __wsum csum_proto; skb_frag_t *last_frag; u8 *hw_csum; /* The hardware checksum status is contained in sizeof(__sum16) * 2 = 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 -= sizeof(__sum16); csum_proto = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - hw_csum -= sizeof(__sum16); - csum_ip_hdr = 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)); /* TODO: IPV6 Rx checksum */ - if (skb->protocol == htons(ETH_P_IP) && !csum_ip_hdr && !csum_proto) + if (skb->protocol == htons(ETH_P_IP) && !csum_proto) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Tue Oct 15 13:36:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836440 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D30DE1D5154; Tue, 15 Oct 2024 13:37:07 +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=1728999431; cv=none; b=SSkudQRped79LFCtQ+rs7DzLrPCuduoUHM/Ka0HUk3plIHGsuzdELXcl1N9ZozGcG7wdXi6nL7dfjKytwYFxQCPXm4abpby19EanXIhYpOaET1Y6KmSHqzXQx2qqsps89huLs0HCarkzedRxADTiTS+CK9WDa5q3NP2yFdxKFcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999431; c=relaxed/simple; bh=3LvpiDgqP364DkwjjEMvB6AdmZyr6ud/1FBUsOwGbGM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uPp3cmdqInVesZw81ens9QiWlYFCdsL+nEpwFoER4L9jdw1hP9bOLgrgNF3RYAmnf16gRB2VUYGrlLSeIggV6ibNwDTbYmDGlOP0iC2AaWTvk25ux/SEA0xYPqCz/1GTK+F9cfiudfteKchMUyFsoZOUd3T09ilCbEg8KW/5I8k= 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="225980130" 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 9FA454005E0C; Tue, 15 Oct 2024 22:37:00 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 03/10] net: ravb: Drop IP protocol check from RX csum verification Date: Tue, 15 Oct 2024 14:36:27 +0100 Message-Id: <20241015133634.193-4-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We do not need to confirm that the protocol is IPv4. If the hardware encounters an unsupported protocol, it will set the checksum value to 0xFFFF. Reviewed-by: Sergey Shtylyov Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 43db69d03684..4bc2532706c2 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -781,8 +781,7 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) else skb_trim(skb, skb->len - 2 * sizeof(__sum16)); - /* TODO: IPV6 Rx checksum */ - if (skb->protocol == htons(ETH_P_IP) && !csum_proto) + if (!csum_proto) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Tue Oct 15 13:36:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836453 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 172161AF0AE; Tue, 15 Oct 2024 13:37:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999444; cv=none; b=J/mI+cb2M9XTw9L6/qVqMoaOBG+0qzuoOEVisOGWtx/+g3tzEja9RiADoAJlO4hxs8xcL8zHF3qHtqVUlqrvZm0JlRmk8z1/8Lqi94gcjXk1st9rTZNS6YKRYHrzQjMOVs/QIxxdKExSIXqK5HtTmak80Xxt9DJazBO7n9Nzuy0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999444; c=relaxed/simple; bh=8SMBbbqWMUC0bk4bj1pzbRGvz1lhMyzwzMh2XDlZFUM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=E30gmDACDhMbe+bdq8ZMDND7/qFyhAhbw4/wP5ZUMytUywJaHnQpYCRSiQd8QiuDfhitVFzsFN2tIyGQtPGnYpGEzYpboUqGapmOW9gebDXQfOVzuoEjqPvry+OAL3FW4tFof2BS6K1OYrE2cnGbSZvaVF3qLJ99rrutzxfpX9U= 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.171 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="221998686" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:15 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 6B2B8400755A; Tue, 15 Oct 2024 22:37:05 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 04/10] net: ravb: Combine if conditions in RX csum validation Date: Tue, 15 Oct 2024 14:36:28 +0100 Message-Id: <20241015133634.193-5-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We can merge the two if conditions on skb_is_nonlinear(). Since skb_frag_size_sub() and skb_trim() do not free memory, it is still safe to access the trimmed bytes at the end of the packet after these calls. Reviewed-by: Sergey Shtylyov Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb_main.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 4bc2532706c2..2f584c353c78 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -750,7 +750,6 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) { struct skb_shared_info *shinfo = skb_shinfo(skb); __wsum csum_proto; - skb_frag_t *last_frag; u8 *hw_csum; /* The hardware checksum status is contained in sizeof(__sum16) * 2 = 4 @@ -766,21 +765,19 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) return; if (skb_is_nonlinear(skb)) { - last_frag = &shinfo->frags[shinfo->nr_frags - 1]; + skb_frag_t *last_frag = &shinfo->frags[shinfo->nr_frags - 1]; + hw_csum = skb_frag_address(last_frag) + skb_frag_size(last_frag); + skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); } else { hw_csum = skb_tail_pointer(skb); + skb_trim(skb, skb->len - 2 * sizeof(__sum16)); } hw_csum -= sizeof(__sum16); csum_proto = 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)); - if (!csum_proto) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Tue Oct 15 13:36:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836454 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BA921C07DD; Tue, 15 Oct 2024 13:37:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999446; cv=none; b=BtaWkxNmEZ++FwR1BELBkAGFF+2TOjRSdIk+rWZMmKxF21ga/M2XQAG7G8Ssu4gjDOTARte2K7dq7pg5m9ub8g2Ev0yeWdABD9knZn44N0h8q7hLCkhkIOqX8sAPE7x5ClWU4kyn8D8nzukdcoFJJ0INPJtOx1MQqmbGBn4xjSY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999446; c=relaxed/simple; bh=16GfyLirqF8+j5oLgvAk3nHhNGDQxQO8vfgC4gzQQ4s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qe2rHAu9nIaxmd4RLcQpXwxEWnCNfKeSUqXcyERmFmNY7Fi0rsAw2UEu8gYClIMeHCb3T7r61NSpWA5Tdor8v8eqqhEcR1qDkYkGi6N7QQZ4FgHJOXW0nfeXQq+fj2K6HHlTAuZ593IQbbv5RYPy/4A79Tx6rEyYWS2w+gJl/3g= 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.171 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="221998689" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:15 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 2A39E4005E0C; Tue, 15 Oct 2024 22:37:09 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 05/10] net: ravb: Simplify types in RX csum validation Date: Tue, 15 Oct 2024 14:36:29 +0100 Message-Id: <20241015133634.193-6-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The hardware checksum value is used as a 16-bit flag, it is zero when the checksum has been validated and non-zero otherwise. Therefore we don't need to treat this as an actual __wsum type or call csum_unfold(), we can just use a u16 pointer. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb_main.c | 26 +++++++++++------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 2f584c353c78..ca8f785b96b4 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -749,11 +749,11 @@ static void ravb_get_tx_tstamp(struct net_device *ndev) static void ravb_rx_csum_gbeth(struct sk_buff *skb) { struct skb_shared_info *shinfo = skb_shinfo(skb); - __wsum csum_proto; - u8 *hw_csum; + size_t csum_len; + u16 *hw_csum; - /* The hardware checksum status is contained in sizeof(__sum16) * 2 = 4 - * bytes appended to packet data. + /* The hardware checksum status is contained in 4 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(). @@ -761,24 +761,22 @@ static void ravb_rx_csum_gbeth(struct sk_buff *skb) * 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)) + csum_len = sizeof(*hw_csum) * 2; + if (unlikely(skb->len < csum_len)) return; if (skb_is_nonlinear(skb)) { skb_frag_t *last_frag = &shinfo->frags[shinfo->nr_frags - 1]; - hw_csum = skb_frag_address(last_frag) + - skb_frag_size(last_frag); - skb_frag_size_sub(last_frag, 2 * sizeof(__sum16)); + hw_csum = (u16 *)(skb_frag_address(last_frag) + + skb_frag_size(last_frag)); + skb_frag_size_sub(last_frag, csum_len); } else { - hw_csum = skb_tail_pointer(skb); - skb_trim(skb, skb->len - 2 * sizeof(__sum16)); + hw_csum = (u16 *)skb_tail_pointer(skb); + skb_trim(skb, skb->len - csum_len); } - hw_csum -= sizeof(__sum16); - csum_proto = csum_unfold((__force __sum16)get_unaligned_le16(hw_csum)); - - if (!csum_proto) + if (!get_unaligned(--hw_csum)) skb->ip_summed = CHECKSUM_UNNECESSARY; } From patchwork Tue Oct 15 13:36:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836455 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A83E1C07DD; Tue, 15 Oct 2024 13:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999450; cv=none; b=qXVFOugcBZ03g/1o8TDZbLiwdnGDR+5S8dp951pf6BXJEcG3oJir+GzPUaeiwgSMjImOB6GlucwadlQHT4KwSFmtMmKEuY1SK38HTI8cHL5zx2U+BoTgdLoXsFPMhMI9nqebzT3KYvt6qSeryFDp+RDvZZ58hwuNgXlPmMHVQHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999450; c=relaxed/simple; bh=+1CORkNEcU+tbqU4x8sfFFTSsiVLKAyf4utwrlBY780=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tW+7+LBTrHHrFjzTXeGW5AAQ7SdpJRAJSDqgrpLh1bFu1Ww6LuvtjYdABOv0gDDXSM7N+/MndHpxDzX5a/uvMPAm48k4tAh5gmk9Di7AcX0CkJL/UEabH3/A8f7cHU4BJn2sNtyi0hqlEPBySe1K9uIEufeQtUEr90ybSjD3Uac= 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.171 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="221998698" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:28 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id E0D1940031EA; Tue, 15 Oct 2024 22:37:14 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 06/10] net: ravb: Disable IP header TX checksum offloading Date: Tue, 15 Oct 2024 14:36:30 +0100 Message-Id: <20241015133634.193-7-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 For IPv4 packets, the header checksum will always be calculated in software in the TX path (Documentation/networking/checksum-offloads.rst says "No offloading of the IP header checksum is performed; it is always done in software.") 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 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index 98496aa39f3d..a5b4f4fe77b1 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,7 +998,7 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; -#define CSR1_CSUM_ENABLE (CSR1_TIP4 | CSR1_TTCP4 | CSR1_TUDP4) +#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4) enum CSR2_BIT { CSR2_RIP4 = 0x00000001, From patchwork Tue Oct 15 13:36:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836456 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D131E1AF0B9; Tue, 15 Oct 2024 13:37:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999459; cv=none; b=q2K8UghvMMlDZKFhfmZVPVBziz6j3SDptGq1ShIXjQxMupIrbt5v2hRLanwJB7oegl/IOyZmr1GPZlfqSLipFKN2gP8apwP5xDjz8ktIjade7H4cAdlo9Pus+ENhzu2mDuexHozY1Lpt9egM/L8WcFMzVaDO4LJhYHIGGwPbwQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999459; c=relaxed/simple; bh=oNh1LBfzKYEMAG2t3CpJgC1JHnKYkQ+eRce0cJyaSYg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pr6FTwLncae2ZqCLZvOOYsPRxg6d87+kbvh0GNP8zXK0ILdg/oCWDmDvgjJidMYeNyMDPVVIltaKjl1gACsIDXMKMSXhQa5jBhh5yYuxz+YwGBn6hE34NxE+1ahvuTRKjwLtPLv9whdeAiuHT8pHuGmxfgRhIbfN/XJLM5DKIL8= 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.171 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="221998705" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:36 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id A9D774007529; Tue, 15 Oct 2024 22:37:19 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 07/10] net: ravb: Simplify UDP TX checksum offload Date: Tue, 15 Oct 2024 14:36:31 +0100 Message-Id: <20241015133634.193-8-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The GbEth IP will pass through a zero UDP checksum without asserting any error flags so we do not need to resort to software checksum calculation in this case. Reviewed-by: Sergey Shtylyov Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb_main.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index ca8f785b96b4..80c0d36bffcb 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2075,20 +2075,11 @@ static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) switch (ip->protocol) { case IPPROTO_TCP: - break; case IPPROTO_UDP: - /* If the checksum value in the UDP header field is 0, TOE does - * not calculate checksum for UDP part of this frame as it is - * optional function as per standards. - */ - if (udp_hdr(skb)->check == 0) - return false; - break; + return true; default: return false; } - - return true; } /* Packet transmit function for Ethernet AVB */ From patchwork Tue Oct 15 13:36:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836457 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 913C41C07DD; Tue, 15 Oct 2024 13:37:38 +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=1728999460; cv=none; b=dluPKKDt7Xoab4Qu92WjzJ96MXfTZ2FfXNLzp6mzk06KxBI/+e2KronnfcVinX2pczRRAXb7bZpNYFIBEYVHF2pOeCZICsSO8pYEX5+ZSh8HhvasHxpjQyJjMCmy4/CSB/ruW+mhtGYnJ/4kFJ4QRO1TgncebV60EB5ysmsrRbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999460; c=relaxed/simple; bh=txyR+mA932jM1LipFmOg1u9e0+KitNu/lcqvX6Nf22M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CJQu+r0rP7haqQGFZfNLfBHO//E83Tiv6BuE2JGddOfFsVpNwdOJSMZ5cWXctgRc5cGkjUt8AciNvUHKUlnUWp3bKUu1rwKRcZyNgZRAvuZ+Keq9fneRJ/wqmjcA0bF56dRBJvTL4tPciyKY0ejiRYGxZwiTtleBZ20iOEQkUGs= 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="225980157" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:37 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 6F6D04005E3A; Tue, 15 Oct 2024 22:37:24 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 08/10] net: ravb: Enable IPv6 RX checksum offloading for GbEth Date: Tue, 15 Oct 2024 14:36:32 +0100 Message-Id: <20241015133634.193-9-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums in the RX path. Reviewed-by: Sergey Shtylyov Signed-off-by: Paul Barker --- drivers/net/ethernet/renesas/ravb.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index a5b4f4fe77b1..e1e55e677215 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1014,7 +1014,8 @@ enum CSR2_BIT { CSR2_RDHD = 0x08000000, }; -#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4) +#define CSR2_CSUM_ENABLE (CSR2_RTCP4 | CSR2_RUDP4 | CSR2_RICMP4 | \ + CSR2_RTCP6 | CSR2_RUDP6 | CSR2_RICMP6) #define DBAT_ENTRY_NUM 22 #define RX_QUEUE_OFFSET 4 From patchwork Tue Oct 15 13:36:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836459 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AA0531AF0BB; Tue, 15 Oct 2024 13:37:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=210.160.252.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999468; cv=none; b=OCjCzLqSr9vJLdiD25TK3KOgmhH4/LoZntVFXcklALav0HCclrur0woWg4mK3DxfPt/zBToFhk3JV7MhNeCEn0+hT6ofblvyIgZTjlYXjnBdsX6mU3J94Dxx3YGHIHwStFFk5roYUnGujdy11lS68fb91OumJzXw67VUyRCSWik= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999468; c=relaxed/simple; bh=bc5yl74zdn98bGrzflzZJhT8dVZ1ucUyhLi6xxRM+Rg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Y23DOypGNm9aZIAgZifyU5myEfWBK2QE3amZu1eOE7coYugjT0sp8YcwY0IZfOAbnSmA9/vK5UWb4Z+9wQfpzPEcb7vd6WyOsPAws6mPHyAcQoMny+N2gU72zhICepd1m+aBqc3ik3OjSQk+h9DuBzCDSFr1jEoh2Sz0DKYUe2M= 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.171 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="221998714" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:45 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id ADE22400755A; Tue, 15 Oct 2024 22:37:28 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload for GbEth Date: Tue, 15 Oct 2024 14:36:33 +0100 Message-Id: <20241015133634.193-10-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The GbEth IP supports offloading IPv6 TCP, UDP & ICMPv6 checksums in the TX path. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 2 +- drivers/net/ethernet/renesas/ravb_main.c | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index e1e55e677215..d7b3810ce21b 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -998,7 +998,7 @@ enum CSR1_BIT { CSR1_TDHD = 0x08000000, }; -#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4) +#define CSR1_CSUM_ENABLE (CSR1_TTCP4 | CSR1_TUDP4 | CSR1_TTCP6 | CSR1_TUDP6) enum CSR2_BIT { CSR2_RIP4 = 0x00000001, diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 80c0d36bffcb..14b4462331b0 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2063,17 +2063,24 @@ static void ravb_tx_timeout_work(struct work_struct *work) static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) { - struct iphdr *ip = ip_hdr(skb); + u8 inner_protocol; /* TODO: Need to add support for VLAN tag 802.1Q */ if (skb_vlan_tag_present(skb)) return false; - /* TODO: Need to add hardware checksum for IPv6 */ - if (skb->protocol != htons(ETH_P_IP)) + switch (ntohs(skb->protocol)) { + case ETH_P_IP: + inner_protocol = ip_hdr(skb)->protocol; + break; + case ETH_P_IPV6: + inner_protocol = ipv6_hdr(skb)->nexthdr; + break; + default: return false; + } - switch (ip->protocol) { + switch (inner_protocol) { case IPPROTO_TCP: case IPPROTO_UDP: return true; From patchwork Tue Oct 15 13:36:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Barker X-Patchwork-Id: 13836458 X-Patchwork-Delegate: geert@linux-m68k.org Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B083D1FAF14; Tue, 15 Oct 2024 13:37:40 +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=1728999462; cv=none; b=fU4TEpszesArAXCGEqE3aHuJQKb9+NRXDWoB/hCaLFKstJGF+9nN3Bt+8HlI51lWl89DuoBZkofkLumbm9gRNpdBV5S4IanXT8aCDIyoQztz/bk/98PaV8tvyOQM/XQUnQ5xXhb6ppx5De7vF31gPd+sKNcioaP51RgYYzG8wfI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728999462; c=relaxed/simple; bh=j6RReWYcf79gWTDSp+9jFx/cBR/XOms6tCBdzHuMCHc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W11uC32GiAHRuU7bgHaPOxR3RH0bpc6eJdLFsv3tZ8LTzX0Vdp3x3BBzTUCD+U8NBoi+XI/hZzFkug+ZCZqY4UWLSzKIKECBNEjkKw0vvGkvT6JVu1CcJ91efkjlKDhkbr8VWcg8Q+TvznitIHo12xunP//KuXzXvGgU4Ft1gqg= 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="225980160" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 15 Oct 2024 22:37:38 +0900 Received: from GBR-5CG2373LKG.adwin.renesas.com (unknown [10.226.93.176]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 687F040031EA; Tue, 15 Oct 2024 22:37:34 +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_S=C3=B6derlu?= =?utf-8?q?nd?= , Biju Das , Claudiu Beznea , netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support Date: Tue, 15 Oct 2024 14:36:34 +0100 Message-Id: <20241015133634.193-11-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-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The GbEth IP supports offloading checksum calculation for VLAN-tagged packets, provided that the EtherType is 0x8100 and only one VLAN tag is present. Signed-off-by: Paul Barker Reviewed-by: Sergey Shtylyov --- drivers/net/ethernet/renesas/ravb.h | 1 + drivers/net/ethernet/renesas/ravb_main.c | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h index d7b3810ce21b..7b48060c250b 100644 --- a/drivers/net/ethernet/renesas/ravb.h +++ b/drivers/net/ethernet/renesas/ravb.h @@ -1055,6 +1055,7 @@ struct ravb_hw_info { size_t gstrings_size; netdev_features_t net_hw_features; netdev_features_t net_features; + netdev_features_t vlan_features; int stats_len; u32 tccr_mask; u32 tx_max_frame_size; diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c index 14b4462331b0..bc56f1f4bec9 100644 --- a/drivers/net/ethernet/renesas/ravb_main.c +++ b/drivers/net/ethernet/renesas/ravb_main.c @@ -2063,13 +2063,27 @@ static void ravb_tx_timeout_work(struct work_struct *work) static bool ravb_can_tx_csum_gbeth(struct sk_buff *skb) { + u16 net_protocol = ntohs(skb->protocol); u8 inner_protocol; - /* TODO: Need to add support for VLAN tag 802.1Q */ - if (skb_vlan_tag_present(skb)) - return false; + /* GbEth IP can calculate the checksum if: + * - there are zero or one VLAN headers with TPID=0x8100 + * - the network protocol is IPv4 or IPv6 + * - the transport protocol is TCP, UDP or ICMP + * - the packet is not fragmented + */ + + if (net_protocol == ETH_P_8021Q) { + struct vlan_hdr vhdr, *vh; + + vh = skb_header_pointer(skb, ETH_HLEN, sizeof(vhdr), &vhdr); + if (!vh) + return false; + + net_protocol = ntohs(vh->h_vlan_encapsulated_proto); + } - switch (ntohs(skb->protocol)) { + switch (net_protocol) { case ETH_P_IP: inner_protocol = ip_hdr(skb)->protocol; break; @@ -2772,6 +2786,7 @@ static const struct ravb_hw_info gbeth_hw_info = { .gstrings_size = sizeof(ravb_gstrings_stats_gbeth), .net_hw_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM, .net_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM, + .vlan_features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM, .stats_len = ARRAY_SIZE(ravb_gstrings_stats_gbeth), .tccr_mask = TCCR_TSRQ0, .tx_max_frame_size = 1522, @@ -2914,6 +2929,7 @@ static int ravb_probe(struct platform_device *pdev) ndev->features = info->net_features; ndev->hw_features = info->net_hw_features; + ndev->vlan_features = info->vlan_features; error = reset_control_deassert(rstc); if (error)