svn commit: r353792 - head/sys/netinet6

2019-10-21 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Oct 21 08:36:15 2019
New Revision: 353792
URL: https://svnweb.freebsd.org/changeset/base/353792

Log:
  frag6: add read-only sysctl for nfrags.
  
  Add a read-only sysctl exporting the global number of fragments
  (base system and all vnets).  This is helpful to (a) know how many
  fragments are currently being processed, (b) if there are possible
  leaks, (c) if vnet teardown is not working correctly, and lastly
  (d) it can be used as part of test-suits to ensure (a) to (c).
  
  MFC after:3 weeks
  Sponsored by: Netflix

Modified:
  head/sys/netinet6/frag6.c

Modified: head/sys/netinet6/frag6.c
==
--- head/sys/netinet6/frag6.c   Mon Oct 21 03:01:05 2019(r353791)
+++ head/sys/netinet6/frag6.c   Mon Oct 21 08:36:15 2019(r353792)
@@ -150,6 +150,10 @@ VNET_DEFINE_STATIC(uint32_t,   ip6qb_hashseed);
  */
 SYSCTL_DECL(_net_inet6_ip6);
 
+SYSCTL_UINT(_net_inet6_ip6, OID_AUTO, frag6_nfrags,
+   CTLFLAG_RD, __DEVOLATILE(u_int *, &frag6_nfrags), 0,
+   "Global number of IPv6 fragments across all reassembly queues.");
+
 static void
 frag6_set_bucketsize(void)
 {
___
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"


svn commit: r353793 - head/sys/netinet6

2019-10-21 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Oct 21 08:48:47 2019
New Revision: 353793
URL: https://svnweb.freebsd.org/changeset/base/353793

Log:
  frag6: fix vnet teardown leak
  
  When shutting down a VNET we did not cleanup the fragmentation hashes.
  This has multiple problems: (1) leak memory but also (2) leak on the
  global counters, which might eventually lead to a problem on a system
  starting and stopping a lot of vnets and dealing with a lot of IPv6
  fragments that the counters/limits would be exhausted and processing
  would no longer take place.
  
  Unfortunately we do not have a useable variable to indicate when
  per-VNET initialization of frag6 has happened (or when destroy happened)
  so introduce a boolean to flag this. This is needed here as well as
  it was in r353635 for ip_reass.c in order to avoid tripping over the
  already destroyed locks if interfaces go away after the frag6 destroy.
  
  While splitting things up convert the TRY_LOCK to a LOCK operation in
  now frag6_drain_one().  The try-lock was derived from a manual hand-rolled
  implementation and carried forward all the time.  We no longer can afford
  not to get the lock as that would mean we would continue to leak memory.
  
  Assert that all the buckets are empty before destroying to lock to
  ensure long-term stability of a clean shutdown.
  
  Reported by:  hselasky
  Reviewed by:  hselasky
  MFC after:3 weeks
  Sponsored by: Netflix
  Differential Revision:https://reviews.freebsd.org/D22054

Modified:
  head/sys/netinet6/frag6.c
  head/sys/netinet6/ip6_input.c
  head/sys/netinet6/ip6_var.h

Modified: head/sys/netinet6/frag6.c
==
--- head/sys/netinet6/frag6.c   Mon Oct 21 08:36:15 2019(r353792)
+++ head/sys/netinet6/frag6.c   Mon Oct 21 08:48:47 2019(r353793)
@@ -100,6 +100,12 @@ struct ip6asfrag {
 
 static MALLOC_DEFINE(M_FRAG6, "frag6", "IPv6 fragment reassembly header");
 
+#ifdef VIMAGE
+/* A flag to indicate if IPv6 fragmentation is initialized. */
+VNET_DEFINE_STATIC(bool,   frag6_on);
+#defineV_frag6_on  VNET(frag6_on)
+#endif
+
 /* System wide (global) maximum and count of packets in reassembly queues. */ 
 static int ip6_maxfrags;
 static volatile u_int frag6_nfrags = 0;
@@ -289,6 +295,15 @@ frag6_cleanup(void *arg __unused, struct ifnet *ifp)
 
KASSERT(ifp != NULL, ("%s: ifp is NULL", __func__));
 
+#ifdef VIMAGE
+   /*
+* Skip processing if IPv6 reassembly is not initialised or
+* torn down by frag6_destroy().
+*/
+   if (!V_frag6_on)
+   return;
+#endif
+
CURVNET_SET_QUIET(ifp->if_vnet);
for (i = 0; i < IP6REASS_NHASH; i++) {
IP6QB_LOCK(i);
@@ -929,6 +944,9 @@ frag6_init(void)
}
V_ip6qb_hashseed = arc4random();
V_ip6_maxfragsperpacket = 64;
+#ifdef VIMAGE
+   V_frag6_on = true;
+#endif
if (!IS_DEFAULT_VNET(curvnet))
return;
 
@@ -940,31 +958,57 @@ frag6_init(void)
 /*
  * Drain off all datagram fragments.
  */
+static void
+frag6_drain_one(void)
+{
+   struct ip6q *head;
+   uint32_t bucket;
+
+   for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
+   IP6QB_LOCK(bucket);
+   head = IP6QB_HEAD(bucket);
+   while (head->ip6q_next != head) {
+   IP6STAT_INC(ip6s_fragdropped);
+   /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
+   frag6_freef(head->ip6q_next, bucket);
+   }
+   IP6QB_UNLOCK(bucket);
+   }
+}
+
 void
 frag6_drain(void)
 {
VNET_ITERATOR_DECL(vnet_iter);
-   struct ip6q *head;
-   uint32_t bucket;
 
VNET_LIST_RLOCK_NOSLEEP();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
-   for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
-   if (IP6QB_TRYLOCK(bucket) == 0)
-   continue;
-   head = IP6QB_HEAD(bucket);
-   while (head->ip6q_next != head) {
-   IP6STAT_INC(ip6s_fragdropped);
-   /* XXX in6_ifstat_inc(ifp, ifs6_reass_fail) */
-   frag6_freef(head->ip6q_next, bucket);
-   }
-   IP6QB_UNLOCK(bucket);
-   }
+   frag6_drain_one();
CURVNET_RESTORE();
}
VNET_LIST_RUNLOCK_NOSLEEP();
 }
+
+#ifdef VIMAGE
+/*
+ * Clear up IPv6 reassembly structures.
+ */
+void
+frag6_destroy(void)
+{
+   uint32_t bucket;
+
+   frag6_drain_one();
+   V_frag6_on = false;
+   for (bucket = 0; bucket < IP6REASS_NHASH; bucket++) {
+   KASSERT(V_ip6qb[bucket].count == 0,
+   ("%s: V_ip6qb[%d] (%p) count not 0 (%d)", __func__,
+   bucket, &V_ip6q

svn commit: r353794 - in head: etc/mtree tests/sys tests/sys/netinet6 tests/sys/netinet6/frag6

2019-10-21 Thread Bjoern A. Zeeb
Author: bz
Date: Mon Oct 21 09:33:45 2019
New Revision: 353794
URL: https://svnweb.freebsd.org/changeset/base/353794

Log:
  frag6: import a set of test cases
  
  In order to ensure that changing the frag6 code does not change behaviour
  or break code a set of test cases were implemented.
  
  Like some other test cases these use Scapy to generate packets and possibly
  wait for expected answers.  In most cases we do check the global and
  per interface (netstat) statistics output using the libxo output and grep
  to validate fields and numbers.  This is a bit hackish but we currently have
  no better way to match a selected number of stats only (we have to ignore
  some of the ND6 variables; otherwise we could use the entire list).
  
  Test cases include atomic fragments, single fragments, multi-fragments,
  and try to cover most error cases in the code currently.
  In addition vnet teardown is tested to not panic.
  
  A separate set (not in-tree currently) of probes were used in order to
  make sure that the test cases actually test what they should.
  
  The "sniffer" code was copied and adjusted from the netpfil version
  as we sometimes will not get packets or have longer timeouts to deal with.
  
  Sponsored by: Netflix

Added:
  head/tests/sys/netinet6/
  head/tests/sys/netinet6/Makefile   (contents, props changed)
  head/tests/sys/netinet6/frag6/
  head/tests/sys/netinet6/frag6/Makefile   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6.subr   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_01.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_01.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_02.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_02.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_03.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_03.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_04.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_04.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_05.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_05.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_06.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_06.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_07.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_07.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_08.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_08.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_09.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_09.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_10.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_10.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_11.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_11.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_12.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_12.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_13.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_13.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_14.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_14.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_15.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_15.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_16.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_16.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_17.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_17.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_18.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_18.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_19.py   (contents, props changed)
  head/tests/sys/netinet6/frag6/frag6_19.sh   (contents, props changed)
  head/tests/sys/netinet6/frag6/sniffer.py   (contents, props changed)
Modified:
  head/etc/mtree/BSD.tests.dist
  head/tests/sys/Makefile

Modified: head/etc/mtree/BSD.tests.dist
==
--- head/etc/mtree/BSD.tests.dist   Mon Oct 21 08:48:47 2019
(r353793)
+++ head/etc/mtree/BSD.tests.dist   Mon Oct 21 09:33:45 2019
(r353794)
@@ -792,6 +792,10 @@
 ..
 netinet
 ..
+netinet6
+frag6
+..
+..
 netipsec
 tunnel
 ..

Modified: head/tests/sys/Makefile
==
--- head/tests/sys/Mak

svn commit: r353795 - head/sys/powerpc/aim

2019-10-21 Thread Leandro Lupori
Author: luporl
Date: Mon Oct 21 11:56:57 2019
New Revision: 353795
URL: https://svnweb.freebsd.org/changeset/base/353795

Log:
  [PPC64] Add minidump support to PowerNV
  
  Implementation of PowerNV specific minidump code.
  
  Reviewed by:  jhibbits
  Differential Revision:https://reviews.freebsd.org/D21643

Modified:
  head/sys/powerpc/aim/moea64_native.c

Modified: head/sys/powerpc/aim/moea64_native.c
==
--- head/sys/powerpc/aim/moea64_native.cMon Oct 21 09:33:45 2019
(r353794)
+++ head/sys/powerpc/aim/moea64_native.cMon Oct 21 11:56:57 2019
(r353795)
@@ -213,6 +213,12 @@ static struct rwlock moea64_eviction_lock;
 static volatile struct pate *moea64_part_table;
 
 /*
+ * Dump function.
+ */
+static void*moea64_dump_pmap_native(mmu_t mmu, void *ctx, void *buf,
+   u_long *nbytes);
+
+/*
  * PTE calls.
  */
 static int moea64_pte_insert_native(mmu_t, struct pvo_entry *);
@@ -233,6 +239,7 @@ static mmu_method_t moea64_native_methods[] = {
/* Internal interfaces */
MMUMETHOD(mmu_bootstrap,moea64_bootstrap_native),
MMUMETHOD(mmu_cpu_bootstrap,moea64_cpu_bootstrap_native),
+MMUMETHOD(mmu_dump_pmap,moea64_dump_pmap_native),
 
MMUMETHOD(moea64_pte_synch, moea64_pte_synch_native),
MMUMETHOD(moea64_pte_clear, moea64_pte_clear_native),   
@@ -787,3 +794,21 @@ moea64_pte_insert_native(mmu_t mmu, struct pvo_entry *
return (-1);
 }
 
+static void *
+moea64_dump_pmap_native(mmu_t mmu, void *ctx, void *buf, u_long *nbytes)
+{
+   struct dump_context *dctx;
+   u_long ptex, ptex_end;
+
+   dctx = (struct dump_context *)ctx;
+   ptex = dctx->ptex;
+   ptex_end = ptex + dctx->blksz / sizeof(struct lpte);
+   ptex_end = MIN(ptex_end, dctx->ptex_end);
+   *nbytes = (ptex_end - ptex) * sizeof(struct lpte);
+
+   if (*nbytes == 0)
+   return (NULL);
+
+   dctx->ptex = ptex_end;
+   return (__DEVOLATILE(struct lpte *, moea64_pteg_table) + ptex);
+}
___
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"


svn commit: r353796 - head/sys/kern

2019-10-21 Thread Andriy Gapon
Author: avg
Date: Mon Oct 21 12:21:56 2019
New Revision: 353796
URL: https://svnweb.freebsd.org/changeset/base/353796

Log:
  debug,kassert.warnings is a statistic, not a tunable
  
  MFC after:1 week

Modified:
  head/sys/kern/kern_shutdown.c

Modified: head/sys/kern/kern_shutdown.c
==
--- head/sys/kern/kern_shutdown.c   Mon Oct 21 11:56:57 2019
(r353795)
+++ head/sys/kern/kern_shutdown.c   Mon Oct 21 12:21:56 2019
(r353796)
@@ -713,7 +713,7 @@ SYSCTL_INT(_debug_kassert, OID_AUTO, do_log, KASSERT_R
 &kassert_do_log, 0,
 "If warn_only is enabled, log (1) or do not log (0) assertion violations");
 
-SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, KASSERT_RWTUN,
+SYSCTL_INT(_debug_kassert, OID_AUTO, warnings, CTLFLAG_RD | CTLFLAG_STATS,
 &kassert_warnings, 0, "number of KASSERTs that have been triggered");
 
 SYSCTL_INT(_debug_kassert, OID_AUTO, log_panic_at, KASSERT_RWTUN,
___
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"


svn commit: r353798 - in head: . sys/net

2019-10-21 Thread Kyle Evans
Author: kevans
Date: Mon Oct 21 14:38:11 2019
New Revision: 353798
URL: https://svnweb.freebsd.org/changeset/base/353798

Log:
  tuntap(4): restrict scope of net.link.tap.user_open slightly
  
  net.link.tap.user_open has historically allowed non-root users to do devfs
  cloning and open /dev/tap* nodes based on permissions. Loosen this up to
  make it only allow users to do devfs cloning -- we no longer check it in
  tunopen.
  
  This allows tap devices to be created that can actually be opened by a user,
  rather than swiftly restricting them to root because the magic sysctl has
  not been set.
  
  The sysctl has not yet been completely deprecated, because more thought is
  needed for how to handle the devfs cloning case. There is not an easy
  suitable replacement for the sysctl there, and more care needs to be placed
  in determining whether that's OK or not.
  
  PR:   200185

Modified:
  head/UPDATING
  head/sys/net/if_tuntap.c

Modified: head/UPDATING
==
--- head/UPDATING   Mon Oct 21 14:34:40 2019(r353797)
+++ head/UPDATING   Mon Oct 21 14:38:11 2019(r353798)
@@ -26,6 +26,15 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
disable the most expensive debugging functionality run
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
+20191021:
+   The net.link.tap.user_open sysctl no longer prevents user opening of
+   already created /dev/tapNN devices.  Access is still controlled by
+   node permissions, just like tun devices.  The net.link.tap.user_open
+   sysctl is now used only to allow users to perform devfs cloning of
+   tap devices, and the subsequent open may not succeed if the user is not
+   in the appropriate group.  This sysctl may be deprecated/removed
+   completely in the future.
+
 20191009:
mips, powerpc, and sparc64 are no longer built as part of
universe / tinderbox unless MAKE_OBSOLETE_GCC is defined. If

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cMon Oct 21 14:34:40 2019(r353797)
+++ head/sys/net/if_tuntap.cMon Oct 21 14:38:11 2019(r353798)
@@ -181,7 +181,7 @@ static const char vmnetname[] = "vmnet";
 static MALLOC_DEFINE(M_TUN, tunname, "Tunnel Interface");
 static int tundebug = 0;
 static int tundclone = 1;
-static int tap_allow_uopen = 0;/* allow user open() */
+static int tap_allow_uopen = 0;/* allow user devfs cloning */
 static int tapuponopen = 0;/* IFF_UP on open() */
 static int tapdclone = 1;  /* enable devfs cloning */
 
@@ -202,7 +202,7 @@ SYSCTL_INT(_net_link_tun, OID_AUTO, devfs_cloning, CTL
 static SYSCTL_NODE(_net_link, OID_AUTO, tap, CTLFLAG_RW, 0,
 "Ethernet tunnel software network interface");
 SYSCTL_INT(_net_link_tap, OID_AUTO, user_open, CTLFLAG_RW, &tap_allow_uopen, 0,
-"Allow user to open /dev/tap (based on node permissions)");
+"Enable legacy devfs interface creation for all users");
 SYSCTL_INT(_net_link_tap, OID_AUTO, up_on_open, CTLFLAG_RW, &tapuponopen, 0,
 "Bring interface up when /dev/tap is opened");
 SYSCTL_INT(_net_link_tap, OID_AUTO, devfs_cloning, CTLFLAG_RWTUN, &tapdclone, 
0,
@@ -1047,17 +1047,6 @@ tunopen(struct cdev *dev, int flag, int mode, struct t
if (error != 0) {
CURVNET_RESTORE();
return (error); /* Shouldn't happen */
-   }
-
-   if ((tunflags & TUN_L2) != 0) {
-   /* Restrict? */
-   if (tap_allow_uopen == 0) {
-   error = priv_check(td, PRIV_NET_TAP);
-   if (error != 0) {
-   CURVNET_RESTORE();
-   return (error);
-   }
-   }
}
 
tp = dev->si_drv1;
___
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"


svn commit: r353802 - head/sys/dev/virtio/network

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 17:59:02 2019
New Revision: 353802
URL: https://svnweb.freebsd.org/changeset/base/353802

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/virtio/network/if_vtnet.c

Modified: head/sys/dev/virtio/network/if_vtnet.c
==
--- head/sys/dev/virtio/network/if_vtnet.c  Mon Oct 21 17:54:53 2019
(r353801)
+++ head/sys/dev/virtio/network/if_vtnet.c  Mon Oct 21 17:59:02 2019
(r353802)
@@ -3285,6 +3285,34 @@ vtnet_rx_filter(struct vtnet_softc *sc)
ifp->if_flags & IFF_ALLMULTI ? "enable" : "disable");
 }
 
+static u_int
+vtnet_copy_ifaddr(void *arg, struct sockaddr_dl *sdl, u_int ucnt)
+{
+   struct vtnet_softc *sc = arg;
+
+   if (memcmp(LLADDR(sdl), sc->vtnet_hwaddr, ETHER_ADDR_LEN) == 0)
+   return (0);
+
+   if (ucnt < VTNET_MAX_MAC_ENTRIES)
+   bcopy(LLADDR(sdl),
+   &sc->vtnet_mac_filter->vmf_unicast.macs[ucnt],
+   ETHER_ADDR_LEN);
+
+   return (1);
+}
+
+static u_int
+vtnet_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt)
+{
+   struct vtnet_mac_filter *filter = arg;
+
+   if (mcnt < VTNET_MAX_MAC_ENTRIES)
+   bcopy(LLADDR(sdl), &filter->vmf_multicast.macs[mcnt],
+   ETHER_ADDR_LEN);
+
+   return (1);
+}
+
 static void
 vtnet_rx_filter_mac(struct vtnet_softc *sc)
 {
@@ -3293,42 +3321,23 @@ vtnet_rx_filter_mac(struct vtnet_softc *sc)
struct sglist_seg segs[4];
struct sglist sg;
struct ifnet *ifp;
-   struct ifaddr *ifa;
-   struct ifmultiaddr *ifma;
-   int ucnt, mcnt, promisc, allmulti, error;
+   bool promisc, allmulti;
+   u_int ucnt, mcnt;
+   int error;
uint8_t ack;
 
ifp = sc->vtnet_ifp;
filter = sc->vtnet_mac_filter;
-   ucnt = 0;
-   mcnt = 0;
-   promisc = 0;
-   allmulti = 0;
 
VTNET_CORE_LOCK_ASSERT(sc);
KASSERT(sc->vtnet_flags & VTNET_FLAG_CTRL_RX,
("%s: CTRL_RX feature not negotiated", __func__));
 
/* Unicast MAC addresses: */
-   if_addr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
-   if (ifa->ifa_addr->sa_family != AF_LINK)
-   continue;
-   else if (memcmp(LLADDR((struct sockaddr_dl *)ifa->ifa_addr),
-   sc->vtnet_hwaddr, ETHER_ADDR_LEN) == 0)
-   continue;
-   else if (ucnt == VTNET_MAX_MAC_ENTRIES) {
-   promisc = 1;
-   break;
-   }
+   ucnt = if_foreach_lladdr(ifp, vtnet_copy_ifaddr, sc);
+   promisc = (ucnt > VTNET_MAX_MAC_ENTRIES);
 
-   bcopy(LLADDR((struct sockaddr_dl *)ifa->ifa_addr),
-   &filter->vmf_unicast.macs[ucnt], ETHER_ADDR_LEN);
-   ucnt++;
-   }
-   if_addr_runlock(ifp);
-
-   if (promisc != 0) {
+   if (promisc) {
filter->vmf_unicast.nentries = 0;
if_printf(ifp, "more than %d MAC addresses assigned, "
"falling back to promiscuous mode\n",
@@ -3337,22 +3346,10 @@ vtnet_rx_filter_mac(struct vtnet_softc *sc)
filter->vmf_unicast.nentries = ucnt;
 
/* Multicast MAC addresses: */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   else if (mcnt == VTNET_MAX_MAC_ENTRIES) {
-   allmulti = 1;
-   break;
-   }
+   mcnt = if_foreach_llmaddr(ifp, vtnet_copy_maddr, filter);
+   allmulti = (mcnt > VTNET_MAX_MAC_ENTRIES);
 
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-   &filter->vmf_multicast.macs[mcnt], ETHER_ADDR_LEN);
-   mcnt++;
-   }
-   if_maddr_runlock(ifp);
-
-   if (allmulti != 0) {
+   if (allmulti) {
filter->vmf_multicast.nentries = 0;
if_printf(ifp, "more than %d multicast MAC addresses "
"assigned, falling back to all-multicast mode\n",
@@ -3360,7 +3357,7 @@ vtnet_rx_filter_mac(struct vtnet_softc *sc)
} else
filter->vmf_multicast.nentries = mcnt;
 
-   if (promisc != 0 && allmulti != 0)
+   if (promisc && allmulti)
goto out;
 
hdr.class = VIRTIO_NET_CTRL_MAC;
___
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"


svn commit: r353807 - head/sys/dev/alc

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:06 2019
New Revision: 353807
URL: https://svnweb.freebsd.org/changeset/base/353807

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/alc/if_alc.c

Modified: head/sys/dev/alc/if_alc.c
==
--- head/sys/dev/alc/if_alc.c   Mon Oct 21 18:05:43 2019(r353806)
+++ head/sys/dev/alc/if_alc.c   Mon Oct 21 18:06:06 2019(r353807)
@@ -4581,12 +4581,22 @@ alc_rxvlan(struct alc_softc *sc)
CSR_WRITE_4(sc, ALC_MAC_CFG, reg);
 }
 
+static u_int
+alc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *mchash = arg;
+   uint32_t crc;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+
+   return (1);
+}
+
 static void
 alc_rxfilter(struct alc_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
uint32_t mchash[2];
uint32_t rxcfg;
 
@@ -4609,15 +4619,7 @@ alc_rxfilter(struct alc_softc *sc)
goto chipit;
}
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->alc_ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, alc_hash_maddr, mchash);
 
 chipit:
CSR_WRITE_4(sc, ALC_MAR0, mchash[0]);
___
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"


svn commit: r353803 - head/sys/dev/vmware/vmxnet3

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 17:59:16 2019
New Revision: 353803
URL: https://svnweb.freebsd.org/changeset/base/353803

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/vmware/vmxnet3/if_vmx.c

Modified: head/sys/dev/vmware/vmxnet3/if_vmx.c
==
--- head/sys/dev/vmware/vmxnet3/if_vmx.cMon Oct 21 17:59:02 2019
(r353802)
+++ head/sys/dev/vmware/vmxnet3/if_vmx.cMon Oct 21 17:59:16 2019
(r353803)
@@ -1995,12 +1995,23 @@ vmxnet3_vlan_unregister(if_ctx_t ctx, uint16_t tag)
vmxnet3_update_vlan_filter(iflib_get_softc(ctx), 0, tag);
 }
 
+static u_int
+vmxnet3_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int count)
+{
+   struct vmxnet3_softc *sc = arg;
+
+   if (count < VMXNET3_MULTICAST_MAX)
+   bcopy(LLADDR(sdl), &sc->vmx_mcast[count * ETHER_ADDR_LEN],
+   ETHER_ADDR_LEN);
+
+   return (1);
+}
+
 static void
 vmxnet3_set_rxfilter(struct vmxnet3_softc *sc, int flags)
 {
struct ifnet *ifp;
struct vmxnet3_driver_shared *ds;
-   struct ifmultiaddr *ifma;
u_int mode;
 
ifp = sc->vmx_ifp;
@@ -2012,24 +2023,10 @@ vmxnet3_set_rxfilter(struct vmxnet3_softc *sc, int fla
if (flags & IFF_ALLMULTI)
mode |= VMXNET3_RXMODE_ALLMULTI;
else {
-   int cnt = 0, overflow = 0;
+   int cnt;
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   else if (cnt == VMXNET3_MULTICAST_MAX) {
-   overflow = 1;
-   break;
-   }
-
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-  &sc->vmx_mcast[cnt*ETHER_ADDR_LEN], ETHER_ADDR_LEN);
-   cnt++;
-   }
-   if_maddr_runlock(ifp);
-
-   if (overflow != 0) {
+   cnt = if_foreach_llmaddr(ifp, vmxnet3_hash_maddr, sc);
+   if (cnt >= VMXNET3_MULTICAST_MAX) {
cnt = 0;
mode |= VMXNET3_RXMODE_ALLMULTI;
} else if (cnt > 0)
___
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"


svn commit: r353809 - head/sys/dev/ath

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:15 2019
New Revision: 353809
URL: https://svnweb.freebsd.org/changeset/base/353809

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/ath/if_ath.c

Modified: head/sys/dev/ath/if_ath.c
==
--- head/sys/dev/ath/if_ath.c   Mon Oct 21 18:06:09 2019(r353808)
+++ head/sys/dev/ath/if_ath.c   Mon Oct 21 18:06:15 2019(r353809)
@@ -3591,6 +3591,25 @@ ath_update_promisc(struct ieee80211com *ic)
DPRINTF(sc, ATH_DEBUG_MODE, "%s: RX filter 0x%x\n", __func__, rfilt);
 }
 
+static u_int
+ath_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t val, *mfilt = arg;
+   char *dl;
+   uint8_t pos;
+
+   /* calculate XOR of eight 6bit values */
+   dl = LLADDR(sdl);
+   val = le32dec(dl + 0);
+   pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
+   val = le32dec(dl + 3);
+   pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^ val;
+   pos &= 0x3f;
+   mfilt[pos / 32] |= (1 << (pos % 32));
+
+   return (1);
+}
+
 /*
  * Driver-internal mcast update call.
  *
@@ -3605,35 +3624,13 @@ ath_update_mcast_hw(struct ath_softc *sc)
/* calculate and install multicast filter */
if (ic->ic_allmulti == 0) {
struct ieee80211vap *vap;
-   struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
 
/*
 * Merge multicast addresses to form the hardware filter.
 */
mfilt[0] = mfilt[1] = 0;
-   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
-   ifp = vap->iv_ifp;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) 
{
-   caddr_t dl;
-   uint32_t val;
-   uint8_t pos;
-
-   /* calculate XOR of eight 6bit values */
-   dl = LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr);
-   val = le32dec(dl + 0);
-   pos = (val >> 18) ^ (val >> 12) ^ (val >> 6) ^
-   val;
-   val = le32dec(dl + 3);
-   pos ^= (val >> 18) ^ (val >> 12) ^ (val >> 6) ^
-   val;
-   pos &= 0x3f;
-   mfilt[pos / 32] |= (1 << (pos % 32));
-   }
-   if_maddr_runlock(ifp);
-   }
+   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
+   if_foreach_llmaddr(vap->iv_ifp, ath_hash_maddr, &mfilt);
} else
mfilt[0] = mfilt[1] = ~0;
 
