Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/mii Add detachment support to the MII layer.



details:   https://anonhg.NetBSD.org/src/rev/c2db85142c00
branches:  trunk
changeset: 481378:c2db85142c00
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 27 16:44:30 2000 +0000

description:
Add detachment support to the MII layer.

diffstat:

 sys/dev/mii/exphy.c       |   8 ++++-
 sys/dev/mii/icsphy.c      |   8 ++++-
 sys/dev/mii/inphy.c       |   8 ++++-
 sys/dev/mii/iophy.c       |   8 ++++-
 sys/dev/mii/lxtphy.c      |   8 ++++-
 sys/dev/mii/mii.c         |  70 +++++++++++++++++++++++++++++++++++++++++++++-
 sys/dev/mii/mii_physubr.c |  49 ++++++++++++++++++++++++++++++++-
 sys/dev/mii/miivar.h      |   8 ++++-
 sys/dev/mii/nsphy.c       |   8 ++++-
 sys/dev/mii/qsphy.c       |   8 ++++-
 sys/dev/mii/sqphy.c       |   8 ++++-
 sys/dev/mii/tlphy.c       |   8 ++++-
 sys/dev/mii/tqphy.c       |   8 ++++-
 sys/dev/mii/ukphy.c       |   8 ++++-
 14 files changed, 189 insertions(+), 26 deletions(-)

diffs (truncated from 501 to 300 lines):

diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/exphy.c
--- a/sys/dev/mii/exphy.c       Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/exphy.c       Thu Jan 27 16:44:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exphy.c,v 1.18 1999/11/12 18:12:59 thorpej Exp $       */
+/*     $NetBSD: exphy.c,v 1.19 2000/01/27 16:44:30 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -88,7 +88,8 @@
 void   exphyattach __P((struct device *, struct device *, void *));
 
 struct cfattach exphy_ca = {
-       sizeof(struct mii_softc), exphymatch, exphyattach
+       sizeof(struct mii_softc), exphymatch, exphyattach, mii_detach,
+           mii_activate
 };
 
 int    exphy_service __P((struct mii_softc *, struct mii_data *, int));
@@ -165,6 +166,9 @@
 {
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
 
+       if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+               return (ENXIO);
+
        /*
         * We can't isolate the 3Com PHY, so it has to be the only one!
         */
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/icsphy.c
--- a/sys/dev/mii/icsphy.c      Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/icsphy.c      Thu Jan 27 16:44:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icsphy.c,v 1.12 1999/11/12 18:13:00 thorpej Exp $      */
+/*     $NetBSD: icsphy.c,v 1.13 2000/01/27 16:44:30 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -91,7 +91,8 @@
 void   icsphyattach __P((struct device *, struct device *, void *));
 
 struct cfattach icsphy_ca = {
-       sizeof(struct mii_softc), icsphymatch, icsphyattach
+       sizeof(struct mii_softc), icsphymatch, icsphyattach, mii_detach,
+           mii_activate
 };
 
 int    icsphy_service __P((struct mii_softc *, struct mii_data *, int));
@@ -151,6 +152,9 @@
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        int reg;
 
+       if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+               return (ENXIO);
+
        switch (cmd) {
        case MII_POLLSTAT:
                /*
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/inphy.c
--- a/sys/dev/mii/inphy.c       Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/inphy.c       Thu Jan 27 16:44:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: inphy.c,v 1.13 1999/11/12 18:13:00 thorpej Exp $       */
+/*     $NetBSD: inphy.c,v 1.14 2000/01/27 16:44:30 thorpej Exp $       */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -92,7 +92,8 @@
 void   inphyattach __P((struct device *, struct device *, void *));
 
 struct cfattach inphy_ca = {
-       sizeof(struct mii_softc), inphymatch, inphyattach
+       sizeof(struct mii_softc), inphymatch, inphyattach, mii_detach,
+           mii_activate
 };
 
 int    inphy_service __P((struct mii_softc *, struct mii_data *, int));
@@ -158,6 +159,9 @@
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        int reg;
 
