Date: Wed, 19 Nov 2025 22:24:44 +0000 From: Dmitry Salychev <dsl@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: a731cb93a662 - main - dpaa2: Setup interface caps on attach Message-ID: <691e43ac.358da.4734848a@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by dsl: URL: https://cgit.FreeBSD.org/src/commit/?id=a731cb93a66271713d6ea197946e4a307e5b0837 commit a731cb93a66271713d6ea197946e4a307e5b0837 Author: Dmitry Salychev <dsl@FreeBSD.org> AuthorDate: 2025-10-28 22:30:05 +0000 Commit: Dmitry Salychev <dsl@FreeBSD.org> CommitDate: 2025-11-19 22:23:30 +0000 dpaa2: Setup interface caps on attach 39d4094173f9 ("epair: add support for checksum offloading") revealed that HW checksum offloading is not enabled when the dpaa2_ni driver is attached despite being declared and enabled on the dpni interface. I modified dpaa2_ni_setup_if_caps to take into account both IPv4 and IPv6 checksum offloading capabilities and added a call to re-configure interface capabilities on attach to fix it. Reviewed by: bz Fixes: 39d4094173f9 ("epair: add support for checksum offloading") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D53436 --- sys/dev/dpaa2/dpaa2_ni.c | 52 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/sys/dev/dpaa2/dpaa2_ni.c b/sys/dev/dpaa2/dpaa2_ni.c index 698b440376e3..98a6c6047188 100644 --- a/sys/dev/dpaa2/dpaa2_ni.c +++ b/sys/dev/dpaa2/dpaa2_ni.c @@ -559,7 +559,8 @@ dpaa2_ni_attach(device_t dev) if_settransmitfn(ifp, dpaa2_ni_transmit); if_setqflushfn(ifp, dpaa2_ni_qflush); - if_setcapabilities(ifp, IFCAP_VLAN_MTU | IFCAP_HWCSUM | IFCAP_JUMBO_MTU); + if_setcapabilities(ifp, IFCAP_VLAN_MTU | IFCAP_HWCSUM | + IFCAP_HWCSUM_IPV6 | IFCAP_JUMBO_MTU); if_setcapenable(ifp, if_getcapabilities(ifp)); DPAA2_CMD_INIT(&cmd); @@ -627,6 +628,12 @@ dpaa2_ni_attach(device_t dev) __func__, error); goto close_ni; } + error = dpaa2_ni_setup_if_caps(sc); + if (error) { + device_printf(dev, "%s: failed to setup interface capabilities: " + "error=%d\n", __func__, error); + goto close_ni; + } ether_ifattach(sc->ifp, sc->mac.addr); callout_init(&sc->mii_callout, 0); @@ -1569,8 +1576,7 @@ dpaa2_ni_setup_msi(struct dpaa2_ni_softc *sc) static int dpaa2_ni_setup_if_caps(struct dpaa2_ni_softc *sc) { - const bool en_rxcsum = if_getcapenable(sc->ifp) & IFCAP_RXCSUM; - const bool en_txcsum = if_getcapenable(sc->ifp) & IFCAP_TXCSUM; + bool en_rxcsum, en_txcsum; device_t pdev = device_get_parent(sc->dev); device_t dev = sc->dev; device_t child = dev; @@ -1582,6 +1588,17 @@ dpaa2_ni_setup_if_caps(struct dpaa2_ni_softc *sc) DPAA2_CMD_INIT(&cmd); + /* + * XXX-DSL: DPAA2 allows to validate L3/L4 checksums on reception and/or + * generate L3/L4 checksums on transmission without + * differentiating between IPv4/v6, i.e. enable for both + * protocols if requested. + */ + en_rxcsum = if_getcapenable(sc->ifp) & + (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); + en_txcsum = if_getcapenable(sc->ifp) & + (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6); + error = DPAA2_CMD_RC_OPEN(dev, child, &cmd, rcinfo->id, &rc_token); if (error) { device_printf(dev, "%s: failed to open resource container: " @@ -1627,6 +1644,13 @@ dpaa2_ni_setup_if_caps(struct dpaa2_ni_softc *sc) goto close_ni; } + if (bootverbose) { + device_printf(dev, "%s: L3/L4 checksum validation %s\n", + __func__, en_rxcsum ? "enabled" : "disabled"); + device_printf(dev, "%s: L3/L4 checksum generation %s\n", + __func__, en_txcsum ? "enabled" : "disabled"); + } + (void)DPAA2_CMD_NI_CLOSE(dev, child, &cmd); (void)DPAA2_CMD_RC_CLOSE(dev, child, DPAA2_CMD_TK(&cmd, rc_token)); return (0); @@ -2574,13 +2598,27 @@ dpaa2_ni_ioctl(if_t ifp, u_long c, caddr_t data) break; case SIOCSIFCAP: changed = if_getcapenable(ifp) ^ ifr->ifr_reqcap; - if (changed & IFCAP_HWCSUM) { - if ((ifr->ifr_reqcap & changed) & IFCAP_HWCSUM) { - if_setcapenablebit(ifp, IFCAP_HWCSUM, 0); + if (changed & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) { + if ((ifr->ifr_reqcap & changed) & + (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) { + if_setcapenablebit(ifp, + IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6, 0); } else { - if_setcapenablebit(ifp, 0, IFCAP_HWCSUM); + if_setcapenablebit(ifp, 0, + IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6); } } + if (changed & (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6)) { + if ((ifr->ifr_reqcap & changed) & + (IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6)) { + if_setcapenablebit(ifp, + IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6, 0); + } else { + if_setcapenablebit(ifp, 0, + IFCAP_TXCSUM | IFCAP_TXCSUM_IPV6); + } + } + rc = dpaa2_ni_setup_if_caps(sc); if (rc) { printf("%s: failed to update iface capabilities: "help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?691e43ac.358da.4734848a>
