Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to ...



details:   https://anonhg.NetBSD.org/src/rev/51f87c6df410
branches:  trunk
changeset: 456806:51f87c6df410
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue May 28 07:41:46 2019 +0000

description:
Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.

diffstat:

 sys/arch/arm/at91/at91emac.c          |   6 ++++--
 sys/arch/arm/ep93xx/epe.c             |   6 ++++--
 sys/arch/arm/gemini/if_gmc.c          |   9 ++++++---
 sys/arch/arm/imx/if_enet.c            |   6 ++++--
 sys/arch/arm/sunxi/sun4i_emac.c       |  15 ++++++++-------
 sys/arch/arm/xscale/ixp425_if_npe.c   |  10 ++++++++--
 sys/arch/mac68k/dev/if_mc.c           |   7 +++++--
 sys/arch/macppc/dev/am79c950.c        |   7 +++++--
 sys/arch/macppc/dev/if_bm.c           |  10 +++++++---
 sys/arch/macppc/dev/if_gm.c           |   7 +++++--
 sys/arch/mips/adm5120/dev/if_admsw.c  |   6 ++++--
 sys/arch/mips/alchemy/dev/if_aumac.c  |   7 +++++--
 sys/arch/mips/atheros/dev/if_ae.c     |   7 +++++--
 sys/arch/mips/cavium/dev/octeon_gmx.c |  13 +++++++++----
 sys/arch/mips/sibyte/dev/sbmac.c      |   6 ++++--
 sys/arch/newsmips/apbus/if_sn.c       |   9 ++++++---
 sys/arch/playstation2/dev/emac3.c     |  10 +++++++---
 sys/arch/powerpc/booke/dev/pq3etsec.c |   6 ++++--
 sys/arch/powerpc/ibm4xx/dev/if_emac.c |   9 ++++++---
 sys/arch/sgimips/mace/if_mec.c        |   7 +++++--
 sys/arch/sun3/dev/if_ie.c             |   8 +++++---
 sys/dev/bi/if_ni.c                    |   9 ++++++---
 sys/dev/cadence/if_cemac.c            |   6 ++++--
 sys/dev/ic/aic6915.c                  |  11 ++++++++---
 sys/dev/ic/ath.c                      |   9 ++++++---
 sys/dev/ic/athn.c                     |   6 ++++--
 sys/dev/ic/atw.c                      |  10 +++++++---
 sys/dev/ic/awi.c                      |  13 +++++++++----
 sys/dev/ic/cs89x0.c                   |   6 ++++--
 sys/dev/ic/dm9000.c                   |   4 +++-
 sys/dev/ic/dp8390.c                   |   7 +++++--
 sys/dev/ic/dp83932.c                  |   8 ++++++--
 sys/dev/ic/elinkxl.c                  |  18 +++++++++++++-----
 sys/dev/ic/gem.c                      |   7 +++++--
 sys/dev/ic/hme.c                      |   7 +++++--
 sys/dev/ic/i82557.c                   |   7 +++++--
 sys/dev/ic/i82586.c                   |  15 +++++++++++----
 sys/dev/ic/i82596.c                   |  11 +++++++----
 sys/dev/ic/lan9118.c                  |  11 +++++++----
 sys/dev/ic/lance.c                    |   8 ++++++--
 sys/dev/ic/lemac.c                    |  10 +++++++---
 sys/dev/ic/mb86960.c                  |   7 +++++--
 sys/dev/ic/mtd803.c                   |   6 ++++--
 sys/dev/ic/pdq_ifsubr.c               |   9 ++++++---
 sys/dev/ic/rtl81x9.c                  |  17 ++++++++++-------
 sys/dev/ic/rtw.c                      |   6 ++++--
 sys/dev/ic/seeq8005.c                 |  14 +++++++++++---
 sys/dev/ic/sgec.c                     |   9 ++++++---
 sys/dev/ic/smc83c170.c                |   7 +++++--
 sys/dev/ic/tulip.c                    |  17 +++++++++++++++--
 sys/dev/ic/wi.c                       |  13 +++++++++----
 sys/dev/isa/if_iy.c                   |   9 +++++++--
 sys/dev/marvell/if_gfe.c              |   6 ++++--
 sys/dev/marvell/if_mvgbe.c            |   7 +++++--
 sys/dev/marvell/if_mvxpe.c            |   7 +++++--
 sys/dev/pci/if_age.c                  |   6 ++++--
 sys/dev/pci/if_alc.c                  |   4 +++-
 sys/dev/pci/if_ale.c                  |   5 +++--
 sys/dev/pci/if_bge.c                  |   7 +++++--
 sys/dev/pci/if_bnx.c                  |   7 +++++--
 sys/dev/pci/if_cas.c                  |   6 ++++--
 sys/dev/pci/if_de.c                   |  13 +++++++++----
 sys/dev/pci/if_dge.c                  |   7 +++++--
 sys/dev/pci/if_et.c                   |   6 ++++--
 sys/dev/pci/if_jme.c                  |   9 ++++++---
 sys/dev/pci/if_kse.c                  |  11 ++++++++---
 sys/dev/pci/if_lii.c                  |   7 +++++--
 sys/dev/pci/if_msk.c                  |   7 +++++--
 sys/dev/pci/if_nfe.c                  |   7 +++++--
 sys/dev/pci/if_pcn.c                  |   7 +++++--
 sys/dev/pci/if_sip.c                  |   7 +++++--
 sys/dev/pci/if_sk.c                   |   7 +++++--
 sys/dev/pci/if_ste.c                  |  11 ++++++++---
 sys/dev/pci/if_stge.c                 |  11 ++++++++---
 sys/dev/pci/if_ti.c                   |  14 ++++++++++----
 sys/dev/pci/if_tl.c                   |   9 ++++++---
 sys/dev/pci/if_txp.c                  |   7 +++++--
 sys/dev/pci/if_vge.c                  |  16 ++++++++++++----
 sys/dev/pci/if_vr.c                   |  10 +++++++---
 sys/dev/pci/if_vte.c                  |  10 +++++++---
 sys/dev/pci/if_xge.c                  |  11 ++++++++---
 sys/dev/pcmcia/if_ray.c               |   8 ++++++--
 sys/dev/pcmcia/if_xi.c                |  13 ++++++++-----
 sys/dev/qbus/if_il.c                  |   9 ++++++---
 sys/dev/qbus/if_qe.c                  |   9 ++++++---
 sys/dev/sbus/be.c                     |   7 +++++--
 sys/dev/sbus/qe.c                     |   6 ++++--
 sys/dev/scsipi/if_se.c                |   8 ++++++--
 sys/dev/usb/if_aue.c                  |  13 +++++++++----
 sys/dev/usb/if_axe.c                  |  13 +++++++++----
 sys/dev/usb/if_axen.c                 |   7 +++++--
 sys/dev/usb/if_cue.c                  |  13 +++++++++----
 sys/dev/usb/if_kue.c                  |  13 +++++++++----
 sys/dev/usb/if_mue.c                  |  10 +++++++---
 sys/dev/usb/if_otus.c                 |   9 ++++++---
 sys/dev/usb/if_udav.c                 |  15 ++++++++++-----
 sys/dev/usb/if_ure.c                  |  13 +++++++++----
 sys/dev/usb/if_url.c                  |  15 ++++++++++-----
 usr.sbin/cpuctl/arch/i386.c           |  15 +++++++++------
 99 files changed, 630 insertions(+), 276 deletions(-)

