| 663 | } |
| 664 | |
| 665 | static void |
| 666 | lagg_capabilities(struct lagg_softc *sc) |
| 667 | { |
| 668 | struct lagg_port *lp; |
| 669 | int cap, ena, pena; |
| 670 | uint64_t hwa; |
| 671 | struct ifnet_hw_tsomax hw_tsomax; |
| 672 | |
| 673 | LAGG_XLOCK_ASSERT(sc); |
| 674 | |
| 675 | /* Get common enabled capabilities for the lagg ports */ |
| 676 | ena = ~0; |
| 677 | CK_SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) |
| 678 | ena &= lp->lp_ifp->if_capenable; |
| 679 | ena = (ena == ~0 ? 0 : ena); |
| 680 | |
| 681 | /* |
| 682 | * Apply common enabled capabilities back to the lagg ports. |
| 683 | * May require several iterations if they are dependent. |
| 684 | */ |
| 685 | do { |
| 686 | pena = ena; |
| 687 | CK_SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { |
| 688 | lagg_setcaps(lp, ena); |
| 689 | ena &= lp->lp_ifp->if_capenable; |
| 690 | } |
| 691 | } while (pena != ena); |
| 692 | |
| 693 | /* Get other capabilities from the lagg ports */ |
| 694 | cap = ~0; |
| 695 | hwa = ~(uint64_t)0; |
| 696 | memset(&hw_tsomax, 0, sizeof(hw_tsomax)); |
| 697 | CK_SLIST_FOREACH(lp, &sc->sc_ports, lp_entries) { |
| 698 | cap &= lp->lp_ifp->if_capabilities; |
| 699 | hwa &= lp->lp_ifp->if_hwassist; |
| 700 | if_hw_tsomax_common(lp->lp_ifp, &hw_tsomax); |
| 701 | } |
| 702 | cap = (cap == ~0 ? 0 : cap); |
| 703 | hwa = (hwa == ~(uint64_t)0 ? 0 : hwa); |
| 704 | |
| 705 | if (sc->sc_ifp->if_capabilities != cap || |
| 706 | sc->sc_ifp->if_capenable != ena || |
| 707 | sc->sc_ifp->if_hwassist != hwa || |
| 708 | if_hw_tsomax_update(sc->sc_ifp, &hw_tsomax) != 0) { |
| 709 | sc->sc_ifp->if_capabilities = cap; |
| 710 | sc->sc_ifp->if_capenable = ena; |
| 711 | sc->sc_ifp->if_hwassist = hwa; |
| 712 | getmicrotime(&sc->sc_ifp->if_lastchange); |
| 713 | |
| 714 | if (sc->sc_ifflags & IFF_DEBUG) |
| 715 | if_printf(sc->sc_ifp, |
| 716 | "capabilities 0x%08x enabled 0x%08x\n", cap, ena); |
| 717 | } |
| 718 | } |
| 719 | |
| 720 | static int |
| 721 | lagg_port_create(struct lagg_softc *sc, struct ifnet *ifp) |
no test coverage detected