___
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"


svn commit: r353814 - head/sys/dev/fxp

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:53 2019
New Revision: 353814
URL: https://svnweb.freebsd.org/changeset/base/353814

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/fxp/if_fxp.c

Modified: head/sys/dev/fxp/if_fxp.c
==
--- head/sys/dev/fxp/if_fxp.c   Mon Oct 21 18:06:31 2019(r353813)
+++ head/sys/dev/fxp/if_fxp.c   Mon Oct 21 18:06:53 2019(r353814)
@@ -245,7 +245,7 @@ static void fxp_discard_rfabuf(struct fxp_softc *sc,
struct fxp_rx *rxp);
 static int fxp_new_rfabuf(struct fxp_softc *sc,
struct fxp_rx *rxp);
-static int fxp_mc_addrs(struct fxp_softc *sc);
+static voidfxp_mc_addrs(struct fxp_softc *sc);
 static voidfxp_mc_setup(struct fxp_softc *sc);
 static uint16_tfxp_eeprom_getword(struct fxp_softc *sc, int 
offset,
int autosize);
@@ -2976,27 +2976,37 @@ fxp_ioctl(if_t ifp, u_long command, caddr_t data)
return (error);
 }
 
+static u_int
+fxp_setup_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct fxp_softc *sc = arg;
+   struct fxp_cb_mcs *mcsp = sc->mcsp;
+
+   if (mcsp->mc_cnt < MAXMCADDR)
+   bcopy(LLADDR(sdl), mcsp->mc_addr[mcsp->mc_cnt * ETHER_ADDR_LEN],
+   ETHER_ADDR_LEN);
+   mcsp->mc_cnt++;
+   return (1);
+}
+
 /*
  * Fill in the multicast address list and return number of entries.
  */
-static int
+static void
 fxp_mc_addrs(struct fxp_softc *sc)
 {
struct fxp_cb_mcs *mcsp = sc->mcsp;
if_t ifp = sc->ifp;
-   int nmcasts = 0;
 
if ((if_getflags(ifp) & IFF_ALLMULTI) == 0) {
-   if_maddr_rlock(ifp);
-   if_setupmultiaddr(ifp, mcsp->mc_addr, &nmcasts, MAXMCADDR);
-   if (nmcasts >= MAXMCADDR) {
+   mcsp->mc_cnt = 0;
+   if_foreach_llmaddr(sc->ifp, fxp_setup_maddr, sc);
+   if (mcsp->mc_cnt >= MAXMCADDR) {
if_setflagbits(ifp, IFF_ALLMULTI, 0);
-   nmcasts = 0;
+   mcsp->mc_cnt = 0;
}
-   if_maddr_runlock(ifp);
}
-   mcsp->mc_cnt = htole16(nmcasts * ETHER_ADDR_LEN);
-   return (nmcasts);
+   mcsp->mc_cnt = htole16(mcsp->mc_cnt * ETHER_ADDR_LEN);
 }
 
 /*
___
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"


svn commit: r353819 - head/sys/dev/mge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:15 2019
New Revision: 353819
URL: https://svnweb.freebsd.org/changeset/base/353819

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/mge/if_mge.c

Modified: head/sys/dev/mge/if_mge.c
==
--- head/sys/dev/mge/if_mge.c   Mon Oct 21 18:07:11 2019(r353818)
+++ head/sys/dev/mge/if_mge.c   Mon Oct 21 18:07:15 2019(r353819)
@@ -2032,45 +2032,51 @@ mge_crc8(uint8_t *data, int size)
return(crc);
 }
 
+struct mge_hash_maddr_ctx {
+   uint32_t smt[MGE_MCAST_REG_NUMBER];
+   uint32_t omt[MGE_MCAST_REG_NUMBER];
+};
+
+static u_int
+mge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   static const uint8_t special[5] = { 0x01, 0x00, 0x5E, 0x00, 0x00 };
+   struct mge_hash_maddr_ctx *ctx = arg;
+   static const uint8_t v = (MGE_RX_DEFAULT_QUEUE << 1) | 1;
+   uint8_t *mac;
+   int i;
+
+   mac = LLADDR(sdl);
+   if (memcmp(mac, special, sizeof(special)) == 0) {
+   i = mac[5];
+   ctx->smt[i >> 2] |= v << ((i & 0x03) << 3);
+   } else {
+   i = mge_crc8(mac, ETHER_ADDR_LEN);
+   ctx->omt[i >> 2] |= v << ((i & 0x03) << 3);
+   }
+   return (1);
+}
+
 static void
 mge_setup_multicast(struct mge_softc *sc)
 {
-   uint8_t special[5] = { 0x01, 0x00, 0x5E, 0x00, 0x00 };
-   uint8_t v = (MGE_RX_DEFAULT_QUEUE << 1) | 1;
-   uint32_t smt[MGE_MCAST_REG_NUMBER];
-   uint32_t omt[MGE_MCAST_REG_NUMBER];
+   struct mge_hash_maddr_ctx ctx;
struct ifnet *ifp = sc->ifp;
-   struct ifmultiaddr *ifma;
-   uint8_t *mac;
+   static const uint8_t v = (MGE_RX_DEFAULT_QUEUE << 1) | 1;
int i;
 
if (ifp->if_flags & IFF_ALLMULTI) {
for (i = 0; i < MGE_MCAST_REG_NUMBER; i++)
-   smt[i] = omt[i] = (v << 24) | (v << 16) | (v << 8) | v;
+   ctx.smt[i] = ctx.omt[i] =
+   (v << 24) | (v << 16) | (v << 8) | v;
} else {
-   memset(smt, 0, sizeof(smt));
-   memset(omt, 0, sizeof(omt));
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   mac = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-   if (memcmp(mac, special, sizeof(special)) == 0) {
-   i = mac[5];
-   smt[i >> 2] |= v << ((i & 0x03) << 3);
-   } else {
-   i = mge_crc8(mac, ETHER_ADDR_LEN);
-   omt[i >> 2] |= v << ((i & 0x03) << 3);
-   }
-   }
-   if_maddr_runlock(ifp);
+   memset(&ctx, 0, sizeof(ctx));
+   if_foreach_llmaddr(ifp, mge_hash_maddr, &ctx);
}
 
for (i = 0; i < MGE_MCAST_REG_NUMBER; i++) {
-   MGE_WRITE(sc, MGE_DA_FILTER_SPEC_MCAST(i), smt[i]);
-   MGE_WRITE(sc, MGE_DA_FILTER_OTH_MCAST(i), omt[i]);
+   MGE_WRITE(sc, MGE_DA_FILTER_SPEC_MCAST(i), ctx.smt[i]);
+   MGE_WRITE(sc, MGE_DA_FILTER_OTH_MCAST(i), ctx.omt[i]);
}
 }
 
___
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"


svn commit: r353810 - head/sys/dev/bce

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:19 2019
New Revision: 353810
URL: https://svnweb.freebsd.org/changeset/base/353810

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/bce/if_bce.c

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Mon Oct 21 18:06:15 2019(r353809)
+++ head/sys/dev/bce/if_bce.c   Mon Oct 21 18:06:19 2019(r353810)
@@ -8065,14 +8065,25 @@ bce_intr_exit:
 /* Returns: */
 /*   Nothing.   */
 //
+static u_int
+bce_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   u32 *hashes = arg;
+   int h;
+
+   h = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0xFF;
+   hashes[(h & 0xE0) >> 5] |= 1 << (h & 0x1F);
+
+   return (1);
+}
+
 static void
 bce_set_rx_mode(struct bce_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
u32 hashes[NUM_MC_HASH_REGISTERS] = { 0, 0, 0, 0, 0, 0, 0, 0 };
u32 rx_mode, sort_mode;
-   int h, i;
+   int i;
 
DBENTER(BCE_VERBOSE_MISC);
 
@@ -8115,16 +8126,7 @@ bce_set_rx_mode(struct bce_softc *sc)
} else {
/* Accept one or more multicast(s). */
DBPRINT(sc, BCE_INFO_MISC, "Enabling selective multicast 
mode.\n");
-
-   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_le(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN) & 0xFF;
-   hashes[(h & 0xE0) >> 5] |= 1 << (h & 0x1F);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, bce_hash_maddr, hashes);
 
for (i = 0; i < NUM_MC_HASH_REGISTERS; i++)
REG_WR(sc, BCE_EMAC_MULTICAST_HASH0 + (i * 4), 
hashes[i]);
___
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"


svn commit: r353817 - head/sys/dev/le

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:07 2019
New Revision: 353817
URL: https://svnweb.freebsd.org/changeset/base/353817

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/le/lance.c

Modified: head/sys/dev/le/lance.c
==
--- head/sys/dev/le/lance.c Mon Oct 21 18:07:02 2019(r353816)
+++ head/sys/dev/le/lance.c Mon Oct 21 18:07:07 2019(r353817)
@@ -577,6 +577,27 @@ lance_ioctl(struct ifnet *ifp, u_long cmd, caddr_t dat
return (error);
 }
 
+struct lance_hash_maddr_ctx {
+   struct lance_softc *sc;
+   uint16_t *af;
+};
+
+static u_int
+lance_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct lance_hash_maddr_ctx *ctx = arg;
+   struct lance_softc *sc = ctx->sc;
+   uint32_t crc;
+
+   crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* Just want the 6 most significant bits. */
+   crc >>= 26;
+   /* Set the corresponding bit in the filter. */
+   ctx->af[crc >> 4] |= LE_HTOLE16(1 << (crc & 0xf));
+
+   return (1);
+}
+
 /*
  * Set up the logical address filter.
  */
@@ -584,8 +605,7 @@ void
 lance_setladrf(struct lance_softc *sc, uint16_t *af)
 {
struct ifnet *ifp = sc->sc_ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
+   struct lance_hash_maddr_ctx ctx = { sc, af };
 
/*
 * Set up multicast address filter by passing all multicast addresses
@@ -601,21 +621,7 @@ lance_setladrf(struct lance_softc *sc, uint16_t *af)
}
 
af[0] = af[1] = af[2] = af[3] = 0x;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-
-   /* Just want the 6 most significant bits. */
-   crc >>= 26;
-
-   /* Set the corresponding bit in the filter. */
-   af[crc >> 4] |= LE_HTOLE16(1 << (crc & 0xf));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, lance_hash_maddr, &ctx);
 }
 
 /*
___
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"


svn commit: r353825 - head/sys/dev/sge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:40 2019
New Revision: 353825
URL: https://svnweb.freebsd.org/changeset/base/353825

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/sge/if_sge.c

Modified: head/sys/dev/sge/if_sge.c
==
--- head/sys/dev/sge/if_sge.c   Mon Oct 21 18:07:35 2019(r353824)
+++ head/sys/dev/sge/if_sge.c   Mon Oct 21 18:07:40 2019(r353825)
@@ -442,12 +442,22 @@ sge_miibus_statchg(device_t dev)
}
 }
 
+static u_int
+sge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int count)
+{
+   uint32_t crc, *hashes = arg;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   hashes[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+
+   return (1);
+}
+
 static void
 sge_rxfilter(struct sge_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc, hashes[2];
+   uint32_t hashes[2];
uint16_t rxfilt;
 
SGE_LOCK_ASSERT(sc);
@@ -468,15 +478,7 @@ sge_rxfilter(struct sge_softc *sc)
rxfilt |= AcceptMulticast;
hashes[0] = hashes[1] = 0;
/* Now program new ones. */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   hashes[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, sge_hash_maddr, hashes);
}
CSR_WRITE_2(sc, RxMacControl, rxfilt);
CSR_WRITE_4(sc, RxHashTable, hashes[0]);
___
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"


svn commit: r353829 - head/sys/dev/stge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:56 2019
New Revision: 353829
URL: https://svnweb.freebsd.org/changeset/base/353829

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/stge/if_stge.c

Modified: head/sys/dev/stge/if_stge.c
==
--- head/sys/dev/stge/if_stge.c Mon Oct 21 18:07:53 2019(r353828)
+++ head/sys/dev/stge/if_stge.c Mon Oct 21 18:07:56 2019(r353829)
@@ -2507,12 +2507,24 @@ stge_set_filter(struct stge_softc *sc)
CSR_WRITE_2(sc, STGE_ReceiveMode, mode);
 }
 
+static u_int
+stge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *mchash = arg;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* Just want the 6 least significant bits. */
+   crc &= 0x3f;
+   /* Set the corresponding bit in the hash table. */
+   mchash[crc >> 5] |= 1 << (crc & 0x1f);
+
+   return (1);
+}
+
 static void
 stge_set_multi(struct stge_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
uint32_t mchash[2];
uint16_t mode;
int count;
@@ -2542,25 +2554,8 @@ stge_set_multi(struct stge_softc *sc)
 * high order bits select the register, while the rest of the bits
 * select the bit within the register.
 */
-
bzero(mchash, sizeof(mchash));
-
-   count = 0;
-   if_maddr_rlock(sc->sc_ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->sc_ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-
-   /* Just want the 6 least significant bits. */
-   crc &= 0x3f;
-
-   /* Set the corresponding bit in the hash table. */
-   mchash[crc >> 5] |= 1 << (crc & 0x1f);
-   count++;
-   }
-   if_maddr_runlock(ifp);
+   count = if_foreach_llmaddr(ifp, stge_hash_maddr, mchash);
 
mode &= ~(RM_ReceiveMulticast | RM_ReceiveAllFrames);
if (count > 0)
___
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"


svn commit: r353832 - head/sys/dev/vr

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:08:16 2019
New Revision: 353832
URL: https://svnweb.freebsd.org/changeset/base/353832

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/vr/if_vr.c

Modified: head/sys/dev/vr/if_vr.c
==
--- head/sys/dev/vr/if_vr.c Mon Oct 21 18:08:12 2019(r353831)
+++ head/sys/dev/vr/if_vr.c Mon Oct 21 18:08:16 2019(r353832)
@@ -432,6 +432,44 @@ vr_cam_data(struct vr_softc *sc, int type, int idx, ui
return (i == VR_TIMEOUT ? ETIMEDOUT : 0);
 }
 
+struct vr_hash_maddr_cam_ctx {
+   struct vr_softc *sc;
+   uint32_t mask;
+   int error;
+};
+
+static u_int
+vr_hash_maddr_cam(void *arg, struct sockaddr_dl *sdl, u_int mcnt)
+{
+   struct vr_hash_maddr_cam_ctx *ctx = arg;
+
+   if (ctx->error != 0)
+   return (0);
+   ctx->error = vr_cam_data(ctx->sc, VR_MCAST_CAM, mcnt, LLADDR(sdl));
+   if (ctx->error != 0) {
+   ctx->mask = 0;
+   return (0);
+   }
+   ctx->mask |= 1 << mcnt;
+
+   return (1);
+}
+
+static u_int
+vr_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int h;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
 /*
  * Program the 64-bit multicast hash filter.
  */
@@ -439,12 +477,9 @@ static void
 vr_set_filter(struct vr_softc *sc)
 {
struct ifnet*ifp;
-   int h;
uint32_thashes[2] = { 0, 0 };
-   struct ifmultiaddr  *ifma;
uint8_t rxfilt;
int error, mcnt;
-   uint32_tcam_mask;
 
VR_LOCK_ASSERT(sc);
 
@@ -466,27 +501,18 @@ vr_set_filter(struct vr_softc *sc)
 
/* Now program new ones. */
error = 0;
-   mcnt = 0;
-   if_maddr_rlock(ifp);
if ((sc->vr_quirks & VR_Q_CAM) != 0) {
+   struct vr_hash_maddr_cam_ctx ctx;
+
/*
 * For hardwares that have CAM capability, use
 * 32 entries multicast perfect filter.
 */
-   cam_mask = 0;
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   error = vr_cam_data(sc, VR_MCAST_CAM, mcnt,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   if (error != 0) {
-   cam_mask = 0;
-   break;
-   }
-   cam_mask |= 1 << mcnt;
-   mcnt++;
-   }
-   vr_cam_mask(sc, VR_MCAST_CAM, cam_mask);
+   ctx.sc = sc;
+   ctx.mask = 0;
+   ctx.error = 0;
+   mcnt = if_foreach_llmaddr(ifp, vr_hash_maddr_cam, &ctx);
+   vr_cam_mask(sc, VR_MCAST_CAM, ctx.mask);
}
 
if ((sc->vr_quirks & VR_Q_CAM) == 0 || error != 0) {
@@ -495,20 +521,8 @@ vr_set_filter(struct vr_softc *sc)
 * setting multicast CAM filter failed, use hash
 * table based filtering.
 */
-   mcnt = 0;
-   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) >> 26;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   mcnt++;
-   }
+   mcnt = if_foreach_llmaddr(ifp, vr_hash_maddr, hashes);
}
-   if_maddr_runlock(ifp);
 
if (mcnt > 0)
rxfilt |= VR_RXCFG_RX_MULTI;
___
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"


svn commit: r353824 - head/sys/dev/rl

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:35 2019
New Revision: 353824
URL: https://svnweb.freebsd.org/changeset/base/353824

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/rl/if_rl.c

Modified: head/sys/dev/rl/if_rl.c
==
--- head/sys/dev/rl/if_rl.c Mon Oct 21 18:07:32 2019(r353823)
+++ head/sys/dev/rl/if_rl.c Mon Oct 21 18:07:35 2019(r353824)
@@ -509,6 +509,21 @@ rl_miibus_statchg(device_t dev)
 */
 }
 
+static u_int
+rl_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int h;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
 /*
  * Program the 64-bit multicast hash filter.
  */
@@ -516,9 +531,7 @@ static void
 rl_rxfilter(struct rl_softc *sc)
 {
struct ifnet*ifp = sc->rl_ifp;
-   int h = 0;
uint32_thashes[2] = { 0, 0 };
-   struct ifmultiaddr  *ifma;
uint32_trxfilt;
 
RL_LOCK_ASSERT(sc);
@@ -539,18 +552,7 @@ rl_rxfilter(struct rl_softc *sc)
hashes[1] = 0x;
} else {
/* Now program new ones. */
-   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) >> 26;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, rl_hash_maddr, hashes);
if (hashes[0] != 0 || hashes[1] != 0)
rxfilt |= RL_RXCFG_RX_MULTI;
}
___
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"


svn commit: r353820 - head/sys/dev/msk

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:19 2019
New Revision: 353820
URL: https://svnweb.freebsd.org/changeset/base/353820

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/msk/if_msk.c

Modified: head/sys/dev/msk/if_msk.c
==
--- head/sys/dev/msk/if_msk.c   Mon Oct 21 18:07:15 2019(r353819)
+++ head/sys/dev/msk/if_msk.c   Mon Oct 21 18:07:19 2019(r353820)
@@ -573,14 +573,27 @@ msk_miibus_statchg(device_t dev)
}
 }
 
+static u_int
+msk_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *mchash = arg;
+   uint32_t crc;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* Just want the 6 least significant bits. */
+   crc &= 0x3f;
+   /* Set the corresponding bit in the hash table. */
+   mchash[crc >> 5] |= 1 << (crc & 0x1f);
+
+   return (1);
+}
+
 static void
 msk_rxfilter(struct msk_if_softc *sc_if)
 {
struct msk_softc *sc;
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
uint32_t mchash[2];
-   uint32_t crc;
uint16_t mode;
 
sc = sc_if->msk_softc;
@@ -599,18 +612,7 @@ msk_rxfilter(struct msk_if_softc *sc_if)
mchash[1] = 0x;
} else {
mode |= GM_RXCR_UCF_ENA;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   /* Just want the 6 least significant bits. */
-   crc &= 0x3f;
-   /* Set the corresponding bit in the hash table. */
-   mchash[crc >> 5] |= 1 << (crc & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, msk_hash_maddr, mchash);
if (mchash[0] != 0 || mchash[1] != 0)
mode |= GM_RXCR_MCF_ENA;
}
___
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"


svn commit: r353821 - head/sys/dev/nfe

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:24 2019
New Revision: 353821
URL: https://svnweb.freebsd.org/changeset/base/353821

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/nfe/if_nfe.c

Modified: head/sys/dev/nfe/if_nfe.c
==
--- head/sys/dev/nfe/if_nfe.c   Mon Oct 21 18:07:19 2019(r353820)
+++ head/sys/dev/nfe/if_nfe.c   Mon Oct 21 18:07:24 2019(r353821)
@@ -2557,75 +2557,67 @@ nfe_encap(struct nfe_softc *sc, struct mbuf **m_head)
return (0);
 }
 
+struct nfe_hash_maddr_ctx {
+   uint8_t addr[ETHER_ADDR_LEN];
+   uint8_t mask[ETHER_ADDR_LEN];
+};
 
+static u_int
+nfe_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct nfe_hash_maddr_ctx *ctx = arg;
+   uint8_t *addrp, mcaddr;
+   int j;
+
+   addrp = LLADDR(sdl);
+   for (j = 0; j < ETHER_ADDR_LEN; j++) {
+   mcaddr = addrp[j];
+   ctx->addr[j] &= mcaddr;
+   ctx->mask[j] &= ~mcaddr;
+   }
+
+   return (1);
+}
+
 static void
 nfe_setmulti(struct nfe_softc *sc)
 {
if_t ifp = sc->nfe_ifp;
-   int i, mc_count, mcnt;
+   struct nfe_hash_maddr_ctx ctx;
uint32_t filter;
-   uint8_t addr[ETHER_ADDR_LEN], mask[ETHER_ADDR_LEN];
uint8_t etherbroadcastaddr[ETHER_ADDR_LEN] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
-   uint8_t *mta;
+   int i;
 
NFE_LOCK_ASSERT(sc);
 
if ((if_getflags(ifp) & (IFF_ALLMULTI | IFF_PROMISC)) != 0) {
-   bzero(addr, ETHER_ADDR_LEN);
-   bzero(mask, ETHER_ADDR_LEN);
+   bzero(ctx.addr, ETHER_ADDR_LEN);
+   bzero(ctx.mask, ETHER_ADDR_LEN);
goto done;
}
 
-   bcopy(etherbroadcastaddr, addr, ETHER_ADDR_LEN);
-   bcopy(etherbroadcastaddr, mask, ETHER_ADDR_LEN);
+   bcopy(etherbroadcastaddr, ctx.addr, ETHER_ADDR_LEN);
+   bcopy(etherbroadcastaddr, ctx.mask, ETHER_ADDR_LEN);
 
-   mc_count = if_multiaddr_count(ifp, -1);
-   mta = malloc(sizeof(uint8_t) * ETHER_ADDR_LEN * mc_count, M_DEVBUF,
-   M_NOWAIT);
+   if_foreach_llmaddr(ifp, nfe_hash_maddr, &ctx);
 
-   /* Unable to get memory - process without filtering */
-   if (mta == NULL) {
-   device_printf(sc->nfe_dev, "nfe_setmulti: failed to allocate"
-   "temp multicast buffer!\n");
-
-   bzero(addr, ETHER_ADDR_LEN);
-   bzero(mask, ETHER_ADDR_LEN);
-   goto done;
-   }
-
-   if_multiaddr_array(ifp, mta, &mcnt, mc_count);
-
-   for (i = 0; i < mcnt; i++) {
-   uint8_t *addrp;
-   int j;
-
-   addrp = mta + (i * ETHER_ADDR_LEN);
-   for (j = 0; j < ETHER_ADDR_LEN; j++) {
-   u_int8_t mcaddr = addrp[j];
-   addr[j] &= mcaddr;
-   mask[j] &= ~mcaddr;
-   }
-   }
-
-   free(mta, M_DEVBUF);
-
for (i = 0; i < ETHER_ADDR_LEN; i++) {
-   mask[i] |= addr[i];
+   ctx.mask[i] |= ctx.addr[i];
}
 
 done:
-   addr[0] |= 0x01;/* make sure multicast bit is set */
+   ctx.addr[0] |= 0x01;/* make sure multicast bit is set */
 
-   NFE_WRITE(sc, NFE_MULTIADDR_HI,
-   addr[3] << 24 | addr[2] << 16 | addr[1] << 8 | addr[0]);
+   NFE_WRITE(sc, NFE_MULTIADDR_HI, ctx.addr[3] << 24 | ctx.addr[2] << 16 |
+   ctx.addr[1] << 8 | ctx.addr[0]);
NFE_WRITE(sc, NFE_MULTIADDR_LO,
-   addr[5] <<  8 | addr[4]);
-   NFE_WRITE(sc, NFE_MULTIMASK_HI,
-   mask[3] << 24 | mask[2] << 16 | mask[1] << 8 | mask[0]);
+   ctx.addr[5] <<  8 | ctx.addr[4]);
+   NFE_WRITE(sc, NFE_MULTIMASK_HI, ctx.mask[3] << 24 | ctx.mask[2] << 16 |
+   ctx.mask[1] << 8 | ctx.mask[0]);
NFE_WRITE(sc, NFE_MULTIMASK_LO,
-   mask[5] <<  8 | mask[4]);
+   ctx.mask[5] <<  8 | ctx.mask[4]);
 
filter = NFE_READ(sc, NFE_RXFILTER);
filter &= NFE_PFF_RX_PAUSE;
___
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"


svn commit: r353831 - head/sys/dev/vge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:08:12 2019
New Revision: 353831
URL: https://svnweb.freebsd.org/changeset/base/353831

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/vge/if_vge.c

Modified: head/sys/dev/vge/if_vge.c
==
--- head/sys/dev/vge/if_vge.c   Mon Oct 21 18:08:03 2019(r353830)
+++ head/sys/dev/vge/if_vge.c   Mon Oct 21 18:08:12 2019(r353831)
@@ -529,6 +529,34 @@ vge_setvlan(struct vge_softc *sc)
CSR_WRITE_1(sc, VGE_RXCFG, cfg);
 }
 
+static u_int
+vge_set_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct vge_softc *sc = arg;
+
+if (sc->vge_camidx == VGE_CAM_MAXADDRS)
+   return (0);
+
+   (void )vge_cam_set(sc, LLADDR(sdl));
+
+   return (1);
+}
+
+static u_int
+vge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t h, *hashes = arg;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
+
 /*
  * Program the multicast filter. We use the 64-entry CAM filter
  * for perfect filtering. If there's more than 64 multicast addresses,
@@ -538,10 +566,8 @@ static void
 vge_rxfilter(struct vge_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t h, hashes[2];
+   uint32_t hashes[2];
uint8_t rxcfg;
-   int error = 0;
 
VGE_LOCK_ASSERT(sc);
 
@@ -572,33 +598,15 @@ vge_rxfilter(struct vge_softc *sc)
}
 
vge_cam_clear(sc);
+
/* Now program new ones */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   error = vge_cam_set(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   if (error)
-   break;
-   }
+   if_foreach_llmaddr(ifp, vge_set_maddr, sc);
 
/* If there were too many addresses, use the hash filter. */
-   if (error) {
+if (sc->vge_camidx == VGE_CAM_MAXADDRS) {
vge_cam_clear(sc);
-
-   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) >> 26;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   }
+if_foreach_llmaddr(ifp, vge_hash_maddr, hashes);
}
-   if_maddr_runlock(ifp);
 
 done:
if (hashes[0] != 0 || hashes[1] != 0)
___
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"


svn commit: r353830 - head/sys/dev/ti

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:08:03 2019
New Revision: 353830
URL: https://svnweb.freebsd.org/changeset/base/353830

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/ti/if_ti.c
  head/sys/dev/ti/if_tireg.h

