ure: improve checksum offloading

This patch fixes three issues:
(1) Initially, set the hwassist flags correctly when enabling
    transmit checksum offload for TCP/IPv6 and UDP/IPv6.
(2) Keep the hwassist flags in sync with the capabilities when
    changing txcsum.
(3) Keep the hwasssit flags in sync with the capabilities when
    changing txcsum6.
Without this patch, transmit checksum offloading for TCP/IPv6 and
UDP/IPv6 is never used and transmit checksum offloading for IPv4,
TCP/IPv4 and UDP/IPv4 is always used, even if disabled via
ifconfig ue? -txcsum.

Reviewed by:		Timo Völker
MFC after:		3 days
Differential Revision:	https://reviews.freebsd.org/D54974
This commit is contained in:
Michael Tuexen
2026-01-31 11:42:10 +01:00
parent ab9b047369
commit 7b6e84c9ac
+3
View File
@@ -1015,6 +1015,7 @@ ure_attach_post_sub(struct usb_ether *ue)
if_sethwassist(ifp, CSUM_IP|CSUM_IP_UDP|CSUM_IP_TCP);
#ifdef INET6
if_setcapabilitiesbit(ifp, IFCAP_HWCSUM_IPV6, 0);
if_sethwassistbits(ifp, CSUM_IP6_UDP|CSUM_IP6_TCP, 0);
#endif
if_setcapenable(ifp, if_getcapabilities(ifp));
@@ -1463,6 +1464,7 @@ ure_ioctl(if_t ifp, u_long cmd, caddr_t data)
if ((mask & IFCAP_TXCSUM) != 0 &&
(if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
if_togglecapenable(ifp, IFCAP_TXCSUM);
if_togglehwassist(ifp, CSUM_IP|CSUM_IP_UDP|CSUM_IP_TCP);
}
if ((mask & IFCAP_RXCSUM) != 0 &&
(if_getcapabilities(ifp) & IFCAP_RXCSUM) != 0) {
@@ -1471,6 +1473,7 @@ ure_ioctl(if_t ifp, u_long cmd, caddr_t data)
if ((mask & IFCAP_TXCSUM_IPV6) != 0 &&
(if_getcapabilities(ifp) & IFCAP_TXCSUM_IPV6) != 0) {
if_togglecapenable(ifp, IFCAP_TXCSUM_IPV6);
if_togglehwassist(ifp, CSUM_IP6_UDP|CSUM_IP6_TCP);
}
if ((mask & IFCAP_RXCSUM_IPV6) != 0 &&
(if_getcapabilities(ifp) & IFCAP_RXCSUM_IPV6) != 0) {