FreeBSD/sys/net/ieee8023ad_lacp.c
/*
 * lacp_select_active_aggregator: select an aggregator to be used to transmit
 * packets from lagg(4) interface.
 */
select an aggregator to be used to transmit
packets from lagg(4) interface.
select an aggregator to be used to transmit packets from lagg ( 4 ) interface .
static void
lacp_select_active_aggregator(struct lacp_softc *lsc)
{
	struct lacp_aggregator *la;
	struct lacp_aggregator *best_la = NULL;
	uint64_t best_speed = 0;
	char buf[LACP_LAGIDSTR_MAX+1];
	LACP_TRACE(NULL);
	TAILQ_FOREACH(la, &lsc->lsc_aggregators, la_q) {
		uint64_t speed;
		if (la->la_nports == 0) {
			continue;
		}
		speed = lacp_aggregator_bandwidth(la);
		LACP_DPRINTF((NULL, "%s, speed=%jd, nports=%d\n",
		    lacp_format_lagid_aggregator(la, buf, sizeof(buf)),
		    speed, la->la_nports));
		if ((best_la != NULL && LACP_SYS_PRI(la->la_partner) <
		    LACP_SYS_PRI(best_la->la_partner)) ||
		    speed > best_speed ||
		    (speed == best_speed &&
		    la == lsc->lsc_active_aggregator)) {
			best_la = la;
			best_speed = speed;
		}
	}
	KASSERT(best_la == NULL || best_la->la_nports > 0,
	    ("invalid aggregator refcnt"));
	KASSERT(best_la == NULL || !TAILQ_EMPTY(&best_la->la_ports),
	    ("invalid aggregator list"));
	if (lsc->lsc_active_aggregator != best_la) {
		LACP_DPRINTF((NULL, "active aggregator changed\n"));
		LACP_DPRINTF((NULL, "old %s\n",
		    lacp_format_lagid_aggregator(lsc->lsc_active_aggregator,
		    buf, sizeof(buf))));
	} else {
		LACP_DPRINTF((NULL, "active aggregator not changed\n"));
	}
	LACP_DPRINTF((NULL, "new %s\n",
	    lacp_format_lagid_aggregator(best_la, buf, sizeof(buf))));
	if (lsc->lsc_active_aggregator != best_la) {
		lsc->lsc_active_aggregator = best_la;
		lacp_update_portmap(lsc);
		if (best_la) {
			lacp_suppress_distributing(lsc, best_la);
		}
	}
}
static void lacp_select_active_aggregator ( struct lacp_softc * lsc ) { struct lacp_aggregator * la ; struct lacp_aggregator * best_la = NULL ; uint64_t best_speed = 0 ; char buf [ LACP_LAGIDSTR_MAX + 1 ] ; LACP_TRACE ( NULL ) ; TAILQ_FOREACH ( la , & lsc -> lsc_aggregators , la_q ) { uint64_t speed ; if ( la -> la_nports == 0 ) { continue ; } speed = lacp_aggregator_bandwidth ( la ) ; LACP_DPRINTF ( ( NULL , " \n " , lacp_format_lagid_aggregator ( la , buf , sizeof ( buf ) ) , speed , la -> la_nports ) ) ; if ( ( best_la != NULL && LACP_SYS_PRI ( la -> la_partner ) < LACP_SYS_PRI ( best_la -> la_partner ) ) || speed > best_speed || ( speed == best_speed && la == lsc -> lsc_active_aggregator ) ) { best_la = la ; best_speed = speed ; } } KASSERT ( best_la == NULL || best_la -> la_nports > 0 , ( " " ) ) ; KASSERT ( best_la == NULL || ! TAILQ_EMPTY ( & best_la -> la_ports ) , ( " " ) ) ; if ( lsc -> lsc_active_aggregator != best_la ) { LACP_DPRINTF ( ( NULL , " \n " ) ) ; LACP_DPRINTF ( ( NULL , " \n " , lacp_format_lagid_aggregator ( lsc -> lsc_active_aggregator , buf , sizeof ( buf ) ) ) ) ; } else { LACP_DPRINTF ( ( NULL , " \n " ) ) ; } LACP_DPRINTF ( ( NULL , " \n " , lacp_format_lagid_aggregator ( best_la , buf , sizeof ( buf ) ) ) ) ; if ( lsc -> lsc_active_aggregator != best_la ) { lsc -> lsc_active_aggregator = best_la ; lacp_update_portmap ( lsc ) ; if ( best_la ) { lacp_suppress_distributing ( lsc , best_la ) ; } } }
lacp_select_active_aggregator: select an aggregator to be used to transmit
 packets from lagg(4) interface.
lacp_select_active_aggregator : select an aggregator to be used to transmit packets from lagg ( 4 ) interface .
/*
		 * This aggregator is chosen if the partner has a better
		 * system priority or, the total aggregated speed is higher
		 * or, it is already the chosen aggregator
		 */