Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/ieee8023ad_lacp.c
Show First 20 Lines • Show All 829 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
struct lagg_port * | struct lagg_port * | ||||
lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m) | lacp_select_tx_port(struct lagg_softc *sc, struct mbuf *m) | ||||
{ | { | ||||
struct lacp_softc *lsc = LACP_SOFTC(sc); | struct lacp_softc *lsc = LACP_SOFTC(sc); | ||||
struct lacp_portmap *pm; | struct lacp_portmap *pm; | ||||
struct lacp_port *lp; | struct lacp_port *lp; | ||||
struct lacp_port **map; | |||||
uint32_t hash; | uint32_t hash; | ||||
int count; | |||||
if (__predict_false(lsc->lsc_suppress_distributing)) { | if (__predict_false(lsc->lsc_suppress_distributing)) { | ||||
LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__)); | LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__)); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
pm = &lsc->lsc_pmap[lsc->lsc_activemap]; | pm = &lsc->lsc_pmap[lsc->lsc_activemap]; | ||||
if (pm->pm_count == 0) { | if (pm->pm_count == 0) { | ||||
LACP_DPRINTF((NULL, "%s: no active aggregator\n", __func__)); | LACP_DPRINTF((NULL, "%s: no active aggregator\n", __func__)); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
#ifdef NUMA | |||||
if ((sc->sc_opts & LAGG_OPT_USE_NUMA) && | |||||
pm->pm_num_dom > 1 && m->m_pkthdr.numa_domain < MAXMEMDOM) { | |||||
count = pm->pm_numa[m->m_pkthdr.numa_domain].count; | |||||
if (count > 0) { | |||||
map = pm->pm_numa[m->m_pkthdr.numa_domain].map; | |||||
} else { | |||||
/* No ports on this domain; use global hash. */ | |||||
map = pm->pm_map; | |||||
count = pm->pm_count; | |||||
} | |||||
} else | |||||
#endif | |||||
{ | |||||
map = pm->pm_map; | |||||
count = pm->pm_count; | |||||
} | |||||
if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && | if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) && | ||||
M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) | M_HASHTYPE_GET(m) != M_HASHTYPE_NONE) | ||||
hash = m->m_pkthdr.flowid >> sc->flowid_shift; | hash = m->m_pkthdr.flowid >> sc->flowid_shift; | ||||
else | else | ||||
hash = m_ether_tcpip_hash(sc->sc_flags, m, lsc->lsc_hashkey); | hash = m_ether_tcpip_hash(sc->sc_flags, m, lsc->lsc_hashkey); | ||||
hash %= pm->pm_count; | |||||
lp = pm->pm_map[hash]; | |||||
hash %= count; | |||||
lp = map[hash]; | |||||
KASSERT((lp->lp_state & LACP_STATE_DISTRIBUTING) != 0, | KASSERT((lp->lp_state & LACP_STATE_DISTRIBUTING) != 0, | ||||
("aggregated port is not distributing")); | ("aggregated port is not distributing")); | ||||
return (lp->lp_lagg); | return (lp->lp_lagg); | ||||
} | } | ||||
#ifdef RATELIMIT | #ifdef RATELIMIT | ||||
struct lagg_port * | struct lagg_port * | ||||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct lagg_softc *sc = lsc->lsc_softc; | struct lagg_softc *sc = lsc->lsc_softc; | ||||
struct lacp_aggregator *la; | struct lacp_aggregator *la; | ||||
struct lacp_portmap *p; | struct lacp_portmap *p; | ||||
struct lacp_port *lp; | struct lacp_port *lp; | ||||
uint64_t speed; | uint64_t speed; | ||||
u_int newmap; | u_int newmap; | ||||
int i; | int i; | ||||
#ifdef NUMA | |||||
int count; | |||||
uint8_t domain; | |||||
#endif | |||||
newmap = lsc->lsc_activemap == 0 ? 1 : 0; | newmap = lsc->lsc_activemap == 0 ? 1 : 0; | ||||
p = &lsc->lsc_pmap[newmap]; | p = &lsc->lsc_pmap[newmap]; | ||||
la = lsc->lsc_active_aggregator; | la = lsc->lsc_active_aggregator; | ||||
speed = 0; | speed = 0; | ||||
bzero(p, sizeof(struct lacp_portmap)); | bzero(p, sizeof(struct lacp_portmap)); | ||||
if (la != NULL && la->la_nports > 0) { | if (la != NULL && la->la_nports > 0) { | ||||
p->pm_count = la->la_nports; | p->pm_count = la->la_nports; | ||||
i = 0; | i = 0; | ||||
TAILQ_FOREACH(lp, &la->la_ports, lp_dist_q) | TAILQ_FOREACH(lp, &la->la_ports, lp_dist_q) { | ||||
p->pm_map[i++] = lp; | p->pm_map[i++] = lp; | ||||
#ifdef NUMA | |||||
domain = lp->lp_ifp->if_numa_domain; | |||||
if (domain >= MAXMEMDOM) | |||||
continue; | |||||
count = p->pm_numa[domain].count; | |||||
p->pm_numa[domain].map[count] = lp; | |||||
p->pm_numa[domain].count++; | |||||
#endif | |||||
} | |||||
KASSERT(i == p->pm_count, ("Invalid port count")); | KASSERT(i == p->pm_count, ("Invalid port count")); | ||||
#ifdef NUMA | |||||
for (i = 0; i < MAXMEMDOM; i++) { | |||||
if (p->pm_numa[i].count != 0) | |||||
p->pm_num_dom++; | |||||
} | |||||
#endif | |||||
speed = lacp_aggregator_bandwidth(la); | speed = lacp_aggregator_bandwidth(la); | ||||
} | } | ||||
sc->sc_ifp->if_baudrate = speed; | sc->sc_ifp->if_baudrate = speed; | ||||
/* switch the active portmap over */ | /* switch the active portmap over */ | ||||
atomic_store_rel_int(&lsc->lsc_activemap, newmap); | atomic_store_rel_int(&lsc->lsc_activemap, newmap); | ||||
LACP_DPRINTF((NULL, "Set table %d with %d ports\n", | LACP_DPRINTF((NULL, "Set table %d with %d ports\n", | ||||
lsc->lsc_activemap, | lsc->lsc_activemap, | ||||
▲ Show 20 Lines • Show All 1,111 Lines • Show Last 20 Lines |