-/* $OpenBSD: sgec.c,v 1.15 2006/08/31 22:10:57 miod Exp $ */
+/* $OpenBSD: sgec.c,v 1.16 2008/08/22 17:09:06 deraadt Exp $ */
/* $NetBSD: sgec.c,v 1.5 2000/06/04 02:14:14 matt Exp $ */
/*
* Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
#include <net/if.h>
#include <net/if_dl.h>
+#include <net/if_media.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
void sgec_txintr(struct ze_softc *);
void zeinit(struct ze_softc *);
int zeioctl(struct ifnet *, u_long, caddr_t);
+int ze_ifmedia_change(struct ifnet *const);
+void ze_ifmedia_status(struct ifnet *const, struct ifmediareq *);
void zekick(struct ze_softc *);
int zereset(struct ze_softc *);
void zestart(struct ifnet *);
ether_ifattach(ifp);
printf(": address %s\n", ether_sprintf(sc->sc_ac.ac_enaddr));
+
+ ifmedia_init(&sc->sc_ifmedia, 0, ze_ifmedia_change,
+ ze_ifmedia_status);
+ ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5, 0, 0);
+ ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_10_5);
+ sc->sc_flags |= SGECF_LINKUP;
return;
/*
return;
}
+int
+ze_ifmedia_change(struct ifnet *const ifp)
+{
+ return (0);
+}
+
+void
+ze_ifmedia_status(struct ifnet *const ifp, struct ifmediareq *req)
+{
+ struct ze_softc *sc = ifp->if_softc;
+
+ req->ifm_status = IFM_AVALID;
+ if (sc->sc_flags & SGECF_LINKUP)
+ req->ifm_status |= IFM_ACTIVE;
+ req->ifm_active = IFM_10_5 | IFM_ETHER;
+}
+
/*
* Initialization of interface.
*/
struct ifnet *ifp = &sc->sc_if;
u_short tdes0;
+ sc->sc_flags |= SGECF_LINKUP;
while ((zc->zc_xmit[sc->sc_lastack].ze_tdr & ZE_TDR_OW) == 0) {
int idx = sc->sc_lastack;
printf("%s: transmit watchdog timeout\n",
sc->sc_dev.dv_xname);
if (tdes0 & (ZE_TDES0_LO | ZE_TDES0_NC))
- printf("%s: no carrier\n",
- sc->sc_dev.dv_xname);
+ sc->sc_flags &= ~SGECF_LINKUP;
if (tdes0 & ZE_TDES0_EC) {
printf("%s: excessive collisions, tdr %d\n",
sc->sc_dev.dv_xname,
}
break;
+ case SIOCSIFMEDIA:
+ case SIOCGIFMEDIA:
+ error = ifmedia_ioctl(ifp, (struct ifreq *)data,
+ &sc->sc_ifmedia, cmd);
+ break;
+
case SIOCSIFFLAGS:
if ((ifp->if_flags & IFF_UP) == 0 &&
(ifp->if_flags & IFF_RUNNING) != 0) {
-/* $OpenBSD: sgecvar.h,v 1.5 2006/08/30 19:28:11 miod Exp $ */
+/* $OpenBSD: sgecvar.h,v 1.6 2008/08/22 17:09:06 deraadt Exp $ */
/* $NetBSD: sgecvar.h,v 1.2 2000/06/04 02:14:14 matt Exp $ */
/*
* Copyright (c) 1999 Ludd, University of Lule}, Sweden. All rights reserved.
struct evcount sc_intrcnt; /* Interrupt counters */
struct arpcom sc_ac; /* Ethernet common part */
#define sc_if sc_ac.ac_if /* network-visible interface */
+ struct ifmedia sc_ifmedia;
bus_space_tag_t sc_iot;
bus_addr_t sc_ioh;
bus_dma_tag_t sc_dmat;
int sc_flags;
#define SGECF_SETUP 0x00000001 /* need to send setup packet */
#define SGECF_VXTQUIRKS 0x00000002 /* need VXT2000 care */
+#define SGECF_LINKUP 0x00000004 /* got link */
};
void sgec_attach(struct ze_softc *);