Author: glebius
Date: Mon Oct 21 18:11:32 2019
New Revision: 353846
URL: https://svnweb.freebsd.org/changeset/base/353846

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/ffec/if_ffec.c

Modified: head/sys/dev/ffec/if_ffec.c
==============================================================================
--- head/sys/dev/ffec/if_ffec.c Mon Oct 21 18:11:28 2019        (r353845)
+++ head/sys/dev/ffec/if_ffec.c Mon Oct 21 18:11:32 2019        (r353846)
@@ -974,13 +974,24 @@ ffec_get_hwaddr(struct ffec_softc *sc, uint8_t *hwaddr
        }
 }
 
+static u_int
+ffec_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+       uint64_t *ghash = arg;
+       uint32_t crc;
+
+       /* 6 bits from MSB in LE CRC32 are used for hash. */
+       crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+       *ghash |= 1LLU << (((uint8_t *)&crc)[3] >> 2);
+
+       return (1);
+}
+
 static void
 ffec_setup_rxfilter(struct ffec_softc *sc)
 {
        struct ifnet *ifp;
-       struct ifmultiaddr *ifma;
        uint8_t *eaddr;
-       uint32_t crc;
        uint64_t ghash, ihash;
 
        FFEC_ASSERT_LOCKED(sc);
@@ -994,16 +1005,7 @@ ffec_setup_rxfilter(struct ffec_softc *sc)
                ghash = 0xffffffffffffffffLLU;
        else {
                ghash = 0;
-               if_maddr_rlock(ifp);
-               CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
-                       if (ifma->ifma_addr->sa_family != AF_LINK)
-                               continue;
-                       /* 6 bits from MSB in LE CRC32 are used for hash. */
-                       crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
-                           ifma->ifma_addr), ETHER_ADDR_LEN);
-                       ghash |= 1LLU << (((uint8_t *)&crc)[3] >> 2);
-               }
-               if_maddr_runlock(ifp);
+               if_foreach_llmaddr(ifp, ffec_hash_maddr, &ghash);
        }
        WR4(sc, FEC_GAUR_REG, (uint32_t)(ghash >> 32));
        WR4(sc, FEC_GALR_REG, (uint32_t)ghash);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to