Modified: head/sys/dev/ti/if_ti.c
==
--- head/sys/dev/ti/if_ti.c Mon Oct 21 18:07:56 2019(r353829)
+++ head/sys/dev/ti/if_ti.c Mon Oct 21 18:08:03 2019(r353830)
@@ -207,8 +207,8 @@ static uint32_t ti_eeprom_putbyte(struct ti_softc *, i
 static uint8_t ti_eeprom_getbyte(struct ti_softc *, int, uint8_t *);
 static int ti_read_eeprom(struct ti_softc *, caddr_t, int, int);
 
-static void ti_add_mcast(struct ti_softc *, struct ether_addr *);
-static void ti_del_mcast(struct ti_softc *, struct ether_addr *);
+static u_int ti_add_mcast(void *, struct sockaddr_dl *, u_int);
+static u_int ti_del_mcast(void *, struct sockaddr_dl *, u_int);
 static void ti_setmulti(struct ti_softc *);
 
 static void ti_mem_read(struct ti_softc *, uint32_t, uint32_t, void *);
@@ -1878,14 +1878,15 @@ ti_init_tx_ring(struct ti_softc *sc)
  * but we have to support the old way too so that Tigon 1 cards will
  * work.
  */
-static void
-ti_add_mcast(struct ti_softc *sc, struct ether_addr *addr)
+static u_int
+ti_add_mcast(void *arg, struct sockaddr_dl *sdl, u_int count)
 {
+   struct ti_softc *sc = arg;
struct ti_cmd_desc cmd;
uint16_t *m;
uint32_t ext[2] = {0, 0};
 
-   m = (uint16_t *)&addr->octet[0];
+   m = (uint16_t *)LLADDR(sdl);
 
switch (sc->ti_hwrev) {
case TI_HWREV_TIGON:
@@ -1900,18 +1901,20 @@ ti_add_mcast(struct ti_softc *sc, struct ether_addr *a
break;
default:
device_printf(sc->ti_dev, "unknown hwrev\n");
-   break;
+   return (0);
}
+   return (1);
 }
 
-static void
-ti_del_mcast(struct ti_softc *sc, struct ether_addr *addr)
+static u_int
+ti_del_mcast(void *arg, struct sockaddr_dl *sdl, u_int count)
 {
+   struct ti_softc *sc = arg;
struct ti_cmd_desc cmd;
uint16_t *m;
uint32_t ext[2] = {0, 0};
 
-   m = (uint16_t *)&addr->octet[0];
+   m = (uint16_t *)LLADDR(sdl);
 
switch (sc->ti_hwrev) {
case TI_HWREV_TIGON:
@@ -1926,8 +1929,10 @@ ti_del_mcast(struct ti_softc *sc, struct ether_addr *a
break;
default:
device_printf(sc->ti_dev, "unknown hwrev\n");
-   break;
+   return (0);
}
+
+   return (1);
 }
 
 /*
@@ -1948,9 +1953,7 @@ static void
 ti_setmulti(struct ti_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
struct ti_cmd_desc cmd;
-   struct ti_mc_entry *mc;
uint32_t intrs;
 
TI_LOCK_ASSERT(sc);
@@ -1969,30 +1972,10 @@ ti_setmulti(struct ti_softc *sc)
CSR_WRITE_4(sc, TI_MB_HOSTINTR, 1);
 
/* First, zot all the existing filters. */
-   while (SLIST_FIRST(&sc->ti_mc_listhead) != NULL) {
-   mc = SLIST_FIRST(&sc->ti_mc_listhead);
-   ti_del_mcast(sc, &mc->mc_addr);
-   SLIST_REMOVE_HEAD(&sc->ti_mc_listhead, mc_entries);
-   free(mc, M_DEVBUF);
-   }
+   if_foreach_llmaddr(ifp, ti_del_mcast, sc);
 
/* Now program new ones. */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   mc = malloc(sizeof(struct ti_mc_entry), M_DEVBUF, M_NOWAIT);
-   if (mc == NULL) {
-   device_printf(sc->ti_dev,
-   "no memory for mcast filter entry\n");
-   continue;
-   }
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-   (char *)&mc->mc_addr, ETHER_ADDR_LEN);
-   SLIST_INSERT_HEAD(&sc->ti_mc_listhead, mc, mc_entries);
-   ti_add_mcast(sc, &mc->mc_addr);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, ti_add_mcast, sc);
 
/* Re-enable interrupts. */
CSR_WRITE_4(sc, TI_MB_HOSTINTR, intrs);

Modified: head/sys/dev/ti/if_tireg.h
==
--- head/sys/dev/ti/if_tireg.h  Mon Oct 21 18:07:56 2019(r353829)
+++ head/sys/dev/ti/if_tireg.h  Mon Oct 21 18:08:03 2019(r353830)
@@ -1010,11 +1010,6 @@ struct ti_type {
 #define TI_TIMEOUT 1000
 #define TI_TXCONS_UNSET0x  /* impossible value */
 
-struct ti_mc_entry {
-   struct ether_addr   mc_addr;
-   SLIST_ENTRY(ti_mc_entry)mc_entries;
-};
-
 typedef enum {
TI_FLAG_NONE= 0x00,
TI_FLAG_DEBUGING= 0x01,
@@ -1048,7 +1043,6 @@ struct ti_softc {
int ti_std;

svn commit: r353804 - head/sys/dev/ae

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 17:59:53 2019
New Revision: 353804
URL: https://svnweb.freebsd.org/changeset/base/353804

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/ae/if_ae.c

Modified: head/sys/dev/ae/if_ae.c
==
--- head/sys/dev/ae/if_ae.c Mon Oct 21 17:59:16 2019(r353803)
+++ head/sys/dev/ae/if_ae.c Mon Oct 21 17:59:53 2019(r353804)
@@ -2031,12 +2031,21 @@ ae_rxvlan(ae_softc_t *sc)
AE_WRITE_4(sc, AE_MAC_REG, val);
 }
 
+static u_int
+ae_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *mchash = arg;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+
+   return (1);
+}
+
 static void
 ae_rxfilter(ae_softc_t *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
uint32_t mchash[2];
uint32_t rxcfg;
 
@@ -2072,15 +2081,7 @@ ae_rxfilter(ae_softc_t *sc)
 * Load multicast tables.
 */
bzero(mchash, sizeof(mchash));
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, ae_hash_maddr, &mchash);
AE_WRITE_4(sc, AE_REG_MHT0, mchash[0]);
AE_WRITE_4(sc, AE_REG_MHT1, mchash[1]);
AE_WRITE_4(sc, AE_MAC_REG, rxcfg);
___
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"


svn commit: r353805 - head/sys/dev/age

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:00:17 2019
New Revision: 353805
URL: https://svnweb.freebsd.org/changeset/base/353805

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/age/if_age.c

Modified: head/sys/dev/age/if_age.c
==
--- head/sys/dev/age/if_age.c   Mon Oct 21 17:59:53 2019(r353804)
+++ head/sys/dev/age/if_age.c   Mon Oct 21 18:00:17 2019(r353805)
@@ -3140,12 +3140,22 @@ age_rxvlan(struct age_softc *sc)
CSR_WRITE_4(sc, AGE_MAC_CFG, reg);
 }
 
+static u_int
+age_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *mchash = arg;
+   uint32_t crc;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+
+   return (1);
+}
+
 static void
 age_rxfilter(struct age_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
uint32_t mchash[2];
uint32_t rxcfg;
 
@@ -3170,16 +3180,7 @@ age_rxfilter(struct age_softc *sc)
 
/* Program new filter. */
bzero(mchash, sizeof(mchash));
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->age_ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, age_hash_maddr, mchash);
 
CSR_WRITE_4(sc, AGE_MAR0, mchash[0]);
CSR_WRITE_4(sc, AGE_MAR1, mchash[1]);
___
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"


svn commit: r353811 - head/sys/dev/bfe

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:23 2019
New Revision: 353811
URL: https://svnweb.freebsd.org/changeset/base/353811

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/bfe/if_bfe.c

Modified: head/sys/dev/bfe/if_bfe.c
==
--- head/sys/dev/bfe/if_bfe.c   Mon Oct 21 18:06:19 2019(r353810)
+++ head/sys/dev/bfe/if_bfe.c   Mon Oct 21 18:06:23 2019(r353811)
@@ -1080,13 +1080,21 @@ bfe_cam_write(struct bfe_softc *sc, u_char *data, int 
bfe_wait_bit(sc, BFE_CAM_CTRL, BFE_CAM_BUSY, 1, 1);
 }
 
+static u_int
+bfe_write_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct bfe_softc *sc = arg;
+
+   bfe_cam_write(sc, LLADDR(sdl), cnt + 1);
+
+   return (1);
+}
+
 static void
 bfe_set_rx_mode(struct bfe_softc *sc)
 {
struct ifnet *ifp = sc->bfe_ifp;
-   struct ifmultiaddr  *ifma;
u_int32_t val;
-   int i = 0;
 
BFE_LOCK_ASSERT(sc);
 
@@ -1104,20 +1112,13 @@ bfe_set_rx_mode(struct bfe_softc *sc)
 
 
CSR_WRITE_4(sc, BFE_CAM_CTRL, 0);
-   bfe_cam_write(sc, IF_LLADDR(sc->bfe_ifp), i++);
+   bfe_cam_write(sc, IF_LLADDR(sc->bfe_ifp), 0);
 
if (ifp->if_flags & IFF_ALLMULTI)
val |= BFE_RXCONF_ALLMULTI;
else {
val &= ~BFE_RXCONF_ALLMULTI;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   bfe_cam_write(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr), i++);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, bfe_write_maddr, sc);
}
 
CSR_WRITE_4(sc, BFE_RXCONF, val);
___
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"


svn commit: r353806 - head/sys/dev/al_eth

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:05:43 2019
New Revision: 353806
URL: https://svnweb.freebsd.org/changeset/base/353806

Log:
  Convert to if_foreach_llmaddr() KPI.
  
  This driver seems to have a bug.  The bug was carefully saved during
  conversion.  In the al_eth_mac_table_unicast_add() the argument 'addr',
  which is the actual address is unused.  So, the function is called as
  many times as we have addresses, but with the exactly same argument
  list.  This doesn't make any sense, but was preserved.

Modified:
  head/sys/dev/al_eth/al_eth.c

Modified: head/sys/dev/al_eth/al_eth.c
==
--- head/sys/dev/al_eth/al_eth.cMon Oct 21 18:00:17 2019
(r353805)
+++ head/sys/dev/al_eth/al_eth.cMon Oct 21 18:05:43 2019
(r353806)
@@ -603,7 +603,7 @@ al_dma_free_coherent(bus_dma_tag_t tag, bus_dmamap_t m
 
 static void
 al_eth_mac_table_unicast_add(struct al_eth_adapter *adapter,
-uint8_t idx, uint8_t *addr, uint8_t udma_mask)
+uint8_t idx, uint8_t udma_mask)
 {
struct al_eth_fwd_mac_table_entry entry = { { 0 } };
 
@@ -2876,6 +2876,30 @@ al_get_counter(struct ifnet *ifp, ift_counter cnt)
}
 }
 
+static u_int
+al_count_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   unsigned char *mac;
+
+   mac = LLADDR(sdl);
+   /* default mc address inside mac address */
+   if (mac[3] != 0 && mac[4] != 0 && mac[5] != 1)
+   return (1);
+   else
+   return (0);
+}
+
+static u_int
+al_program_addr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct al_eth_adapter *adapter = arg;
+
+   al_eth_mac_table_unicast_add(adapter,
+   AL_ETH_MAC_TABLE_UNICAST_IDX_BASE + 1 + cnt, 1);
+
+   return (1);
+}
+
 /*
  *  Unicast, Multicast and Promiscuous mode set
  *
@@ -2884,44 +2908,17 @@ al_get_counter(struct ifnet *ifp, ift_counter cnt)
  *  responsible for configuring the hardware for proper unicast, multicast,
  *  promiscuous mode, and all-multi behavior.
  */
-#defineMAX_NUM_MULTICAST_ADDRESSES 32
-#defineMAX_NUM_ADDRESSES   32
-
 static void
 al_eth_set_rx_mode(struct al_eth_adapter *adapter)
 {
struct ifnet *ifp = adapter->netdev;
-   struct ifmultiaddr *ifma; /* multicast addresses configured */
-   struct ifaddr *ifua; /* unicast address */
-   int mc = 0;
-   int uc = 0;
+   int mc, uc;
uint8_t i;
-   unsigned char *mac;
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   if (mc == MAX_NUM_MULTICAST_ADDRESSES)
-   break;
+   /* XXXGL: why generic count won't work? */
+   mc = if_foreach_llmaddr(ifp, al_count_maddr, NULL);
+   uc = if_lladdr_count(ifp);
 
-   mac = LLADDR((struct sockaddr_dl *) ifma->ifma_addr);
-   /* default mc address inside mac address */
-   if (mac[3] != 0 && mac[4] != 0 && mac[5] != 1)
-   mc++;
-   }
-   if_maddr_runlock(ifp);
-
-   if_addr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifua, &ifp->if_addrhead, ifa_link) {
-   if (ifua->ifa_addr->sa_family != AF_LINK)
-   continue;
-   if (uc == MAX_NUM_ADDRESSES)
-   break;
-   uc++;
-   }
-   if_addr_runlock(ifp);
-
if ((ifp->if_flags & IFF_PROMISC) != 0) {
al_eth_mac_table_promiscuous_set(adapter, true);
} else {
@@ -2957,18 +2954,7 @@ al_eth_set_rx_mode(struct al_eth_adapter *adapter)
}
 
/* set new addresses */
-   i = AL_ETH_MAC_TABLE_UNICAST_IDX_BASE + 1;
-   if_addr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifua, &ifp->if_addrhead, ifa_link) {
-   if (ifua->ifa_addr->sa_family != AF_LINK) {
-   continue;
-   }
-   al_eth_mac_table_unicast_add(adapter, i,
-   (unsigned char *)ifua->ifa_addr, 1);
-   i++;
-   }
-   if_addr_runlock(ifp);
-
+   if_foreach_lladdr(ifp, al_program_addr, adapter);
}
al_eth_mac_table_promiscuous_set(adapter, false);
}
@@ -3001,7 +2987,7 @@ al_eth_config_rx_fwd(struct al_eth_adapter *adapter)
 * MAC address and all broadcast. all the rest will be dropped.
 */
al_eth_mac_table_unicast_add(adapter, AL_ETH_MAC_TABLE_UNICAST_IDX_BASE,
-   adapter->mac_addr, 1);
+   1);
al_eth_mac_table_broadcast_add(adapter, AL_ETH_MAC_TABLE_BROADCAST_IDX, 
1);
al_eth_mac_table_promiscuous

svn commit: r353812 - head/sys/dev/bge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:26 2019
New Revision: 353812
URL: https://svnweb.freebsd.org/changeset/base/353812

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/bge/if_bge.c

Modified: head/sys/dev/bge/if_bge.c
==
--- head/sys/dev/bge/if_bge.c   Mon Oct 21 18:06:23 2019(r353811)
+++ head/sys/dev/bge/if_bge.c   Mon Oct 21 18:06:26 2019(r353812)
@@ -1621,33 +1621,32 @@ bge_setpromisc(struct bge_softc *sc)
BGE_CLRBIT(sc, BGE_RX_MODE, BGE_RXMODE_RX_PROMISC);
 }
 
+static u_int
+bge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int h;
+
+   h = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7F;
+   hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
+
+   return (1);
+}
+
 static void
 bge_setmulti(struct bge_softc *sc)
 {
if_t ifp;
-   int mc_count = 0;
uint32_t hashes[4] = { 0, 0, 0, 0 };
-   int h, i, mcnt;
-   unsigned char *mta;
+   int i;
 
BGE_LOCK_ASSERT(sc);
 
ifp = sc->bge_ifp;
 
-   mc_count = if_multiaddr_count(ifp, -1);
-   mta = malloc(sizeof(unsigned char) *  ETHER_ADDR_LEN *
-   mc_count, M_DEVBUF, M_NOWAIT);
-
-   if(mta == NULL) {
-   device_printf(sc->bge_dev, 
-   "Failed to allocated temp mcast list\n");
-   return;
-   }
-
if (if_getflags(ifp) & IFF_ALLMULTI || if_getflags(ifp) & IFF_PROMISC) {
for (i = 0; i < 4; i++)
CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0x);
-   free(mta, M_DEVBUF);
return;
}
 
@@ -1655,17 +1654,10 @@ bge_setmulti(struct bge_softc *sc)
for (i = 0; i < 4; i++)
CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), 0);
 
-   if_multiaddr_array(ifp, mta, &mcnt, mc_count);
-   for(i = 0; i < mcnt; i++) {
-   h = ether_crc32_le(mta + (i * ETHER_ADDR_LEN),
-   ETHER_ADDR_LEN) & 0x7F;
-   hashes[(h & 0x60) >> 5] |= 1 << (h & 0x1F);
-   }
+   if_foreach_llmaddr(ifp, bge_hash_maddr, hashes);
 
for (i = 0; i < 4; i++)
CSR_WRITE_4(sc, BGE_MAR0 + (i * 4), hashes[i]);
-
-   free(mta, M_DEVBUF);
 }
 
 static void
___
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"


svn commit: r353808 - head/sys/dev/ale

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:09 2019
New Revision: 353808
URL: https://svnweb.freebsd.org/changeset/base/353808

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/ale/if_ale.c

Modified: head/sys/dev/ale/if_ale.c
==
--- head/sys/dev/ale/if_ale.c   Mon Oct 21 18:06:06 2019(r353807)
+++ head/sys/dev/ale/if_ale.c   Mon Oct 21 18:06:09 2019(r353808)
@@ -3008,12 +3008,21 @@ ale_rxvlan(struct ale_softc *sc)
CSR_WRITE_4(sc, ALE_MAC_CFG, reg);
 }
 
+static u_int
+ale_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *mchash = arg;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
+
+   return (1);
+}
+
 static void
 ale_rxfilter(struct ale_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
uint32_t mchash[2];
uint32_t rxcfg;
 
@@ -3038,16 +3047,7 @@ ale_rxfilter(struct ale_softc *sc)
 
/* Program new filter. */
bzero(mchash, sizeof(mchash));
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->ale_ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   mchash[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, ale_hash_maddr, &mchash);
 
CSR_WRITE_4(sc, ALE_MAR0, mchash[0]);
CSR_WRITE_4(sc, ALE_MAR1, mchash[1]);
___
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"


svn commit: r353828 - head/sys/dev/ste

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:53 2019
New Revision: 353828
URL: https://svnweb.freebsd.org/changeset/base/353828

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/ste/if_ste.c

Modified: head/sys/dev/ste/if_ste.c
==
--- head/sys/dev/ste/if_ste.c   Mon Oct 21 18:07:49 2019(r353827)
+++ head/sys/dev/ste/if_ste.c   Mon Oct 21 18:07:53 2019(r353828)
@@ -405,14 +405,27 @@ ste_read_eeprom(struct ste_softc *sc, uint16_t *dest, 
return (err ? 1 : 0);
 }
 
+static u_int
+ste_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int h;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) & 0x3F;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
 static void
 ste_rxfilter(struct ste_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
uint32_t hashes[2] = { 0, 0 };
uint8_t rxcfg;
-   int h;
 
STE_LOCK_ASSERT(sc);
 
@@ -433,18 +446,7 @@ ste_rxfilter(struct ste_softc *sc)
 
rxcfg |= STE_RXMODE_MULTIHASH;
/* Now program new ones. */
-   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) & 0x3F;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, ste_hash_maddr, hashes);
 
 chipit:
CSR_WRITE_2(sc, STE_MAR0, hashes[0] & 0x);
___
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"


svn commit: r353827 - head/sys/dev/sk

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:49 2019
New Revision: 353827
URL: https://svnweb.freebsd.org/changeset/base/353827

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/sk/if_sk.c

Modified: head/sys/dev/sk/if_sk.c
==
--- head/sys/dev/sk/if_sk.c Mon Oct 21 18:07:44 2019(r353826)
+++ head/sys/dev/sk/if_sk.c Mon Oct 21 18:07:49 2019(r353827)
@@ -718,21 +718,49 @@ sk_rxfilter(sc_if)
sk_rxfilter_yukon(sc_if);
 }
 
+struct sk_add_maddr_genesis_ctx {
+   struct sk_if_softc *sc_if;
+   uint32_t hashes[2];
+   uint32_t mode;
+};
+
+static u_int
+sk_add_maddr_genesis(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct sk_add_maddr_genesis_ctx *ctx = arg;
+   int h;
+
+   /*
+* Program the first XM_RXFILT_MAX multicast groups
+* into the perfect filter.
+*/
+   if (cnt + 1 < XM_RXFILT_MAX) {
+   sk_setfilt(ctx->sc_if, (uint16_t *)LLADDR(sdl), cnt + 1);
+   ctx->mode |= XM_MODE_RX_USE_PERFECT;
+   return (1);
+   }
+   h = sk_xmchash((const uint8_t *)LLADDR(sdl));
+   if (h < 32)
+   ctx->hashes[0] |= (1 << h);
+   else
+   ctx->hashes[1] |= (1 << (h - 32));
+   ctx->mode |= XM_MODE_RX_USE_HASH;
+
+   return (1);
+}
+
 static void
-sk_rxfilter_genesis(sc_if)
-   struct sk_if_softc  *sc_if;
+sk_rxfilter_genesis(struct sk_if_softc *sc_if)
 {
struct ifnet*ifp = sc_if->sk_ifp;
-   u_int32_t   hashes[2] = { 0, 0 }, mode;
-   int h = 0, i;
-   struct ifmultiaddr  *ifma;
+   struct sk_add_maddr_genesis_ctx ctx = { sc_if, { 0, 0 } };
+   int i;
u_int16_t   dummy[] = { 0, 0, 0 };
-   u_int16_t   maddr[(ETHER_ADDR_LEN+1)/2];
 
SK_IF_LOCK_ASSERT(sc_if);
 
-   mode = SK_XM_READ_4(sc_if, XM_MODE);
-   mode &= ~(XM_MODE_RX_PROMISC | XM_MODE_RX_USE_HASH |
+   ctx.mode = SK_XM_READ_4(sc_if, XM_MODE);
+   ctx.mode &= ~(XM_MODE_RX_PROMISC | XM_MODE_RX_USE_HASH |
XM_MODE_RX_USE_PERFECT);
/* First, zot all the existing perfect filters. */
for (i = 1; i < XM_RXFILT_MAX; i++)
@@ -741,53 +769,39 @@ sk_rxfilter_genesis(sc_if)
/* Now program new ones. */
if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
if (ifp->if_flags & IFF_ALLMULTI)
-   mode |= XM_MODE_RX_USE_HASH;
+   ctx.mode |= XM_MODE_RX_USE_HASH;
if (ifp->if_flags & IFF_PROMISC)
-   mode |= XM_MODE_RX_PROMISC;
-   hashes[0] = 0x;
-   hashes[1] = 0x;
-   } else {
-   i = 1;
-   if_maddr_rlock(ifp);
+   ctx.mode |= XM_MODE_RX_PROMISC;
+   ctx.hashes[0] = 0x;
+   ctx.hashes[1] = 0x;
+   } else
/* XXX want to maintain reverse semantics */
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs,
-   ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   /*
-* Program the first XM_RXFILT_MAX multicast groups
-* into the perfect filter.
-*/
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-   maddr, ETHER_ADDR_LEN);
-   if (i < XM_RXFILT_MAX) {
-   sk_setfilt(sc_if, maddr, i);
-   mode |= XM_MODE_RX_USE_PERFECT;
-   i++;
-   continue;
-   }
-   h = sk_xmchash((const uint8_t *)maddr);
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   mode |= XM_MODE_RX_USE_HASH;
-   }
-   if_maddr_runlock(ifp);
-   }
+   if_foreach_llmaddr(ifp, sk_add_maddr_genesis, &ctx);
 
-   SK_XM_WRITE_4(sc_if, XM_MODE, mode);
-   SK_XM_WRITE_4(sc_if, XM_MAR0, hashes[0]);
-   SK_XM_WRITE_4(sc_if, XM_MAR2, hashes[1]);
+   SK_XM_WRITE_4(sc_if, XM_MODE, ctx.mode);
+   SK_XM_WRITE_4(sc_if, XM_MAR0, ctx.hashes[0]);
+   SK_XM_WRITE_4(sc_if, XM_MAR2, ctx.hashes[1]);
 }
 
+static u_int
+sk_hash_maddr_yukon(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *hashes = arg;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* Just want the 6 least significant bits. */
+   crc &= 0x3f;
+   /* Set the corresponding bit in the hash tab

svn commit: r353818 - head/sys/dev/lge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:11 2019
New Revision: 353818
URL: https://svnweb.freebsd.org/changeset/base/353818

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/lge/if_lge.c

Modified: head/sys/dev/lge/if_lge.c
==
--- head/sys/dev/lge/if_lge.c   Mon Oct 21 18:07:07 2019(r353817)
+++ head/sys/dev/lge/if_lge.c   Mon Oct 21 18:07:11 2019(r353818)
@@ -367,13 +367,25 @@ lge_miibus_statchg(dev)
return;
 }
 
+static u_int
+lge_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int count)
+{
+   uint32_t h, *hashes = arg;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+   return (1);
+}
+
 static void
 lge_setmulti(sc)
struct lge_softc*sc;
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
-   u_int32_t   h = 0, hashes[2] = { 0, 0 };
+   uint32_t hashes[2] = { 0, 0 };
 
ifp = sc->lge_ifp;
LGE_LOCK_ASSERT(sc);
@@ -392,18 +404,7 @@ lge_setmulti(sc)
CSR_WRITE_4(sc, LGE_MAR1, 0);
 
/* now program new ones */
-   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) >> 26;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, lge_hash_maddr, hashes);
 
CSR_WRITE_4(sc, LGE_MAR0, hashes[0]);
CSR_WRITE_4(sc, LGE_MAR1, hashes[1]);
___
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"


svn commit: r353822 - head/sys/dev/nge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:28 2019
New Revision: 353822
URL: https://svnweb.freebsd.org/changeset/base/353822

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/nge/if_nge.c

Modified: head/sys/dev/nge/if_nge.c
==
--- head/sys/dev/nge/if_nge.c   Mon Oct 21 18:07:24 2019(r353821)
+++ head/sys/dev/nge/if_nge.c   Mon Oct 21 18:07:28 2019(r353822)
@@ -661,13 +661,33 @@ nge_miibus_statchg(device_t dev)
CSR_READ_4(sc, NGE_GPIO) & ~NGE_GPIO_GP3_OUT);
 }
 
+static u_int
+nge_write_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct nge_softc *sc = arg;
+   uint32_t h;
+   int bit, index;
+
+   /*
+* From the 11 bits returned by the crc routine, the top 7
+* bits represent the 16-bit word in the mcast hash table
+* that needs to be updated, and the lower 4 bits represent
+* which bit within that byte needs to be set.
+*/
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 21;
+   index = (h >> 4) & 0x7F;
+   bit = h & 0xF;
+   CSR_WRITE_4(sc, NGE_RXFILT_CTL, NGE_FILTADDR_MCAST_LO + (index * 2));
+   NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit));
+
+   return (1);
+}
+
 static void
 nge_rxfilter(struct nge_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t h, i, rxfilt;
-   int bit, index;
+   uint32_t i, rxfilt;
 
NGE_LOCK_ASSERT(sc);
ifp = sc->nge_ifp;
@@ -720,26 +740,7 @@ nge_rxfilter(struct nge_softc *sc)
CSR_WRITE_4(sc, NGE_RXFILT_DATA, 0);
}
 
