Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if_lagg.c
Show First 20 Lines • Show All 1,603 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Look up the port used by a specific flow. This only works for lagg | * Look up the port used by a specific flow. This only works for lagg | ||||
* protocols with deterministic port mappings (e.g. not roundrobin). | * protocols with deterministic port mappings (e.g. not roundrobin). | ||||
* In addition protocols which use a hash to map flows to ports must | * In addition protocols which use a hash to map flows to ports must | ||||
* be configured to use the mbuf flowid rather than hashing packet | * be configured to use the mbuf flowid rather than hashing packet | ||||
* contents. | * contents. | ||||
*/ | */ | ||||
static struct lagg_port * | static struct lagg_port * | ||||
lookup_snd_tag_port(struct ifnet *ifp, uint32_t flowid, uint32_t flowtype) | lookup_snd_tag_port(struct ifnet *ifp, uint32_t flowid, uint32_t flowtype, | ||||
uint8_t numa_domain) | |||||
{ | { | ||||
struct lagg_softc *sc; | struct lagg_softc *sc; | ||||
struct lagg_port *lp; | struct lagg_port *lp; | ||||
struct lagg_lb *lb; | struct lagg_lb *lb; | ||||
uint32_t p; | uint32_t hash, p; | ||||
sc = ifp->if_softc; | sc = ifp->if_softc; | ||||
switch (sc->sc_proto) { | switch (sc->sc_proto) { | ||||
case LAGG_PROTO_FAILOVER: | case LAGG_PROTO_FAILOVER: | ||||
return (lagg_link_active(sc, sc->sc_primary)); | return (lagg_link_active(sc, sc->sc_primary)); | ||||
case LAGG_PROTO_LOADBALANCE: | case LAGG_PROTO_LOADBALANCE: | ||||
if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) == 0 || | if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) == 0 || | ||||
flowtype == M_HASHTYPE_NONE) | flowtype == M_HASHTYPE_NONE) | ||||
return (NULL); | return (NULL); | ||||
p = flowid >> sc->flowid_shift; | p = flowid >> sc->flowid_shift; | ||||
p %= sc->sc_count; | p %= sc->sc_count; | ||||
lb = (struct lagg_lb *)sc->sc_psc; | lb = (struct lagg_lb *)sc->sc_psc; | ||||
lp = lb->lb_ports[p]; | lp = lb->lb_ports[p]; | ||||
return (lagg_link_active(sc, lp)); | return (lagg_link_active(sc, lp)); | ||||
case LAGG_PROTO_LACP: | case LAGG_PROTO_LACP: | ||||
if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) == 0 || | if ((sc->sc_opts & LAGG_OPT_USE_FLOWID) == 0 || | ||||
flowtype == M_HASHTYPE_NONE) | flowtype == M_HASHTYPE_NONE) | ||||
return (NULL); | return (NULL); | ||||
return (lacp_select_tx_port_by_hash(sc, flowid)); | hash = flowid >> sc->flowid_shift; | ||||
return (lacp_select_tx_port_by_hash(sc, hash, numa_domain)); | |||||
default: | default: | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
} | } | ||||
static int | static int | ||||
lagg_snd_tag_alloc(struct ifnet *ifp, | lagg_snd_tag_alloc(struct ifnet *ifp, | ||||
union if_snd_tag_alloc_params *params, | union if_snd_tag_alloc_params *params, | ||||
struct m_snd_tag **ppmt) | struct m_snd_tag **ppmt) | ||||
{ | { | ||||
struct lagg_snd_tag *lst; | struct lagg_snd_tag *lst; | ||||
struct lagg_softc *sc; | struct lagg_softc *sc; | ||||
struct lagg_port *lp; | struct lagg_port *lp; | ||||
struct ifnet *lp_ifp; | struct ifnet *lp_ifp; | ||||
int error; | int error; | ||||
sc = ifp->if_softc; | sc = ifp->if_softc; | ||||
LAGG_RLOCK(); | LAGG_RLOCK(); | ||||
lp = lookup_snd_tag_port(ifp, params->hdr.flowid, params->hdr.flowtype); | lp = lookup_snd_tag_port(ifp, params->hdr.flowid, | ||||
params->hdr.flowtype, params->hdr.numa_domain); | |||||
if (lp == NULL) { | if (lp == NULL) { | ||||
LAGG_RUNLOCK(); | LAGG_RUNLOCK(); | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
if (lp->lp_ifp == NULL || lp->lp_ifp->if_snd_tag_alloc == NULL) { | if (lp->lp_ifp == NULL || lp->lp_ifp->if_snd_tag_alloc == NULL) { | ||||
LAGG_RUNLOCK(); | LAGG_RUNLOCK(); | ||||
return (EOPNOTSUPP); | return (EOPNOTSUPP); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 758 Lines • Show Last 20 Lines |