-/* $OpenBSD: if_re_cardbus.c,v 1.30 2022/04/06 18:59:28 naddy Exp $ */
+/* $OpenBSD: if_re_cardbus.c,v 1.31 2024/01/19 03:46:15 dlg Exp $ */
/*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
struct re_cardbus_softc *csc = (void *)self;
struct rl_softc *sc = &csc->sc_rl;
struct cardbus_devfunc *ct = csc->ct;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- /* Remove timeout handler */
- timeout_del(&sc->timer_handle);
-
- /* Detach PHY */
- if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
- mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
-
- /* Delete media stuff */
- ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
- ether_ifdetach(ifp);
- if_detach(ifp);
+ re_detach(sc);
/* Disable interrupts */
if (sc->sc_ih != NULL)
-/* $OpenBSD: re.c,v 1.216 2023/11/10 15:51:20 bluhm Exp $ */
+/* $OpenBSD: re.c,v 1.217 2024/01/19 03:46:14 dlg Exp $ */
/* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */
/*
* Copyright (c) 1997, 1998-2003
#endif
#if NKSTAT > 0
void re_kstat_attach(struct rl_softc *);
+void re_kstat_detach(struct rl_softc *);
#endif
void in_delayed_cksum(struct mbuf *);
return (1);
}
+void
+re_detach(struct rl_softc *sc)
+{
+ struct ifnet *ifp = &sc->sc_arpcom.ac_if;
+
+#if NKSTAT > 0
+ re_kstat_detach(sc);
+#endif
+
+ /* Remove timeout handler */
+ timeout_del(&sc->timer_handle);
+
+ /* Detach PHY */
+ if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
+ mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
+
+ /* Delete media stuff */
+ ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
+ ether_ifdetach(ifp);
+ if_detach(ifp);
+}
int
re_newbuf(struct rl_softc *sc)
bus_dmamem_unmap(sc->sc_dmat,
(caddr_t)re_ks_sc->re_ks_sc_stats, sizeof(struct re_stats));
freedma:
- bus_dmamem_free(sc->sc_dmat, &re_ks_sc->re_ks_sc_seg, 1);
+ bus_dmamem_free(sc->sc_dmat, &re_ks_sc->re_ks_sc_seg,
+ re_ks_sc->re_ks_sc_nsegs);
destroy:
bus_dmamap_destroy(sc->sc_dmat, re_ks_sc->re_ks_sc_map);
free:
free(re_ks_sc, M_DEVBUF, sizeof(*re_ks_sc));
}
+
+void
+re_kstat_detach(struct rl_softc *sc)
+{
+ struct kstat *ks = sc->rl_kstat;
+ struct re_kstat_softc *re_ks_sc;
+
+ if (ks == NULL)
+ return;
+
+ kstat_remove(ks);
+ re_ks_sc = ks->ks_ptr;
+ kstat_destroy(ks);
+
+ bus_dmamap_unload(sc->sc_dmat, re_ks_sc->re_ks_sc_map);
+ bus_dmamem_unmap(sc->sc_dmat,
+ (caddr_t)re_ks_sc->re_ks_sc_stats, sizeof(struct re_stats));
+ bus_dmamem_free(sc->sc_dmat, &re_ks_sc->re_ks_sc_seg,
+ re_ks_sc->re_ks_sc_nsegs);
+ bus_dmamap_destroy(sc->sc_dmat, re_ks_sc->re_ks_sc_map);
+ free(re_ks_sc, M_DEVBUF, sizeof(*re_ks_sc));
+}
#endif /* NKSTAT > 0 */
-/* $OpenBSD: revar.h,v 1.7 2010/07/27 20:53:39 kettenis Exp $ */
+/* $OpenBSD: revar.h,v 1.8 2024/01/19 03:46:15 dlg Exp $ */
/*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
int re_intr(void *);
int re_attach(struct rl_softc *, const char *);
+void re_detach(struct rl_softc *);
void re_reset(struct rl_softc *);
int re_init(struct ifnet *);
void re_stop(struct ifnet *);
-/* $OpenBSD: if_re_pci.c,v 1.56 2022/03/11 18:00:48 mpi Exp $ */
+/* $OpenBSD: if_re_pci.c,v 1.57 2024/01/19 03:46:15 dlg Exp $ */
/*
* Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org>
{
struct re_pci_softc *psc = (struct re_pci_softc *)self;
struct rl_softc *sc = &psc->sc_rl;
- struct ifnet *ifp = &sc->sc_arpcom.ac_if;
- /* Remove timeout handler */
- timeout_del(&sc->timer_handle);
-
- /* Detach PHY */
- if (LIST_FIRST(&sc->sc_mii.mii_phys) != NULL)
- mii_detach(&sc->sc_mii, MII_PHY_ANY, MII_OFFSET_ANY);
-
- /* Delete media stuff */
- ifmedia_delete_instance(&sc->sc_mii.mii_media, IFM_INST_ANY);
- ether_ifdetach(ifp);
- if_detach(ifp);
+ re_detach(sc);
/* Disable interrupts */
if (sc->sc_ih != NULL)