-   /*
-* From the 11 bits returned by the crc routine, the top 7
-* bits represent the 16-bit word in the mcast hash table
-* that needs to be updated, and the lower 4 bits represent
-* which bit within that byte needs to be set.
-*/
-   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) >> 21;
-   index = (h >> 4) & 0x7F;
-   bit = h & 0xF;
-   CSR_WRITE_4(sc, NGE_RXFILT_CTL,
-   NGE_FILTADDR_MCAST_LO + (index * 2));
-   NGE_SETBIT(sc, NGE_RXFILT_DATA, (1 << bit));
-   }
-   if_maddr_runlock(ifp);
-
+   if_foreach_llmaddr(ifp, nge_write_maddr, sc);
 done:
CSR_WRITE_4(sc, NGE_RXFILT_CTL, rxfilt);
/* Turn the receive filter on. */
___
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"


svn commit: r353816 - head/sys/dev/hme

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:02 2019
New Revision: 353816
URL: https://svnweb.freebsd.org/changeset/base/353816

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/hme/if_hme.c

Modified: head/sys/dev/hme/if_hme.c
==
--- head/sys/dev/hme/if_hme.c   Mon Oct 21 18:06:57 2019(r353815)
+++ head/sys/dev/hme/if_hme.c   Mon Oct 21 18:07:02 2019(r353816)
@@ -1656,6 +1656,20 @@ hme_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
return (error);
 }
 
+static u_int
+hme_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *hash = arg;
+
+   crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* Just want the 6 most significant bits. */
+   crc >>= 26;
+   /* Set the corresponding bit in the filter. */
+   hash[crc >> 4] |= 1 << (crc & 0xf);
+
+   return (1);
+}
+
 /*
  * Set up the logical address filter.
  */
@@ -1663,8 +1677,6 @@ static void
 hme_setladrf(struct hme_softc *sc, int reenable)
 {
struct ifnet *ifp = sc->sc_ifp;
-   struct ifmultiaddr *inm;
-   u_int32_t crc;
u_int32_t hash[4];
u_int32_t macc;
 
@@ -1721,21 +1733,7 @@ hme_setladrf(struct hme_softc *sc, int reenable)
 * selects the word, while the rest of the bits select the bit within
 * the word.
 */
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
-   if (inm->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
-   inm->ifma_addr), ETHER_ADDR_LEN);
-
-   /* Just want the 6 most significant bits. */
-   crc >>= 26;
-
-   /* Set the corresponding bit in the filter. */
-   hash[crc >> 4] |= 1 << (crc & 0xf);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, hme_hash_maddr, &hash);
 
 chipit:
/* Now load the hash table into the chip */
___
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"


svn commit: r353826 - head/sys/dev/sis

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:44 2019
New Revision: 353826
URL: https://svnweb.freebsd.org/changeset/base/353826

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/sis/if_sis.c

Modified: head/sys/dev/sis/if_sis.c
==
--- head/sys/dev/sis/if_sis.c   Mon Oct 21 18:07:40 2019(r353825)
+++ head/sys/dev/sis/if_sis.c   Mon Oct 21 18:07:44 2019(r353826)
@@ -694,13 +694,29 @@ sis_rxfilter(struct sis_softc *sc)
sis_rxfilter_sis(sc);
 }
 
+static u_int
+sis_write_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct sis_softc *sc = arg;
+   uint32_t h;
+   int bit, index;
+
+   h = sis_mchash(sc, LLADDR(sdl));
+   index = h >> 3;
+   bit = h & 0x1F;
+   CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO + index);
+   if (bit > 0xF)
+   bit -= 0x10;
+   SIS_SETBIT(sc, SIS_RXFILT_DATA, (1 << bit));
+
+   return (1);
+}
+
 static void
 sis_rxfilter_ns(struct sis_softc *sc)
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
-   uint32_th, i, filter;
-   int bit, index;
+   uint32_ti, filter;
 
ifp = sc->sis_ifp;
filter = CSR_READ_4(sc, SIS_RXFILT_CTL);
@@ -743,21 +759,7 @@ sis_rxfilter_ns(struct sis_softc *sc)
CSR_WRITE_4(sc, SIS_RXFILT_DATA, 0);
}
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   h = sis_mchash(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   index = h >> 3;
-   bit = h & 0x1F;
-   CSR_WRITE_4(sc, SIS_RXFILT_CTL, NS_FILTADDR_FMEM_LO +
-   index);
-   if (bit > 0xF)
-   bit -= 0x10;
-   SIS_SETBIT(sc, SIS_RXFILT_DATA, (1 << bit));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, sis_write_maddr, sc);
}
 
/* Turn the receive filter on */
@@ -765,13 +767,29 @@ sis_rxfilter_ns(struct sis_softc *sc)
CSR_READ_4(sc, SIS_RXFILT_CTL);
 }
 
+struct sis_hash_maddr_ctx {
+   struct sis_softc *sc;
+   uint16_t hashes[16];
+};
+
+static u_int
+sis_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct sis_hash_maddr_ctx *ctx = arg;
+   uint32_t h;
+
+   h = sis_mchash(ctx->sc, LLADDR(sdl));
+   ctx->hashes[h >> 4] |= 1 << (h & 0xf);
+
+   return (1);
+}
+
 static void
 sis_rxfilter_sis(struct sis_softc *sc)
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
-   uint32_tfilter, h, i, n;
-   uint16_thashes[16];
+   struct sis_hash_maddr_ctx ctx;
+   uint32_tfilter, i, n;
 
ifp = sc->sis_ifp;
 
@@ -796,31 +814,21 @@ sis_rxfilter_sis(struct sis_softc *sc)
if (ifp->if_flags & IFF_PROMISC)
filter |= SIS_RXFILTCTL_ALLPHYS;
for (i = 0; i < n; i++)
-   hashes[i] = ~0;
+   ctx.hashes[i] = ~0;
} else {
for (i = 0; i < n; i++)
-   hashes[i] = 0;
-   i = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   h = sis_mchash(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   hashes[h >> 4] |= 1 << (h & 0xf);
-   i++;
-   }
-   if_maddr_runlock(ifp);
-   if (i > n) {
+   ctx.hashes[i] = 0;
+   ctx.sc = sc;
+   if (if_foreach_llmaddr(ifp, sis_hash_maddr, &ctx) > n) {
filter |= SIS_RXFILTCTL_ALLMULTI;
for (i = 0; i < n; i++)
-   hashes[i] = ~0;
+   ctx.hashes[i] = ~0;
}
}
 
for (i = 0; i < n; i++) {
CSR_WRITE_4(sc, SIS_RXFILT_CTL, (4 + i) << 16);
-   CSR_WRITE_4(sc, SIS_RXFILT_DATA, hashes[i]);
+   CSR_WRITE_4(sc, SIS_RXFILT_DATA, ctx.hashes[i]);
}
 
/* Turn the receive filter on */
___
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"


svn commit: r353833 - head/sys/dev/vte

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:08:20 2019
New Revision: 353833
URL: https://svnweb.freebsd.org/changeset/base/353833

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/vte/if_vte.c

Modified: head/sys/dev/vte/if_vte.c
==
--- head/sys/dev/vte/if_vte.c   Mon Oct 21 18:08:16 2019(r353832)
+++ head/sys/dev/vte/if_vte.c   Mon Oct 21 18:08:20 2019(r353833)
@@ -1955,27 +1955,57 @@ vte_init_rx_ring(struct vte_softc *sc)
return (0);
 }
 
+struct vte_maddr_ctx {
+   uint16_t rxfilt_perf[VTE_RXFILT_PERFECT_CNT][3];
+   uint16_t mchash[4];
+   u_int nperf;
+};
+
+static u_int
+vte_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct vte_maddr_ctx *ctx = arg;
+   uint8_t *eaddr;
+   uint32_t crc;
+
+   /*
+* Program the first 3 multicast groups into the perfect filter.
+* For all others, use the hash table.
+*/
+   if (ctx->nperf < VTE_RXFILT_PERFECT_CNT) {
+   eaddr = LLADDR(sdl);
+   ctx->rxfilt_perf[ctx->nperf][0] = eaddr[1] << 8 | eaddr[0];
+   ctx->rxfilt_perf[ctx->nperf][1] = eaddr[3] << 8 | eaddr[2];
+   ctx->rxfilt_perf[ctx->nperf][2] = eaddr[5] << 8 | eaddr[4];
+   ctx->nperf++;
+
+   return (1);
+   }
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   ctx->mchash[crc >> 30] |= 1 << ((crc >> 26) & 0x0F);
+
+   return (1);
+}
+
 static void
 vte_rxfilter(struct vte_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint8_t *eaddr;
-   uint32_t crc;
-   uint16_t rxfilt_perf[VTE_RXFILT_PERFECT_CNT][3];
-   uint16_t mchash[4], mcr;
-   int i, nperf;
+   struct vte_maddr_ctx ctx;
+   uint16_t mcr;
+   int i;
 
VTE_LOCK_ASSERT(sc);
 
ifp = sc->vte_ifp;
 
-   bzero(mchash, sizeof(mchash));
+   bzero(ctx.mchash, sizeof(ctx.mchash));
for (i = 0; i < VTE_RXFILT_PERFECT_CNT; i++) {
-   rxfilt_perf[i][0] = 0x;
-   rxfilt_perf[i][1] = 0x;
-   rxfilt_perf[i][2] = 0x;
+   ctx.rxfilt_perf[i][0] = 0x;
+   ctx.rxfilt_perf[i][1] = 0x;
+   ctx.rxfilt_perf[i][2] = 0x;
}
+   ctx.nperf = 0;
 
mcr = CSR_READ_2(sc, VTE_MCR0);
mcr &= ~(MCR0_PROMISC | MCR0_MULTICAST);
@@ -1987,54 +2017,32 @@ vte_rxfilter(struct vte_softc *sc)
mcr |= MCR0_PROMISC;
if ((ifp->if_flags & IFF_ALLMULTI) != 0)
mcr |= MCR0_MULTICAST;
-   mchash[0] = 0x;
-   mchash[1] = 0x;
-   mchash[2] = 0x;
-   mchash[3] = 0x;
+   ctx.mchash[0] = 0x;
+   ctx.mchash[1] = 0x;
+   ctx.mchash[2] = 0x;
+   ctx.mchash[3] = 0x;
goto chipit;
}
 
-   nperf = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->vte_ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   /*
-* Program the first 3 multicast groups into
-* the perfect filter.  For all others, use the
-* hash table.
-*/
-   if (nperf < VTE_RXFILT_PERFECT_CNT) {
-   eaddr = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-   rxfilt_perf[nperf][0] = eaddr[1] << 8 | eaddr[0];
-   rxfilt_perf[nperf][1] = eaddr[3] << 8 | eaddr[2];
-   rxfilt_perf[nperf][2] = eaddr[5] << 8 | eaddr[4];
-   nperf++;
-   continue;
-   }
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-   mchash[crc >> 30] |= 1 << ((crc >> 26) & 0x0F);
-   }
-   if_maddr_runlock(ifp);
-   if (mchash[0] != 0 || mchash[1] != 0 || mchash[2] != 0 ||
-   mchash[3] != 0)
+   if_foreach_llmaddr(ifp, vte_hash_maddr, &ctx);
+   if (ctx.mchash[0] != 0 || ctx.mchash[1] != 0 ||
+   ctx.mchash[2] != 0 || ctx.mchash[3] != 0)
mcr |= MCR0_MULTICAST;
 
 chipit:
/* Program multicast hash table. */
-   CSR_WRITE_2(sc, VTE_MAR0, mchash[0]);
-   CSR_WRITE_2(sc, VTE_MAR1, mchash[1]);
-   CSR_WRITE_2(sc, VTE_MAR2, mchash[2]);
-   CSR_WRITE_2(sc, VTE_MAR3, mchash[3]);
+   CSR_WRITE_2(sc, VTE_MAR0, ctx.mchash[0]);
+   CSR_WRITE_2(sc, VTE_MAR1, ctx.mchash[1]);
+   CSR_WRITE_2(sc, VTE_MAR2, ctx.mchash[2]);
+   CSR_WRITE_2(sc, VTE_MAR3, ctx.mchash[3]);
/* Program perfect filter table. */
for (i = 0; i < VTE_RXFILT_PERFECT_CNT; i++) {
CSR_WRITE_2(sc, VTE_RXFILTER_PEEF

svn commit: r353823 - head/sys/dev/re

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:07:32 2019
New Revision: 353823
URL: https://svnweb.freebsd.org/changeset/base/353823

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/re/if_re.c

Modified: head/sys/dev/re/if_re.c
==
--- head/sys/dev/re/if_re.c Mon Oct 21 18:07:28 2019(r353822)
+++ head/sys/dev/re/if_re.c Mon Oct 21 18:07:32 2019(r353823)
@@ -649,6 +649,20 @@ re_miibus_statchg(device_t dev)
 */
 }
 
+static u_int
+re_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t h, *hashes = arg;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
 /*
  * Set the RX configuration and 64-bit multicast hash filter.
  */
@@ -656,9 +670,8 @@ static void
 re_set_rxmode(struct rl_softc *sc)
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
-   uint32_thashes[2] = { 0, 0 };
-   uint32_th, rxfilt;
+   uint32_th, hashes[2] = { 0, 0 };
+   uint32_trxfilt;
 
RL_LOCK_ASSERT(sc);
 
@@ -683,18 +696,7 @@ re_set_rxmode(struct rl_softc *sc)
goto done;
}
 
-   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) >> 26;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, re_hash_maddr, hashes);
 
if (hashes[0] != 0 || hashes[1] != 0) {
/*
___
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"


svn commit: r353815 - head/sys/dev/gem

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:57 2019
New Revision: 353815
URL: https://svnweb.freebsd.org/changeset/base/353815

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/gem/if_gem.c

Modified: head/sys/dev/gem/if_gem.c
==
--- head/sys/dev/gem/if_gem.c   Mon Oct 21 18:06:53 2019(r353814)
+++ head/sys/dev/gem/if_gem.c   Mon Oct 21 18:06:57 2019(r353815)
@@ -2202,14 +2202,27 @@ gem_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
return (error);
 }
 
+static u_int
+gem_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *hash = arg;
+
+   crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* We just want the 8 most significant bits. */
+   crc >>= 24;
+   /* Set the corresponding bit in the filter. */
+   hash[crc >> 4] |= 1 << (15 - (crc & 15));
+
+   return (1);
+}
+
 static void
 gem_setladrf(struct gem_softc *sc)
 {
struct ifnet *ifp = sc->sc_ifp;
-   struct ifmultiaddr *inm;
int i;
uint32_t hash[16];
-   uint32_t crc, v;
+   uint32_t v;
 
GEM_LOCK_ASSERT(sc, MA_OWNED);
 
@@ -2245,23 +2258,8 @@ gem_setladrf(struct gem_softc *sc)
 * is the MSB).
 */
 
-   /* Clear the hash table. */
memset(hash, 0, sizeof(hash));
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
-   if (inm->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
-   inm->ifma_addr), ETHER_ADDR_LEN);
-
-   /* We just want the 8 most significant bits. */
-   crc >>= 24;
-
-   /* Set the corresponding bit in the filter. */
-   hash[crc >> 4] |= 1 << (15 - (crc & 15));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, gem_hash_maddr, hash);
 
v |= GEM_MAC_RX_HASH_FILTER;
 
___
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"


svn commit: r353834 - head/sys/dev/xl

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:08:25 2019
New Revision: 353834
URL: https://svnweb.freebsd.org/changeset/base/353834

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/xl/if_xl.c

Modified: head/sys/dev/xl/if_xl.c
==
--- head/sys/dev/xl/if_xl.c Mon Oct 21 18:08:20 2019(r353833)
+++ head/sys/dev/xl/if_xl.c Mon Oct 21 18:08:25 2019(r353834)
@@ -606,11 +606,20 @@ xl_rxfilter(struct xl_softc *sc)
  * NICs older than the 3c905B have only one multicast option, which
  * is to enable reception of all multicast frames.
  */
+static u_int
+xl_check_maddr_90x(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint8_t *rxfilt = arg;
+
+   *rxfilt |= XL_RXFILTER_ALLMULTI;
+
+   return (1);
+}
+
 static void
 xl_rxfilter_90x(struct xl_softc *sc)
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
u_int8_trxfilt;
 
XL_LOCK_ASSERT(sc);
@@ -634,16 +643,8 @@ xl_rxfilter_90x(struct xl_softc *sc)
rxfilt |= XL_RXFILTER_ALLFRAMES;
if (ifp->if_flags & IFF_ALLMULTI)
rxfilt |= XL_RXFILTER_ALLMULTI;
-   } else {
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   rxfilt |= XL_RXFILTER_ALLMULTI;
-   break;
-   }
-   if_maddr_runlock(ifp);
-   }
+   } else
+   if_foreach_llmaddr(sc->xl_ifp, xl_check_maddr_90x, &rxfilt);
 
CSR_WRITE_2(sc, XL_COMMAND, rxfilt | XL_CMD_RX_SET_FILT);
XL_SEL_WIN(7);
@@ -651,14 +652,34 @@ xl_rxfilter_90x(struct xl_softc *sc)
 
 /*
  * 3c905B adapters have a hash filter that we can program.
+ * Note: the 3c905B currently only supports a 64-bit
+ * hash table, which means we really only need 6 bits,
+ * but the manual indicates that future chip revisions
+ * will have a 256-bit hash table, hence the routine
+ * is set up to calculate 8 bits of position info in
+ * case we need it some day.
+ * Note II, The Sequel: _CURRENT_ versions of the
+ * 3c905B have a 256 bit hash table. This means we have
+ * to use all 8 bits regardless.  On older cards, the
+ * upper 2 bits will be ignored. G
  */
+static u_int
+xl_check_maddr_90xB(void *arg, struct sockaddr_dl *sdl, u_int count)
+{
+   struct xl_softc *sc = arg;
+   uint16_t h;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) & 0xFF;
+   CSR_WRITE_2(sc, XL_COMMAND, h | XL_CMD_RX_SET_HASH | XL_HASH_SET);
+
+   return (1);
+}
+
 static void
 xl_rxfilter_90xB(struct xl_softc *sc)
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
-   int i, mcnt;
-   u_int16_t   h;
+   int i;
u_int8_trxfilt;
 
XL_LOCK_ASSERT(sc);
@@ -689,31 +710,7 @@ xl_rxfilter_90xB(struct xl_softc *sc)
CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_RX_SET_HASH | i);
 
/* Now program new ones. */
-   mcnt = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   /*
-* Note: the 3c905B currently only supports a 64-bit
-* hash table, which means we really only need 6 bits,
-* but the manual indicates that future chip revisions
-* will have a 256-bit hash table, hence the routine
-* is set up to calculate 8 bits of position info in
-* case we need it some day.
-* Note II, The Sequel: _CURRENT_ versions of the
-* 3c905B have a 256 bit hash table. This means we have
-* to use all 8 bits regardless.  On older cards, the
-* upper 2 bits will be ignored. G
-*/
-   h = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN) & 0xFF;
-   CSR_WRITE_2(sc, XL_COMMAND,
-   h | XL_CMD_RX_SET_HASH | XL_HASH_SET);
-   mcnt++;
-   }
-   if_maddr_runlock(ifp);
-   if (mcnt > 0)
+   if (if_foreach_llmaddr(sc->xl_ifp, xl_check_maddr_90xB, sc) > 0)
rxfilt |= XL_RXFILTER_MULTIHASH;
}
 
___
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubsc

svn commit: r353813 - head/sys/dev/bxe

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:06:31 2019
New Revision: 353813
URL: https://svnweb.freebsd.org/changeset/base/353813

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/bxe/bxe.c
  head/sys/dev/bxe/bxe.h

Modified: head/sys/dev/bxe/bxe.c
==
--- head/sys/dev/bxe/bxe.c  Mon Oct 21 18:06:26 2019(r353812)
+++ head/sys/dev/bxe/bxe.c  Mon Oct 21 18:06:31 2019(r353813)
@@ -12065,27 +12065,31 @@ bxe_initial_phy_init(struct bxe_softc *sc,
 return (rc);
 }
 
-/* must be called under IF_ADDR_LOCK */
+static u_int
+bxe_push_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+struct ecore_mcast_list_elem *mc_mac = arg;
+
+mc_mac += cnt;
+mc_mac->mac = (uint8_t *)LLADDR(sdl);
+
+return (1);
+}
+
 static int
 bxe_init_mcast_macs_list(struct bxe_softc *sc,
  struct ecore_mcast_ramrod_params *p)
 {
 if_t ifp = sc->ifp;
-int mc_count = 0;
-struct ifmultiaddr *ifma;
+int mc_count;
 struct ecore_mcast_list_elem *mc_mac;
 
-CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-if (ifma->ifma_addr->sa_family != AF_LINK) {
-continue;
-}
-
-mc_count++;
-}
-
 ECORE_LIST_INIT(&p->mcast_list);
 p->mcast_list_len = 0;
 
+/* XXXGL: multicast count may change later */
+mc_count = if_llmaddr_count(ifp);
+
 if (!mc_count) {
 return (0);
 }
@@ -12097,20 +12101,15 @@ bxe_init_mcast_macs_list(struct bxe_softc 
 return (-1);
 }
 bzero(mc_mac, (sizeof(*mc_mac) * mc_count));
+if_foreach_llmaddr(ifp, bxe_push_maddr, mc_mac);
 
-CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-if (ifma->ifma_addr->sa_family != AF_LINK) {
-continue;
-}
-
-mc_mac->mac = (uint8_t *)LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-ECORE_LIST_PUSH_TAIL(&mc_mac->link, &p->mcast_list);
-
+for (int i = 0; i < mc_count; i ++) {
+ECORE_LIST_PUSH_TAIL(&mc_mac[i].link, &p->mcast_list);
 BLOGD(sc, DBG_LOAD,
   "Setting MCAST %02X:%02X:%02X:%02X:%02X:%02X and mc_count %d\n",
-  mc_mac->mac[0], mc_mac->mac[1], mc_mac->mac[2],
-  mc_mac->mac[3], mc_mac->mac[4], mc_mac->mac[5], mc_count);
-   mc_mac++;
+  mc_mac[i].mac[0], mc_mac[i].mac[1], mc_mac[i].mac[2],
+  mc_mac[i].mac[3], mc_mac[i].mac[4], mc_mac[i].mac[5],
+  mc_count);
 }
 
 p->mcast_list_len = mc_count;
@@ -12171,69 +12170,59 @@ bxe_set_mc_list(struct bxe_softc *sc)
 return (rc);
 }
 
