summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2017-06-08 14:33:47 +0000
committermav <mav@FreeBSD.org>2017-06-08 14:33:47 +0000
commit85c25de3733c5de0c5d9f29eaa3ea3fc9598bee0 (patch)
tree40ff6fa5340c45141da4cff002c7eb8133c8d5e1 /sys/net
parent25eb2a63b566c12a0939c1d3c5e016347f768a14 (diff)
downloadFreeBSD-src-85c25de3733c5de0c5d9f29eaa3ea3fc9598bee0.zip
FreeBSD-src-85c25de3733c5de0c5d9f29eaa3ea3fc9598bee0.tar.gz
MFC r318966: Improve applying unified capabilities to the lagg ports.
Some NICs have some capabilities dependent, so that disabling one require disabling some other (TXCSUM/RXCSUM on em). This code tries to reach the consensus more insistently. Approved by: re (marius)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_lagg.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c
index bf9c05f..69d2f35 100644
--- a/sys/net/if_lagg.c
+++ b/sys/net/if_lagg.c
@@ -561,24 +561,41 @@ static void
lagg_capabilities(struct lagg_softc *sc)
{
struct lagg_port *lp;
- int cap = ~0, ena = ~0;
- u_long hwa = ~0UL;
+ int cap, ena, pena;
+ uint64_t hwa;
struct ifnet_hw_tsomax hw_tsomax;
LAGG_XLOCK_ASSERT(sc);
- memset(&hw_tsomax, 0, sizeof(hw_tsomax));
+ /* Get common enabled capabilities for the lagg ports */
+ ena = ~0;
+ SLIST_FOREACH(lp, &sc->sc_ports, lp_entries)
+ ena &= lp->lp_ifp->if_capenable;
+ ena = (ena == ~0 ? 0 : ena);
+
+ /*
+ * Apply common enabled capabilities back to the lagg ports.
+ * May require several iterations if they are dependent.
+ */
+ do {
+ pena = ena;
+ SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) {
+ lagg_setcaps(lp, ena);
+ ena &= lp->lp_ifp->if_capenable;
+ }
+ } while (pena != ena);
- /* Get capabilities from the lagg ports */
+ /* Get other capabilities from the lagg ports */
+ cap = ~0;
+ hwa = ~(uint64_t)0;
+ memset(&hw_tsomax, 0, sizeof(hw_tsomax));
SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) {
cap &= lp->lp_ifp->if_capabilities;
- ena &= lp->lp_ifp->if_capenable;
hwa &= lp->lp_ifp->if_hwassist;
if_hw_tsomax_common(lp->lp_ifp, &hw_tsomax);
}
cap = (cap == ~0 ? 0 : cap);
- ena = (ena == ~0 ? 0 : ena);
- hwa = (hwa == ~0 ? 0 : hwa);
+ hwa = (hwa == ~(uint64_t)0 ? 0 : hwa);
if (sc->sc_ifp->if_capabilities != cap ||
sc->sc_ifp->if_capenable != ena ||
@@ -593,10 +610,6 @@ lagg_capabilities(struct lagg_softc *sc)
if_printf(sc->sc_ifp,
"capabilities 0x%08x enabled 0x%08x\n", cap, ena);
}
-
- /* Apply unified capabilities back to the lagg ports. */
- SLIST_FOREACH(lp, &sc->sc_ports, lp_entries)
- lagg_setcaps(lp, ena);
}
static int
OpenPOWER on IntegriCloud