From: Paul Barker <paul.barker.ct@bp.renesas.com>
To: Sergey Shtylyov <s.shtylyov@omp.ru>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: "Paul Barker" <paul.barker.ct@bp.renesas.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Niklas Söderlund" <niklas.soderlund+renesas@ragnatech.se>,
"Biju Das" <biju.das.jz@bp.renesas.com>,
"Claudiu Beznea" <claudiu.beznea.uj@bp.renesas.com>,
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 [thread overview]
Message-ID: <20241015133634.193-6-paul.barker.ct@bp.renesas.com> (raw)
In-Reply-To: <20241015133634.193-1-paul.barker.ct@bp.renesas.com>
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 <paul.barker.ct@bp.renesas.com>
---
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;
}
--
2.43.0
next prev parent reply other threads:[~2024-10-15 13:37 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 13:36 [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 01/10] net: ravb: Factor out checksum offload enable bits Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 02/10] net: ravb: Disable IP header RX checksum offloading Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 03/10] net: ravb: Drop IP protocol check from RX csum verification Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 04/10] net: ravb: Combine if conditions in RX csum validation Paul Barker
2024-10-15 13:36 ` Paul Barker [this message]
2024-10-15 15:23 ` [net-next PATCH v2 05/10] net: ravb: Simplify types " Sergey Shtylyov
2024-10-15 13:36 ` [net-next PATCH v2 06/10] net: ravb: Disable IP header TX checksum offloading Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 07/10] net: ravb: Simplify UDP TX checksum offload Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 08/10] net: ravb: Enable IPv6 RX checksum offloading for GbEth Paul Barker
2024-10-15 13:36 ` [net-next PATCH v2 09/10] net: ravb: Enable IPv6 TX checksum offload " Paul Barker
2024-10-15 15:47 ` Sergey Shtylyov
2024-10-15 13:36 ` [net-next PATCH v2 10/10] net: ravb: Add VLAN checksum support Paul Barker
2024-10-15 15:50 ` Sergey Shtylyov
2024-10-18 2:30 ` [net-next PATCH v2 00/10] Extend GbEth checksum offload support to VLAN/IPv6 packets patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241015133634.193-6-paul.barker.ct@bp.renesas.com \
--to=paul.barker.ct@bp.renesas.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=geert+renesas@glider.be \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=niklas.soderlund+renesas@ragnatech.se \
--cc=pabeni@redhat.com \
--cc=s.shtylyov@omp.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).