+struct bxe_set_addr_ctx {
+   struct bxe_softc *sc;
+   unsigned long ramrod_flags;
+   int rc;
+};
+
+static u_int
+bxe_set_addr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+struct bxe_set_addr_ctx *ctx = arg;
+struct ecore_vlan_mac_obj *mac_obj = &ctx->sc->sp_objs->mac_obj;
+int rc;
+
+if (ctx->rc < 0)
+   return (0);
+
+rc = bxe_set_mac_one(ctx->sc, (uint8_t *)LLADDR(sdl), mac_obj, TRUE,
+ ECORE_UC_LIST_MAC, &ctx->ramrod_flags);
+
+/* do not treat adding same MAC as an error */
+if (rc == -EEXIST)
+   BLOGD(ctx->sc, DBG_SP, "Failed to schedule ADD operations (EEXIST)\n");
+else if (rc < 0) {
+BLOGE(ctx->sc, "Failed to schedule ADD operations (%d)\n", rc);
+ctx->rc = rc;
+}
+
+return (1);
+}
+
 static int
 bxe_set_uc_list(struct bxe_softc *sc)
 {
 if_t ifp = sc->ifp;
 struct ecore_vlan_mac_obj *mac_obj = &sc->sp_objs->mac_obj;
-struct ifaddr *ifa;
-unsigned long ramrod_flags = 0;
+struct bxe_set_addr_ctx ctx = { sc, 0, 0 };
 int rc;
 
-#if __FreeBSD_version < 80
-IF_ADDR_LOCK(ifp);
-#else
-if_addr_rlock(ifp);
-#endif
-
 /* first schedule a cleanup up of old configuration */
 rc = bxe_del_all_macs(sc, mac_obj, ECORE_UC_LIST_MAC, FALSE);
 if (rc < 0) {
 BLOGE(sc, "Failed to schedule delete of all ETH MACs (%d)\n", rc);
-#if __FreeBSD_version < 80
-IF_ADDR_UNLOCK(ifp);
-#else
-if_addr_runlock(ifp);
-#endif
 return (rc);
 }
 
-ifa = if_getifaddr(ifp); /* XXX Is this structure */
-while (ifa) {
-if (ifa->ifa_addr->sa_family != AF_LINK) {
-ifa = CK_STAILQ_NEXT(ifa, ifa_link);
-continue;
-}
+if_foreach_lladdr(ifp, bxe_set_addr, &ctx);
+if (ctx.rc < 0)
+   return (ctx.rc);
 
-rc = bxe_set_mac_one(sc, (uint8_t *)LLADDR((struct sockaddr_dl 
*)ifa->ifa_addr),
- mac_obj, TRUE, ECORE_UC_LIST_MAC, &ramrod_flags);
-if (rc == -EEXIST) {
-BLOGD(sc, DBG_SP, "Failed to schedule ADD operations (EEXIST)\n");
-/* do not treat adding same MAC as an error */
-rc = 0;
-} else if (rc < 0) {
-BLOGE(sc, "Failed to schedule ADD operations (%d)

svn commit: r353837 - head/sys/dev/bnxt

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:10:52 2019
New Revision: 353837
URL: https://svnweb.freebsd.org/changeset/base/353837

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/bnxt/if_bnxt.c

Modified: head/sys/dev/bnxt/if_bnxt.c
==
--- head/sys/dev/bnxt/if_bnxt.c Mon Oct 21 18:10:46 2019(r353836)
+++ head/sys/dev/bnxt/if_bnxt.c Mon Oct 21 18:10:52 2019(r353837)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include 
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1185,30 +1186,41 @@ bnxt_stop(if_ctx_t ctx)
return;
 }
 
+static u_int
+bnxt_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint8_t *mta = arg;
+
+   if (cnt == BNXT_MAX_MC_ADDRS)
+   return (1);
+
+   bcopy(LLADDR(sdl), &mta[cnt * ETHER_ADDR_LEN], ETHER_ADDR_LEN);
+
+   return (1);
+}
+
 static void
 bnxt_multi_set(if_ctx_t ctx)
 {
struct bnxt_softc *softc = iflib_get_softc(ctx);
if_t ifp = iflib_get_ifp(ctx);
uint8_t *mta;
-   int cnt, mcnt;
+   int mcnt;
 
-   mcnt = if_multiaddr_count(ifp, -1);
+   mta = softc->vnic_info.mc_list.idi_vaddr;
+   bzero(mta, softc->vnic_info.mc_list.idi_size);
+   mcnt = if_foreach_llmaddr(ifp, bnxt_copy_maddr, mta);
 
if (mcnt > BNXT_MAX_MC_ADDRS) {
softc->vnic_info.rx_mask |=
HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info);
-   }
-   else {
+   } else {
softc->vnic_info.rx_mask &=
~HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
-   mta = softc->vnic_info.mc_list.idi_vaddr;
-   bzero(mta, softc->vnic_info.mc_list.idi_size);
-   if_multiaddr_array(ifp, mta, &cnt, mcnt);
bus_dmamap_sync(softc->vnic_info.mc_list.idi_tag,
softc->vnic_info.mc_list.idi_map, BUS_DMASYNC_PREWRITE);
-   softc->vnic_info.mc_list_count = cnt;
+   softc->vnic_info.mc_list_count = mcnt;
softc->vnic_info.rx_mask |=
HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST;
if (bnxt_hwrm_cfa_l2_set_rx_mask(softc, &softc->vnic_info))
@@ -1370,7 +1382,7 @@ bnxt_promisc_set(if_ctx_t ctx, int flags)
int rc;
 
if (ifp->if_flags & IFF_ALLMULTI ||
-   if_multiaddr_count(ifp, -1) > BNXT_MAX_MC_ADDRS)
+   if_llmaddr_count(ifp) > BNXT_MAX_MC_ADDRS)
softc->vnic_info.rx_mask |=
HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST;
else
___
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"


svn commit: r353842 - head/sys/dev/dc

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:15 2019
New Revision: 353842
URL: https://svnweb.freebsd.org/changeset/base/353842

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/dc/if_dc.c

Modified: head/sys/dev/dc/if_dc.c
==
--- head/sys/dev/dc/if_dc.c Mon Oct 21 18:11:11 2019(r353841)
+++ head/sys/dev/dc/if_dc.c Mon Oct 21 18:11:15 2019(r353842)
@@ -962,13 +962,24 @@ dc_mchash_be(const uint8_t *addr)
  * frames. We also sneak the broadcast address into the hash filter since
  * we need that too.
  */
+static u_int
+dc_hash_maddr_21143(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct dc_softc *sc = arg;
+   uint32_t h;
+
+   h = dc_mchash_le(sc, LLADDR(sdl));
+   sc->dc_cdata.dc_sbuf[h >> 4] |= htole32(1 << (h & 0xF));
+
+   return (1);
+}
+
 static void
 dc_setfilt_21143(struct dc_softc *sc)
 {
uint16_t eaddr[(ETHER_ADDR_LEN+1)/2];
struct dc_desc *sframe;
uint32_t h, *sp;
-   struct ifmultiaddr *ifma;
struct ifnet *ifp;
int i;
 
@@ -998,15 +1009,7 @@ dc_setfilt_21143(struct dc_softc *sc)
else
DC_CLRBIT(sc, DC_NETCFG, DC_NETCFG_RX_ALLMULTI);
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   h = dc_mchash_le(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   sp[h >> 4] |= htole32(1 << (h & 0xF));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, dc_hash_maddr_21143, sp);
 
if (ifp->if_flags & IFF_BROADCAST) {
h = dc_mchash_le(sc, ifp->if_broadcastaddr);
@@ -1036,14 +1039,47 @@ dc_setfilt_21143(struct dc_softc *sc)
sc->dc_wdog_timer = 5;
 }
 
+static u_int
+dc_hash_maddr_admtek_be(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int h = 0;
+
+   h = dc_mchash_be(LLADDR(sdl));
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
+struct dc_hash_maddr_admtek_le_ctx {
+   struct dc_softc *sc;
+   uint32_t hashes[2];
+};
+
+static u_int
+dc_hash_maddr_admtek_le(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct dc_hash_maddr_admtek_le_ctx *ctx = arg;
+   int h = 0;
+
+   h = dc_mchash_le(ctx->sc, LLADDR(sdl));
+   if (h < 32)
+   ctx->hashes[0] |= (1 << h);
+   else
+   ctx->hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
+
 static void
 dc_setfilt_admtek(struct dc_softc *sc)
 {
uint8_t eaddr[ETHER_ADDR_LEN];
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   int h = 0;
-   uint32_t hashes[2] = { 0, 0 };
+   struct dc_hash_maddr_admtek_le_ctx ctx = { sc, { 0, 0 }};
 
ifp = sc->dc_ifp;
 
@@ -1076,25 +1112,13 @@ dc_setfilt_admtek(struct dc_softc *sc)
return;
 
/* Now program new ones. */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   if (DC_IS_CENTAUR(sc))
-   h = dc_mchash_le(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   else
-   h = dc_mchash_be(
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   }
-   if_maddr_runlock(ifp);
+   if (DC_IS_CENTAUR(sc))
+   if_foreach_llmaddr(ifp, dc_hash_maddr_admtek_le, &ctx);
+   else
+   if_foreach_llmaddr(ifp, dc_hash_maddr_admtek_be, &ctx.hashes);
 
-   CSR_WRITE_4(sc, DC_AL_MAR0, hashes[0]);
-   CSR_WRITE_4(sc, DC_AL_MAR1, hashes[1]);
+   CSR_WRITE_4(sc, DC_AL_MAR0, ctx.hashes[0]);
+   CSR_WRITE_4(sc, DC_AL_MAR1, ctx.hashes[1]);
 }
 
 static void
@@ -1102,8 +1126,6 @@ dc_setfilt_asix(struct dc_softc *sc)
 {
uint32_t eaddr[(ETHER_ADDR_LEN+3)/4];
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   int h = 0;
uint32_t hashes[2] = { 0, 0 };
 
ifp = sc->dc_ifp;
@@ -1149,17 +1171,7 @@ dc_setfilt_asix(struct dc_softc *sc)
return;
 
/* now program new ones */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   h = dc_mchash_be(LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-

svn commit: r353836 - head/sys/dev/altera/atse

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:10:46 2019
New Revision: 353836
URL: https://svnweb.freebsd.org/changeset/base/353836

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/altera/atse/if_atse.c

Modified: head/sys/dev/altera/atse/if_atse.c
==
--- head/sys/dev/altera/atse/if_atse.c  Mon Oct 21 18:08:57 2019
(r353835)
+++ head/sys/dev/altera/atse/if_atse.c  Mon Oct 21 18:10:46 2019
(r353836)
@@ -427,12 +427,14 @@ atse_stop_locked(struct atse_softc *sc)
return (0);
 }
 
-static uint8_t
-atse_mchash(struct atse_softc *sc __unused, const uint8_t *addr)
+static u_int
+atse_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
 {
-   uint8_t x, y;
+   uint64_t *h = arg;
+   uint8_t *addr, x, y;
int i, j;
 
+   addr = LLADDR(sdl);
x = 0;
for (i = 0; i < ETHER_ADDR_LEN; i++) {
y = addr[i] & 0x01;
@@ -440,14 +442,14 @@ atse_mchash(struct atse_softc *sc __unused, const uint
y ^= (addr[i] >> j) & 0x01;
x |= (y << i);
}
+   *h |= (1 << x);
 
-   return (x);
+   return (1);
 }
 
 static int
 atse_rxfilter_locked(struct atse_softc *sc)
 {
-   struct ifmultiaddr *ifma;
struct ifnet *ifp;
uint32_t val4;
int i;
@@ -478,22 +480,13 @@ atse_rxfilter_locked(struct atse_softc *sc)
 */
uint64_t h;
 
-   h = 0;
/*
 * Re-build and re-program hash table.  First build the
 * bit-field "yes" or "no" for each slot per address, then
 * do all the programming afterwards.
 */
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK) {
-   continue;
-   }
-
-   h |= (1 << atse_mchash(sc,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr)));
-   }
-   if_maddr_runlock(ifp);
+   h = 0;
+   (void)if_foreach_llmaddr(ifp, atse_hash_maddr, &h);
for (i = 0; i <= MHASH_LEN; i++) {
CSR_WRITE_4(sc, MHASH_START + i,
(h & (1 << i)) ? 0x01 : 0x00);
___
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"


svn commit: r353846 - head/sys/dev/ffec

2019-10-21 Thread Gleb Smirnoff
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 = 0xLLU;
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"


svn commit: r353838 - head/sys/dev/cadence

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:10:58 2019
New Revision: 353838
URL: https://svnweb.freebsd.org/changeset/base/353838

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/cadence/if_cgem.c

Modified: head/sys/dev/cadence/if_cgem.c
==
--- head/sys/dev/cadence/if_cgem.c  Mon Oct 21 18:10:52 2019
(r353837)
+++ head/sys/dev/cadence/if_cgem.c  Mon Oct 21 18:10:58 2019
(r353838)
@@ -299,6 +299,21 @@ cgem_mac_hash(u_char eaddr[])
return hash;
 }
 
+static u_int
+cgem_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int index;
+
+   index = cgem_mac_hash(LLADDR(sdl));
+   if (index > 31)
+   hashes[0] |= (1 << (index - 32));
+   else
+   hashes[1] |= (1 << index);
+
+   return (1);
+}
+
 /* After any change in rx flags or multi-cast addresses, set up
  * hash registers and net config register bits.
  */
@@ -306,15 +321,9 @@ static void
 cgem_rx_filter(struct cgem_softc *sc)
 {
if_t ifp = sc->ifp;
-   u_char *mta;
-
-   int index, i, mcnt;
-   uint32_t hash_hi, hash_lo;
+   uint32_t hashes[2] = { 0, 0 };
uint32_t net_cfg;
 
-   hash_hi = 0;
-   hash_lo = 0;
-
net_cfg = RD4(sc, CGEM_NET_CFG);
 
net_cfg &= ~(CGEM_NET_CFG_MULTI_HASH_EN |
@@ -327,36 +336,17 @@ cgem_rx_filter(struct cgem_softc *sc)
if ((if_getflags(ifp) & IFF_BROADCAST) == 0)
net_cfg |= CGEM_NET_CFG_NO_BCAST;
if ((if_getflags(ifp) & IFF_ALLMULTI) != 0) {
-   hash_hi = 0x;
-   hash_lo = 0x;
-   } else {
-   mcnt = if_multiaddr_count(ifp, -1);
-   mta = malloc(ETHER_ADDR_LEN * mcnt, M_DEVBUF,
-M_NOWAIT);
-   if (mta == NULL) {
-   device_printf(sc->dev,
- "failed to allocate temp mcast list\n");
-   return;
-   }
-   if_multiaddr_array(ifp, mta, &mcnt, mcnt);
-   for (i = 0; i < mcnt; i++) {
-   index = cgem_mac_hash(
-   LLADDR((struct sockaddr_dl *)
-  (mta + (i * ETHER_ADDR_LEN;
-   if (index > 31)
-   hash_hi |= (1 << (index - 32));
-   else
-   hash_lo |= (1 << index);
-   }
-   free(mta, M_DEVBUF);
-   }
+   hashes[0] = 0x;
+   hashes[1] = 0x;
+   } else
+   if_foreach_llmaddr(ifp, cgem_hash_maddr, hashes);
 
-   if (hash_hi != 0 || hash_lo != 0)
+   if (hashes[0] != 0 || hashes[1] != 0)
net_cfg |= CGEM_NET_CFG_MULTI_HASH_EN;
}
 
-   WR4(sc, CGEM_HASH_TOP, hash_hi);
-   WR4(sc, CGEM_HASH_BOT, hash_lo);
+   WR4(sc, CGEM_HASH_TOP, hashes[0]);
+   WR4(sc, CGEM_HASH_BOT, hashes[1]);
WR4(sc, CGEM_NET_CFG, net_cfg);
 }
 
___
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"


svn commit: r353843 - head/sys/dev/dwc

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:19 2019
New Revision: 353843
URL: https://svnweb.freebsd.org/changeset/base/353843

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/dwc/if_dwc.c

Modified: head/sys/dev/dwc/if_dwc.c
==
--- head/sys/dev/dwc/if_dwc.c   Mon Oct 21 18:11:15 2019(r353842)
+++ head/sys/dev/dwc/if_dwc.c   Mon Oct 21 18:11:19 2019(r353843)
@@ -581,13 +581,37 @@ bitreverse(uint8_t x)
return (nibbletab[x & 0xf] << 4) | nibbletab[x >> 4];
 }
 
+struct dwc_hash_maddr_ctx {
+   struct dwc_softc *sc;
+   uint32_t hash[8];
+};
+
+static u_int
+dwc_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct dwc_hash_maddr_ctx *ctx = arg;
+   uint32_t crc, hashbit, hashreg;
+   uint8_t val;
+
+   crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* Take lower 8 bits and reverse it */
+   val = bitreverse(~crc & 0xff);
+   if (ctx->sc->mactype == DWC_GMAC_ALT_DESC)
+   val >>= 2; /* Only need lower 6 bits */
+   hashreg = (val >> 5);
+   hashbit = (val & 31);
+   ctx->hash[hashreg] |= (1 << hashbit);
+
+   return (1);
+}
+
 static void
 dwc_setup_rxfilter(struct dwc_softc *sc)
 {
-   struct ifmultiaddr *ifma;
+   struct dwc_hash_maddr_ctx ctx;
struct ifnet *ifp;
-   uint8_t *eaddr, val;
-   uint32_t crc, ffval, hashbit, hashreg, hi, lo, hash[8];
+   uint8_t *eaddr;
+   uint32_t ffval, hi, lo;
int nhash, i;
 
DWC_ASSERT_LOCKED(sc);
@@ -601,27 +625,13 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
if ((ifp->if_flags & IFF_ALLMULTI) != 0) {
ffval = (FRAME_FILTER_PM);
for (i = 0; i < nhash; i++)
-   hash[i] = ~0;
+   ctx.hash[i] = ~0;
} else {
ffval = (FRAME_FILTER_HMC);
for (i = 0; i < nhash; i++)
-   hash[i] = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-
-   /* Take lower 8 bits and reverse it */
-   val = bitreverse(~crc & 0xff);
-   if (sc->mactype == DWC_GMAC_ALT_DESC)
-   val >>= nhash; /* Only need lower 6 bits */
-   hashreg = (val >> 5);
-   hashbit = (val & 31);
-   hash[hashreg] |= (1 << hashbit);
-   }
-   if_maddr_runlock(ifp);
+   ctx.hash[i] = 0;
+   ctx.sc = sc;
+   if_foreach_llmaddr(ifp, dwc_hash_maddr, &ctx);
}
 
/*
@@ -641,11 +651,11 @@ dwc_setup_rxfilter(struct dwc_softc *sc)
WRITE4(sc, MAC_ADDRESS_HIGH(0), hi);
WRITE4(sc, MAC_FRAME_FILTER, ffval);
if (sc->mactype == DWC_GMAC_ALT_DESC) {
-   WRITE4(sc, GMAC_MAC_HTLOW, hash[0]);
-   WRITE4(sc, GMAC_MAC_HTHIGH, hash[1]);
+   WRITE4(sc, GMAC_MAC_HTLOW, ctx.hash[0]);
+   WRITE4(sc, GMAC_MAC_HTHIGH, ctx.hash[1]);
} else {
for (i = 0; i < nhash; i++)
-   WRITE4(sc, HASH_TABLE_REG(i), hash[i]);
+   WRITE4(sc, HASH_TABLE_REG(i), ctx.hash[i]);
}
 }
 
___
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"


svn commit: r353848 - head/sys/dev/jme

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:43 2019
New Revision: 353848
URL: https://svnweb.freebsd.org/changeset/base/353848

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/jme/if_jme.c

Modified: head/sys/dev/jme/if_jme.c
==
--- head/sys/dev/jme/if_jme.c   Mon Oct 21 18:11:38 2019(r353847)
+++ head/sys/dev/jme/if_jme.c   Mon Oct 21 18:11:43 2019(r353848)
@@ -3236,12 +3236,26 @@ jme_set_vlan(struct jme_softc *sc)
CSR_WRITE_4(sc, JME_RXMAC, reg);
 }
 
+static u_int
+jme_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *mchash = arg;
+
+   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+
+   /* Just want the 6 least significant bits. */
+   crc &= 0x3f;
+
+   /* Set the corresponding bit in the hash table. */
+   mchash[crc >> 5] |= 1 << (crc & 0x1f);
+
+   return (1);
+}
+
 static void
 jme_set_filter(struct jme_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t crc;
uint32_t mchash[2];
uint32_t rxcfg;
 
@@ -3276,21 +3290,7 @@ jme_set_filter(struct jme_softc *sc)
 */
rxcfg |= RXMAC_MULTICAST;
bzero(mchash, sizeof(mchash));
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->jme_ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr), ETHER_ADDR_LEN);
-
-   /* Just want the 6 least significant bits. */
-   crc &= 0x3f;
-
-   /* Set the corresponding bit in the hash table. */
-   mchash[crc >> 5] |= 1 << (crc & 0x1f);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, jme_hash_maddr, &mchash);
 
CSR_WRITE_4(sc, JME_MAR0, mchash[0]);
CSR_WRITE_4(sc, JME_MAR1, mchash[1]);
___
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"


svn commit: r353839 - head/sys/dev/cas

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:02 2019
New Revision: 353839
URL: https://svnweb.freebsd.org/changeset/base/353839

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/cas/if_cas.c

Modified: head/sys/dev/cas/if_cas.c
==
--- head/sys/dev/cas/if_cas.c   Mon Oct 21 18:10:58 2019(r353838)
+++ head/sys/dev/cas/if_cas.c   Mon Oct 21 18:11:02 2019(r353839)
@@ -2498,14 +2498,27 @@ cas_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
return (error);
 }
 
+static u_int
+cas_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, *hash = arg;
+
+   crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN);
+   /* We just want the 8 most significant bits. */
+   crc >>= 24;
+   /* Set the corresponding bit in the filter. */
+   hash[crc >> 4] |= 1 << (15 - (crc & 15));
+
+   return (1);
+}
+
 static void
 cas_setladrf(struct cas_softc *sc)
 {
struct ifnet *ifp = sc->sc_ifp;
-   struct ifmultiaddr *inm;
int i;
uint32_t hash[16];
-   uint32_t crc, v;
+   uint32_t v;
 
CAS_LOCK_ASSERT(sc, MA_OWNED);
 
@@ -2542,23 +2555,8 @@ cas_setladrf(struct cas_softc *sc)
 * is the MSB).
 */
 
-   /* Clear the hash table. */
memset(hash, 0, sizeof(hash));
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
-   if (inm->ifma_addr->sa_family != AF_LINK)
-   continue;
-   crc = ether_crc32_le(LLADDR((struct sockaddr_dl *)
-   inm->ifma_addr), ETHER_ADDR_LEN);
-
-   /* We just want the 8 most significant bits. */
-   crc >>= 24;
-
-   /* Set the corresponding bit in the filter. */
-   hash[crc >> 4] |= 1 << (15 - (crc & 15));
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, cas_hash_maddr, &hash);
 
v |= CAS_MAC_RX_CONF_HFILTER;
 
___
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"


svn commit: r353841 - head/sys/dev/cxgbe

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:11 2019
New Revision: 353841
URL: https://svnweb.freebsd.org/changeset/base/353841

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/cxgbe/t4_main.c

Modified: head/sys/dev/cxgbe/t4_main.c
==
--- head/sys/dev/cxgbe/t4_main.cMon Oct 21 18:11:08 2019
(r353840)
+++ head/sys/dev/cxgbe/t4_main.cMon Oct 21 18:11:11 2019
(r353841)
@@ -4782,7 +4782,55 @@ apply_link_config(struct port_info *pi)
 }
 
 #define FW_MAC_EXACT_CHUNK 7
+struct mcaddr_ctx {
+   struct ifnet *ifp;
+   const uint8_t *mcaddr[FW_MAC_EXACT_CHUNK];
+   uint64_t hash;
+   int i;
+   int del;
+   int rc;
+};
 
+static u_int
+add_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct mcaddr_ctx *ctx = arg;
+   struct vi_info *vi = ctx->ifp->if_softc;
+   struct port_info *pi = vi->pi;
+   struct adapter *sc = pi->adapter;
+
+   if (ctx->rc < 0)
+   return (0);
+
+   ctx->mcaddr[ctx->i] = LLADDR(sdl);
+   MPASS(ETHER_IS_MULTICAST(ctx->mcaddr[ctx->i]));
+   ctx->i++;
+
+   if (ctx->i == FW_MAC_EXACT_CHUNK) {
+   ctx->rc = t4_alloc_mac_filt(sc, sc->mbox, vi->viid, ctx->del,
+   ctx->i, ctx->mcaddr, NULL, &ctx->hash, 0);
+   if (ctx->rc < 0) {
+   int j;
+
+   for (j = 0; j < ctx->i; j++) {
+   if_printf(ctx->ifp,
+   "failed to add mc address"
+   " %02x:%02x:%02x:"
+   "%02x:%02x:%02x rc=%d\n",
+   ctx->mcaddr[j][0], ctx->mcaddr[j][1],
+   ctx->mcaddr[j][2], ctx->mcaddr[j][3],
+   ctx->mcaddr[j][4], ctx->mcaddr[j][5],
+   -ctx->rc);
+   }
+   return (0);
+   }
+   ctx->del = 0;
+   ctx->i = 0;
+   }
+
+   return (1);
+}
+
 /*
  * Program the port's XGMAC based on parameters in ifnet.  The caller also
  * indicates which parameters should be programmed (the rest are left alone).
@@ -4838,66 +4886,51 @@ update_mac_settings(struct ifnet *ifp, int flags)
}
 
if (flags & XGMAC_MCADDRS) {
-   const uint8_t *mcaddr[FW_MAC_EXACT_CHUNK];
-   int del = 1;
-   uint64_t hash = 0;
-   struct ifmultiaddr *ifma;
-   int i = 0, j;
+   struct epoch_tracker et;
+   struct mcaddr_ctx ctx;
+   int j;
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   mcaddr[i] =
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-   MPASS(ETHER_IS_MULTICAST(mcaddr[i]));
-   i++;
-
-   if (i == FW_MAC_EXACT_CHUNK) {
-   rc = t4_alloc_mac_filt(sc, sc->mbox, vi->viid,
-   del, i, mcaddr, NULL, &hash, 0);
-   if (rc < 0) {
-   rc = -rc;
-   for (j = 0; j < i; j++) {
-   if_printf(ifp,
-   "failed to add mc address"
-   " %02x:%02x:%02x:"
-   "%02x:%02x:%02x rc=%d\n",
-   mcaddr[j][0], mcaddr[j][1],
-   mcaddr[j][2], mcaddr[j][3],
-   mcaddr[j][4], mcaddr[j][5],
-   rc);
-   }
-   goto mcfail;
-   }
-   del = 0;
-   i = 0;
-   }
+   ctx.ifp = ifp;
+   ctx.hash = 0;
+   ctx.i = 0;
+   ctx.del = 1;
+   /*
+* Unlike other drivers, we accumulate list of pointers into
+* interface address lists and we need to keep it safe even
+* after if_foreach_llmaddr() returns, thus we must enter the
+* network epoch.
+*/
+   NET_EPOCH_ENTER(et);
+   if_foreach_llmaddr(ifp, add_maddr, &ctx);
+   if (ctx.rc < 0) {
+   NET_EPOCH_EXIT(et);
+   rc = -ctx.rc

svn commit: r353849 - head/sys/dev/liquidio

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:48 2019
New Revision: 353849
URL: https://svnweb.freebsd.org/changeset/base/353849

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/liquidio/lio_ioctl.c

Modified: head/sys/dev/liquidio/lio_ioctl.c
==
--- head/sys/dev/liquidio/lio_ioctl.c   Mon Oct 21 18:11:43 2019
(r353848)
+++ head/sys/dev/liquidio/lio_ioctl.c   Mon Oct 21 18:11:48 2019
(r353849)
@@ -491,6 +491,22 @@ lio_get_new_flags(struct ifnet *ifp)
return (f);
 }
 
+static u_int
+lio_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint64_t *mc = arg;
+
+   if (cnt == LIO_MAX_MULTICAST_ADDR)
+   return (0);
+
+   mc += cnt;
+   *mc = 0;
+   memcpy(((uint8_t *)mc) + 2, LLADDR(sdl), ETHER_ADDR_LEN);
+   /* no need to swap bytes */
+
+   return (1);
+}
+
 /* @param ifp network device */
 static int
 lio_set_mcast_list(struct ifnet *ifp)
@@ -498,9 +514,7 @@ lio_set_mcast_list(struct ifnet *ifp)
struct lio  *lio = if_getsoftc(ifp);
struct octeon_device*oct = lio->oct_dev;
struct lio_ctrl_pkt nctrl;
-   struct ifmultiaddr  *ifma;
-   uint64_t*mc;
-   int mc_count = 0;
+   int mc_count;
int ret;
 
bzero(&nctrl, sizeof(struct lio_ctrl_pkt));
@@ -514,26 +528,7 @@ lio_set_mcast_list(struct ifnet *ifp)
nctrl.cb_fn = lio_ctrl_cmd_completion;
 
/* copy all the addresses into the udd */
-   mc = &nctrl.udd[0];
-
-   /* to protect access to if_multiaddrs */
-   if_maddr_rlock(ifp);
-
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   *mc = 0;
-   memcpy(((uint8_t *)mc) + 2,
-  LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-  ETHER_ADDR_LEN);
-   /* no need to swap bytes */
-
-   mc_count++;
-   if (++mc > &nctrl.udd[LIO_MAX_MULTICAST_ADDR])
-   break;
-   }
-
-   if_maddr_runlock(ifp);
+   mc_count = if_foreach_llmaddr(ifp, lio_copy_maddr, &nctrl.udd[0]);
 
/*
 * Apparently, any activity in this call from the kernel has to
___
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"


svn commit: r353847 - head/sys/dev/if_ndis

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:38 2019
New Revision: 353847
URL: https://svnweb.freebsd.org/changeset/base/353847

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/if_ndis/if_ndis.c

Modified: head/sys/dev/if_ndis/if_ndis.c
==
--- head/sys/dev/if_ndis/if_ndis.c  Mon Oct 21 18:11:32 2019
(r353846)
+++ head/sys/dev/if_ndis/if_ndis.c  Mon Oct 21 18:11:38 2019
(r353847)
@@ -282,6 +282,22 @@ ndisdrv_modevent(mod, cmd, arg)
return (error);
 }
 
+struct mclist_ctx {
+   uint8_t *mclist;
+   int mclistsz;
+};
+
+static u_int
+ndis_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct mclist_ctx *ctx = arg;
+
+   if (cnt < ctx->mclistsz)
+   bcopy(LLADDR(sdl), ctx->mclist + (ETHER_ADDR_LEN * cnt),
+   ETHER_ADDR_LEN);
+   return (1);
+}
+
 /*
  * Program the 64-bit multicast hash filter.
  */
@@ -290,9 +306,8 @@ ndis_setmulti(sc)
struct ndis_softc   *sc;
 {
struct ifnet*ifp;
-   struct ifmultiaddr  *ifma;
-   int len, mclistsz, error;
-   uint8_t *mclist;
+   struct mclist_ctx   ctx;
+   int len, error;
 
 
if (!NDIS_INITIALIZED(sc))
@@ -313,40 +328,31 @@ ndis_setmulti(sc)
return;
}
 
-   if (CK_STAILQ_EMPTY(&ifp->if_multiaddrs))
+   if (if_llmaddr_count(ifp) == 0)
return;
 
-   len = sizeof(mclistsz);
-   ndis_get_info(sc, OID_802_3_MAXIMUM_LIST_SIZE, &mclistsz, &len);
+   len = sizeof(ctx.mclistsz);
+   ndis_get_info(sc, OID_802_3_MAXIMUM_LIST_SIZE, &ctx.mclistsz, &len);
 
-   mclist = malloc(ETHER_ADDR_LEN * mclistsz, M_TEMP, M_NOWAIT|M_ZERO);
+   ctx.mclist = malloc(ETHER_ADDR_LEN * ctx.mclistsz, M_TEMP,
+   M_NOWAIT | M_ZERO);
 
