On Thu, Mar 04, 2021 at 10:06:24PM +1000, David Gwynne wrote: > this applies the tricks with addresses from veb and etherbridge > code to the normal ethernet input processing. it seems to make > things a bit faster. some tests have shown a 15% improvement in > forwarding performance with this diff. > > ive been running with it for the last week on sparc64 and amd64 > without issue. > > ok?
Fine with me. Surprised about the preformance difference. I would assume that one memcmp() is about the same as one ether_addr_to_e64() call. > Index: if_ethersubr.c > =================================================================== > RCS file: /cvs/src/sys/net/if_ethersubr.c,v > retrieving revision 1.271 > diff -u -p -r1.271 if_ethersubr.c > --- if_ethersubr.c 26 Feb 2021 01:12:37 -0000 1.271 > +++ if_ethersubr.c 27 Feb 2021 01:24:44 -0000 > @@ -382,6 +382,7 @@ ether_input(struct ifnet *ifp, struct mb > struct arpcom *ac; > const struct ether_brport *eb; > unsigned int sdelim = 0; > + uint64_t dst, self; > > /* Drop short frames */ > if (m->m_len < ETHER_HDR_LEN) > @@ -450,7 +451,9 @@ ether_input(struct ifnet *ifp, struct mb > */ > > eh = mtod(m, struct ether_header *); > - if (memcmp(ac->ac_enaddr, eh->ether_dhost, ETHER_ADDR_LEN) != 0) { > + dst = ether_addr_to_e64((struct ether_addr *)eh->ether_dhost); > + self = ether_addr_to_e64((struct ether_addr *)ac->ac_enaddr); > + if (dst != self) { > #if NCARP > 0 > /* > * If it's not for this port, it could be for carp(4). > @@ -468,7 +471,7 @@ ether_input(struct ifnet *ifp, struct mb > /* > * If not, it must be multicast or broadcast to go further. > */ > - if (!ETHER_IS_MULTICAST(eh->ether_dhost)) > + if (!ETH64_IS_MULTICAST(dst)) > goto dropanyway; > > /* > @@ -476,15 +479,13 @@ ether_input(struct ifnet *ifp, struct mb > * if it came from us. > */ > if ((ifp->if_flags & IFF_SIMPLEX) == 0) { > - if (memcmp(ac->ac_enaddr, eh->ether_shost, > - ETHER_ADDR_LEN) == 0) > + uint64_t src = ether_addr_to_e64( > + (struct ether_addr *)eh->ether_shost); > + if (self == src) > goto dropanyway; > } > > - if (ETHER_IS_BROADCAST(eh->ether_dhost)) > - m->m_flags |= M_BCAST; > - else > - m->m_flags |= M_MCAST; > + SET(m->m_flags, ETH64_IS_BROADCAST(dst) ? M_BCAST : M_MCAST); > ifp->if_imcasts++; > } > > -- :wq Claudio