Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Oct 2019 18:12:36 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r353859 - head/sys/dev/tsec
Message-ID:  <201910211812.x9LICaS8072765@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: glebius
Date: Mon Oct 21 18:12:36 2019
New Revision: 353859
URL: https://svnweb.freebsd.org/changeset/base/353859

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/tsec/if_tsec.c

Modified: head/sys/dev/tsec/if_tsec.c
==============================================================================
--- head/sys/dev/tsec/if_tsec.c	Mon Oct 21 18:12:31 2019	(r353858)
+++ head/sys/dev/tsec/if_tsec.c	Mon Oct 21 18:12:36 2019	(r353859)
@@ -1886,13 +1886,22 @@ tsec_offload_process_frame(struct tsec_softc *sc, stru
 	m_adj(m, sizeof(struct tsec_rx_fcb));
 }
 
+static u_int
+tsec_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+	uint32_t h, *hashtable = arg;
+
+	h = (ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 24) & 0xFF;
+	hashtable[(h >> 5)] |= 1 << (0x1F - (h & 0x1F));
+
+	return (1);
+}
+
 static void
 tsec_setup_multicast(struct tsec_softc *sc)
 {
 	uint32_t hashtable[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
 	struct ifnet *ifp = sc->tsec_ifp;
-	struct ifmultiaddr *ifma;
-	uint32_t h;
 	int i;
 
 	TSEC_GLOBAL_LOCK_ASSERT(sc);
@@ -1904,18 +1913,7 @@ tsec_setup_multicast(struct tsec_softc *sc)
 		return;
 	}
 
-	if_maddr_rlock(ifp);
-	CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-
-		if (ifma->ifma_addr->sa_family != AF_LINK)
-			continue;
-
-		h = (ether_crc32_be(LLADDR((struct sockaddr_dl *)
-		    ifma->ifma_addr), ETHER_ADDR_LEN) >> 24) & 0xFF;
-
-		hashtable[(h >> 5)] |= 1 << (0x1F - (h & 0x1F));
-	}
-	if_maddr_runlock(ifp);
+	if_foreach_llmaddr(ifp, tsec_hash_maddr, &hashtable);
 
 	for (i = 0; i < 8; i++)
 		TSEC_WRITE(sc, TSEC_REG_GADDR(i), hashtable[i]);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910211812.x9LICaS8072765>