-   if (mclist == NULL) {
+   if (ctx.mclist == NULL) {
sc->ndis_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
goto out;
}
 
sc->ndis_filter |= NDIS_PACKET_TYPE_MULTICAST;
 
-   len = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-   mclist + (ETHER_ADDR_LEN * len), ETHER_ADDR_LEN);
-   len++;
-   if (len > mclistsz) {
-   if_maddr_runlock(ifp);
-   sc->ndis_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
-   sc->ndis_filter &= ~NDIS_PACKET_TYPE_MULTICAST;
+   len = if_foreach_llmaddr(ifp, ndis_copy_maddr, &ctx);
+   if (len > ctx.mclistsz) {
+   sc->ndis_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
+   sc->ndis_filter &= ~NDIS_PACKET_TYPE_MULTICAST;
goto out;
-   }
}
-   if_maddr_runlock(ifp);
 
len = len * ETHER_ADDR_LEN;
-   error = ndis_set_info(sc, OID_802_3_MULTICAST_LIST, mclist, &len);
+   error = ndis_set_info(sc, OID_802_3_MULTICAST_LIST, ctx.mclist, &len);
if (error) {
device_printf(sc->ndis_dev, "set mclist failed: %d\n", error);
sc->ndis_filter |= NDIS_PACKET_TYPE_ALL_MULTICAST;
@@ -354,7 +360,7 @@ ndis_setmulti(sc)
}
 
 out:
-   free(mclist, M_TEMP);
+   free(ctx.mclist, M_TEMP);
 
len = sizeof(sc->ndis_filter);
error = ndis_set_info(sc, OID_GEN_CURRENT_PACKET_FILTER,
___
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"


svn commit: r353840 - in head/sys/dev/cxgb: . common

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:08 2019
New Revision: 353840
URL: https://svnweb.freebsd.org/changeset/base/353840

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/cxgb/common/cxgb_xgmac.c
  head/sys/dev/cxgb/cxgb_adapter.h

Modified: head/sys/dev/cxgb/common/cxgb_xgmac.c
==
--- head/sys/dev/cxgb/common/cxgb_xgmac.c   Mon Oct 21 18:11:02 2019
(r353839)
+++ head/sys/dev/cxgb/common/cxgb_xgmac.c   Mon Oct 21 18:11:08 2019
(r353840)
@@ -408,9 +408,32 @@ static int hash_hw_addr(const u8 *addr)
  * Configures the MAC Rx mode (promiscuity, etc) and exact and hash
  * address filters.
  */
+struct t3_mcaddr_ctx {
+   struct cmac *mac;
+   u32 hash_lo, hash_hi;
+};
+
+static u_int
+t3_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct t3_mcaddr_ctx *ctx = arg;
+   int hash;
+
+   if (ctx->mac->nucast + cnt < EXACT_ADDR_FILTERS)
+   set_addr_filter(ctx->mac, ctx->mac->nucast + cnt, LLADDR(sdl));
+   else {
+   hash = hash_hw_addr(LLADDR(sdl));
+   if (hash < 32)
+   ctx->hash_lo |= (1 << hash);
+   else
+   ctx->hash_hi |= (1 << (hash - 32));
+   }
+   return (1);
+}
+
 int t3_mac_set_rx_mode(struct cmac *mac, struct t3_rx_mode *rm)
 {
-   u32 hash_lo, hash_hi;
+   struct t3_mcaddr_ctx ctx;
adapter_t *adap = mac->adapter;
unsigned int oft = mac->offset;
 
@@ -422,27 +445,15 @@ int t3_mac_set_rx_mode(struct cmac *mac, struct t3_rx_
 mac->promisc_map ? F_COPYALLFRAMES : 0);
 
if (allmulti_rx_mode(rm) || mac->multiport)
-   hash_lo = hash_hi = 0x;
+   ctx.hash_lo = ctx.hash_hi = 0x;
else {
-   u8 *addr;
-   int exact_addr_idx = mac->nucast;
-
-   hash_lo = hash_hi = 0;
-   while ((addr = t3_get_next_mcaddr(rm)))
-   if (exact_addr_idx < EXACT_ADDR_FILTERS)
-   set_addr_filter(mac, exact_addr_idx++, addr);
-   else {
-   int hash = hash_hw_addr(addr);
-
-   if (hash < 32)
-   hash_lo |= (1 << hash);
-   else
-   hash_hi |= (1 << (hash - 32));
-   }
+   ctx.mac = mac;
+   ctx.hash_lo = ctx.hash_hi = 0;
+   if_foreach_llmaddr(rm->port->ifp, t3_hash_maddr, &ctx);
}
 
-   t3_write_reg(adap, A_XGM_RX_HASH_LOW + oft, hash_lo);
-   t3_write_reg(adap, A_XGM_RX_HASH_HIGH + oft, hash_hi);
+   t3_write_reg(adap, A_XGM_RX_HASH_LOW + oft, ctx.hash_lo);
+   t3_write_reg(adap, A_XGM_RX_HASH_HIGH + oft, ctx.hash_hi);
return 0;
 }
 

Modified: head/sys/dev/cxgb/cxgb_adapter.h
==
--- head/sys/dev/cxgb/cxgb_adapter.hMon Oct 21 18:11:02 2019
(r353839)
+++ head/sys/dev/cxgb/cxgb_adapter.hMon Oct 21 18:11:08 2019
(r353840)
@@ -463,30 +463,6 @@ t3_os_pci_write_config_2(adapter_t *adapter, int reg, 
pci_write_config(adapter->dev, reg, val, 2);
 }
 
-static __inline uint8_t *
-t3_get_next_mcaddr(struct t3_rx_mode *rm)
-{
-   uint8_t *macaddr = NULL;
-   struct ifnet *ifp = rm->port->ifp;
-   struct ifmultiaddr *ifma;
-   int i = 0;
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   if (i == rm->idx) {
-   macaddr = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-   break;
-   }
-   i++;
-   }
-   if_maddr_runlock(ifp);
-   
-   rm->idx++;
-   return (macaddr);
-}
-
 static __inline void
 t3_init_rx_mode(struct t3_rx_mode *rm, struct port_info *port)
 {
___
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"


svn commit: r353844 - head/sys/dev/e1000

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:24 2019
New Revision: 353844
URL: https://svnweb.freebsd.org/changeset/base/353844

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/e1000/if_em.c

Modified: head/sys/dev/e1000/if_em.c
==
--- head/sys/dev/e1000/if_em.c  Mon Oct 21 18:11:19 2019(r353843)
+++ head/sys/dev/e1000/if_em.c  Mon Oct 21 18:11:24 2019(r353844)
@@ -1655,7 +1655,7 @@ em_disable_promisc(if_ctx_t ctx)
if (if_getflags(ifp) & IFF_ALLMULTI)
mcnt = MAX_NUM_MULTICAST_ADDRESSES;
else
-   mcnt = if_multiaddr_count(ifp, MAX_NUM_MULTICAST_ADDRESSES);
+   mcnt = if_llmaddr_count(ifp);
/* Don't disable if in MAX groups */
if (mcnt < MAX_NUM_MULTICAST_ADDRESSES)
reg_rctl &=  (~E1000_RCTL_MPE);
@@ -1664,6 +1664,19 @@ em_disable_promisc(if_ctx_t ctx)
 }
 
 
+static u_int
+em_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   u8 *mta = arg;
+
+   if (cnt == MAX_NUM_MULTICAST_ADDRESSES)
+   return (1);
+
+   bcopy(LLADDR(sdl), &mta[cnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
+
+   return (1);
+}
+
 /*
  *  Multicast Update
  *
@@ -1695,7 +1708,7 @@ em_if_multi_set(if_ctx_t ctx)
msec_delay(5);
}
 
-   if_multiaddr_array(ifp, mta, &mcnt, MAX_NUM_MULTICAST_ADDRESSES);
+   mcnt = if_foreach_llmaddr(ifp, em_copy_maddr, mta);
 
if (mcnt >= MAX_NUM_MULTICAST_ADDRESSES) {
reg_rctl = E1000_READ_REG(&adapter->hw, E1000_RCTL);
___
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"


svn commit: r353845 - head/sys/dev/et

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:28 2019
New Revision: 353845
URL: https://svnweb.freebsd.org/changeset/base/353845

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/et/if_et.c

Modified: head/sys/dev/et/if_et.c
==
--- head/sys/dev/et/if_et.c Mon Oct 21 18:11:24 2019(r353844)
+++ head/sys/dev/et/if_et.c Mon Oct 21 18:11:28 2019(r353845)
@@ -1560,13 +1560,36 @@ et_free_rx_ring(struct et_softc *sc)
}
 }
 
+static u_int
+et_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t h, *hp, *hash = arg;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
+   h = (h & 0x3f80) >> 23;
+
+   hp = &hash[0];
+   if (h >= 32 && h < 64) {
+   h -= 32;
+   hp = &hash[1];
+   } else if (h >= 64 && h < 96) {
+   h -= 64;
+   hp = &hash[2];
+   } else if (h >= 96) {
+   h -= 96;
+   hp = &hash[3];
+   }
+   *hp |= (1 << h);
+
+   return (1);
+}
+
 static void
 et_setmulti(struct et_softc *sc)
 {
struct ifnet *ifp;
uint32_t hash[4] = { 0, 0, 0, 0 };
uint32_t rxmac_ctrl, pktfilt;
-   struct ifmultiaddr *ifma;
int i, count;
 
ET_LOCK_ASSERT(sc);
@@ -1581,34 +1604,7 @@ et_setmulti(struct et_softc *sc)
goto back;
}
 
-   count = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   uint32_t *hp, h;
-
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   h = ether_crc32_be(LLADDR((struct sockaddr_dl *)
-  ifma->ifma_addr), ETHER_ADDR_LEN);
-   h = (h & 0x3f80) >> 23;
-
-   hp = &hash[0];
-   if (h >= 32 && h < 64) {
-   h -= 32;
-   hp = &hash[1];
-   } else if (h >= 64 && h < 96) {
-   h -= 64;
-   hp = &hash[2];
-   } else if (h >= 96) {
-   h -= 96;
-   hp = &hash[3];
-   }
-   *hp |= (1 << h);
-
-   ++count;
-   }
-   if_maddr_runlock(ifp);
+   count = if_foreach_llmaddr(ifp, et_hash_maddr, &hash);
 
for (i = 0; i < 4; ++i)
CSR_WRITE_4(sc, ET_MULTI_HASH + (i * 4), hash[i]);
___
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"


svn commit: r353852 - head/sys/dev/oce

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:02 2019
New Revision: 353852
URL: https://svnweb.freebsd.org/changeset/base/353852

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/oce/oce_hw.c

Modified: head/sys/dev/oce/oce_hw.c
==
--- head/sys/dev/oce/oce_hw.c   Mon Oct 21 18:11:58 2019(r353851)
+++ head/sys/dev/oce/oce_hw.c   Mon Oct 21 18:12:02 2019(r353852)
@@ -544,7 +544,21 @@ oce_hw_intr_disable(POCE_SOFTC sc)
 }
 
 
+static u_int
+oce_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct mbx_set_common_iface_multicast *req = arg;
 
+   if (req->params.req.num_mac == OCE_MAX_MC_FILTER_SIZE)
+   return (0);
+
+   bcopy(LLADDR(sdl), &req->params.req.mac[req->params.req.num_mac++],
+   ETH_ADDR_LEN);
+
+   return (1);
+}
+
+
 /**
  * @brief  Function for hardware update multicast filter
  * @param sc   software handle to the device
@@ -553,7 +567,6 @@ int
 oce_hw_update_multicast(POCE_SOFTC sc)
 {
struct ifnet*ifp = sc->ifp;
-   struct ifmultiaddr *ifma;
struct mbx_set_common_iface_multicast *req = NULL;
OCE_DMA_MEM dma;
int rc = 0;
@@ -566,29 +579,15 @@ oce_hw_update_multicast(POCE_SOFTC sc)
req = OCE_DMAPTR(&dma, struct mbx_set_common_iface_multicast);
bzero(req, sizeof(struct mbx_set_common_iface_multicast));
 
-#if __FreeBSD_version > 80
-   if_maddr_rlock(ifp);
-#endif
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (req->params.req.num_mac == OCE_MAX_MC_FILTER_SIZE) {
-   /*More multicast addresses than our hardware table
- So Enable multicast promiscus in our hardware to
- accept all multicat packets
-   */
-   req->params.req.promiscuous = 1;
-   break;
-   }
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-   &req->params.req.mac[req->params.req.num_mac],
-   ETH_ADDR_LEN);
-   req->params.req.num_mac = req->params.req.num_mac + 1;
+   if_foreach_llmaddr(ifp, oce_copy_maddr, req);
+   if (req->params.req.num_mac == OCE_MAX_MC_FILTER_SIZE) {
+   /*More multicast addresses than our hardware table
+ So Enable multicast promiscus in our hardware to
+ accept all multicat packets
+   */
+   req->params.req.promiscuous = 1;
}
-#if __FreeBSD_version > 80
-   if_maddr_runlock(ifp);
-#endif
+
req->params.req.if_id = sc->if_id;
rc = oce_update_multicast(sc, &dma);
oce_dma_free(sc, &dma);
___
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"


svn commit: r353854 - head/sys/dev/qlnx/qlnxe

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:12 2019
New Revision: 353854
URL: https://svnweb.freebsd.org/changeset/base/353854

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/qlnx/qlnxe/qlnx_os.c

Modified: head/sys/dev/qlnx/qlnxe/qlnx_os.c
==
--- head/sys/dev/qlnx/qlnxe/qlnx_os.c   Mon Oct 21 18:12:07 2019
(r353853)
+++ head/sys/dev/qlnx/qlnxe/qlnx_os.c   Mon Oct 21 18:12:12 2019
(r353854)
@@ -2644,42 +2644,36 @@ qlnx_hw_set_multi(qlnx_host_t *ha, uint8_t *mta, uint3
 }
 
 
-#define QLNX_MCAST_ADDRS_SIZE (QLNX_MAX_NUM_MULTICAST_ADDRS * ETHER_HDR_LEN)
-static int
-qlnx_set_multi(qlnx_host_t *ha, uint32_t add_multi)
+static u_int
+qlnx_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt)
 {
-   uint8_t mta[QLNX_MCAST_ADDRS_SIZE];
-   struct ifmultiaddr  *ifma;
-   int mcnt = 0;
-   struct ifnet*ifp = ha->ifp;
-   int ret = 0;
+   uint8_t *mta = arg;
 
-   if (qlnx_vf_device(ha) == 0)
+   if (mcnt == QLNX_MAX_NUM_MULTICAST_ADDRS)
return (0);
 
-   if_maddr_rlock(ifp);
+   bcopy(LLADDR(sdl), &mta[mcnt * ETHER_HDR_LEN], ETHER_HDR_LEN);
 
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
+   return (1);
+}
 
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
+static int
+qlnx_set_multi(qlnx_host_t *ha, uint32_t add_multi)
+{
+   uint8_t mta[QLNX_MAX_NUM_MULTICAST_ADDRS * ETHER_HDR_LEN];
+   struct ifnet*ifp = ha->ifp;
+   u_int   mcnt;
 
-   if (mcnt == QLNX_MAX_NUM_MULTICAST_ADDRS)
-   break;
+   if (qlnx_vf_device(ha) == 0)
+   return (0);
 
-   bcopy(LLADDR((struct sockaddr_dl *) ifma->ifma_addr),
-   &mta[mcnt * ETHER_HDR_LEN], ETHER_HDR_LEN);
+   mcnt = if_foreach_llmaddr(ifp, qlnx_copy_maddr, mta);
 
-   mcnt++;
-   }
-
-   if_maddr_runlock(ifp);
-
QLNX_LOCK(ha);
qlnx_hw_set_multi(ha, mta, mcnt, add_multi);
QLNX_UNLOCK(ha);
 
-   return (ret);
+   return (0);
 }
 
 static int
___
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"


svn commit: r353850 - head/sys/dev/malo

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:54 2019
New Revision: 353850
URL: https://svnweb.freebsd.org/changeset/base/353850

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/malo/if_malo.c

Modified: head/sys/dev/malo/if_malo.c
==
--- head/sys/dev/malo/if_malo.c Mon Oct 21 18:11:48 2019(r353849)
+++ head/sys/dev/malo/if_malo.c Mon Oct 21 18:11:54 2019(r353850)
@@ -1510,49 +1510,46 @@ malo_init(void *arg)
ieee80211_start_all(ic);/* start all vap's */
 }
 
+struct malo_copy_maddr_ctx {
+   uint8_t macs[IEEE80211_ADDR_LEN * MALO_HAL_MCAST_MAX];
+   int nmc;
+};
+
+static u_int
+malo_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int nmc)
+{
+   struct malo_copy_maddr_ctx *ctx = arg;
+
+   if (ctx->nmc == MALO_HAL_MCAST_MAX)
+   return (0);
+
+   IEEE80211_ADDR_COPY(ctx->macs + (ctx->nmc * IEEE80211_ADDR_LEN),
+   LLADDR(sdl));
+   ctx->nmc++;
+
+   return (1);
+}
+
 /*
  * Set the multicast filter contents into the hardware.
  */
 static void
 malo_setmcastfilter(struct malo_softc *sc)
 {
+   struct malo_copy_maddr_ctx ctx;
struct ieee80211com *ic = &sc->malo_ic;
struct ieee80211vap *vap;
-   uint8_t macs[IEEE80211_ADDR_LEN * MALO_HAL_MCAST_MAX];
-   uint8_t *mp;
-   int nmc;
 
-   mp = macs;
-   nmc = 0;
 
if (ic->ic_opmode == IEEE80211_M_MONITOR || ic->ic_allmulti > 0 ||
ic->ic_promisc > 0)
goto all;
 
-   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
-   struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
+   ctx.nmc = 0;
+   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
+   if_foreach_llmaddr(vap->iv_ifp, malo_copy_maddr, &ctx);
 
-   ifp = vap->iv_ifp;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (nmc == MALO_HAL_MCAST_MAX) {
-   ifp->if_flags |= IFF_ALLMULTI;
-   if_maddr_runlock(ifp);
-   goto all;
-   }
-   IEEE80211_ADDR_COPY(mp,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-
-   mp += IEEE80211_ADDR_LEN, nmc++;
-   }
-   if_maddr_runlock(ifp);
-   }
-
-   malo_hal_setmcast(sc->malo_mh, nmc, macs);
+   malo_hal_setmcast(sc->malo_mh, ctx.nmc, ctx.macs);
 
 all:
/*
___
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"


svn commit: r353855 - head/sys/dev/qlxgb

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:17 2019
New Revision: 353855
URL: https://svnweb.freebsd.org/changeset/base/353855

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/qlxgb/qla_os.c

Modified: head/sys/dev/qlxgb/qla_os.c
==
--- head/sys/dev/qlxgb/qla_os.c Mon Oct 21 18:12:12 2019(r353854)
+++ head/sys/dev/qlxgb/qla_os.c Mon Oct 21 18:12:17 2019(r353855)
@@ -763,32 +763,26 @@ qla_init(void *arg)
QL_DPRINT2((ha->pci_dev, "%s: exit\n", __func__));
 }
 
+static u_int
+qla_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt)
+{
+   uint8_t *mta = arg;
+
+   if (mcnt == Q8_MAX_NUM_MULTICAST_ADDRS)
+   return (0);
+   bcopy(LLADDR(sdl), &mta[mcnt * Q8_MAC_ADDR_LEN], Q8_MAC_ADDR_LEN);
+
+   return (1);
+}
+
 static void
 qla_set_multi(qla_host_t *ha, uint32_t add_multi)
 {
uint8_t mta[Q8_MAX_NUM_MULTICAST_ADDRS * Q8_MAC_ADDR_LEN];
-   struct ifmultiaddr *ifma;
-   int mcnt = 0;
struct ifnet *ifp = ha->ifp;
+   int mcnt;
 
-   if_maddr_rlock(ifp);
-
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (mcnt == Q8_MAX_NUM_MULTICAST_ADDRS)
-   break;
-
-   bcopy(LLADDR((struct sockaddr_dl *) ifma->ifma_addr),
-   &mta[mcnt * Q8_MAC_ADDR_LEN], Q8_MAC_ADDR_LEN);
-
-   mcnt++;
-   }
-
-   if_maddr_runlock(ifp);
-
+   mcnt = if_foreach_llmaddr(ifp, qla_copy_maddr, mta);
qla_hw_set_multi(ha, mta, mcnt, add_multi);
 
return;
___
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"


svn commit: r353862 - head/sys/arm/allwinner

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:13:14 2019
New Revision: 353862
URL: https://svnweb.freebsd.org/changeset/base/353862

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/arm/allwinner/if_awg.c

Modified: head/sys/arm/allwinner/if_awg.c
==
--- head/sys/arm/allwinner/if_awg.c Mon Oct 21 18:12:58 2019
(r353861)
+++ head/sys/arm/allwinner/if_awg.c Mon Oct 21 18:13:14 2019
(r353862)
@@ -675,12 +675,25 @@ bitrev32(uint32_t x)
return (x >> 16) | (x << 16);
 }
 
+static u_int
+awg_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t crc, hashreg, hashbit, *hash = arg;
+
+   crc = ether_crc32_le(LLADDR(sdl), ETHER_ADDR_LEN) & 0x7f;
+   crc = bitrev32(~crc) >> 26;
+   hashreg = (crc >> 5);
+   hashbit = (crc & 0x1f);
+   hash[hashreg] |= (1 << hashbit);
+
+   return (1);
+}
+
 static void
 awg_setup_rxfilter(struct awg_softc *sc)
 {
-   uint32_t val, crc, hashreg, hashbit, hash[2], machi, maclo;
-   int mc_count, mcnt, i;
-   uint8_t *eaddr, *mta;
+   uint32_t val, hash[2], machi, maclo;
+   uint8_t *eaddr;
if_t ifp;
 
AWG_ASSERT_LOCKED(sc);
@@ -689,36 +702,13 @@ awg_setup_rxfilter(struct awg_softc *sc)
val = 0;
hash[0] = hash[1] = 0;
 
-   mc_count = if_multiaddr_count(ifp, -1);
-
if (if_getflags(ifp) & IFF_PROMISC)
val |= DIS_ADDR_FILTER;
else if (if_getflags(ifp) & IFF_ALLMULTI) {
val |= RX_ALL_MULTICAST;
hash[0] = hash[1] = ~0;
-   } else if (mc_count > 0) {
+   } else if (if_foreach_llmaddr(ifp, awg_hash_maddr, hash) > 0)
val |= HASH_MULTICAST;
-
-   mta = malloc(sizeof(unsigned char) * ETHER_ADDR_LEN * mc_count,
-   M_DEVBUF, M_NOWAIT);
-   if (mta == NULL) {
-   if_printf(ifp,
-   "failed to allocate temporary multicast list\n");
-   return;
-   }
-
-   if_multiaddr_array(ifp, mta, &mcnt, mc_count);
-   for (i = 0; i < mcnt; i++) {
-   crc = ether_crc32_le(mta + (i * ETHER_ADDR_LEN),
-   ETHER_ADDR_LEN) & 0x7f;
-   crc = bitrev32(~crc) >> 26;
-   hashreg = (crc >> 5);
-   hashbit = (crc & 0x1f);
-   hash[hashreg] |= (1 << hashbit);
-   }
-
-   free(mta, M_DEVBUF);
-   }
 
/* Write our unicast address */
eaddr = IF_LLADDR(ifp);
___
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"


svn commit: r353857 - head/sys/dev/qlxge

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:26 2019
New Revision: 353857
URL: https://svnweb.freebsd.org/changeset/base/353857

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/qlxge/qls_os.c

Modified: head/sys/dev/qlxge/qls_os.c
==
--- head/sys/dev/qlxge/qls_os.c Mon Oct 21 18:12:21 2019(r353856)
+++ head/sys/dev/qlxge/qls_os.c Mon Oct 21 18:12:26 2019(r353857)
@@ -835,31 +835,27 @@ qls_init(void *arg)
QL_DPRINT2((ha->pci_dev, "%s: exit\n", __func__));
 }
 
+static u_int
+qls_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt)
+{
+   uint8_t *mta = arg;
+
+   if (mcnt == Q8_MAX_NUM_MULTICAST_ADDRS)
+   return (0);
+
+   bcopy(LLADDR(sdl), &mta[mcnt * Q8_MAC_ADDR_LEN], Q8_MAC_ADDR_LEN);
+
+   return (1);
+}
+
 static void
 qls_set_multi(qla_host_t *ha, uint32_t add_multi)
 {
uint8_t mta[Q8_MAX_NUM_MULTICAST_ADDRS * Q8_MAC_ADDR_LEN];
-   struct ifmultiaddr *ifma;
-   int mcnt = 0;
struct ifnet *ifp = ha->ifp;
+   int mcnt;
 
-   if_maddr_rlock(ifp);
-
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (mcnt == Q8_MAX_NUM_MULTICAST_ADDRS)
-   break;
-
-   bcopy(LLADDR((struct sockaddr_dl *) ifma->ifma_addr),
-   &mta[mcnt * Q8_MAC_ADDR_LEN], Q8_MAC_ADDR_LEN);
-
-   mcnt++;
-   }
-
-   if_maddr_runlock(ifp);
+   mcnt = if_foreach_llmaddr(ifp, qls_copy_maddr, mta);
 
if (QLA_LOCK(ha, __func__, 1) == 0) {
qls_hw_set_multi(ha, mta, mcnt, add_multi);
___
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"


svn commit: r353858 - head/sys/dev/rtwn

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:31 2019
New Revision: 353858
URL: https://svnweb.freebsd.org/changeset/base/353858

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/rtwn/if_rtwn_rx.c

Modified: head/sys/dev/rtwn/if_rtwn_rx.c
==
--- head/sys/dev/rtwn/if_rtwn_rx.c  Mon Oct 21 18:12:26 2019
(r353857)
+++ head/sys/dev/rtwn/if_rtwn_rx.c  Mon Oct 21 18:12:31 2019
(r353858)
@@ -366,6 +366,18 @@ rtwn_get_multi_pos(const uint8_t maddr[])
return (pos);
 }
 
+static u_int
+rtwm_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *mfilt = arg;
+   uint8_t pos;
+
+   pos = rtwn_get_multi_pos(LLADDR(sdl));
+   mfilt[pos / 32] |= (1 << (pos % 32));
+
+   return (1);
+}
+
 void
 rtwn_set_multi(struct rtwn_softc *sc)
 {
@@ -377,28 +389,13 @@ rtwn_set_multi(struct rtwn_softc *sc)
/* general structure was copied from ath(4). */
if (ic->ic_allmulti == 0) {
struct ieee80211vap *vap;
-   struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
 
/*
 * Merge multicast addresses to form the hardware filter.
 */
mfilt[0] = mfilt[1] = 0;
-   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
-   ifp = vap->iv_ifp;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) 
{
-   caddr_t dl;
-   uint8_t pos;
-
-   dl = LLADDR((struct sockaddr_dl *)
-   ifma->ifma_addr);
-   pos = rtwn_get_multi_pos(dl);
-
-   mfilt[pos / 32] |= (1 << (pos % 32));
-   }
-   if_maddr_runlock(ifp);
-   }
+   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
+   if_foreach_llmaddr(vap->iv_ifp, rtwm_hash_maddr, mfilt);
} else
mfilt[0] = mfilt[1] = ~0;
 
___
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"


svn commit: r353860 - head/sys/dev/wi

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:40 2019
New Revision: 353860
URL: https://svnweb.freebsd.org/changeset/base/353860

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/wi/if_wi.c

Modified: head/sys/dev/wi/if_wi.c
==
--- head/sys/dev/wi/if_wi.c Mon Oct 21 18:12:36 2019(r353859)
+++ head/sys/dev/wi/if_wi.c Mon Oct 21 18:12:40 2019(r353860)
@@ -1506,41 +1506,45 @@ finish:
CSR_WRITE_2(sc, WI_EVENT_ACK, WI_EV_INFO);
 }
 