+       if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+               return (ENXIO);
+
        switch (cmd) {
        case MII_POLLSTAT:
                /*
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/iophy.c
--- a/sys/dev/mii/iophy.c       Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/iophy.c       Thu Jan 27 16:44:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: iophy.c,v 1.3 1999/11/12 18:13:00 thorpej Exp $        */
+/*     $NetBSD: iophy.c,v 1.4 2000/01/27 16:44:30 thorpej Exp $        */
 
 /*
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -90,7 +90,8 @@
 void   iophyattach __P((struct device *, struct device *, void *));
 
 struct cfattach iophy_ca = {
-       sizeof(struct mii_softc), iophymatch, iophyattach
+       sizeof(struct mii_softc), iophymatch, iophyattach, mii_detach,
+           mii_activate
 };
 
 int    iophy_service __P((struct mii_softc *, struct mii_data *, int));
@@ -160,6 +161,9 @@
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        int reg;
 
+       if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+               return (ENXIO);
+
        switch (cmd) {
        case MII_POLLSTAT:
                /*
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/lxtphy.c
--- a/sys/dev/mii/lxtphy.c      Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/lxtphy.c      Thu Jan 27 16:44:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lxtphy.c,v 1.14 1999/12/21 10:47:00 pk Exp $   */
+/*     $NetBSD: lxtphy.c,v 1.15 2000/01/27 16:44:30 thorpej Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -92,7 +92,8 @@
 void   lxtphyattach __P((struct device *, struct device *, void *));
 
 struct cfattach lxtphy_ca = {
-       sizeof(struct mii_softc), lxtphymatch, lxtphyattach
+       sizeof(struct mii_softc), lxtphymatch, lxtphyattach, mii_detach,
+           mii_activate
 };
 
 int    lxtphy_service __P((struct mii_softc *, struct mii_data *, int));
@@ -151,6 +152,9 @@
        struct ifmedia_entry *ife = mii->mii_media.ifm_cur;
        int reg;
 
+       if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+               return (ENXIO);
+
        switch (cmd) {
        case MII_POLLSTAT:
                /*
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/mii.c
--- a/sys/dev/mii/mii.c Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/mii.c Thu Jan 27 16:44:30 2000 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: mii.c,v 1.16 1999/11/12 18:13:00 thorpej Exp $ */
+/*     $NetBSD: mii.c,v 1.17 2000/01/27 16:44:30 thorpej Exp $ */
 
 /*-
- * Copyright (c) 1998 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -151,6 +151,72 @@
        }
 }
 
+void
+mii_phy_activate(mii, act, phyloc, offloc)
+       struct mii_data *mii;
+       enum devact act;
+       int phyloc, offloc;
+{
+       struct mii_softc *child;
+
+       if (phyloc != MII_PHY_ANY && offloc != MII_PHY_ANY)
+               panic("mii_phy_detach: phyloc and offloc specified");
+
+       if ((mii->mii_flags & MIIF_INITDONE) == 0)
+               return;
+
+       for (child = LIST_FIRST(&mii->mii_phys);
+            child != NULL; child = LIST_NEXT(child, mii_list)) {
+               if (phyloc != MII_PHY_ANY || offloc != MII_OFFSET_ANY) {
+                       if (phyloc != MII_PHY_ANY &&
+                           phyloc != child->mii_phy)
+                               continue;
+                       if (offloc != MII_OFFSET_ANY &&
+                           offloc != child->mii_offset)
+                               continue;
+               }
+               switch (act) {
+               case DVACT_ACTIVATE:
+                       panic("mii_phy_activate: DVACT_ACTIVATE");
+                       break;
+
+               case DVACT_DEACTIVATE:
+                       if (config_deactivate(&child->mii_dev) != 0)
+                               panic("%s: config_activate(%d) failed\n",
+                                   child->mii_dev.dv_xname, act);
+               }
+       }
+}
+
+void
+mii_phy_detach(mii, phyloc, offloc)
+       struct mii_data *mii;
+       int phyloc, offloc;
+{
+       struct mii_softc *child, *nchild;
+
+       if (phyloc != MII_PHY_ANY && offloc != MII_PHY_ANY)
+               panic("mii_phy_detach: phyloc and offloc specified");
+
+       if ((mii->mii_flags & MIIF_INITDONE) == 0)
+               return;
+
+       for (child = LIST_FIRST(&mii->mii_phys);
+            child != NULL; child = nchild) {
+               nchild = LIST_NEXT(child, mii_list);
+               if (phyloc != MII_PHY_ANY || offloc != MII_OFFSET_ANY) {
+                       if (phyloc != MII_PHY_ANY &&
+                           phyloc != child->mii_phy)
+                               continue;
+                       if (offloc != MII_OFFSET_ANY &&
+                           offloc != child->mii_offset)
+                               continue;
+               }
+               LIST_REMOVE(child, mii_list);
+               (void) config_detach(&child->mii_dev, DETACH_FORCE);
+       }
+}
+
 int
 mii_print(aux, pnp)
        void *aux;
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/mii_physubr.c
--- a/sys/dev/mii/mii_physubr.c Thu Jan 27 16:28:32 2000 +0000
+++ b/sys/dev/mii/mii_physubr.c Thu Jan 27 16:44:30 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mii_physubr.c,v 1.8 1999/11/12 18:13:00 thorpej Exp $  */
+/*     $NetBSD: mii_physubr.c,v 1.9 2000/01/27 16:44:30 thorpej Exp $  */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -143,6 +143,9 @@
        struct mii_softc *sc = arg;
        int s, bmsr;
 
+       if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0)
+               return;
+
        s = splnet();
        sc->mii_flags &= ~MIIF_DOINGAUTO;
        bmsr = PHY_READ(sc, MII_BMSR);
@@ -254,3 +257,47 @@
 #undef ADD
 #undef PRINT
 }
+
+void
+mii_delete_media(sc)
+       struct mii_softc *sc;
+{
+       struct mii_data *mii = sc->mii_pdata;
+
+       ifmedia_delete_instance(&mii->mii_media, sc->mii_inst);
+}
+
+int
+mii_activate(self, act)
+       struct device *self;
+       enum devact act;
+{
+       int rv = 0;
+
+       switch (act) {
+       case DVACT_ACTIVATE:
+               rv = EOPNOTSUPP;
+               break;
+
+       case DVACT_DEACTIVATE:
+               /* Nothing special to do. */
+               break;
+       }
+
+       return (rv);
+}
+
+int
+mii_detach(self, flags)
+       struct device *self;
+       int flags;
+{
+       struct mii_softc *sc = (void *) self;
+
+       if (sc->mii_flags & MIIF_DOINGAUTO)
+               untimeout(mii_phy_auto_timeout, sc);
+
+       mii_delete_media(sc);
+
+       return (0);
+}
diff -r d11b83b8dbb3 -r c2db85142c00 sys/dev/mii/miivar.h
--- a/sys/dev/mii/miivar.h      Thu Jan 27 16:28:32 2000 +0000



Home | Main Index | Thread Index | Old Index