diffs (truncated from 4443 to 300 lines):

diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/arm/at91/at91emac.c
--- a/sys/arch/arm/at91/at91emac.c      Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/arm/at91/at91emac.c      Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: at91emac.c,v 1.28 2019/05/23 16:05:01 msaitoh Exp $    */
+/*     $NetBSD: at91emac.c,v 1.29 2019/05/28 07:41:46 msaitoh Exp $    */
 
 /*
  * Copyright (c) 2007 Embedtronics Oy
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.28 2019/05/23 16:05:01 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.29 2019/05/28 07:41:46 msaitoh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -807,6 +807,7 @@
 
        ifp->if_flags &= ~IFF_ALLMULTI;
 
+       ETHER_LOCK(ec);
        ETHER_FIRST_MULTI(step, ec, enm);
        while (enm != NULL) {
                if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -845,6 +846,7 @@
                ETHER_NEXT_MULTI(step, enm);
                nma++;
        }
+       ETHER_UNLOCK(ec);
 
        // program...
        DPRINTFN(1,("%s: en0 %02x:%02x:%02x:%02x:%02x:%02x\n", __FUNCTION__,
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/arm/ep93xx/epe.c
--- a/sys/arch/arm/ep93xx/epe.c Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/arm/ep93xx/epe.c Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: epe.c,v 1.42 2019/05/23 13:10:50 msaitoh Exp $ */
+/*     $NetBSD: epe.c,v 1.43 2019/05/28 07:41:46 msaitoh Exp $ */
 
 /*
  * Copyright (c) 2004 Jesse Off
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.42 2019/05/23 13:10:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.43 2019/05/28 07:41:46 msaitoh Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -722,6 +722,7 @@
 
        ifp->if_flags &= ~IFF_ALLMULTI;
 
+       ETHER_LOCK(ec);
        ETHER_FIRST_MULTI(step, ec, enm);
        while (enm != NULL) {
                if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -761,6 +762,7 @@
                ETHER_NEXT_MULTI(step, enm);
                nma++;
        }
+       ETHER_UNLOCK(ec);
 
        EPE_WRITE(AFP, 0);
        bus_space_write_region_1(sc->sc_iot, sc->sc_ioh, EPE_IndAd,
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/arm/gemini/if_gmc.c
--- a/sys/arch/arm/gemini/if_gmc.c      Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/arm/gemini/if_gmc.c      Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gmc.c,v 1.10 2019/05/23 13:10:50 msaitoh Exp $ */
+/* $NetBSD: if_gmc.c,v 1.11 2019/05/28 07:41:46 msaitoh Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -47,7 +47,7 @@
 #include <net/if_ether.h>
 #include <net/if_dl.h>
 
-__KERNEL_RCSID(0, "$NetBSD: if_gmc.c,v 1.10 2019/05/23 13:10:50 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gmc.c,v 1.11 2019/05/28 07:41:46 msaitoh Exp $");
 
 #define        MAX_TXSEG       32
 
@@ -195,6 +195,7 @@
 static void
 gmc_filter_change(struct gmc_softc *sc)
 {
+       struct ethercom *ec = &sc->sc_ec;
        struct ether_multi *enm;
        struct ether_multistep step;
        uint32_t mhash[2];
@@ -220,7 +221,8 @@
 
        mhash[0] = 0;
        mhash[1] = 0;
-       ETHER_FIRST_MULTI(step, &sc->sc_ec, enm);
+       ETHER_LOCK(ec);
+       ETHER_FIRST_MULTI(step, ec, enm);
        while (enm != NULL) {
                size_t i;
                if (memcmp(enm->enm_addrlo, enm->enm_addrhi, ETHER_ADDR_LEN)) {
@@ -231,6 +233,7 @@
                mhash[(i >> 5) & 1] |= 1 << (i & 31);
                ETHER_NEXT_MULTI(step, enm);
        }
+       ETHER_UNLOCK(ec);
 
        if (sc->sc_gmac_mcast_filter[0] != mhash[0]
            || sc->sc_gmac_mcast_filter[1] != mhash[1]) {
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/arm/imx/if_enet.c
--- a/sys/arch/arm/imx/if_enet.c        Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/arm/imx/if_enet.c        Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_enet.c,v 1.22 2019/05/24 00:13:25 msaitoh Exp $     */
+/*     $NetBSD: if_enet.c,v 1.23 2019/05/28 07:41:46 msaitoh Exp $     */
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.22 2019/05/24 00:13:25 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.23 2019/05/28 07:41:46 msaitoh Exp $");
 
 #include "vlan.h"
 