+struct wi_mcast_ctx {
+   struct wi_mcast mlist;
+   int mcnt;
+};
+
+static u_int
+wi_copy_mcast(void *arg, struct sockaddr_dl *sdl, u_int count)
+{
+   struct wi_mcast_ctx *ctx = arg;
+
+   if (ctx->mcnt >= 16)
+   return (0);
+   IEEE80211_ADDR_COPY(&ctx->mlist.wi_mcast[ctx->mcnt++], LLADDR(sdl));
+
+   return (1);
+}
+
 static int
 wi_write_multi(struct wi_softc *sc)
 {
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap;
-   struct wi_mcast mlist;
-   int n;
+   struct wi_mcast_ctx ctx;
 
if (ic->ic_allmulti > 0 || ic->ic_promisc > 0) {
 allmulti:
-   memset(&mlist, 0, sizeof(mlist));
-   return wi_write_rid(sc, WI_RID_MCAST_LIST, &mlist,
-   sizeof(mlist));
+   memset(&ctx.mlist, 0, sizeof(ctx.mlist));
+   return wi_write_rid(sc, WI_RID_MCAST_LIST, &ctx.mlist,
+   sizeof(ctx.mlist));
}
 
-   n = 0;
+   ctx.mcnt = 0;
TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
-   struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-
-   ifp = vap->iv_ifp;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   if (n >= 16)
-   goto allmulti;
-   IEEE80211_ADDR_COPY(&mlist.wi_mcast[n],
-   (LLADDR((struct sockaddr_dl *)ifma->ifma_addr)));
-   n++;
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(vap->iv_ifp, wi_copy_mcast, &ctx);
+   if (ctx.mcnt >= 16)
+   goto allmulti;
}
-   return wi_write_rid(sc, WI_RID_MCAST_LIST, &mlist,
-   IEEE80211_ADDR_LEN * n);
+   return wi_write_rid(sc, WI_RID_MCAST_LIST, &ctx.mlist,
+   IEEE80211_ADDR_LEN * ctx.mcnt);
 }
 
 static void
___
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"


svn commit: r353853 - head/sys/dev/otus

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:07 2019
New Revision: 353853
URL: https://svnweb.freebsd.org/changeset/base/353853

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/otus/if_otus.c

Modified: head/sys/dev/otus/if_otus.c
==
--- head/sys/dev/otus/if_otus.c Mon Oct 21 18:12:02 2019(r353852)
+++ head/sys/dev/otus/if_otus.c Mon Oct 21 18:12:07 2019(r353853)
@@ -2308,63 +2308,63 @@ otus_tx(struct otus_softc *sc, struct ieee80211_node *
return 0;
 }
 
+static u_int
+otus_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t val, *hashes = arg;
+
+   val = le32dec(LLADDR(sdl) + 4);
+   /* Get address byte 5 */
+   val = val & 0xff00;
+   val = val >> 8;
+
+   /* As per below, shift it >> 2 to get only 6 bits */
+   val = val >> 2;
+   if (val < 32)
+   hashes[0] |= 1 << val;
+   else
+   hashes[1] |= 1 << (val - 32);
+
+   return (1);
+}
+
+
 int
 otus_set_multi(struct otus_softc *sc)
 {
-   uint32_t lo, hi;
struct ieee80211com *ic = &sc->sc_ic;
+   uint32_t hashes[2];
int r;
 
if (ic->ic_allmulti > 0 || ic->ic_promisc > 0 ||
ic->ic_opmode == IEEE80211_M_MONITOR) {
-   lo = 0x;
-   hi = 0x;
+   hashes[0] = 0x;
+   hashes[1] = 0x;
} else {
struct ieee80211vap *vap;
-   struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
 
-   lo = hi = 0;
-   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next) {
-   ifp = vap->iv_ifp;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) 
{
-   caddr_t dl;
-   uint32_t val;
-
-   dl = LLADDR((struct sockaddr_dl *) 
ifma->ifma_addr);
-   val = le32dec(dl + 4);
-   /* Get address byte 5 */
-   val = val & 0xff00;
-   val = val >> 8;
-
-   /* As per below, shift it >> 2 to get only 6 
bits */
-   val = val >> 2;
-   if (val < 32)
-   lo |= 1 << val;
-   else
-   hi |= 1 << (val - 32);
-   }
-   if_maddr_runlock(ifp);
-   }
+   hashes[0] = hashes[1] = 0;
+   TAILQ_FOREACH(vap, &ic->ic_vaps, iv_next)
+   if_foreach_llmaddr(vap->iv_ifp, otus_hash_maddr,
+   hashes);
}
 #if 0
/* XXX openbsd code */
while (enm != NULL) {
bit = enm->enm_addrlo[5] >> 2;
if (bit < 32)
-   lo |= 1 << bit;
+   hashes[0] |= 1 << bit;
else
-   hi |= 1 << (bit - 32);
+   hashes[1] |= 1 << (bit - 32);
ETHER_NEXT_MULTI(step, enm);
}
 #endif
 
-   hi |= 1U << 31; /* Make sure the broadcast bit is set. */
+   hashes[1] |= 1U << 31;  /* Make sure the broadcast bit is set. */
 
OTUS_LOCK(sc);
-   otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_L, lo);
-   otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_H, hi);
+   otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_L, hashes[0]);
+   otus_write(sc, AR_MAC_REG_GROUP_HASH_TBL_H, hashes[1]);
r = otus_write_barrier(sc);
/* XXX operating mode? filter? */
OTUS_UNLOCK(sc);
___
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"


svn commit: r353851 - head/sys/dev/my

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:11:58 2019
New Revision: 353851
URL: https://svnweb.freebsd.org/changeset/base/353851

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/my/if_my.c

Modified: head/sys/dev/my/if_my.c
==
--- head/sys/dev/my/if_my.c Mon Oct 21 18:11:54 2019(r353850)
+++ head/sys/dev/my/if_my.c Mon Oct 21 18:11:58 2019(r353851)
@@ -304,7 +304,20 @@ my_phy_writereg(struct my_softc * sc, int reg, int dat
return;
 }
 
+static u_int
+my_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t *hashes = arg;
+   int h;
 
+   h = ~ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   if (h < 32)
+   hashes[0] |= (1 << h);
+   else
+   hashes[1] |= (1 << (h - 32));
+
+   return (1);
+}
 /*
  * Program the 64-bit multicast hash filter.
  */
@@ -312,11 +325,8 @@ static void
 my_setmulti(struct my_softc * sc)
 {
struct ifnet   *ifp;
-   int h = 0;
u_int32_t   hashes[2] = {0, 0};
-   struct ifmultiaddr *ifma;
u_int32_t   rxfilt;
-   int mcnt = 0;
 
MY_LOCK_ASSERT(sc);
 
@@ -337,28 +347,13 @@ my_setmulti(struct my_softc * sc)
CSR_WRITE_4(sc, MY_MAR1, 0);
 
/* now program new ones */
-   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) >> 26;
-   if (h < 32)
-   hashes[0] |= (1 << h);
-   else
-   hashes[1] |= (1 << (h - 32));
-   mcnt++;
-   }
-   if_maddr_runlock(ifp);
-
-   if (mcnt)
+   if (if_foreach_llmaddr(ifp, my_hash_maddr, hashes) > 0)
rxfilt |= MY_AM;
else
rxfilt &= ~MY_AM;
CSR_WRITE_4(sc, MY_MAR0, hashes[0]);
CSR_WRITE_4(sc, MY_MAR1, hashes[1]);
CSR_WRITE_4(sc, MY_TCRRCR, rxfilt);
-   return;
 }
 
 /*
___
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"


svn commit: r353856 - head/sys/dev/qlxgbe

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:21 2019
New Revision: 353856
URL: https://svnweb.freebsd.org/changeset/base/353856

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/qlxgbe/ql_os.c

Modified: head/sys/dev/qlxgbe/ql_os.c
==
--- head/sys/dev/qlxgbe/ql_os.c Mon Oct 21 18:12:17 2019(r353855)
+++ head/sys/dev/qlxgbe/ql_os.c Mon Oct 21 18:12:21 2019(r353856)
@@ -977,32 +977,28 @@ qla_init(void *arg)
QL_DPRINT2(ha, (ha->pci_dev, "%s: exit\n", __func__));
 }
 
+static u_int
+qla_copy_maddr(void *arg, struct sockaddr_dl *sdl, u_int mcnt)
+{
+   uint8_t *mta = arg;
+
+   if (mcnt == Q8_MAX_NUM_MULTICAST_ADDRS)
+   return (0);
+
+   bcopy(LLADDR(sdl), &mta[mcnt * Q8_MAC_ADDR_LEN], Q8_MAC_ADDR_LEN);
+
+   return (1);
+}
+
 static int
 qla_set_multi(qla_host_t *ha, uint32_t add_multi)
 {
uint8_t mta[Q8_MAX_NUM_MULTICAST_ADDRS * Q8_MAC_ADDR_LEN];
-   struct ifmultiaddr *ifma;
int mcnt = 0;
struct ifnet *ifp = ha->ifp;
int ret = 0;
 
-   if_maddr_rlock(ifp);
-
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (mcnt == Q8_MAX_NUM_MULTICAST_ADDRS)
-   break;
-
-   bcopy(LLADDR((struct sockaddr_dl *) ifma->ifma_addr),
-   &mta[mcnt * Q8_MAC_ADDR_LEN], Q8_MAC_ADDR_LEN);
-
-   mcnt++;
-   }
-
-   if_maddr_runlock(ifp);
+   mcnt = if_foreach_llmaddr(ifp, qla_copy_maddr, mta);
 
if (QLA_LOCK(ha, __func__, QLA_LOCK_DEFAULT_MS_TIMEOUT,
QLA_LOCK_NO_SLEEP) != 0)
___
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"


svn commit: r353861 - head/sys/dev/xilinx

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:12:58 2019
New Revision: 353861
URL: https://svnweb.freebsd.org/changeset/base/353861

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/dev/xilinx/if_xae.c

Modified: head/sys/dev/xilinx/if_xae.c
==
--- head/sys/dev/xilinx/if_xae.cMon Oct 21 18:12:40 2019
(r353860)
+++ head/sys/dev/xilinx/if_xae.cMon Oct 21 18:12:58 2019
(r353861)
@@ -514,14 +514,40 @@ xae_media_change(struct ifnet * ifp)
return (error);
 }
 
+static u_int
+xae_write_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct xae_softc *sc = arg;
+   uint32_t reg;
+   uint8_t *ma;
+
+   if (cnt >= XAE_MULTICAST_TABLE_SIZE)
+   return (1);
+
+   ma = LLADDR(sdl);
+
+   reg = READ4(sc, XAE_FFC) & 0xff00;
+   reg |= cnt;
+   WRITE4(sc, XAE_FFC, reg);
+
+   reg = (ma[0]);
+   reg |= (ma[1] << 8);
+   reg |= (ma[2] << 16);
+   reg |= (ma[3] << 24);
+   WRITE4(sc, XAE_FFV(0), reg);
+
+   reg = ma[4];
+   reg |= ma[5] << 8;
+   WRITE4(sc, XAE_FFV(1), reg);
+
+   return (1);
+}
+
 static void
 xae_setup_rxfilter(struct xae_softc *sc)
 {
-   struct ifmultiaddr *ifma;
struct ifnet *ifp;
uint32_t reg;
-   uint8_t *ma;
-   int i;
 
XAE_ASSERT_LOCKED(sc);
 
@@ -539,33 +565,7 @@ xae_setup_rxfilter(struct xae_softc *sc)
reg &= ~FFC_PM;
WRITE4(sc, XAE_FFC, reg);
 
-   if_maddr_rlock(ifp);
-
-   i = 0;
-   CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (i >= XAE_MULTICAST_TABLE_SIZE)
-   break;
-
-   ma = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-
-   reg = READ4(sc, XAE_FFC) & 0xff00;
-   reg |= i++;
-   WRITE4(sc, XAE_FFC, reg);
-
-   reg = (ma[0]);
-   reg |= (ma[1] << 8);
-   reg |= (ma[2] << 16);
-   reg |= (ma[3] << 24);
-   WRITE4(sc, XAE_FFV(0), reg);
-
-   reg = ma[4];
-   reg |= ma[5] << 8;
-   WRITE4(sc, XAE_FFV(1), reg);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, xae_write_maddr, sc);
}
 
/*
___
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"


svn commit: r353864 - head/sys/arm/ralink

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:13:24 2019
New Revision: 353864
URL: https://svnweb.freebsd.org/changeset/base/353864

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/arm/ralink/if_fv.c

Modified: head/sys/arm/ralink/if_fv.c
==
--- head/sys/arm/ralink/if_fv.c Mon Oct 21 18:13:19 2019(r353863)
+++ head/sys/arm/ralink/if_fv.c Mon Oct 21 18:13:24 2019(r353864)
@@ -200,8 +200,25 @@ DRIVER_MODULE(fvmdio, simplebus, fvmdio_driver, fvmdio
 DRIVER_MODULE(mdio, fvmdio, mdio_driver, mdio_devclass, 0, 0);
 #endif
 
-/* setup frame code refer dc code */
+static u_int
+fv_set_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint16_t *sp = arg;
+   uint8_t *ma;
+   int i;
 
+   ma = LLADDR(sdl);
+   i = cnt * 6;
+   sp[i] = sp[i+1] = (ma[1] << 8 | ma[0]);
+   i += 2;
+   sp[i] = sp[i+1] = (ma[3] << 8 | ma[2]);
+   i += 2;
+   sp[i] = sp[i+1] = (ma[5] << 8 | ma[4]);
+
+   return (1);
+}
+
+/* setup frame code refer dc code */
 static void
 fv_setfilt(struct fv_softc *sc)
 {
@@ -209,9 +226,7 @@ fv_setfilt(struct fv_softc *sc)
struct fv_desc *sframe;
int i;
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
uint16_t *sp;
-   uint8_t *ma;
 
ifp = sc->fv_ifp;
 
@@ -225,20 +240,7 @@ fv_setfilt(struct fv_softc *sc)
sframe->fv_addr = sc->fv_rdata.fv_sf_paddr;
sframe->fv_devcs = ADCTL_Tx_SETUP | FV_DMASIZE(FV_SFRAME_LEN);
 
-   i = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   ma = LLADDR((struct sockaddr_dl *)ifma->ifma_addr);
-   sp[i] = sp[i+1] = (ma[1] << 8 | ma[0]);
-   i += 2;
-   sp[i] = sp[i+1] = (ma[3] << 8 | ma[2]);
-   i += 2;
-   sp[i] = sp[i+1] = (ma[5] << 8 | ma[4]);
-   i += 2;
-   }
-   if_maddr_runlock(ifp);
+   i = if_foreach_llmaddr(ifp, fv_set_maddr, sp) * 6;
 
bcopy(IF_LLADDR(sc->fv_ifp), eaddr, ETHER_ADDR_LEN);
sp[90] = sp[91] = eaddr[0];
___
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"


svn commit: r353865 - head/sys/arm/ti/cpsw

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:13:28 2019
New Revision: 353865
URL: https://svnweb.freebsd.org/changeset/base/353865

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/arm/ti/cpsw/if_cpsw.c

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==
--- head/sys/arm/ti/cpsw/if_cpsw.c  Mon Oct 21 18:13:24 2019
(r353864)
+++ head/sys/arm/ti/cpsw/if_cpsw.c  Mon Oct 21 18:13:28 2019
(r353865)
@@ -2425,12 +2425,27 @@ cpsw_ale_dump_table(struct cpsw_softc *sc) {
printf("\n");
 }
 
+static u_int
+cpswp_set_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct cpswp_softc *sc = arg;
+   uint32_t portmask;
+
+   if (sc->swsc->dualemac)
+   portmask = 1 << (sc->unit + 1) | 1 << 0;
+   else
+   portmask = 7;
+
+   cpsw_ale_mc_entry_set(sc->swsc, portmask, sc->vlan, LLADDR(sdl));
+
+   return (1);
+}
+
 static int
 cpswp_ale_update_addresses(struct cpswp_softc *sc, int purge)
 {
uint8_t *mac;
uint32_t ale_entry[3], ale_type, portmask;
-   struct ifmultiaddr *ifma;
 
if (sc->swsc->dualemac) {
ale_type = ALE_TYPE_VLAN_ADDR << 28 | sc->vlan << 16;
@@ -2445,7 +2460,6 @@ cpswp_ale_update_addresses(struct cpswp_softc *sc, int
 * For simplicity, keep this entry at table index 0 for port 1 and
 * at index 2 for port 2 in the ALE.
 */
-if_addr_rlock(sc->ifp);
mac = LLADDR((struct sockaddr_dl *)sc->ifp->if_addr->ifa_addr);
ale_entry[0] = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5];
ale_entry[1] = ale_type | mac[0] << 8 | mac[1]; /* addr entry + mac */
@@ -2457,7 +2471,6 @@ cpswp_ale_update_addresses(struct cpswp_softc *sc, int
mac[3] << 24 | mac[2] << 16 | mac[1] << 8 | mac[0]);
cpsw_write_4(sc->swsc, CPSW_PORT_P_SA_LO(sc->unit + 1),
mac[5] << 8 | mac[4]);
-if_addr_runlock(sc->ifp);
 
/* Keep the broadcast address at table entry 1 (or 3). */
ale_entry[0] = 0x; /* Lower 32 bits of MAC */
@@ -2472,14 +2485,7 @@ cpswp_ale_update_addresses(struct cpswp_softc *sc, int
cpsw_ale_remove_all_mc_entries(sc->swsc);
 
 /* Set other multicast addrs desired. */
-if_maddr_rlock(sc->ifp);
-CK_STAILQ_FOREACH(ifma, &sc->ifp->if_multiaddrs, ifma_link) {
-if (ifma->ifma_addr->sa_family != AF_LINK)
-continue;
-   cpsw_ale_mc_entry_set(sc->swsc, portmask, sc->vlan,
-   LLADDR((struct sockaddr_dl *)ifma->ifma_addr));
-}
-if_maddr_runlock(sc->ifp);
+   if_foreach_llmaddr(sc->ifp, cpswp_set_maddr, sc);
 
return (0);
 }
___
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"


svn commit: r353863 - head/sys/arm/allwinner

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:13:19 2019
New Revision: 353863
URL: https://svnweb.freebsd.org/changeset/base/353863

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/arm/allwinner/if_emac.c

Modified: head/sys/arm/allwinner/if_emac.c
==
--- head/sys/arm/allwinner/if_emac.cMon Oct 21 18:13:14 2019
(r353862)
+++ head/sys/arm/allwinner/if_emac.cMon Oct 21 18:13:19 2019
(r353863)
@@ -218,12 +218,22 @@ emac_get_hwaddr(struct emac_softc *sc, uint8_t *hwaddr
printf("MAC address: %s\n", ether_sprintf(hwaddr));
 }
 
+static u_int
+emac_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   uint32_t h, *hashes = arg;
+
+   h = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN) >> 26;
+   hashes[h >> 5] |= 1 << (h & 0x1f);
+
+   return (1);
+}
+
 static void
 emac_set_rx_mode(struct emac_softc *sc)
 {
struct ifnet *ifp;
-   struct ifmultiaddr *ifma;
-   uint32_t h, hashes[2];
+   uint32_t hashes[2];
uint32_t rcr = 0;
 
EMAC_ASSERT_LOCKED(sc);
@@ -241,17 +251,8 @@ emac_set_rx_mode(struct emac_softc *sc)
if (ifp->if_flags & IFF_ALLMULTI) {
hashes[0] = 0x;
hashes[1] = 0x;
-   } else {
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &sc->emac_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) >> 26;
-   hashes[h >> 5] |= 1 << (h & 0x1f);
-   }
-   if_maddr_runlock(ifp);
-   }
+   } else
+   if_foreach_llmaddr(ifp, emac_hash_maddr, hashes);
rcr |= EMAC_RX_MCO;
rcr |= EMAC_RX_MHF;
EMAC_WRITE_REG(sc, EMAC_RX_HASH0, hashes[0]);
___
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"


svn commit: r353859 - head/sys/dev/tsec

2019-10-21 Thread Gleb Smirnoff
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]);
___
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"


svn commit: r353867 - head/sys/powerpc/pseries

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:13:37 2019
New Revision: 353867
URL: https://svnweb.freebsd.org/changeset/base/353867

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/powerpc/pseries/phyp_llan.c

Modified: head/sys/powerpc/pseries/phyp_llan.c
==
--- head/sys/powerpc/pseries/phyp_llan.cMon Oct 21 18:13:33 2019
(r353866)
+++ head/sys/powerpc/pseries/phyp_llan.cMon Oct 21 18:13:37 2019
(r353867)
@@ -508,28 +508,28 @@ llan_start(struct ifnet *ifp)
mtx_unlock(&sc->io_lock);
 }
 
+static u_int
+llan_set_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct llan_softc *sc = arg;
+   uint64_t macaddr = 0;
+
+   memcpy((uint8_t *)&macaddr + 2, LLADDR(sdl), 6);
+   phyp_hcall(H_MULTICAST_CTRL, sc->unit, LLAN_ADD_MULTICAST, macaddr);
+
+   return (1);
+}
+
 static int
 llan_set_multicast(struct llan_softc *sc)
 {
struct ifnet *ifp = sc->ifp;
-   struct ifmultiaddr *inm;
-   uint64_t macaddr = 0;
 
mtx_assert(&sc->io_lock, MA_OWNED);
 
phyp_hcall(H_MULTICAST_CTRL, sc->unit, LLAN_CLEAR_MULTICAST, 0);
 
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
-   if (inm->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   memcpy((uint8_t *)&macaddr + 2,
-   LLADDR((struct sockaddr_dl *)inm->ifma_addr), 6);
-   phyp_hcall(H_MULTICAST_CTRL, sc->unit, LLAN_ADD_MULTICAST,
-   macaddr);
-   }
-   if_maddr_runlock(ifp);
+   if_foreach_llmaddr(ifp, llan_set_maddr, sc);
 
return (0);
 }
___
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"


svn commit: r353866 - head/sys/powerpc/ps3

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:13:33 2019
New Revision: 353866
URL: https://svnweb.freebsd.org/changeset/base/353866

Log:
  Convert to if_foreach_llmaddr() KPI.

Modified:
  head/sys/powerpc/ps3/if_glc.c

Modified: head/sys/powerpc/ps3/if_glc.c
==
--- head/sys/powerpc/ps3/if_glc.c   Mon Oct 21 18:13:28 2019
(r353865)
+++ head/sys/powerpc/ps3/if_glc.c   Mon Oct 21 18:13:33 2019
(r353866)
@@ -504,12 +504,31 @@ glc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
return (err);
 }
 
+static u_int
+glc_add_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
+{
+   struct glc_softc *sc = arg;
+   uint64_t addr;
+
+   /*
+* Filter can only hold 32 addresses, so fall back to
+* the IFF_ALLMULTI case if we have too many. +1 is for
+* broadcast.
+*/
+   if (cnt + 1 == 32)
+   return (0);
+
+   addr = 0;
+   memcpy(&((uint8_t *)(&addr))[2], LLADDR(sdl), ETHER_ADDR_LEN);
+   lv1_net_add_multicast_address(sc->sc_bus, sc->sc_dev, addr, 0);
+
+   return (1);
+}
+
 static void
 glc_set_multicast(struct glc_softc *sc)
 {
struct ifnet *ifp = sc->sc_ifp;
-   struct ifmultiaddr *inm;
-   uint64_t addr;
int naddrs;
 
/* Clear multicast filter */
@@ -522,30 +541,10 @@ glc_set_multicast(struct glc_softc *sc)
if ((ifp->if_flags & IFF_ALLMULTI) != 0) {
lv1_net_add_multicast_address(sc->sc_bus, sc->sc_dev, 0, 1);
} else {
-   if_maddr_rlock(ifp);
-   naddrs = 1; /* Include broadcast */
-   CK_STAILQ_FOREACH(inm, &ifp->if_multiaddrs, ifma_link) {
-   if (inm->ifma_addr->sa_family != AF_LINK)
-   continue;
-   addr = 0;
-   memcpy(&((uint8_t *)(&addr))[2],
-   LLADDR((struct sockaddr_dl *)inm->ifma_addr),
-   ETHER_ADDR_LEN);
-
-   lv1_net_add_multicast_address(sc->sc_bus, sc->sc_dev,
-   addr, 0);
-
-   /*
-* Filter can only hold 32 addresses, so fall back to
-* the IFF_ALLMULTI case if we have too many.
-*/
-   if (++naddrs >= 32) {
-   lv1_net_add_multicast_address(sc->sc_bus,
-   sc->sc_dev, 0, 1);
-   break;
-   }
-   }
-   if_maddr_runlock(ifp);
+   naddrs = if_foreach_llmaddr(ifp, glc_add_maddr, sc);
+   if (naddrs + 1 == 32)
+   lv1_net_add_multicast_address(sc->sc_bus,
+   sc->sc_dev, 0, 1);
}
 }
 
___
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"


svn commit: r353869 - in head/sys: kern sys

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:19:32 2019
New Revision: 353869
URL: https://svnweb.freebsd.org/changeset/base/353869

Log:
  Remove epoch tracker from struct thread.  It was an ugly crutch to emulate
  locking semantics for if_addr_rlock() and if_maddr_rlock().

Modified:
  head/sys/kern/init_main.c
  head/sys/kern/kern_thread.c
  head/sys/kern/subr_epoch.c
  head/sys/sys/epoch.h
  head/sys/sys/proc.h

Modified: head/sys/kern/init_main.c
==
--- head/sys/kern/init_main.c   Mon Oct 21 18:17:03 2019(r353868)
+++ head/sys/kern/init_main.c   Mon Oct 21 18:19:32 2019(r353869)
@@ -514,7 +514,6 @@ proc0_init(void *dummy __unused)
td->td_pflags = TDP_KTHREAD;
td->td_cpuset = cpuset_thread0();
td->td_domain.dr_policy = td->td_cpuset->cs_domain;
-   epoch_thread_init(td);
prison0_init();
p->p_peers = 0;
p->p_leader = p;

Modified: head/sys/kern/kern_thread.c
==
--- head/sys/kern/kern_thread.c Mon Oct 21 18:17:03 2019(r353868)
+++ head/sys/kern/kern_thread.c Mon Oct 21 18:19:32 2019(r353869)
@@ -273,7 +273,6 @@ thread_init(void *mem, int size, int flags)
td->td_rlqe = NULL;
EVENTHANDLER_DIRECT_INVOKE(thread_init, td);
umtx_thread_init(td);
-   epoch_thread_init(td);
td->td_kstack = 0;
td->td_sel = NULL;
return (0);
@@ -293,7 +292,6 @@ thread_fini(void *mem, int size)
turnstile_free(td->td_turnstile);
sleepq_free(td->td_sleepqueue);
umtx_thread_fini(td);
-   epoch_thread_fini(td);
seltdfini(td);
 }
 

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Mon Oct 21 18:17:03 2019(r353868)
+++ head/sys/kern/subr_epoch.c  Mon Oct 21 18:19:32 2019(r353869)
@@ -842,17 +842,3 @@ epoch_drain_callbacks(epoch_t epoch)
 
PICKUP_GIANT();
 }
-
-void
-epoch_thread_init(struct thread *td)
-{
-
-   td->td_et = malloc(sizeof(struct epoch_tracker), M_EPOCH, M_WAITOK);
-}
-
-void
-epoch_thread_fini(struct thread *td)
-{
-
-   free(td->td_et, M_EPOCH);
-}

