git: 378577393e40 - main - ure: improve receive checksum offloading
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 10 Feb 2026 17:13:58 UTC
The branch main has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=378577393e407fa2cd9677392da2287e37b4dd33
commit 378577393e407fa2cd9677392da2287e37b4dd33
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2026-02-10 17:08:07 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2026-02-10 17:13:48 +0000
ure: improve receive checksum offloading
Let the receive checksum offload for TCP/IPv6 and UDP/IPv6 be
controlled by ifconfig rxcsum6 and not by ifconfig rxcsum.
While there, make the code more compact and improve stlye.9
conformity.
Reviewed by: Timo Völker
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D55188
---
sys/dev/usb/net/if_ure.c | 38 +++++++++++++++-----------------------
1 file changed, 15 insertions(+), 23 deletions(-)
diff --git a/sys/dev/usb/net/if_ure.c b/sys/dev/usb/net/if_ure.c
index 92160fe9b1d2..257051e6e379 100644
--- a/sys/dev/usb/net/if_ure.c
+++ b/sys/dev/usb/net/if_ure.c
@@ -2131,41 +2131,33 @@ ure_rtl8152_nic_reset(struct ure_softc *sc)
static void
ure_rxcsum(int capenb, struct ure_rxpkt *rp, struct mbuf *m)
{
- int flags;
uint32_t csum, misc;
- int tcp, udp;
m->m_pkthdr.csum_flags = 0;
- if (!(capenb & IFCAP_RXCSUM))
- return;
-
csum = le32toh(rp->ure_csum);
misc = le32toh(rp->ure_misc);
- tcp = udp = 0;
-
- flags = 0;
- if (csum & URE_RXPKT_IPV4_CS)
- flags |= CSUM_IP_CHECKED;
- else if (csum & URE_RXPKT_IPV6_CS)
- flags = 0;
-
- tcp = rp->ure_csum & URE_RXPKT_TCP_CS;
- udp = rp->ure_csum & URE_RXPKT_UDP_CS;
+ if ((capenb & IFCAP_RXCSUM) == 0 &&
+ (csum & URE_RXPKT_IPV4_CS) != 0)
+ return;
+ if ((capenb & IFCAP_RXCSUM_IPV6) == 0 &&
+ (csum & URE_RXPKT_IPV6_CS) != 0)
+ return;
- if (__predict_true((flags & CSUM_IP_CHECKED) &&
- !(misc & URE_RXPKT_IP_F))) {
- flags |= CSUM_IP_VALID;
+ if ((csum & URE_RXPKT_IPV4_CS) != 0) {
+ m->m_pkthdr.csum_flags |= CSUM_IP_CHECKED;
+ if (__predict_true((misc & URE_RXPKT_IP_F) == 0))
+ m->m_pkthdr.csum_flags |= CSUM_IP_VALID;
}
if (__predict_true(
- (tcp && !(misc & URE_RXPKT_TCP_F)) ||
- (udp && !(misc & URE_RXPKT_UDP_F)))) {
- flags |= CSUM_DATA_VALID|CSUM_PSEUDO_HDR;
+ ((rp->ure_csum & URE_RXPKT_TCP_CS) != 0 &&
+ (misc & URE_RXPKT_TCP_F) == 0) ||
+ ((rp->ure_csum & URE_RXPKT_UDP_CS) != 0 &&
+ (misc & URE_RXPKT_UDP_F) == 0))) {
+ m->m_pkthdr.csum_flags |= CSUM_DATA_VALID | CSUM_PSEUDO_HDR;
m->m_pkthdr.csum_data = 0xFFFF;
}
-
- m->m_pkthdr.csum_flags = flags;
}
/*