@@ -775,12 +775,14 @@
        } else {
                gaddr[0] = gaddr[1] = 0;
 
+               ETHER_LOCK(ec);
                ETHER_FIRST_MULTI(step, ec, enm);
                while (enm != NULL) {
                        crc = ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN);
                        gaddr[crc >> 31] |= 1 << ((crc >> 26) & 0x1f);
                        ETHER_NEXT_MULTI(step, enm);
                }
+               ETHER_UNLOCK(ec);
        }
 
        ENET_REG_WRITE(sc, ENET_GAUR, gaddr[0]);
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/arm/sunxi/sun4i_emac.c
--- a/sys/arch/arm/sunxi/sun4i_emac.c   Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/arm/sunxi/sun4i_emac.c   Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sun4i_emac.c,v 1.10 2019/05/23 13:10:50 msaitoh Exp $ */
+/* $NetBSD: sun4i_emac.c,v 1.11 2019/05/28 07:41:46 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2013-2017 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: sun4i_emac.c,v 1.10 2019/05/23 13:10:50 msaitoh Exp $");
+__KERNEL_RCSID(1, "$NetBSD: sun4i_emac.c,v 1.11 2019/05/28 07:41:46 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -839,7 +839,8 @@
 static void
 sun4i_emac_rx_hash(struct sun4i_emac_softc *sc)
 {
-       struct ifnet * const ifp = &sc->sc_ec.ec_if;
+       struct ethercom *ec = &sc->sc_ec;
+       struct ifnet * const ifp = &ec->ec_if;
        struct ether_multistep step;
        struct ether_multi *enm;
        uint32_t hash[2];
@@ -864,12 +865,12 @@
        if ((ifp->if_flags & IFF_PROMISC) == 0) {
                hash[0] = hash[1] = 0;
 
-               ETHER_LOCK(&sc->sc_ec);
-               ETHER_FIRST_MULTI(step, &sc->sc_ec, enm);
+               ETHER_LOCK(ec);
+               ETHER_FIRST_MULTI(step, ec, enm);
                while (enm != NULL) {
                        if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
                            ETHER_ADDR_LEN)) {
-                               ETHER_UNLOCK(&sc->sc_ec);
+                               ETHER_UNLOCK(ec);
                                /*
                                 * We must listen to a range of multicast
                                 * addresses. For now, just accept all
@@ -895,7 +896,7 @@
                        hash[crc >> 5] |= __BIT(crc & 31);
                        ETHER_NEXT_MULTI(step, enm);
                }
-               ETHER_UNLOCK(&sc->sc_ec);
+               ETHER_UNLOCK(ec);
                ifp->if_flags &= ~IFF_ALLMULTI;
                rxctl |= EMAC_RX_CTL_MHF;
        }
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/arm/xscale/ixp425_if_npe.c
--- a/sys/arch/arm/xscale/ixp425_if_npe.c       Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/arm/xscale/ixp425_if_npe.c       Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ixp425_if_npe.c,v 1.40 2019/05/23 10:40:39 msaitoh Exp $ */
+/*     $NetBSD: ixp425_if_npe.c,v 1.41 2019/05/28 07:41:46 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2006 Sam Leffler.  All rights reserved.
@@ -28,7 +28,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/if_npe.c,v 1.1 2006/11/19 23:55:23 sam Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: ixp425_if_npe.c,v 1.40 2019/05/23 10:40:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixp425_if_npe.c,v 1.41 2019/05/28 07:41:46 msaitoh Exp $");
 
 /*
  * Intel XScale NPE Ethernet driver.
@@ -369,11 +369,13 @@
                memset(clr, 0, ETHER_ADDR_LEN);
                memset(set, 0xff, ETHER_ADDR_LEN);
 
+               ETHER_LOCK(ec);
                ETHER_FIRST_MULTI(step, ec, enm);
                while (enm != NULL) {
                        if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
                            ETHER_ADDR_LEN)) {
                                ifp->if_flags |= IFF_ALLMULTI;
+                               ETHER_UNLOCK(ec);
                                goto all_multi;
                        }
 
@@ -384,6 +386,7 @@
 
                        ETHER_NEXT_MULTI(step, enm);
                }
+               ETHER_UNLOCK(ec);
 
                for (i = 0; i < ETHER_ADDR_LEN; i++) {
                        mask[i] = set[i] | ~clr[i];
@@ -999,6 +1002,7 @@
 
                                        /* Multicast */
 
