diff options
Diffstat (limited to 'sys/dev/dpaa2/dpaa2_ni.c')
| -rw-r--r-- | sys/dev/dpaa2/dpaa2_ni.c | 52 |
1 files 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: " |