Modified: head/sys/sys/epoch.h
==
--- head/sys/sys/epoch.hMon Oct 21 18:17:03 2019(r353868)
+++ head/sys/sys/epoch.hMon Oct 21 18:19:32 2019(r353869)
@@ -93,8 +93,5 @@ void epoch_trace_list(struct thread *);
 void epoch_enter(epoch_t epoch);
 void epoch_exit(epoch_t epoch);
 
-void epoch_thread_init(struct thread *);
-void epoch_thread_fini(struct thread *);
-
 #endif /* _KERNEL */
 #endif /* _SYS_EPOCH_H_ */

Modified: head/sys/sys/proc.h
==
--- head/sys/sys/proc.h Mon Oct 21 18:17:03 2019(r353868)
+++ head/sys/sys/proc.h Mon Oct 21 18:19:32 2019(r353869)
@@ -365,7 +365,6 @@ struct thread {
int td_lastcpu; /* (t) Last cpu we were on. */
int td_oncpu;   /* (t) Which cpu we are on. */
void*td_lkpi_task;  /* LinuxKPI task struct pointer */
-   struct epoch_tracker *td_et;/* (k) compat KPI spare tracker */
int td_pmcpend;
 #ifdef EPOCH_TRACE
SLIST_HEAD(, epoch_tracker) td_epochs;
___
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"


svn commit: r353868 - in head: . sys/net sys/sys

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 18:17:03 2019
New Revision: 353868
URL: https://svnweb.freebsd.org/changeset/base/353868

Log:
  Remove obsoleted KPIs that were used to access interface address lists.

Modified:
  head/UPDATING
  head/sys/net/if.c
  head/sys/net/if_var.h
  head/sys/sys/param.h

Modified: head/UPDATING
==
--- head/UPDATING   Mon Oct 21 18:13:37 2019(r353867)
+++ head/UPDATING   Mon Oct 21 18:17:03 2019(r353868)
@@ -27,6 +27,10 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 13.x IS SLOW:
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
 
 20191021:
+   KPIs for network drivers to access interface addresses have changed.
+   Users need to recompile NIC driver modules together with kernel.
+
+20191021:
The net.link.tap.user_open sysctl no longer prevents user opening of
already created /dev/tapNN devices.  Access is still controlled by
node permissions, just like tun devices.  The net.link.tap.user_open

Modified: head/sys/net/if.c
==
--- head/sys/net/if.c   Mon Oct 21 18:13:37 2019(r353867)
+++ head/sys/net/if.c   Mon Oct 21 18:17:03 2019(r353868)
@@ -1768,40 +1768,6 @@ if_data_copy(struct ifnet *ifp, struct if_data *ifd)
 }
 
 /*
- * Wrapper functions for struct ifnet address list locking macros.  These are
- * used by kernel modules to avoid encoding programming interface or binary
- * interface assumptions that may be violated when kernel-internal locking
- * approaches change.
- */
-void
-if_addr_rlock(struct ifnet *ifp)
-{
-
-   epoch_enter_preempt(net_epoch_preempt, curthread->td_et);
-}
-
-void
-if_addr_runlock(struct ifnet *ifp)
-{
-
-   epoch_exit_preempt(net_epoch_preempt, curthread->td_et);
-}
-
-void
-if_maddr_rlock(if_t ifp)
-{
-
-   epoch_enter_preempt(net_epoch_preempt, curthread->td_et);
-}
-
-void
-if_maddr_runlock(if_t ifp)
-{
-
-   epoch_exit_preempt(net_epoch_preempt, curthread->td_et);
-}
-
-/*
  * Initialization, destruction and refcounting functions for ifaddrs.
  */
 struct ifaddr *
@@ -4403,77 +4369,6 @@ if_input(if_t ifp, struct mbuf* sendmp)
(*((struct ifnet *)ifp)->if_input)((struct ifnet *)ifp, sendmp);
return (0);
 
-}
-
-/* XXX */
-#ifndef ETH_ADDR_LEN
-#define ETH_ADDR_LEN 6
-#endif
-
-int 
-if_setupmultiaddr(if_t ifp, void *mta, int *cnt, int max)
-{
-   struct ifmultiaddr *ifma;
-   uint8_t *lmta = (uint8_t *)mta;
-   int mcnt = 0;
-
-   CK_STAILQ_FOREACH(ifma, &((struct ifnet *)ifp)->if_multiaddrs, 
ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-
-   if (mcnt == max)
-   break;
-
-   bcopy(LLADDR((struct sockaddr_dl *)ifma->ifma_addr),
-   &lmta[mcnt * ETH_ADDR_LEN], ETH_ADDR_LEN);
-   mcnt++;
-   }
-   *cnt = mcnt;
-
-   return (0);
-}
-
-int
-if_multiaddr_array(if_t ifp, void *mta, int *cnt, int max)
-{
-   int error;
-
-   if_maddr_rlock(ifp);
-   error = if_setupmultiaddr(ifp, mta, cnt, max);
-   if_maddr_runlock(ifp);
-   return (error);
-}
-
-int
-if_multiaddr_count(if_t ifp, int max)
-{
-   struct ifmultiaddr *ifma;
-   int count;
-
-   count = 0;
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &((struct ifnet *)ifp)->if_multiaddrs, 
ifma_link) {
-   if (ifma->ifma_addr->sa_family != AF_LINK)
-   continue;
-   count++;
-   if (count == max)
-   break;
-   }
-   if_maddr_runlock(ifp);
-   return (count);
-}
-
-int
-if_multi_apply(struct ifnet *ifp, int (*filter)(void *, struct ifmultiaddr *, 
int), void *arg)
-{
-   struct ifmultiaddr *ifma;
-   int cnt = 0;
-
-   if_maddr_rlock(ifp);
-   CK_STAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link)
-   cnt += filter(arg, ifma, cnt);
-   if_maddr_runlock(ifp);
-   return (cnt);
 }
 
 struct mbuf *

Modified: head/sys/net/if_var.h
==
--- head/sys/net/if_var.h   Mon Oct 21 18:13:37 2019(r353867)
+++ head/sys/net/if_var.h   Mon Oct 21 18:17:03 2019(r353868)
@@ -449,16 +449,6 @@ struct ifnet {
 #defineNET_EPOCH_WAIT()epoch_wait_preempt(net_epoch_preempt)
 #defineNET_EPOCH_ASSERT()  MPASS(in_epoch(net_epoch_preempt))
 
-/*
- * Function variations on locking macros intended to be used by loadable
- * kernel modules in order to divorce them from the internals of address list
- * locking.
- */
-void   if_addr_rlock(struct ifnet *ifp);   /* if_addrhead */
-void   if_addr_runlock(struct ifnet *ifp); /* if_addrhead */
-void   i

svn commit: r353871 - head

2019-10-21 Thread Ed Maste
Author: emaste
Date: Mon Oct 21 18:40:03 2019
New Revision: 353871
URL: https://svnweb.freebsd.org/changeset/base/353871

Log:
  Additional fix for -DNO_CLEAN build across r353340 and r353381
  
  opensolaris_atomic.S is now only used on i386 with opensolaris_atomic.c
  used on other platforms.  After r353381 it doesn't exist on those
  platforms so the stale dependency would result in a build error.
  
  r353408 addressed this issue for cddl/lib/libzpool, but it persisted
  with the opensolaris and zfs modules.

Modified:
  head/Makefile.inc1

Modified: head/Makefile.inc1
==
--- head/Makefile.inc1  Mon Oct 21 18:27:12 2019(r353870)
+++ head/Makefile.inc1  Mon Oct 21 18:40:03 2019(r353871)
@@ -1620,6 +1620,18 @@ _cleankernobj_fast_depend_hack: .PHONY
rm -f ${OBJTOP}/sys/${KERNCONF}/assym.* \
${OBJTOP}/sys/${KERNCONF}/.depend.assym.*; \
fi
+# 20191009  r353340  removal of opensolaris_atomic.S (also r353381)
+.if ${MACHINE} != i386
+.for f in opensolaris_atomic
+.for m in opensolaris zfs
+   @if [ -e 
"${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o" ] 
&& \
+   grep -q ${f}.S 
"${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.o"; 
then \
+   echo "Removing stale dependencies for opensolaris_atomic"; \
+   rm -f 
${KRNLOBJDIR}/${KERNCONF}/modules${SRCTOP}/sys/modules/${m}/.depend.${f}.*; \
+   fi
+.endfor
+.endfor
+.endif
 
 ${WMAKE_TGTS:N_worldtmp:Nbuild${libcompat}} ${.ALLTARGETS:M_*:N_worldtmp}: 
.MAKE .PHONY
 
___
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"


svn commit: r353872 - head/stand/lua

2019-10-21 Thread Kyle Evans
Author: kevans
Date: Mon Oct 21 20:09:43 2019
New Revision: 353872
URL: https://svnweb.freebsd.org/changeset/base/353872

Log:
  lualoader: don't botch disabling of color
  
  When colors are disabled, color.escape{fg,bg} would return the passed in
  color rather than the proper ANSI sequence for the color.
  color.escape{fg,bg} would be wrong.
  
  Instead return '', as the associated reset* functions will also return ''.
  This should get rid of the funky '2' and '4' in the kernel selector if
  you're booting serial.
  
  Reported by:  npn

Modified:
  head/stand/lua/color.lua
  head/stand/lua/screen.lua

Modified: head/stand/lua/color.lua
==
--- head/stand/lua/color.luaMon Oct 21 18:40:03 2019(r353871)
+++ head/stand/lua/color.luaMon Oct 21 20:09:43 2019(r353872)
@@ -58,7 +58,7 @@ color.disabled = not color.isEnabled()
 
 function color.escapefg(color_value)
if color.disabled then
-   return color_value
+   return ''
end
return core.KEYSTR_CSI .. "3" .. color_value .. "m"
 end
@@ -72,7 +72,7 @@ end
 
 function color.escapebg(color_value)
if color.disabled then
-   return color_value
+   return ''
end
return core.KEYSTR_CSI .. "4" .. color_value .. "m"
 end

Modified: head/stand/lua/screen.lua
==
--- head/stand/lua/screen.lua   Mon Oct 21 18:40:03 2019(r353871)
+++ head/stand/lua/screen.lua   Mon Oct 21 20:09:43 2019(r353872)
@@ -47,14 +47,14 @@ end
 
 function screen.setforeground(color_value)
if color.disabled then
-   return color_value
+   return
end
printc(color.escapefg(color_value))
 end
 
 function screen.setbackground(color_value)
if color.disabled then
-   return color_value
+   return
end
printc(color.escapebg(color_value))
 end
___
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"


svn commit: r353873 - head/stand/lua

2019-10-21 Thread Kyle Evans
Author: kevans
Date: Mon Oct 21 20:17:31 2019
New Revision: 353873
URL: https://svnweb.freebsd.org/changeset/base/353873

Log:
  lualoader: fix setting of loader_color=NO in loader.conf(5)
  
  Previously color.disabled would be calculated at color module load time,
  then never touched again. We can detect serial boots beyond just what we're
  told by loader.conf(5) so this works out in many cases, but we must
  re-evaluate the situation after the config is loaded to make sure we're not
  supposed to be forcing it enabled/disabled.
  
  Discovered while trying to test r353872.

Modified:
  head/stand/lua/color.lua

Modified: head/stand/lua/color.lua
==
--- head/stand/lua/color.luaMon Oct 21 20:09:43 2019(r353872)
+++ head/stand/lua/color.luaMon Oct 21 20:17:31 2019(r353873)
@@ -29,9 +29,14 @@
 --
 
 local core = require("core")
+local hook = require("hook")
 
 local color = {}
 
+local function recalcDisabled()
+   color.disabled = not color.isEnabled()
+end
+
 -- Module exports
 color.BLACK   = 0
 color.RED = 1
@@ -54,8 +59,6 @@ function color.isEnabled()
return not core.isSerialBoot()
 end
 
-color.disabled = not color.isEnabled()
-
 function color.escapefg(color_value)
if color.disabled then
return ''
@@ -112,5 +115,8 @@ function color.highlight(str)
-- case the terminal defaults don't match what we're expecting.
return core.KEYSTR_CSI .. "1m" .. str .. core.KEYSTR_CSI .. "22m"
 end
+
+recalcDisabled()
+hook.register("config.loaded", recalcDisabled)
 
 return color
___
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"


svn commit: r353874 - head/sys/modules/if_tuntap

2019-10-21 Thread Kyle Evans
Author: kevans
Date: Mon Oct 21 20:28:38 2019
New Revision: 353874
URL: https://svnweb.freebsd.org/changeset/base/353874

Log:
  if_tuntap: remove if_{tun,tap}.ko -> if_tuntap.ko links
  
  These drivers have been merged into a single if_tuntap in 13.0. The
  compatibility links existed only for the interim and will be MFC'd along
  with the if_tuntap merge shortly.
  
  MFC after:never

Modified:
  head/sys/modules/if_tuntap/Makefile

Modified: head/sys/modules/if_tuntap/Makefile
==
--- head/sys/modules/if_tuntap/Makefile Mon Oct 21 20:17:31 2019
(r353873)
+++ head/sys/modules/if_tuntap/Makefile Mon Oct 21 20:28:38 2019
(r353874)
@@ -5,31 +5,4 @@
 KMOD=  if_tuntap
 SRCS=  if_tuntap.c opt_inet.h opt_inet6.h
 
-# Symlink for backwards compatibility with systems installed at 12.0 or older
-.if ${MACHINE_CPUARCH} != "powerpc"
-SYMLINKS=  ${KMOD}.ko ${KMODDIR}/if_tun.ko \
-   ${KMOD}.ko ${KMODDIR}/if_tap.ko
-.else
-# Some PPC systems use msdosfs for /boot, which can't handle links or symlinks
-afterinstall: alias alias_debug
-alias: .PHONY
-   ${INSTALL} -T release -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
-   ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}/if_tun.ko
-   ${INSTALL} -T release -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
-   ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}/if_tap.ko
-.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && \
-"${MK_KERNEL_SYMBOLS}" != "no"
-alias_debug: .PHONY
-   ${INSTALL} -T debug -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
-   ${_INSTALLFLAGS} ${PROG}.debug \
-   ${DESTDIR}${KERN_DEBUGDIR}${KMODDIR}/if_tun.ko
-   ${INSTALL} -T debug -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
-   ${_INSTALLFLAGS} ${PROG}.debug \
-   ${DESTDIR}${KERN_DEBUGDIR}${KMODDIR}/if_tap.ko
-.else
-alias_debug: .PHONY
-.endif
-.endif
-
-
 .include 
___
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"


Re: svn commit: r353848 - head/sys/dev/jme

2019-10-21 Thread Sergey Kandaurov
пн, 21 окт. 2019 г. в 21:14, Gleb Smirnoff :

> Author: glebius
> Date: Mon Oct 21 18:11:43 2019
> New Revision: 353848
> URL: https://svnweb.freebsd.org/changeset/base/353848
>
> Log:
>   Convert to if_foreach_llmaddr() KPI.
>
> Modified:
>   head/sys/dev/jme/if_jme.c
>
> Modified: head/sys/dev/jme/if_jme.c
>
> ==
> --- head/sys/dev/jme/if_jme.c   Mon Oct 21 18:11:38 2019(r353847)
> +++ head/sys/dev/jme/if_jme.c   Mon Oct 21 18:11:43 2019(r353848)
> @@ -3236,12 +3236,26 @@ jme_set_vlan(struct jme_softc *sc)
> CSR_WRITE_4(sc, JME_RXMAC, reg);
>  }
>
> +static u_int
> +jme_hash_maddr(void *arg, struct sockaddr_dl *sdl, u_int cnt)
> +{
> +   uint32_t crc, *mchash = arg;
> +
> +   crc = ether_crc32_be(LLADDR(sdl), ETHER_ADDR_LEN);
> +
> +   /* Just want the 6 least significant bits. */
> +   crc &= 0x3f;
> +
> +   /* Set the corresponding bit in the hash table. */
> +   mchash[crc >> 5] |= 1 << (crc & 0x1f);
> +
> +   return (1);
> +}
> +
>  static void
>  jme_set_filter(struct jme_softc *sc)
>  {
> struct ifnet *ifp;
> -   struct ifmultiaddr *ifma;
> -   uint32_t crc;
> uint32_t mchash[2];
> uint32_t rxcfg;
>
> @@ -3276,21 +3290,7 @@ jme_set_filter(struct jme_softc *sc)
>  */
> rxcfg |= RXMAC_MULTICAST;
> bzero(mchash, sizeof(mchash));
> -
> -   if_maddr_rlock(ifp);
> -   CK_STAILQ_FOREACH(ifma, &sc->jme_ifp->if_multiaddrs, ifma_link) {
> -   if (ifma->ifma_addr->sa_family != AF_LINK)
> -   continue;
> -   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
> -   ifma->ifma_addr), ETHER_ADDR_LEN);
> -
> -   /* Just want the 6 least significant bits. */
> -   crc &= 0x3f;
> -
> -   /* Set the corresponding bit in the hash table. */
> -   mchash[crc >> 5] |= 1 << (crc & 0x1f);
> -   }
> -   if_maddr_runlock(ifp);
> +   if_foreach_llmaddr(ifp, jme_hash_maddr, &mchash);
>

Should not be there just “mchash”?
You seems to be passing (uint32_t **),
also in tsec.


> CSR_WRITE_4(sc, JME_MAR0, mchash[0]);
> CSR_WRITE_4(sc, JME_MAR1, mchash[1]);
>
___
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"


Re: svn commit: r353848 - head/sys/dev/jme

2019-10-21 Thread Gleb Smirnoff
  Sergey,

On Mon, Oct 21, 2019 at 11:30:46PM +0300, Sergey Kandaurov wrote:
S> > struct ifnet *ifp;
S> > -   struct ifmultiaddr *ifma;
S> > -   uint32_t crc;
S> > uint32_t mchash[2];
S> > uint32_t rxcfg;
S> >
S> > @@ -3276,21 +3290,7 @@ jme_set_filter(struct jme_softc *sc)
S> >  */
S> > rxcfg |= RXMAC_MULTICAST;
S> > bzero(mchash, sizeof(mchash));
S> > -
S> > -   if_maddr_rlock(ifp);
S> > -   CK_STAILQ_FOREACH(ifma, &sc->jme_ifp->if_multiaddrs, ifma_link) {
S> > -   if (ifma->ifma_addr->sa_family != AF_LINK)
S> > -   continue;
S> > -   crc = ether_crc32_be(LLADDR((struct sockaddr_dl *)
S> > -   ifma->ifma_addr), ETHER_ADDR_LEN);
S> > -
S> > -   /* Just want the 6 least significant bits. */
S> > -   crc &= 0x3f;
S> > -
S> > -   /* Set the corresponding bit in the hash table. */
S> > -   mchash[crc >> 5] |= 1 << (crc & 0x1f);
S> > -   }
S> > -   if_maddr_runlock(ifp);
S> > +   if_foreach_llmaddr(ifp, jme_hash_maddr, &mchash);
S> >
S> 
S> Should not be there just “mchash”?
S> You seems to be passing (uint32_t **),
S> also in tsec.

mchash and &mchash are the same here.

-- 
Gleb Smirnoff
___
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"


svn commit: r353875 - head/contrib/tcsh

2019-10-21 Thread Brooks Davis
Author: brooks
Date: Mon Oct 21 21:21:34 2019
New Revision: 353875
URL: https://svnweb.freebsd.org/changeset/base/353875

Log:
  Update tcsh to git revision 83c5be0 bringing in a number of bug fixes.
  
  Reported by:  sobomax
  MFC after:3 days
  Sponsored by: DARPA, AFRL
  Differential Revision:https://reviews.freebsd.org/D22099

Modified:
  head/contrib/tcsh/Fixes
  head/contrib/tcsh/README.md
  head/contrib/tcsh/glob.c
  head/contrib/tcsh/host.defs
  head/contrib/tcsh/sh.c
  head/contrib/tcsh/sh.err.c
  head/contrib/tcsh/sh.h
  head/contrib/tcsh/sh.hist.c
  head/contrib/tcsh/sh.lex.c
  head/contrib/tcsh/tc.const.c
  head/contrib/tcsh/tc.sig.h
  head/contrib/tcsh/tcsh.man.new
Directory Properties:
  head/contrib/tcsh/   (props changed)

Modified: head/contrib/tcsh/Fixes
==
--- head/contrib/tcsh/Fixes Mon Oct 21 20:28:38 2019(r353874)
+++ head/contrib/tcsh/Fixes Mon Oct 21 21:21:34 2019(r353875)
@@ -1,3 +1,11 @@
+  5. PR/113: Sobomax: avoid infinite loops for -c commands when stdout is
+ not a tty.
+  4. Avoid infinite loops during history loads when merging, print a better
+ error for errors during history load.
+  3. PR/88: Preserve empty arguments in :q
+  2. PR/94: Small apple issues (SAVESIGVEC, HOSTTYPE)
+  1. PR/81: Fix range matching issue where we were comparing with the
+ range character instead of the start of range. [l-z]* would match foo
  12. V6.21.00 - 20190508
  11. Abort history loading on words and lines too long
  https://bugzilla.redhat.com/show_bug.cgi?id=1598502

Modified: head/contrib/tcsh/README.md
==
--- head/contrib/tcsh/README.md Mon Oct 21 20:28:38 2019(r353874)
+++ head/contrib/tcsh/README.md Mon Oct 21 21:21:34 2019(r353875)
@@ -1,4 +1,4 @@
-# Tcsh
+# TCSH
 
 *C shell with file name completion and command line editing*
 
@@ -14,10 +14,10 @@ PLEASE file any bug reports, fixes, and code for new f
 > https://bugs.astron.com/
 
 Comments, questions, etc. (even flames) are welcome via email to
-the Tcsh Bugs mailing list:
+the tcsh mailing list:
 
-> tcsh-b...@astron.com
-> https://mailman.astron.com/
+> t...@astron.com  
+> https://mailman.astron.com/mailman/listinfo/tcsh
 
 [![Build Status][status]][travis]
 

Modified: head/contrib/tcsh/glob.c
==
--- head/contrib/tcsh/glob.cMon Oct 21 20:28:38 2019(r353874)
+++ head/contrib/tcsh/glob.cMon Oct 21 21:21:34 2019(r353875)
@@ -100,7 +100,7 @@ static  int  Lstat  (const char *, struct 
stat *);
 static int  Stat   (const char *, struct stat *sb);
 static Char*Strchr (Char *, int);
 #ifdef DEBUG
-static void qprintf(const Char *);
+static void qprintf(const char *, const Char *);
 #endif
 
 #defineDOLLAR  '$'
@@ -256,19 +256,20 @@ Strchr(Char *str, int ch)
 
 #ifdef DEBUG
 static void
-qprintf(const Char *s)
+qprintf(const char *pre, const Char *s)
 {
 const Char *p;
-
+   
+xprintf("%s", pre);
 for (p = s; *p; p++)
-   printf("%c", *p & 0xff);
-printf("\n");
+   xprintf("%c", *p & 0xff);
+xprintf("\n%s", pre);
 for (p = s; *p; p++)
-   printf("%c", *p & M_PROTECT ? '"' : ' ');
-printf("\n");
+   xprintf("%c", *p & M_PROTECT ? '"' : ' ');
+xprintf("\n%s", pre);
 for (p = s; *p; p++)
-   printf("%c", *p & M_META ? '_' : ' ');
-printf("\n");
+   xprintf("%c", *p & M_META ? '_' : ' ');
+xprintf("\n");
 }
 #endif /* DEBUG */
 
@@ -412,7 +413,7 @@ glob(const char *pattern, int flags, int (*errfunc) (c
 }
 *bufnext = EOS;
 #ifdef DEBUG
-qprintf(patbuf);
+qprintf("patbuf=", patbuf);
 #endif
 
 if ((err = glob1(patbuf, pglob, no_match)) != 0) {
@@ -709,7 +710,7 @@ match(const char *name, const Char *pat, const Char *p
 
 while (pat < patend || *name) {
size_t lwk, pwk;
-   __Char wc, wk;
+   __Char wc, wk, wc1;
 
c = *pat; /* Only for M_MASK bits */
if (*name == EOS)
@@ -744,18 +745,20 @@ match(const char *name, const Char *pat, const Char *p
pat += pwk;
pwk = One_Char_mbtowc(&wc, pat, MB_LEN_MAX);
}
+   wc1 = wc;
while ((*pat & M_MASK) != M_END) {
if ((*pat & M_MASK) == M_RNG) {
__Char wc2;
 
pat += pwk;
pwk = One_Char_mbtowc(&wc2, pat, MB_LEN_MAX);
-   if (globcharcoll(wc, wk, 0) <= 0 &&
+   if (globcharcoll(wc1, wk, 0) <= 0 &&
globcharcoll(wk, wc2, 0) <= 0)
ok = 1;
} else if (wc == wk)
ok = 1;
pat += pwk;
+   wc1 = wc;
   

svn commit: r353876 - head/sys/kern

2019-10-21 Thread Gleb Smirnoff
Author: glebius
Date: Mon Oct 21 23:12:14 2019
New Revision: 353876
URL: https://svnweb.freebsd.org/changeset/base/353876

Log:
  Assert that any epoch tracker belongs to the thread stack.
  
  Reviewed by:  kib

Modified:
  head/sys/kern/subr_epoch.c

Modified: head/sys/kern/subr_epoch.c
==
--- head/sys/kern/subr_epoch.c  Mon Oct 21 21:21:34 2019(r353875)
+++ head/sys/kern/subr_epoch.c  Mon Oct 21 23:12:14 2019(r353876)
@@ -366,9 +366,13 @@ _epoch_enter_preempt(epoch_t epoch, epoch_tracker_t et
struct thread *td;
 
MPASS(cold || epoch != NULL);
-   INIT_CHECK(epoch);
MPASS(epoch->e_flags & EPOCH_PREEMPT);
td = curthread;
+   MPASS((vm_offset_t)et >= td->td_kstack &&
+   (vm_offset_t)et + sizeof(struct epoch_tracker) <
+   td->td_kstack + td->td_kstack_pages * PAGE_SIZE);
+
+   INIT_CHECK(epoch);
 #ifdef EPOCH_TRACE
epoch_trace_enter(td, epoch, et, file, line);
 #endif
___
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"


svn commit: r353877 - head/sys/net

2019-10-21 Thread Kyle Evans
Author: kevans
Date: Tue Oct 22 00:18:16 2019
New Revision: 353877
URL: https://svnweb.freebsd.org/changeset/base/353877

Log:
  tuntap(4): properly declare if_tun and if_tap modules
  
  Simply adding MODULE_VERSION does not do the trick, because the modules
  haven't been declared. This should actually fix modfind/kldstat, which
  r351229 aimed and failed to do.
  
  This should make vm-bhyve do the right thing again when using the ports
  version, rather than the latest version not in ports.
  
  MFC after:3 days

Modified:
  head/sys/net/if_tuntap.c

Modified: head/sys/net/if_tuntap.c
==
--- head/sys/net/if_tuntap.cMon Oct 21 23:12:14 2019(r353876)
+++ head/sys/net/if_tuntap.cTue Oct 22 00:18:16 2019(r353877)
@@ -783,9 +783,15 @@ static moduledata_t tuntap_mod = {
0
 };
 
+/* We'll only ever have these two, so no need for a macro. */
+static moduledata_t tun_mod = { "if_tun", NULL, 0 };
+static moduledata_t tap_mod = { "if_tap", NULL, 0 };
+
 DECLARE_MODULE(if_tuntap, tuntap_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 MODULE_VERSION(if_tuntap, 1);
+DECLARE_MODULE(if_tun, tun_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 MODULE_VERSION(if_tun, 1);
+DECLARE_MODULE(if_tap, tap_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
 MODULE_VERSION(if_tap, 1);
 
 static int
___
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"