summaryrefslogtreecommitdiffstats
path: root/sys/dev/ed
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2006-01-27 08:25:47 +0000
committerimp <imp@FreeBSD.org>2006-01-27 08:25:47 +0000
commit6efae9acb29b8c64923ae1ee77e7cc82e5e8a0e2 (patch)
tree54cb06ac114294dd37f2a97967880e27b26cc508 /sys/dev/ed
parentc4eb978faff364387f77445334bee6d7ba640725 (diff)
downloadFreeBSD-src-6efae9acb29b8c64923ae1ee77e7cc82e5e8a0e2.zip
FreeBSD-src-6efae9acb29b8c64923ae1ee77e7cc82e5e8a0e2.tar.gz
Create mediachg functions for the 3c503 and hpp cards. This is used
to properly configure the right interface to use. Also call the mediachg function when we set flags UP and are already running. If this were a pure ifmedia driver, we'd not need to do this since we'd be ignoring the linkX flags. This reduces the number of ifdefs to support sub-devices a little as a nice side effect. It also reduces the number of hpp interfaces exposed by 33%.
Diffstat (limited to 'sys/dev/ed')
-rw-r--r--sys/dev/ed/if_ed.c34
-rw-r--r--sys/dev/ed/if_ed_3c503.c22
-rw-r--r--sys/dev/ed/if_ed_hpp.c4
-rw-r--r--sys/dev/ed/if_edvar.h1
4 files changed, 28 insertions, 33 deletions
diff --git a/sys/dev/ed/if_ed.c b/sys/dev/ed/if_ed.c
index f16e517..d94a688 100644
--- a/sys/dev/ed/if_ed.c
+++ b/sys/dev/ed/if_ed.c
@@ -573,20 +573,8 @@ ed_init_locked(struct ed_softc *sc)
*/
ed_nic_outb(sc, ED_P0_TCR, 0);
-#ifdef ED_3C503
- /*
- * If this is a 3Com board, the tranceiver must be software enabled
- * (there is no settable hardware default).
- */
- if (sc->vendor == ED_VENDOR_3COM) {
- if (ifp->if_flags & IFF_LINK2)
- ed_asic_outb(sc, ED_3COM_CR, 0);
- else
- ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
- }
-#endif
if (sc->sc_mediachg)
- sc->sc_mediachg(sc);
+ sc->sc_mediachg(sc);
/*
* Set 'running' flag, and clear output active flag.
@@ -1227,12 +1215,15 @@ ed_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
case SIOCSIFFLAGS:
/*
* If the interface is marked up and stopped, then start it.
+ * If we're up and already running, then it may be a mediachg.
* If it is marked down and running, then stop it.
*/
ED_LOCK(sc);
if (ifp->if_flags & IFF_UP) {
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
ed_init_locked(sc);
+ else if (sc->sc_mediachg)
+ sc->sc_mediachg(sc);
} else {
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
ed_stop(sc);
@@ -1245,23 +1236,6 @@ ed_ioctl(struct ifnet *ifp, u_long command, caddr_t data)
*/
ed_setrcr(sc);
-#ifdef ED_3C503
- /*
- * An unfortunate hack to provide the (required) software
- * control of the tranceiver for 3Com/HP boards.
- * The LINK2 flag disables the tranceiver if set.
- */
- if (sc->vendor == ED_VENDOR_3COM) {
- if (ifp->if_flags & IFF_LINK2)
- ed_asic_outb(sc, ED_3COM_CR, 0);
- else
- ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
- }
-#endif
-#ifdef ED_HPP
- if (sc->vendor == ED_VENDOR_HP)
- ed_hpp_set_physical_link(sc);
-#endif
ED_UNLOCK(sc);
break;
diff --git a/sys/dev/ed/if_ed_3c503.c b/sys/dev/ed/if_ed_3c503.c
index c0fcd67..55b7046 100644
--- a/sys/dev/ed/if_ed_3c503.c
+++ b/sys/dev/ed/if_ed_3c503.c
@@ -60,6 +60,8 @@ __FBSDID("$FreeBSD$");
#include <dev/ed/if_edreg.h>
#include <dev/ed/if_edvar.h>
+static void ed_3c503_mediachg(struct ed_softc *sc);
+
/*
* Probe and vendor-specific initialization routine for 3Com 3c503 boards
*/
@@ -335,7 +337,25 @@ ed_probe_3Com(device_t dev, int port_rid, int flags)
ed_asic_outb(sc, ED_3COM_VPTR1, 0xff);
ed_asic_outb(sc, ED_3COM_VPTR0, 0x00);
- return (ed_clear_memory(dev));
+ error = ed_clear_memory(dev);
+ if (error == 0)
+ sc->sc_mediachg = ed_3c503_mediachg;
+ return (error);
+}
+
+static void
+ed_3c503_mediachg(struct ed_softc *sc)
+{
+ struct ifnet *ifp = sc->ifp;
+
+ /*
+ * If this is a 3Com board, the tranceiver must be software enabled
+ * (there is no settable hardware default).
+ */
+ if (ifp->if_flags & IFF_LINK2)
+ ed_asic_outb(sc, ED_3COM_CR, 0);
+ else
+ ed_asic_outb(sc, ED_3COM_CR, ED_3COM_CR_XSEL);
}
#endif /* ED_3C503 */
diff --git a/sys/dev/ed/if_ed_hpp.c b/sys/dev/ed/if_ed_hpp.c
index 2dac21d..c541705 100644
--- a/sys/dev/ed/if_ed_hpp.c
+++ b/sys/dev/ed/if_ed_hpp.c
@@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
static void ed_hpp_writemem(struct ed_softc *, uint8_t *, uint16_t,
uint16_t);
+static void ed_hpp_set_physical_link(struct ed_softc *sc);
/*
* Interrupt conversion table for the HP PC LAN+
@@ -355,6 +356,7 @@ ed_probe_HP_pclanp(device_t dev, int port_rid, int flags)
return (ENXIO);
}
+ sc->sc_mediachg = ed_hpp_set_physical_link;
return (0);
}
@@ -362,7 +364,7 @@ ed_probe_HP_pclanp(device_t dev, int port_rid, int flags)
* HP PC Lan+ : Set the physical link to use AUI or TP/TL.
*/
-void
+static void
ed_hpp_set_physical_link(struct ed_softc *sc)
{
struct ifnet *ifp = sc->ifp;
diff --git a/sys/dev/ed/if_edvar.h b/sys/dev/ed/if_edvar.h
index 7f8f086..66ca79b 100644
--- a/sys/dev/ed/if_edvar.h
+++ b/sys/dev/ed/if_edvar.h
@@ -220,7 +220,6 @@ void ed_pio_writemem(struct ed_softc *, uint8_t *, uint16_t, uint16_t);
/* The following is unsatisfying XXX */
#ifdef ED_HPP
-void ed_hpp_set_physical_link(struct ed_softc *);
void ed_hpp_readmem(struct ed_softc *, bus_size_t, uint8_t *, uint16_t);
u_short ed_hpp_write_mbufs(struct ed_softc *, struct mbuf *, int);
#endif
OpenPOWER on IntegriCloud