+                                       ETHER_LOCK(ec);
                                        ETHER_FIRST_MULTI(step, ec, enm);
                                        while (enm != NULL) {
                                                uint64_t lowint, highint, dest;
@@ -1017,6 +1021,8 @@
                                                }
                                                ETHER_NEXT_MULTI(step, enm);
                                        }
+                                       ETHER_UNLOCK(ec);
+
                                        if (match == 0) {
                                                /* Discard it */
 #if 0
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/mac68k/dev/if_mc.c
--- a/sys/arch/mac68k/dev/if_mc.c       Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/mac68k/dev/if_mc.c       Tue May 28 07:41:46 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_mc.c,v 1.50 2019/05/23 10:30:35 msaitoh Exp $       */
+/*     $NetBSD: if_mc.c,v 1.51 2019/05/28 07:41:46 msaitoh Exp $       */
 
 /*-
  * Copyright (c) 1997 David Huang <khym%azeotrope.org@localhost>
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.50 2019/05/23 10:30:35 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.51 2019/05/28 07:41:46 msaitoh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -659,6 +659,7 @@
         */
 
        *((uint32_t *)af) = *((uint32_t *)af + 1) = 0;
+       ETHER_LOCK(ec);
        ETHER_FIRST_MULTI(step, ec, enm);
        while (enm != NULL) {
                if (ETHER_CMP(enm->enm_addrlo, enm->enm_addrhi)) {
@@ -670,6 +671,7 @@
                         * ranges is for IP multicast routing, for which the
                         * range is big enough to require all bits set.)
                         */
+                       ETHER_UNLOCK(ec);
                        goto allmulti;
                }
 
@@ -688,6 +690,7 @@
 
                ETHER_NEXT_MULTI(step, enm);
        }
+       ETHER_UNLOCK(ec);
        ifp->if_flags &= ~IFF_ALLMULTI;
        return;
 
diff -r 9ecb2d79edc1 -r 51f87c6df410 sys/arch/macppc/dev/am79c950.c
--- a/sys/arch/macppc/dev/am79c950.c    Tue May 28 07:39:16 2019 +0000
+++ b/sys/arch/macppc/dev/am79c950.c    Tue May 28 07:41:46 2019 +0000



Home | Main Index | Thread Index | Old Index