On Fri, Jul 15, 2022 at 04:51:25PM +0200, Alexander Bluhm wrote: > On Fri, Jul 15, 2022 at 02:05:40AM +0200, Alexander Bluhm wrote: > > If anyone has some of these old network drivers, please test setting > > media type with ifconfig. > > Updated diff. I have compile tested it on amd64, i386, octeon, > macppc, sparc64. Setting media for gem(4) and bge(4) works.
Also compiles and boots on powerpc64 and arm64. How do we proceed here? The diff touches 70 drivers, that cannot be tested due to missing hardware. But I need the MP safe interface in ifmedia. Should I commit the API and the few drivers for the hardware I have? And then slowly commit the remaining drivers. Or put everything in and see what happens? ok? bluhm > Index: arch/octeon/dev/cn30xxgmx.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/arch/octeon/dev/cn30xxgmx.c,v > retrieving revision 1.52 > diff -u -p -r1.52 cn30xxgmx.c > --- arch/octeon/dev/cn30xxgmx.c 6 Apr 2022 18:59:26 -0000 1.52 > +++ arch/octeon/dev/cn30xxgmx.c 14 Jul 2022 22:46:20 -0000 > @@ -725,19 +725,21 @@ cn30xxgmx_reset_timing(struct cn30xxgmx_ > int > cn30xxgmx_reset_flowctl(struct cn30xxgmx_port_softc *sc) > { > - struct ifmedia_entry *ife = sc->sc_port_mii->mii_media.ifm_cur; > + uint64_t media; > + > + ifmedia_current(&sc->sc_port_mii->mii_media, &media, NULL); > > /* > * Get flow control negotiation result. > */ > #ifdef GMX_802_3X_DISABLE_AUTONEG > /* Tentative support for SEIL-compat.. */ > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > sc->sc_port_flowflags &= ~IFM_ETH_FMASK; > } > #else > /* Default configuration of NetBSD */ > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO && > + if (IFM_SUBTYPE(media) == IFM_AUTO && > (sc->sc_port_mii->mii_media_active & IFM_ETH_FMASK) != > sc->sc_port_flowflags) { > sc->sc_port_flowflags = > Index: dev/ic/an.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/an.c,v > retrieving revision 1.79 > diff -u -p -r1.79 an.c > --- dev/ic/an.c 21 Apr 2022 21:03:02 -0000 1.79 > +++ dev/ic/an.c 14 Jul 2022 22:30:51 -0000 > @@ -1277,17 +1277,18 @@ an_media_change(struct ifnet *ifp) > { > struct an_softc *sc = ifp->if_softc; > struct ieee80211com *ic = &sc->sc_ic; > - struct ifmedia_entry *ime; > + uint64_t media; > enum ieee80211_opmode newmode; > int i, rate, error = 0; > > - ime = ic->ic_media.ifm_cur; > - if (IFM_SUBTYPE(ime->ifm_media) == IFM_AUTO) { > + ifmedia_current(&ic->ic_media, &media, NULL); > + > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > i = -1; > } else { > struct ieee80211_rateset *rs = > &ic->ic_sup_rates[IEEE80211_MODE_11B]; > - rate = ieee80211_media2rate(ime->ifm_media); > + rate = ieee80211_media2rate(media); > if (rate == 0) > return EINVAL; > for (i = 0; i < rs->rs_nrates; i++) { > @@ -1303,13 +1304,13 @@ an_media_change(struct ifnet *ifp) > } > > #ifndef IEEE80211_STA_ONLY > - if (ime->ifm_media & IFM_IEEE80211_ADHOC) > + if (media & IFM_IEEE80211_ADHOC) > newmode = IEEE80211_M_IBSS; > - else if (ime->ifm_media & IFM_IEEE80211_HOSTAP) > + else if (media & IFM_IEEE80211_HOSTAP) > newmode = IEEE80211_M_HOSTAP; > else > #endif > - if (ime->ifm_media & IFM_IEEE80211_MONITOR) > + if (media & IFM_IEEE80211_MONITOR) > newmode = IEEE80211_M_MONITOR; > else > newmode = IEEE80211_M_STA; > @@ -1323,7 +1324,8 @@ an_media_change(struct ifnet *ifp) > else > error = 0; > } > - ifp->if_baudrate = ifmedia_baudrate(ic->ic_media.ifm_cur->ifm_media); > + ifmedia_current(&ic->ic_media, &media, NULL); > + ifp->if_baudrate = ifmedia_baudrate(media); > > return error; > } > Index: dev/ic/elink3.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/elink3.c,v > retrieving revision 1.98 > diff -u -p -r1.98 elink3.c > --- dev/ic/elink3.c 12 Dec 2020 11:48:52 -0000 1.98 > +++ dev/ic/elink3.c 14 Jul 2022 22:30:51 -0000 > @@ -571,6 +571,7 @@ epinit(struct ep_softc *sc) > register struct ifnet *ifp = &sc->sc_arpcom.ac_if; > bus_space_tag_t iot = sc->sc_iot; > bus_space_handle_t ioh = sc->sc_ioh; > + u_int data; > int i; > > /* make sure any pending reset has completed before touching board */ > @@ -650,7 +651,8 @@ epinit(struct ep_softc *sc) > bus_space_write_2(iot, ioh, EP_COMMAND, ACK_INTR | 0xff); > > epsetfilter(sc); > - epsetmedia(sc, sc->sc_mii.mii_media.ifm_cur->ifm_data); > + ifmedia_current(&sc->sc_mii.mii_media, NULL, &data); > + epsetmedia(sc, data); > > bus_space_write_2(iot, ioh, EP_COMMAND, RX_ENABLE); > bus_space_write_2(iot, ioh, EP_COMMAND, TX_ENABLE); > @@ -687,8 +689,10 @@ int > ep_media_change(struct ifnet *ifp) > { > register struct ep_softc *sc = ifp->if_softc; > + u_int data; > > - return epsetmedia(sc, sc->sc_mii.mii_media.ifm_cur->ifm_data); > + ifmedia_current(&sc->sc_mii.mii_media, NULL, &data); > + return epsetmedia(sc, data); > } > > /* > @@ -887,8 +891,8 @@ ep_media_status(struct ifnet *ifp, struc > } > > /* XXX read from softc when we start autosensing media */ > - req->ifm_active = sc->sc_mii.mii_media.ifm_cur->ifm_media; > - > + ifmedia_current(&sc->sc_mii.mii_media, &req->ifm_active, NULL); > + > switch (sc->ep_chipset) { > case EP_CHIPSET_VORTEX: > case EP_CHIPSET_BOOMERANG: > Index: dev/ic/gem.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/gem.c,v > retrieving revision 1.127 > diff -u -p -r1.127 gem.c > --- dev/ic/gem.c 12 Jul 2022 22:08:17 -0000 1.127 > +++ dev/ic/gem.c 14 Jul 2022 22:30:51 -0000 > @@ -1348,16 +1348,18 @@ void > gem_mii_statchg(struct device *dev) > { > struct gem_softc *sc = (void *)dev; > -#ifdef GEM_DEBUG > - uint64_t instance = IFM_INST(sc->sc_mii.mii_media.ifm_cur->ifm_media); > -#endif > bus_space_tag_t t = sc->sc_bustag; > bus_space_handle_t mac = sc->sc_h1; > u_int32_t v; > > #ifdef GEM_DEBUG > - if (sc->sc_debug) > - printf("gem_mii_statchg: status change: phy = %lld\n", > instance); > + if (sc->sc_debug) { > + uint64_t media; > + > + ifmedia_current(&sc->sc_mii.mii_media, &media, NULL); > + printf("%s: status change: phy = %lld\n", > + __func__, IFM_INST(media)); > + } > #endif > > /* Set tx full duplex options */ > Index: dev/ic/hme.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/hme.c,v > retrieving revision 1.83 > diff -u -p -r1.83 hme.c > --- dev/ic/hme.c 12 Dec 2020 11:48:52 -0000 1.83 > +++ dev/ic/hme.c 14 Jul 2022 22:30:51 -0000 > @@ -1103,9 +1103,12 @@ hme_mediachange(struct ifnet *ifp) > bus_space_tag_t t = sc->sc_bustag; > bus_space_handle_t mif = sc->sc_mif; > bus_space_handle_t mac = sc->sc_mac; > - uint64_t instance = IFM_INST(sc->sc_mii.mii_media.ifm_cur->ifm_media); > - int phy = sc->sc_phys[instance]; > + uint64_t media; > + int phy; > u_int32_t v; > + > + ifmedia_current(&sc->sc_mii.mii_media, &media, NULL); > + phy = sc->sc_phys[IFM_INST(media)]; > > #ifdef HMEDEBUG > if (sc->sc_debug) > Index: dev/ic/if_wi.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/if_wi.c,v > retrieving revision 1.177 > diff -u -p -r1.177 if_wi.c > --- dev/ic/if_wi.c 14 Jul 2022 13:46:24 -0000 1.177 > +++ dev/ic/if_wi.c 14 Jul 2022 22:30:51 -0000 > @@ -2659,9 +2659,10 @@ wi_get_id(struct wi_softc *sc) > STATIC int > wi_sync_media(struct wi_softc *sc, int ptype, int txrate) > { > - uint64_t media = sc->sc_media.ifm_cur->ifm_media; > - uint64_t options = IFM_OPTIONS(media); > - uint64_t subtype; > + uint64_t media, options, subtype; > + > + ifmedia_current(&sc->sc_media, &media, NULL); > + options = IFM_OPTIONS(media); > > switch (txrate) { > case 1: > @@ -2719,17 +2720,20 @@ STATIC int > wi_media_change(struct ifnet *ifp) > { > struct wi_softc *sc = ifp->if_softc; > + uint64_t media; > int otype = sc->wi_ptype; > int orate = sc->wi_tx_rate; > int ocreate_ibss = sc->wi_create_ibss; > > - if ((sc->sc_media.ifm_cur->ifm_media & IFM_IEEE80211_HOSTAP) && > + ifmedia_current(&sc->sc_media, &media, NULL); > + > + if ((media & IFM_IEEE80211_HOSTAP) && > sc->sc_firmware_type != WI_INTERSIL) > return (EINVAL); > > sc->wi_create_ibss = 0; > > - switch (sc->sc_media.ifm_cur->ifm_media & IFM_OMASK) { > + switch (media & IFM_OMASK) { > case 0: > sc->wi_ptype = WI_PORTTYPE_BSS; > break; > @@ -2753,7 +2757,7 @@ wi_media_change(struct ifnet *ifp) > return (EINVAL); > } > > - switch (IFM_SUBTYPE(sc->sc_media.ifm_cur->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_IEEE80211_DS1: > sc->wi_tx_rate = 1; > break; > @@ -2777,7 +2781,8 @@ wi_media_change(struct ifnet *ifp) > wi_init(sc); > } > > - ifp->if_baudrate = ifmedia_baudrate(sc->sc_media.ifm_cur->ifm_media); > + ifmedia_current(&sc->sc_media, &media, NULL); > + ifp->if_baudrate = ifmedia_baudrate(media); > > return (0); > } > @@ -2816,7 +2821,7 @@ wi_media_status(struct ifnet *ifp, struc > } > } > } else { > - imr->ifm_active = sc->sc_media.ifm_cur->ifm_media; > + ifmedia_current(&sc->sc_media, &imr->ifm_active, NULL); > } > > imr->ifm_status = IFM_AVALID; > Index: dev/ic/rtl80x9.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/rtl80x9.c,v > retrieving revision 1.12 > diff -u -p -r1.12 rtl80x9.c > --- dev/ic/rtl80x9.c 7 Mar 2021 06:21:38 -0000 1.12 > +++ dev/ic/rtl80x9.c 14 Jul 2022 17:59:35 -0000 > @@ -101,12 +101,14 @@ rtl80x9_mediastatus(struct dp8390_softc > void > rtl80x9_init_card(struct dp8390_softc *sc) > { > - struct ifmedia *ifm = &sc->sc_media; > struct ifnet *ifp = &sc->sc_arpcom.ac_if; > + uint64_t media; > u_int8_t cr_proto = sc->cr_proto | > ((ifp->if_flags & IFF_RUNNING) ? ED_CR_STA : ED_CR_STP); > u_int8_t reg; > > + ifmedia_current(&sc->sc_media, &media, NULL); > + > /* Set NIC to page 3 registers. */ > NIC_PUT(sc->sc_regt, sc->sc_regh, ED_P0_CR, cr_proto | ED_CR_PAGE_3); > > @@ -117,7 +119,7 @@ rtl80x9_init_card(struct dp8390_softc *s > /* First, set basic media type. */ > reg = NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG2); > reg &= ~(RTL3_CONFIG2_PL1|RTL3_CONFIG2_PL0); > - switch (IFM_SUBTYPE(ifm->ifm_cur->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > /* Nothing to do; both bits clear == auto-detect. */ > break; > @@ -138,7 +140,7 @@ rtl80x9_init_card(struct dp8390_softc *s > > /* Now, set duplex mode. */ > reg = NIC_GET(sc->sc_regt, sc->sc_regh, NERTL_RTL3_CONFIG3); > - if (ifm->ifm_cur->ifm_media & IFM_FDX) > + if (media & IFM_FDX) > reg |= RTL3_CONFIG3_FUDUP; > else > reg &= ~RTL3_CONFIG3_FUDUP; > Index: dev/ic/smc83c170.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/smc83c170.c,v > retrieving revision 1.30 > diff -u -p -r1.30 smc83c170.c > --- dev/ic/smc83c170.c 9 Jan 2022 05:42:42 -0000 1.30 > +++ dev/ic/smc83c170.c 14 Jul 2022 22:30:51 -0000 > @@ -1404,14 +1404,15 @@ epic_mediachange(struct ifnet *ifp) > { > struct epic_softc *sc = ifp->if_softc; > struct mii_data *mii = &sc->sc_mii; > - struct ifmedia *ifm = &mii->mii_media; > - uint64_t media = ifm->ifm_cur->ifm_media; > + uint64_t media; > u_int32_t miicfg; > struct mii_softc *miisc; > int cfg; > > if (!(ifp->if_flags & IFF_UP)) > return (0); > + > + ifmedia_current(&mii->mii_media, &media, NULL); > > if (IFM_INST(media) != sc->sc_serinst) { > /* If we're not selecting serial interface, select MII mode */ > Index: dev/ic/smc91cxx.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/smc91cxx.c,v > retrieving revision 1.51 > diff -u -p -r1.51 smc91cxx.c > --- dev/ic/smc91cxx.c 9 Jan 2022 05:42:42 -0000 1.51 > +++ dev/ic/smc91cxx.c 14 Jul 2022 22:30:51 -0000 > @@ -394,6 +394,7 @@ smc91cxx_init(struct smc91cxx_softc *sc) > struct ifnet *ifp = &sc->sc_arpcom.ac_if; > bus_space_tag_t bst = sc->sc_bst; > bus_space_handle_t bsh = sc->sc_bsh; > + uint64_t media; > u_int16_t tmp; > int s, i; > > @@ -444,7 +445,8 @@ smc91cxx_init(struct smc91cxx_softc *sc) > /* > * Set current media. > */ > - smc91cxx_set_media(sc, sc->sc_mii.mii_media.ifm_cur->ifm_media); > + ifmedia_current(&sc->sc_mii.mii_media, &media, NULL); > + smc91cxx_set_media(sc, media); > > /* > * Set the receive filter. We want receive enable and auto > Index: dev/ic/ti.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/ic/ti.c,v > retrieving revision 1.29 > diff -u -p -r1.29 ti.c > --- dev/ic/ti.c 9 Jan 2022 05:42:42 -0000 1.29 > +++ dev/ic/ti.c 14 Jul 2022 22:30:51 -0000 > @@ -2085,7 +2085,7 @@ ti_init2(struct ti_softc *sc) > */ > ifm = &sc->ifmedia; > tmp = ifm->ifm_media; > - ifm->ifm_media = ifm->ifm_cur->ifm_media; > + ifmedia_current(ifm, &ifm->ifm_media, NULL); > ti_ifmedia_upd(ifp); > ifm->ifm_media = tmp; > } > Index: dev/isa/if_ec.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/isa/if_ec.c,v > retrieving revision 1.19 > diff -u -p -r1.19 if_ec.c > --- dev/isa/if_ec.c 6 Apr 2022 18:59:28 -0000 1.19 > +++ dev/isa/if_ec.c 14 Jul 2022 22:30:51 -0000 > @@ -719,21 +719,20 @@ ec_mediachange(struct dp8390_softc *sc) > void > ec_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr) > { > - struct ifmedia *ifm = &sc->sc_media; > - > /* > * The currently selected media is always the active media. > */ > - ifmr->ifm_active = ifm->ifm_cur->ifm_media; > + ifmedia_current(&sc->sc_media, &ifmr->ifm_active, NULL); > } > > void > ec_init_card(struct dp8390_softc *sc) > { > struct ec_softc *esc = (struct ec_softc *)sc; > - struct ifmedia *ifm = &sc->sc_media; > + uint64_t media; > > - (void) ec_set_media(esc, ifm->ifm_cur->ifm_media); > + ifmedia_current(&sc->sc_media, &media, NULL); > + (void) ec_set_media(esc, media); > } > > int > Index: dev/isa/if_ex.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/isa/if_ex.c,v > retrieving revision 1.48 > diff -u -p -r1.48 if_ex.c > --- dev/isa/if_ex.c 6 Apr 2022 18:59:28 -0000 1.48 > +++ dev/isa/if_ex.c 14 Jul 2022 23:03:34 -0000 > @@ -241,7 +241,6 @@ ex_attach(struct device *parent, struct > struct ex_softc *sc = (void *)self; > struct isa_attach_args *ia = aux; > struct ifnet *ifp = &sc->arpcom.ac_if; > - struct ifmedia *ifm; > int temp; > > DODEBUG(Start_End, printf("ex_attach: start\n");); > @@ -266,9 +265,7 @@ ex_attach(struct device *parent, struct > ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL); > ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_NONE, 0, NULL); > ifmedia_set(&sc->ifmedia, ex_get_media(sc)); > - > - ifm = &sc->ifmedia; > - ifm->ifm_media = ifm->ifm_cur->ifm_media; > + ifmedia_current(&sc->ifmedia, &sc->ifmedia.ifm_media, NULL); > ex_ifmedia_upd(ifp); > > if_attach(ifp); > Index: dev/isa/if_we.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/isa/if_we.c,v > retrieving revision 1.28 > diff -u -p -r1.28 if_we.c > --- dev/isa/if_we.c 6 Apr 2022 18:59:28 -0000 1.28 > +++ dev/isa/if_we.c 14 Jul 2022 22:30:51 -0000 > @@ -789,12 +789,10 @@ we_mediachange(struct dp8390_softc *sc) > void > we_mediastatus(struct dp8390_softc *sc, struct ifmediareq *ifmr) > { > - struct ifmedia *ifm = &sc->sc_media; > - > /* > * The currently selected media is always the active media. > */ > - ifmr->ifm_active = ifm->ifm_cur->ifm_media; > + ifmedia_current(&sc->sc_media, &ifmr->ifm_active, NULL); > } > > const char * > Index: dev/mii/acphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/acphy.c,v > retrieving revision 1.10 > diff -u -p -r1.10 acphy.c > --- dev/mii/acphy.c 6 Apr 2022 18:59:29 -0000 1.10 > +++ dev/mii/acphy.c 14 Jul 2022 18:29:37 -0000 > @@ -140,15 +140,17 @@ acphyattach(struct device *parent, struc > int > acphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -157,7 +159,7 @@ acphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -176,7 +178,7 @@ acphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -200,7 +202,6 @@ void > acphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, dr; > > mii->mii_media_status = IFM_AVALID; > @@ -243,5 +244,5 @@ acphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/amphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/amphy.c,v > retrieving revision 1.22 > diff -u -p -r1.22 amphy.c > --- dev/mii/amphy.c 6 Apr 2022 18:59:29 -0000 1.22 > +++ dev/mii/amphy.c 14 Jul 2022 18:31:37 -0000 > @@ -130,15 +130,17 @@ amphyattach(struct device *parent, struc > int > amphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -147,7 +149,7 @@ amphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -166,7 +168,7 @@ amphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -189,7 +191,6 @@ void > amphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, par, anlpar; > > mii->mii_media_status = IFM_AVALID; > @@ -252,5 +253,5 @@ amphy_status(struct mii_softc *sc) > else if (par & DSCSR_10HDX) > mii->mii_media_active |= IFM_10_T|IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/atphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/atphy.c,v > retrieving revision 1.13 > diff -u -p -r1.13 atphy.c > --- dev/mii/atphy.c 6 Apr 2022 18:59:29 -0000 1.13 > +++ dev/mii/atphy.c 14 Jul 2022 18:34:43 -0000 > @@ -146,15 +146,17 @@ atphy_attach(struct device *parent, stru > int > atphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > uint16_t anar, bmcr, bmsr; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -163,7 +165,7 @@ atphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > bmcr = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO); > return (0); > @@ -176,7 +178,7 @@ atphy_service(struct mii_softc *sc, stru > break; > > bmcr = 0; > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > case IFM_1000_T: > atphy_mii_phy_auto(sc); > @@ -203,8 +205,8 @@ atphy_service(struct mii_softc *sc, stru > return (EINVAL); > } > > - anar = mii_anar(ife->ifm_media); > - if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { > + anar = mii_anar(media); > + if (((media & IFM_GMASK) & IFM_FDX) != 0) { > bmcr |= BMCR_FDX; > /* Enable pause. */ > if (sc->mii_flags & MIIF_DOPAUSE) > @@ -228,7 +230,7 @@ done: > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -240,7 +242,7 @@ done: > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { > + if (IFM_SUBTYPE(media) != IFM_AUTO) { > sc->mii_ticks = 0; > break; > } > Index: dev/mii/bmtphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/bmtphy.c,v > retrieving revision 1.21 > diff -u -p -r1.21 bmtphy.c > --- dev/mii/bmtphy.c 6 Apr 2022 18:59:29 -0000 1.21 > +++ dev/mii/bmtphy.c 14 Jul 2022 18:39:06 -0000 > @@ -134,18 +134,20 @@ bmtphyattach(struct device *parent, stru > int > bmtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -154,7 +156,7 @@ bmtphy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -173,7 +175,7 @@ bmtphy_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -197,7 +199,6 @@ void > bmtphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, aux_csr; > > mii->mii_media_status = IFM_AVALID; > @@ -239,7 +240,7 @@ bmtphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > Index: dev/mii/brgphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/brgphy.c,v > retrieving revision 1.108 > diff -u -p -r1.108 brgphy.c > --- dev/mii/brgphy.c 6 Apr 2022 18:59:29 -0000 1.108 > +++ dev/mii/brgphy.c 14 Jul 2022 18:49:20 -0000 > @@ -307,18 +307,20 @@ brgphy_attach(struct device *parent, str > int > brgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg, speed = 0, gig; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -327,7 +329,7 @@ brgphy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -341,7 +343,7 @@ brgphy_service(struct mii_softc *sc, str > > PHY_RESET(sc); /* XXX hardware bug work-around */ > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > (void) brgphy_mii_phy_auto(sc); > break; > @@ -358,7 +360,7 @@ brgphy_service(struct mii_softc *sc, str > speed = BMCR_S10; > setit: > brgphy_loop(sc); > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { > + if ((media & IFM_GMASK) == IFM_FDX) { > speed |= BMCR_FDX; > gig = GTCR_ADV_1000TFDX; > } else { > @@ -369,9 +371,9 @@ setit: > PHY_WRITE(sc, MII_ANAR, ANAR_CSMA); > PHY_WRITE(sc, MII_BMCR, speed); > > - if ((IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) && > - (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_SX) && > - (IFM_SUBTYPE(ife->ifm_media) != IFM_2500_SX)) > + if ((IFM_SUBTYPE(media) != IFM_1000_T) && > + (IFM_SUBTYPE(media) != IFM_1000_SX) && > + (IFM_SUBTYPE(media) != IFM_2500_SX)) > break; > > PHY_WRITE(sc, MII_100T2CR, gig); > @@ -395,7 +397,7 @@ setit: > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -407,7 +409,7 @@ setit: > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > break; > > /* > @@ -474,7 +476,6 @@ void > brgphy_copper_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmcr, bmsr; > > mii->mii_media_status = IFM_AVALID; > @@ -542,14 +543,13 @@ brgphy_copper_status(struct mii_softc *s > mii->mii_media_active |= IFM_ETH_MASTER; > } > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > brgphy_fiber_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmcr, bmsr; > > mii->mii_media_status = IFM_AVALID; > @@ -584,14 +584,13 @@ brgphy_fiber_status(struct mii_softc *sc > if (mii->mii_media_active & IFM_FDX) > mii->mii_media_active |= mii_phy_flowstatus(sc); > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > brgphy_5708s_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmcr, bmsr; > > mii->mii_media_status = IFM_AVALID; > @@ -646,14 +645,13 @@ brgphy_5708s_status(struct mii_softc *sc > mii->mii_media_active |= IFM_FLOW | > IFM_ETH_RXPAUSE; > } > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > brgphy_5709s_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmcr, bmsr; > > mii->mii_media_status = IFM_AVALID; > @@ -707,7 +705,7 @@ brgphy_5709s_status(struct mii_softc *sc > if (mii->mii_media_active & IFM_FDX) > mii->mii_media_active |= mii_phy_flowstatus(sc); > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > int > Index: dev/mii/brswphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/brswphy.c,v > retrieving revision 1.4 > diff -u -p -r1.4 brswphy.c > --- dev/mii/brswphy.c 6 Apr 2022 18:59:29 -0000 1.4 > +++ dev/mii/brswphy.c 14 Jul 2022 19:22:34 -0000 > @@ -231,18 +231,20 @@ brswphyattach(struct device *parent, str > int > brswphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -251,7 +253,7 @@ brswphy_service(struct mii_softc *sc, st > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -270,7 +272,7 @@ brswphy_service(struct mii_softc *sc, st > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/ciphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/ciphy.c,v > retrieving revision 1.28 > diff -u -p -r1.28 ciphy.c > --- dev/mii/ciphy.c 6 Apr 2022 18:59:29 -0000 1.28 > +++ dev/mii/ciphy.c 14 Jul 2022 18:53:21 -0000 > @@ -140,15 +140,17 @@ ciphyattach(struct device *parent, struc > int > ciphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg, speed, gig; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -157,7 +159,7 @@ ciphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -171,7 +173,7 @@ ciphy_service(struct mii_softc *sc, stru > > ciphy_fixup(sc); /* XXX hardware bug work-around */ > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > if (mii_phy_auto(sc, 0) == EJUSTRETURN) > return (0); > @@ -185,7 +187,7 @@ ciphy_service(struct mii_softc *sc, stru > case IFM_10_T: > speed = BMCR_S10; > setit: > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { > + if ((media & IFM_GMASK) == IFM_FDX) { > speed |= BMCR_FDX; > gig = GTCR_ADV_1000TFDX; > } else { > @@ -196,7 +198,7 @@ setit: > PHY_WRITE(sc, MII_BMCR, speed); > PHY_WRITE(sc, MII_ANAR, ANAR_CSMA); > > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) > + if (IFM_SUBTYPE(media) != IFM_1000_T) > break; > > PHY_WRITE(sc, MII_100T2CR, gig); > @@ -219,7 +221,7 @@ setit: > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/dcphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/dcphy.c,v > retrieving revision 1.26 > diff -u -p -r1.26 dcphy.c > --- dev/mii/dcphy.c 6 Apr 2022 18:59:29 -0000 1.26 > +++ dev/mii/dcphy.c 14 Jul 2022 18:54:48 -0000 > @@ -174,7 +174,7 @@ int > dcphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > struct dc_softc *dc_sc; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > u_int32_t mode; > > @@ -183,12 +183,14 @@ dcphy_service(struct mii_softc *sc, stru > > dc_sc = mii->mii_ifp->if_softc; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -197,7 +199,7 @@ dcphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -212,7 +214,7 @@ dcphy_service(struct mii_softc *sc, stru > mode &= ~(DC_NETCFG_FULLDUPLEX|DC_NETCFG_PORTSEL| > DC_NETCFG_PCS|DC_NETCFG_SCRAMBLER|DC_NETCFG_SPEEDSEL); > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > /*PHY_RESET(sc);*/ > sc->mii_flags &= ~MIIF_DOINGAUTO; > @@ -223,7 +225,7 @@ dcphy_service(struct mii_softc *sc, stru > DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); > mode |= DC_NETCFG_PORTSEL|DC_NETCFG_PCS| > DC_NETCFG_SCRAMBLER; > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) > + if ((media & IFM_GMASK) == IFM_FDX) > mode |= DC_NETCFG_FULLDUPLEX; > else > mode &= ~DC_NETCFG_FULLDUPLEX; > @@ -232,7 +234,7 @@ dcphy_service(struct mii_softc *sc, stru > case IFM_10_T: > DC_CLRBIT(dc_sc, DC_SIARESET, DC_SIA_RESET); > DC_CLRBIT(dc_sc, DC_10BTCTRL, 0xFFFF); > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) > + if ((media & IFM_GMASK) == IFM_FDX) > DC_SETBIT(dc_sc, DC_10BTCTRL, 0x7F3D); > else > DC_SETBIT(dc_sc, DC_10BTCTRL, 0x7F3F); > @@ -240,7 +242,7 @@ dcphy_service(struct mii_softc *sc, stru > DC_CLRBIT(dc_sc, DC_10BTCTRL, DC_TCTL_AUTONEGENBL); > mode &= ~DC_NETCFG_PORTSEL; > mode |= DC_NETCFG_SPEEDSEL; > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) > + if ((media & IFM_GMASK) == IFM_FDX) > mode |= DC_NETCFG_FULLDUPLEX; > else > mode &= ~DC_NETCFG_FULLDUPLEX; > @@ -255,7 +257,7 @@ dcphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -267,7 +269,7 @@ dcphy_service(struct mii_softc *sc, stru > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > break; > > reg = CSR_READ_4(dc_sc, DC_10BTSTAT); > Index: dev/mii/eephy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/eephy.c,v > retrieving revision 1.60 > diff -u -p -r1.60 eephy.c > --- dev/mii/eephy.c 6 Apr 2022 18:59:29 -0000 1.60 > +++ dev/mii/eephy.c 14 Jul 2022 18:55:57 -0000 > @@ -301,18 +301,20 @@ eephy_reset(struct mii_softc *sc) > int > eephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int bmcr; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -321,7 +323,7 @@ eephy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > bmcr = PHY_READ(sc, E1000_CR); > PHY_WRITE(sc, E1000_CR, bmcr | E1000_CR_ISOLATE); > return (0); > @@ -339,7 +341,7 @@ eephy_service(struct mii_softc *sc, stru > * If autonegotiation is not enabled, we need a > * software reset for the settings to take effect. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { > + if (IFM_SUBTYPE(media) != IFM_AUTO) { > bmcr = PHY_READ(sc, E1000_CR); > PHY_WRITE(sc, E1000_CR, bmcr | E1000_CR_RESET); > } > @@ -349,7 +351,7 @@ eephy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/etphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/etphy.c,v > retrieving revision 1.8 > diff -u -p -r1.8 etphy.c > --- dev/mii/etphy.c 6 Apr 2022 18:59:29 -0000 1.8 > +++ dev/mii/etphy.c 14 Jul 2022 19:00:51 -0000 > @@ -183,15 +183,17 @@ etphy_attach(struct device *parent, stru > int > etphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int bmcr; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return 0; > break; > > @@ -200,7 +202,7 @@ etphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > bmcr = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO); > return 0; > @@ -212,7 +214,7 @@ etphy_service(struct mii_softc *sc, stru > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > break; > > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { > + if (IFM_SUBTYPE(media) != IFM_AUTO) { > bmcr = PHY_READ(sc, MII_BMCR) & ~BMCR_AUTOEN; > PHY_WRITE(sc, MII_BMCR, bmcr); > PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_PDOWN); > @@ -220,11 +222,11 @@ etphy_service(struct mii_softc *sc, stru > > mii_phy_setmedia(sc); > > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { > + if (IFM_SUBTYPE(media) != IFM_AUTO) { > bmcr = PHY_READ(sc, MII_BMCR) & ~BMCR_PDOWN; > PHY_WRITE(sc, MII_BMCR, bmcr); > > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) { > + if (IFM_SUBTYPE(media) == IFM_1000_T) { > PHY_WRITE(sc, MII_BMCR, > bmcr | BMCR_AUTOEN | BMCR_STARTNEG); > } > @@ -235,7 +237,7 @@ etphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return 0; > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/exphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/exphy.c,v > retrieving revision 1.24 > diff -u -p -r1.24 exphy.c > --- dev/mii/exphy.c 6 Apr 2022 18:59:29 -0000 1.24 > +++ dev/mii/exphy.c 14 Jul 2022 19:01:17 -0000 > @@ -148,15 +148,17 @@ exphyattach(struct device *parent, struc > int > exphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > /* > * We can't isolate the 3Com PHY, so it has to be the only one! > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > panic("exphy_service: can't isolate 3Com PHY"); > > switch (cmd) { > Index: dev/mii/gentbi.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/gentbi.c,v > retrieving revision 1.12 > diff -u -p -r1.12 gentbi.c > --- dev/mii/gentbi.c 6 Apr 2022 18:59:29 -0000 1.12 > +++ dev/mii/gentbi.c 14 Jul 2022 19:03:39 -0000 > @@ -164,15 +164,17 @@ gentbiattach(struct device *parent, stru > int > gentbi_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -181,7 +183,7 @@ gentbi_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -200,7 +202,7 @@ gentbi_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -224,7 +226,6 @@ void > gentbi_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, anlpar; > > mii->mii_media_status = IFM_AVALID; > @@ -268,5 +269,5 @@ gentbi_status(struct mii_softc *sc) > mii->mii_media_active |= > mii_phy_flowstatus(sc) | IFM_FDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/icsphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/icsphy.c,v > retrieving revision 1.25 > diff -u -p -r1.25 icsphy.c > --- dev/mii/icsphy.c 6 Apr 2022 18:59:29 -0000 1.25 > +++ dev/mii/icsphy.c 14 Jul 2022 19:04:47 -0000 > @@ -147,18 +147,20 @@ icsphyattach(struct device *parent, stru > int > icsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -167,7 +169,7 @@ icsphy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -186,7 +188,7 @@ icsphy_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -210,7 +212,6 @@ void > icsphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmcr, qpr; > > mii->mii_media_status = IFM_AVALID; > @@ -254,7 +255,7 @@ icsphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > Index: dev/mii/inphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/inphy.c,v > retrieving revision 1.23 > diff -u -p -r1.23 inphy.c > --- dev/mii/inphy.c 6 Apr 2022 18:59:29 -0000 1.23 > +++ dev/mii/inphy.c 14 Jul 2022 19:05:45 -0000 > @@ -147,18 +147,20 @@ inphyattach(struct device *parent, struc > int > inphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -167,7 +169,7 @@ inphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -186,7 +188,7 @@ inphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -210,7 +212,6 @@ void > inphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, scr; > > mii->mii_media_status = IFM_AVALID; > @@ -251,5 +252,5 @@ inphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/iophy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/iophy.c,v > retrieving revision 1.22 > diff -u -p -r1.22 iophy.c > --- dev/mii/iophy.c 6 Apr 2022 18:59:29 -0000 1.22 > +++ dev/mii/iophy.c 14 Jul 2022 19:06:27 -0000 > @@ -142,18 +142,20 @@ iophyattach(struct device *parent, struc > int > iophy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -162,7 +164,7 @@ iophy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -181,7 +183,7 @@ iophy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -205,7 +207,6 @@ void > iophy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, ext0; > > mii->mii_media_status = IFM_AVALID; > @@ -248,5 +249,5 @@ iophy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/ipgphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/ipgphy.c,v > retrieving revision 1.20 > diff -u -p -r1.20 ipgphy.c > --- dev/mii/ipgphy.c 6 Apr 2022 18:59:29 -0000 1.20 > +++ dev/mii/ipgphy.c 14 Jul 2022 19:07:55 -0000 > @@ -130,15 +130,17 @@ ipgphy_attach(struct device *parent, str > int > ipgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > uint32_t gig, reg, speed; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -147,7 +149,7 @@ ipgphy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -161,7 +163,7 @@ ipgphy_service(struct mii_softc *sc, str > > PHY_RESET(sc); > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > (void)ipgphy_mii_phy_auto(sc); > goto done; > @@ -187,7 +189,7 @@ ipgphy_service(struct mii_softc *sc, str > return (EINVAL); > } > > - if (((ife->ifm_media & IFM_GMASK) & IFM_FDX) != 0) { > + if (((media & IFM_GMASK) & IFM_FDX) != 0) { > speed |= BMCR_FDX; > gig = GTCR_ADV_1000TFDX; > } else > @@ -196,7 +198,7 @@ ipgphy_service(struct mii_softc *sc, str > PHY_WRITE(sc, MII_100T2CR, 0); > PHY_WRITE(sc, MII_BMCR, speed); > > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) > + if (IFM_SUBTYPE(media) != IFM_1000_T) > break; > > PHY_WRITE(sc, MII_100T2CR, gig); > @@ -214,7 +216,7 @@ done: > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -226,7 +228,7 @@ done: > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { > + if (IFM_SUBTYPE(media) != IFM_AUTO) { > sc->mii_ticks = 0; > break; > } > @@ -267,7 +269,6 @@ void > ipgphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > uint32_t bmsr, bmcr, stat; > > mii->mii_media_status = IFM_AVALID; > @@ -343,7 +344,7 @@ ipgphy_status(struct mii_softc *sc) > mii->mii_media_active |= IFM_ETH_MASTER; > } > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > int > Index: dev/mii/jmphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/jmphy.c,v > retrieving revision 1.7 > diff -u -p -r1.7 jmphy.c > --- dev/mii/jmphy.c 6 Apr 2022 18:59:29 -0000 1.7 > +++ dev/mii/jmphy.c 14 Jul 2022 19:10:34 -0000 > @@ -52,8 +52,8 @@ void jmphy_status(struct mii_softc *); > int jmphy_match(struct device *, void *, void *); > void jmphy_attach(struct device *, struct device *, void *); > void jmphy_reset(struct mii_softc *); > -uint16_t jmphy_anar(struct ifmedia_entry *); > -int jmphy_auto(struct mii_softc *, struct ifmedia_entry *); > +uint16_t jmphy_anar(uint64_t); > +int jmphy_auto(struct mii_softc *, uint64_t); > > const struct mii_phy_funcs jmphy_funcs = { > jmphy_service, jmphy_status, jmphy_reset, > @@ -124,15 +124,17 @@ jmphy_attach(struct device *parent, stru > int > jmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > uint16_t bmcr; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -141,7 +143,7 @@ jmphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > bmcr = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, bmcr | BMCR_ISO); > return (0); > @@ -153,7 +155,7 @@ jmphy_service(struct mii_softc *sc, stru > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > break; > > - if (jmphy_auto(sc, ife) != EJUSTRETURN) > + if (jmphy_auto(sc, media) != EJUSTRETURN) > return (EINVAL); > break; > > @@ -161,7 +163,7 @@ jmphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -173,7 +175,7 @@ jmphy_service(struct mii_softc *sc, stru > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > break; > > /* Check for link. */ > @@ -189,7 +191,7 @@ jmphy_service(struct mii_softc *sc, stru > return (0); > > sc->mii_ticks = 0; > - jmphy_auto(sc, ife); > + jmphy_auto(sc, media); > break; > } > > @@ -282,12 +284,12 @@ jmphy_reset(struct mii_softc *sc) > } > > uint16_t > -jmphy_anar(struct ifmedia_entry *ife) > +jmphy_anar(uint64_t media) > { > uint16_t anar; > > anar = 0; > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > anar |= ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10; > break; > @@ -307,13 +309,13 @@ jmphy_anar(struct ifmedia_entry *ife) > } > > int > -jmphy_auto(struct mii_softc *sc, struct ifmedia_entry *ife) > +jmphy_auto(struct mii_softc *sc, uint64_t media) > { > uint16_t anar, bmcr, gig; > > gig = 0; > bmcr = PHY_READ(sc, MII_BMCR); > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > gig |= GTCR_ADV_1000TFDX | GTCR_ADV_1000THDX; > break; > @@ -330,10 +332,10 @@ jmphy_auto(struct mii_softc *sc, struct > return (EINVAL); > } > > - if ((ife->ifm_media & IFM_LOOP) != 0) > + if ((media & IFM_LOOP) != 0) > bmcr |= BMCR_LOOP; > > - anar = jmphy_anar(ife); > + anar = jmphy_anar(media); > if (sc->mii_flags & MIIF_DOPAUSE) > anar |= ANAR_PAUSE_TOWARDS; > > Index: dev/mii/luphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/luphy.c,v > retrieving revision 1.7 > diff -u -p -r1.7 luphy.c > --- dev/mii/luphy.c 6 Apr 2022 18:59:29 -0000 1.7 > +++ dev/mii/luphy.c 14 Jul 2022 19:11:08 -0000 > @@ -120,14 +120,16 @@ luphyattach(struct device *parent, struc > int > luphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > + > + ifmedia_current(&mii->mii_media, &media, NULL); > > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -137,7 +139,7 @@ luphy_service(struct mii_softc *sc, stru > * just return. Isolating unused PHYs from the bus > * causes at least the MII bus of the HME to wedge. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -153,7 +155,7 @@ luphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/lxtphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/lxtphy.c,v > retrieving revision 1.23 > diff -u -p -r1.23 lxtphy.c > --- dev/mii/lxtphy.c 6 Apr 2022 18:59:29 -0000 1.23 > +++ dev/mii/lxtphy.c 14 Jul 2022 19:14:03 -0000 > @@ -156,18 +156,20 @@ lxtphyattach(struct device *parent, stru > int > lxtphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -176,7 +178,7 @@ lxtphy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -195,7 +197,7 @@ lxtphy_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -219,7 +221,6 @@ void > lxtphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmcr, bmsr, csr; > > mii->mii_media_status = IFM_AVALID; > @@ -261,7 +262,7 @@ lxtphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > Index: dev/mii/mii_physubr.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/mii_physubr.c,v > retrieving revision 1.46 > diff -u -p -r1.46 mii_physubr.c > --- dev/mii/mii_physubr.c 15 Jan 2020 00:14:47 -0000 1.46 > +++ dev/mii/mii_physubr.c 14 Jul 2022 19:16:10 -0000 > @@ -80,10 +80,13 @@ void > mii_phy_setmedia(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > + u_int data; > int bmcr, anar, gtcr; > > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { > + ifmedia_current(&mii->mii_media, &media, &data); > + > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > if ((PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) == 0 || > (sc->mii_flags & MIIF_FORCEANEG)) > (void) mii_phy_auto(sc, 1); > @@ -94,16 +97,16 @@ mii_phy_setmedia(struct mii_softc *sc) > * Table index is stored in the media entry. > */ > #ifdef DIAGNOSTIC > - if (ife->ifm_data >= MII_NMEDIA) > + if (data >= MII_NMEDIA) > panic("mii_phy_setmedia"); > #endif > > - anar = mii_media_table[ife->ifm_data].mm_anar; > - bmcr = mii_media_table[ife->ifm_data].mm_bmcr; > - gtcr = mii_media_table[ife->ifm_data].mm_gtcr; > + anar = mii_media_table[data].mm_anar; > + bmcr = mii_media_table[data].mm_bmcr; > + gtcr = mii_media_table[data].mm_gtcr; > > if (mii->mii_media.ifm_media & IFM_ETH_MASTER) { > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_1000_T: > gtcr |= GTCR_MAN_MS|GTCR_ADV_MS; > break; > @@ -113,7 +116,7 @@ mii_phy_setmedia(struct mii_softc *sc) > } > } > > - if (ife->ifm_media & IFM_LOOP) > + if (media & IFM_LOOP) > bmcr |= BMCR_LOOP; > > PHY_WRITE(sc, MII_ANAR, anar); > @@ -231,20 +234,22 @@ int > mii_phy_tick(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > /* Just bail now if the interface is down. */ > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > return (EJUSTRETURN); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > /* > * If we're not doing autonegotiation, we don't need to do > * any extra work here. However, we need to check the link > * status so we can generate an announcement if the status > * changes. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > return (0); > > /* Read the status register twice; BMSR_LINK is latch-low. */ > Index: dev/mii/mlphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/mlphy.c,v > retrieving revision 1.6 > diff -u -p -r1.6 mlphy.c > --- dev/mii/mlphy.c 6 Apr 2022 18:59:29 -0000 1.6 > +++ dev/mii/mlphy.c 14 Jul 2022 19:21:04 -0000 > @@ -200,9 +200,10 @@ mlphy_attach(struct device *parent, stru > int > mlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > struct mii_softc *other = NULL; > struct mlphy_softc *msc = (struct mlphy_softc *)sc; > + uint64_t media; > + u_int data; > int other_inst, reg; > > LIST_FOREACH(other, &mii->mii_phys, mii_list) > @@ -212,12 +213,14 @@ mlphy_service(struct mii_softc *sc, stru > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, &data); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -228,7 +231,7 @@ mlphy_service(struct mii_softc *sc, stru > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > break; > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > msc->ml_state = ML_STATE_AUTO_SELF; > if (other != NULL) { > @@ -249,7 +252,7 @@ mlphy_service(struct mii_softc *sc, stru > */ > if (other != NULL) { > mii_phy_reset(other); > - PHY_WRITE(other, MII_BMCR, ife->ifm_data); > + PHY_WRITE(other, MII_BMCR, data); > } > mii_phy_setmedia(sc); > msc->ml_state = 0; > @@ -282,7 +285,7 @@ mlphy_service(struct mii_softc *sc, stru > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > break; > /* > * Check to see if we have link. If we do, we don't > @@ -336,7 +339,7 @@ mlphy_service(struct mii_softc *sc, stru > if (msc->ml_state == ML_STATE_AUTO_OTHER && other != NULL) { > other_inst = other->mii_inst; > other->mii_inst = sc->mii_inst; > - if (IFM_INST(ife->ifm_media) == other->mii_inst) > + if (IFM_INST(media) == other->mii_inst) > (void) PHY_SERVICE(other, mii, MII_POLLSTAT); > other->mii_inst = other_inst; > sc->mii_media_active = other->mii_media_active; > Index: dev/mii/mtdphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/mtdphy.c,v > retrieving revision 1.16 > diff -u -p -r1.16 mtdphy.c > --- dev/mii/mtdphy.c 6 Apr 2022 18:59:29 -0000 1.16 > +++ dev/mii/mtdphy.c 14 Jul 2022 19:21:48 -0000 > @@ -109,18 +109,20 @@ mtdphyattach(struct device *parent, stru > int > mtdphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -128,7 +130,7 @@ mtdphy_service(struct mii_softc *sc, str > /* > * If the interface is not up, don't do anything. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -144,7 +146,7 @@ mtdphy_service(struct mii_softc *sc, str > /* > *If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/nsgphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/nsgphy.c,v > retrieving revision 1.26 > diff -u -p -r1.26 nsgphy.c > --- dev/mii/nsgphy.c 6 Apr 2022 18:59:29 -0000 1.26 > +++ dev/mii/nsgphy.c 14 Jul 2022 19:23:21 -0000 > @@ -153,18 +153,20 @@ nsgphyattach(struct device *parent, stru > int > nsgphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -173,7 +175,7 @@ nsgphy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -192,7 +194,7 @@ nsgphy_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -215,7 +217,6 @@ void > nsgphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, physup, gtsr; > > mii->mii_media_status = IFM_AVALID; > @@ -272,5 +273,5 @@ nsgphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/nsphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/nsphy.c,v > retrieving revision 1.29 > diff -u -p -r1.29 nsphy.c > --- dev/mii/nsphy.c 6 Apr 2022 18:59:29 -0000 1.29 > +++ dev/mii/nsphy.c 14 Jul 2022 19:23:47 -0000 > @@ -143,18 +143,20 @@ nsphyattach(struct device *parent, struc > int > nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -163,7 +165,7 @@ nsphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -212,7 +214,7 @@ nsphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -236,7 +238,6 @@ void > nsphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, par, anlpar; > > mii->mii_media_status = IFM_AVALID; > @@ -303,7 +304,7 @@ nsphy_status(struct mii_softc *sc) > mii->mii_media_active |= IFM_100_TX; > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > Index: dev/mii/nsphyter.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/nsphyter.c,v > retrieving revision 1.20 > diff -u -p -r1.20 nsphyter.c > --- dev/mii/nsphyter.c 6 Apr 2022 18:59:29 -0000 1.20 > +++ dev/mii/nsphyter.c 14 Jul 2022 19:24:16 -0000 > @@ -146,18 +146,20 @@ nsphyterattach(struct device *parent, st > int > nsphyter_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -166,7 +168,7 @@ nsphyter_service(struct mii_softc *sc, s > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -185,7 +187,7 @@ nsphyter_service(struct mii_softc *sc, s > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -209,7 +211,6 @@ void > nsphyter_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, physts; > > mii->mii_media_status = IFM_AVALID; > @@ -252,5 +253,5 @@ nsphyter_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/qsphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/qsphy.c,v > retrieving revision 1.22 > diff -u -p -r1.22 qsphy.c > --- dev/mii/qsphy.c 6 Apr 2022 18:59:29 -0000 1.22 > +++ dev/mii/qsphy.c 14 Jul 2022 19:24:54 -0000 > @@ -141,18 +141,20 @@ qsphyattach(struct device *parent, struc > int > qsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -161,7 +163,7 @@ qsphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -180,7 +182,7 @@ qsphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -204,7 +206,6 @@ void > qsphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, pctl; > > mii->mii_media_status = IFM_AVALID; > @@ -255,7 +256,7 @@ qsphy_status(struct mii_softc *sc) > break; > } > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > > void > Index: dev/mii/rdcphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/rdcphy.c,v > retrieving revision 1.5 > diff -u -p -r1.5 rdcphy.c > --- dev/mii/rdcphy.c 19 Apr 2022 03:26:33 -0000 1.5 > +++ dev/mii/rdcphy.c 14 Jul 2022 19:26:04 -0000 > @@ -161,18 +161,20 @@ int > rdcphy_service(struct mii_softc *self, struct mii_data *mii, int cmd) > { > struct rdcphy_softc *sc = (struct rdcphy_softc *)self; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->sc_mii.mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) > + if (IFM_INST(media) != sc->sc_mii.mii_inst) > return (0); > break; > > @@ -181,7 +183,7 @@ rdcphy_service(struct mii_softc *self, s > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { > + if (IFM_INST(media) != sc->sc_mii.mii_inst) { > reg = PHY_READ(&sc->sc_mii, MII_BMCR); > PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -194,7 +196,7 @@ rdcphy_service(struct mii_softc *self, s > break; > > mii_phy_setmedia(&sc->sc_mii); > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_100_TX: > case IFM_10_T: > /* > @@ -223,13 +225,13 @@ rdcphy_service(struct mii_softc *self, s > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) > + if (IFM_INST(media) != sc->sc_mii.mii_inst) > return (0); > > if (mii_phy_tick(&sc->sc_mii) == EJUSTRETURN) > return (0); > > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) { > + if (IFM_SUBTYPE(media) != IFM_AUTO) { > /* > * It seems the PHY hardware does not correctly > * report link status changes when manual link > @@ -262,10 +264,7 @@ void > rdcphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife; > int bmsr, bmcr, physts; > - > - ife = mii->mii_media.ifm_cur; > > mii->mii_media_status = IFM_AVALID; > mii->mii_media_active = IFM_ETHER; > Index: dev/mii/rgephy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/rgephy.c,v > retrieving revision 1.41 > diff -u -p -r1.41 rgephy.c > --- dev/mii/rgephy.c 6 Apr 2022 18:59:29 -0000 1.41 > +++ dev/mii/rgephy.c 14 Jul 2022 19:27:01 -0000 > @@ -141,18 +141,20 @@ rgephyattach(struct device *parent, stru > int > rgephy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int anar, reg, speed, gig = 0; > char *devname; > > devname = sc->mii_dev.dv_parent->dv_cfdata->cf_driver->cd_name; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -161,7 +163,7 @@ rgephy_service(struct mii_softc *sc, str > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -178,7 +180,7 @@ rgephy_service(struct mii_softc *sc, str > anar = PHY_READ(sc, MII_ANAR); > anar &= ~(ANAR_TX_FD | ANAR_TX | ANAR_10_FD | ANAR_10); > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > (void) rgephy_mii_phy_auto(sc); > break; > @@ -194,19 +196,19 @@ rgephy_service(struct mii_softc *sc, str > anar |= ANAR_10_FD | ANAR_10; > setit: > rgephy_loop(sc); > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { > + if ((media & IFM_GMASK) == IFM_FDX) { > speed |= BMCR_FDX; > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) > + if (IFM_SUBTYPE(media) == IFM_1000_T) > gig = GTCR_ADV_1000TFDX; > anar &= ~(ANAR_TX | ANAR_10); > } else { > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T) > + if (IFM_SUBTYPE(media) == IFM_1000_T) > gig = GTCR_ADV_1000THDX; > anar &= > ~(ANAR_TX_FD | ANAR_10_FD); > } > > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_1000_T && > + if (IFM_SUBTYPE(media) == IFM_1000_T && > mii->mii_media.ifm_media & IFM_ETH_MASTER) > gig |= GTCR_MAN_MS|GTCR_ADV_MS; > > @@ -229,7 +231,7 @@ setit: > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -241,7 +243,7 @@ setit: > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > break; > > /* > Index: dev/mii/rlphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/rlphy.c,v > retrieving revision 1.34 > diff -u -p -r1.34 rlphy.c > --- dev/mii/rlphy.c 6 Apr 2022 18:59:29 -0000 1.34 > +++ dev/mii/rlphy.c 14 Jul 2022 19:28:23 -0000 > @@ -142,15 +142,18 @@ rlphyattach(struct device *parent, struc > int > rlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > + u_int data; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, &data); > + > /* > * Can't isolate the RTL8139 phy, so it has to be the only one. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > panic("rlphy_service: attempt to isolate phy"); > > switch (cmd) { > @@ -164,7 +167,7 @@ rlphy_service(struct mii_softc *sc, stru > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > break; > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > /* > * If we're already in auto mode, just return. > @@ -183,8 +186,8 @@ rlphy_service(struct mii_softc *sc, stru > * BMCR data is stored in the ifmedia entry. > */ > PHY_WRITE(sc, MII_ANAR, > - mii_anar(ife->ifm_media)); > - PHY_WRITE(sc, MII_BMCR, ife->ifm_data); > + mii_anar(media)); > + PHY_WRITE(sc, MII_BMCR, data); > } > break; > > @@ -218,7 +221,6 @@ void > rlphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, anlpar; > char *devname; > > @@ -311,5 +313,5 @@ rlphy_status(struct mii_softc *sc) > } > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/sqphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/sqphy.c,v > retrieving revision 1.22 > diff -u -p -r1.22 sqphy.c > --- dev/mii/sqphy.c 6 Apr 2022 18:59:29 -0000 1.22 > +++ dev/mii/sqphy.c 14 Jul 2022 19:28:51 -0000 > @@ -144,18 +144,20 @@ sqphyattach(struct device *parent, struc > int > sqphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -164,7 +166,7 @@ sqphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -183,7 +185,7 @@ sqphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -207,7 +209,6 @@ void > sqphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, status; > > mii->mii_media_status = IFM_AVALID; > @@ -250,5 +251,5 @@ sqphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/tlphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/tlphy.c,v > retrieving revision 1.22 > diff -u -p -r1.22 tlphy.c > --- dev/mii/tlphy.c 6 Apr 2022 18:59:29 -0000 1.22 > +++ dev/mii/tlphy.c 14 Jul 2022 19:42:22 -0000 > @@ -180,7 +180,7 @@ int > tlphy_service(struct mii_softc *self, struct mii_data *mii, int cmd) > { > struct tlphy_softc *sc = (struct tlphy_softc *)self; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->sc_mii.mii_dev.dv_flags & DVF_ACTIVE) == 0) > @@ -189,12 +189,14 @@ tlphy_service(struct mii_softc *self, st > if ((sc->sc_mii.mii_flags & MIIF_DOINGAUTO) == 0 && sc->sc_need_acomp) > tlphy_acomp(sc); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) > + if (IFM_INST(media) != sc->sc_mii.mii_inst) > return (0); > break; > > @@ -203,7 +205,7 @@ tlphy_service(struct mii_softc *self, st > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) { > + if (IFM_INST(media) != sc->sc_mii.mii_inst) { > reg = PHY_READ(&sc->sc_mii, MII_BMCR); > PHY_WRITE(&sc->sc_mii, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -215,7 +217,7 @@ tlphy_service(struct mii_softc *self, st > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > break; > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > /* > * The ThunderLAN PHY doesn't self-configure after > @@ -245,7 +247,7 @@ tlphy_service(struct mii_softc *self, st > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii.mii_inst) > + if (IFM_INST(media) != sc->sc_mii.mii_inst) > return (0); > > if (mii_phy_tick(&sc->sc_mii) == EJUSTRETURN) > @@ -285,7 +287,7 @@ tlphy_status(struct mii_softc *physc) > tlctrl = PHY_READ(&sc->sc_mii, MII_TLPHY_CTRL); > if (tlctrl & CTRL_AUISEL) { > mii->mii_media_status = 0; > - mii->mii_media_active = mii->mii_media.ifm_cur->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > return; > } > > Index: dev/mii/tqphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/tqphy.c,v > retrieving revision 1.19 > diff -u -p -r1.19 tqphy.c > --- dev/mii/tqphy.c 6 Apr 2022 18:59:29 -0000 1.19 > +++ dev/mii/tqphy.c 14 Jul 2022 19:31:43 -0000 > @@ -144,18 +144,20 @@ tqphyattach(struct device *parent, struc > int > tqphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -164,7 +166,7 @@ tqphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -183,7 +185,7 @@ tqphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > @@ -207,7 +209,6 @@ void > tqphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, diag; > > mii->mii_media_status = IFM_AVALID; > @@ -245,5 +246,5 @@ tqphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/txphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/txphy.c,v > retrieving revision 1.12 > diff -u -p -r1.12 txphy.c > --- dev/mii/txphy.c 6 Apr 2022 18:59:29 -0000 1.12 > +++ dev/mii/txphy.c 14 Jul 2022 19:32:33 -0000 > @@ -108,15 +108,17 @@ txphyattach(struct device *parent, struc > int > txphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > /* > * Can't isolate the RTL8139 phy, so it has to be the only one. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > panic("txphy_service: attempt to isolate phy"); > > switch (cmd) { > Index: dev/mii/ukphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/ukphy.c,v > retrieving revision 1.25 > diff -u -p -r1.25 ukphy.c > --- dev/mii/ukphy.c 6 Apr 2022 18:59:29 -0000 1.25 > +++ dev/mii/ukphy.c 14 Jul 2022 19:32:59 -0000 > @@ -140,18 +140,20 @@ ukphyattach(struct device *parent, struc > int > ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -160,7 +162,7 @@ ukphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -179,7 +181,7 @@ ukphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > if (mii_phy_tick(sc) == EJUSTRETURN) > Index: dev/mii/ukphy_subr.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/ukphy_subr.c,v > retrieving revision 1.10 > diff -u -p -r1.10 ukphy_subr.c > --- dev/mii/ukphy_subr.c 24 Oct 2008 16:50:01 -0000 1.10 > +++ dev/mii/ukphy_subr.c 14 Jul 2022 19:33:54 -0000 > @@ -55,7 +55,6 @@ void > ukphy_status(struct mii_softc *phy) > { > struct mii_data *mii = phy->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int bmsr, bmcr, anlpar, gtcr, gtsr; > > mii->mii_media_status = IFM_AVALID; > @@ -121,5 +120,5 @@ ukphy_status(struct mii_softc *phy) > (gtsr & GTSR_MS_RES)) > mii->mii_media_active |= IFM_ETH_MASTER; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/urlphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/urlphy.c,v > retrieving revision 1.18 > diff -u -p -r1.18 urlphy.c > --- dev/mii/urlphy.c 6 Apr 2022 18:59:29 -0000 1.18 > +++ dev/mii/urlphy.c 14 Jul 2022 19:33:32 -0000 > @@ -132,7 +132,7 @@ urlphy_attach(struct device *parent, str > int > urlphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > DPRINTF(("%s: %s: enter\n", sc->mii_dev.dv_xname, __func__)); > @@ -140,12 +140,14 @@ urlphy_service(struct mii_softc *sc, str > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -153,7 +155,7 @@ urlphy_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* If the interface is not up, don't do anything. */ > @@ -167,7 +169,7 @@ urlphy_service(struct mii_softc *sc, str > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* Just bail now if the interface is down. */ > @@ -180,7 +182,7 @@ urlphy_service(struct mii_softc *sc, str > * status so we can generate an announcement if the status > * changes. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > return (0); > > /* Read the status register twice; MSR_LINK is latch-low. */ > @@ -222,7 +224,6 @@ void > urlphy_status(struct mii_softc *sc) > { > struct mii_data *mii = sc->mii_pdata; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > int msr, bmsr, bmcr; > > DPRINTF(("%s: %s: enter\n", sc->mii_dev.dv_xname, __func__)); > @@ -260,5 +261,5 @@ urlphy_status(struct mii_softc *sc) > else > mii->mii_media_active |= IFM_HDX; > } else > - mii->mii_media_active = ife->ifm_media; > + ifmedia_current(&mii->mii_media, &mii->mii_media_active, NULL); > } > Index: dev/mii/xmphy.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/mii/xmphy.c,v > retrieving revision 1.24 > diff -u -p -r1.24 xmphy.c > --- dev/mii/xmphy.c 6 Apr 2022 18:59:29 -0000 1.24 > +++ dev/mii/xmphy.c 14 Jul 2022 19:34:56 -0000 > @@ -135,18 +135,20 @@ xmphy_attach(struct device *parent, stru > int > xmphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int reg; > > if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) > return (ENXIO); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > break; > > @@ -155,7 +157,7 @@ xmphy_service(struct mii_softc *sc, stru > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { > + if (IFM_INST(media) != sc->mii_inst) { > reg = PHY_READ(sc, MII_BMCR); > PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); > return (0); > @@ -167,13 +169,13 @@ xmphy_service(struct mii_softc *sc, stru > if ((mii->mii_ifp->if_flags & IFF_UP) == 0) > break; > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > (void) xmphy_mii_phy_auto(sc); > break; > case IFM_1000_SX: > PHY_RESET(sc); > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { > + if ((media & IFM_GMASK) == IFM_FDX) { > PHY_WRITE(sc, MII_ANAR, ANAR_10_FD); > PHY_WRITE(sc, MII_BMCR, BMCR_FDX); > } else { > @@ -190,7 +192,7 @@ xmphy_service(struct mii_softc *sc, stru > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->mii_inst) > + if (IFM_INST(media) != sc->mii_inst) > return (0); > > /* > @@ -202,7 +204,7 @@ xmphy_service(struct mii_softc *sc, stru > /* > * Only used for autonegotiation. > */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > break; > > /* > Index: dev/pci/if_bge.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_bge.c,v > retrieving revision 1.398 > diff -u -p -r1.398 if_bge.c > --- dev/pci/if_bge.c 11 Mar 2022 18:00:45 -0000 1.398 > +++ dev/pci/if_bge.c 14 Jul 2022 22:30:51 -0000 > @@ -1054,12 +1054,15 @@ bge_miibus_statchg(struct device *dev) > { > struct bge_softc *sc = (struct bge_softc *)dev; > struct mii_data *mii = &sc->bge_mii; > + uint64_t media; > u_int32_t mac_mode, rx_mode, tx_mode; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > /* > * Get flow control negotiation result. > */ > - if (IFM_SUBTYPE(mii->mii_media.ifm_cur->ifm_media) == IFM_AUTO && > + if (IFM_SUBTYPE(media) == IFM_AUTO && > (mii->mii_media_active & IFM_ETH_FMASK) != sc->bge_flowflags) > sc->bge_flowflags = mii->mii_media_active & IFM_ETH_FMASK; > > @@ -3095,7 +3098,8 @@ bge_attach(struct device *parent, struct > 0, NULL); > ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL); > ifmedia_set(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO); > - sc->bge_ifmedia.ifm_media = sc->bge_ifmedia.ifm_cur->ifm_media; > + ifmedia_current(&sc->bge_ifmedia, &sc->bge_ifmedia.ifm_media, > + NULL); > } else { > int mii_flags; > > Index: dev/pci/if_bnx.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_bnx.c,v > retrieving revision 1.132 > diff -u -p -r1.132 if_bnx.c > --- dev/pci/if_bnx.c 11 Mar 2022 18:00:45 -0000 1.132 > +++ dev/pci/if_bnx.c 14 Jul 2022 22:30:51 -0000 > @@ -1240,6 +1240,7 @@ bnx_miibus_statchg(struct device *dev) > { > struct bnx_softc *sc = (struct bnx_softc *)dev; > struct mii_data *mii = &sc->bnx_mii; > + uint64_t media; > u_int32_t rx_mode = sc->rx_mode; > int val; > > @@ -1248,10 +1249,12 @@ bnx_miibus_statchg(struct device *dev) > BNX_EMAC_MODE_MAC_LOOP | BNX_EMAC_MODE_FORCE_LINK | > BNX_EMAC_MODE_25G); > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > /* > * Get flow control negotiation result. > */ > - if (IFM_SUBTYPE(mii->mii_media.ifm_cur->ifm_media) == IFM_AUTO && > + if (IFM_SUBTYPE(media) == IFM_AUTO && > (mii->mii_media_active & IFM_ETH_FMASK) != sc->bnx_flowflags) { > sc->bnx_flowflags = mii->mii_media_active & IFM_ETH_FMASK; > mii->mii_media_active &= ~IFM_ETH_FMASK; > Index: dev/pci/if_cas.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_cas.c,v > retrieving revision 1.54 > diff -u -p -r1.54 if_cas.c > --- dev/pci/if_cas.c 11 Mar 2022 18:00:45 -0000 1.54 > +++ dev/pci/if_cas.c 14 Jul 2022 22:30:51 -0000 > @@ -1496,17 +1496,18 @@ void > cas_mii_statchg(struct device *dev) > { > struct cas_softc *sc = (void *)dev; > -#ifdef CAS_DEBUG > - uint64_t instance = IFM_INST(sc->sc_mii.mii_media.ifm_cur->ifm_media); > -#endif > bus_space_tag_t t = sc->sc_memt; > bus_space_handle_t mac = sc->sc_memh; > u_int32_t v; > > #ifdef CAS_DEBUG > - if (sc->sc_debug) > - printf("cas_mii_statchg: status change: phy = %d\n", > - sc->sc_phys[instance]); > + if (sc->sc_debug) { > + uint64_t media; > + > + ifmedia_current(&sc->sc_mii.mii_media, &media, NULL); > + printf("%s: status change: phy = %d\n", > + __func__, sc->sc_phys[IFM_INST(media)]); > + } > #endif > > /* Set tx full duplex options */ > Index: dev/pci/if_iwm.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_iwm.c,v > retrieving revision 1.403 > diff -u -p -r1.403 if_iwm.c > --- dev/pci/if_iwm.c 11 Jul 2022 11:28:37 -0000 1.403 > +++ dev/pci/if_iwm.c 14 Jul 2022 22:30:51 -0000 > @@ -8493,6 +8493,7 @@ iwm_scan(struct iwm_softc *sc) > { > struct ieee80211com *ic = &sc->sc_ic; > struct ifnet *ifp = IC2IFP(ic); > + uint64_t media; > int err; > > if (sc->sc_flags & IWM_FLAG_BGSCAN) { > @@ -8513,11 +8514,13 @@ iwm_scan(struct iwm_softc *sc) > return err; > } > > + ifmedia_current(&ic->ic_media, &media, NULL); > + > /* > * The current mode might have been fixed during association. > * Ensure all channels get scanned. > */ > - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) > + if (IFM_MODE(media) == IFM_AUTO) > ieee80211_setmode(ic, IEEE80211_MODE_AUTO); > > sc->sc_flags |= IWM_FLAG_SCANNING; > Index: dev/pci/if_iwn.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_iwn.c,v > retrieving revision 1.260 > diff -u -p -r1.260 if_iwn.c > --- dev/pci/if_iwn.c 19 Jun 2022 18:27:06 -0000 1.260 > +++ dev/pci/if_iwn.c 14 Jul 2022 22:30:51 -0000 > @@ -5355,11 +5355,14 @@ iwn_scan(struct iwn_softc *sc, uint16_t > > error = iwn_cmd(sc, IWN_CMD_SCAN, buf, buflen, 1); > if (error == 0) { > + uint64_t media; > + > /* > * The current mode might have been fixed during association. > * Ensure all channels get scanned. > */ > - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) > + ifmedia_current(&ic->ic_media, &media, NULL); > + if (IFM_MODE(media) == IFM_AUTO) > ieee80211_setmode(ic, IEEE80211_MODE_AUTO); > > sc->sc_flags |= IWN_FLAG_SCANNING; > Index: dev/pci/if_iwx.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_iwx.c,v > retrieving revision 1.149 > diff -u -p -r1.149 if_iwx.c > --- dev/pci/if_iwx.c 14 May 2022 05:42:39 -0000 1.149 > +++ dev/pci/if_iwx.c 14 Jul 2022 22:30:51 -0000 > @@ -7322,6 +7322,7 @@ iwx_scan(struct iwx_softc *sc) > { > struct ieee80211com *ic = &sc->sc_ic; > struct ifnet *ifp = IC2IFP(ic); > + uint64_t media; > int err; > > if (sc->sc_flags & IWX_FLAG_BGSCAN) { > @@ -7339,11 +7340,13 @@ iwx_scan(struct iwx_softc *sc) > return err; > } > > + ifmedia_current(&ic->ic_media, &media, NULL); > + > /* > * The current mode might have been fixed during association. > * Ensure all channels get scanned. > */ > - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) > + if (IFM_MODE(media) == IFM_AUTO) > ieee80211_setmode(ic, IEEE80211_MODE_AUTO); > > sc->sc_flags |= IWX_FLAG_SCANNING; > Index: dev/pci/if_msk.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_msk.c,v > retrieving revision 1.142 > diff -u -p -r1.142 if_msk.c > --- dev/pci/if_msk.c 11 Mar 2022 18:00:46 -0000 1.142 > +++ dev/pci/if_msk.c 14 Jul 2022 22:30:51 -0000 > @@ -442,13 +442,15 @@ msk_miibus_statchg(struct device *dev) > { > struct sk_if_softc *sc_if = (struct sk_if_softc *)dev; > struct mii_data *mii = &sc_if->sk_mii; > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int gpcr; > > gpcr = SK_YU_READ_2(sc_if, YUKON_GPCR); > gpcr &= (YU_GPCR_TXEN | YU_GPCR_RXEN); > > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO || > + ifmedia_current(&mii->mii_media, &media, NULL); > + > + if (IFM_SUBTYPE(media) != IFM_AUTO || > sc_if->sk_softc->sk_type == SK_YUKON_FE_P) { > /* Set speed. */ > gpcr |= YU_GPCR_SPEED_DIS; > Index: dev/pci/if_nge.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_nge.c,v > retrieving revision 1.96 > diff -u -p -r1.96 if_nge.c > --- dev/pci/if_nge.c 11 Mar 2022 18:00:48 -0000 1.96 > +++ dev/pci/if_nge.c 14 Jul 2022 22:30:51 -0000 > @@ -1179,8 +1179,11 @@ nge_tick(void *xsc) > } > > if (sc->nge_tbi) { > - if (IFM_SUBTYPE(sc->nge_ifmedia.ifm_cur->ifm_media) > - == IFM_AUTO) { > + uint64_t media; > + > + ifmedia_current(&sc->nge_ifmedia, &media, NULL); > + > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > u_int32_t bmsr, anlpar, txcfg, rxcfg; > > bmsr = CSR_READ_4(sc, NGE_TBI_BMSR); > @@ -1558,7 +1561,7 @@ nge_init(void *xsc) > > /* Set full/half duplex mode. */ > if (sc->nge_tbi) > - media = sc->nge_ifmedia.ifm_cur->ifm_media; > + ifmedia_current(&sc->nge_ifmedia, &media, NULL); > else > media = mii->mii_media_active; > > @@ -1670,13 +1673,15 @@ int > nge_ifmedia_tbi_upd(struct ifnet *ifp) > { > struct nge_softc *sc = ifp->if_softc; > + uint64_t media; > > DPRINTFN(2, ("%s: nge_ifmedia_tbi_upd\n", sc->sc_dv.dv_xname)); > > sc->nge_link = 0; > > - if (IFM_SUBTYPE(sc->nge_ifmedia.ifm_cur->ifm_media) > - == IFM_AUTO) { > + ifmedia_current(&sc->nge_ifmedia, &media, NULL); > + > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > u_int32_t anar, bmcr; > anar = CSR_READ_4(sc, NGE_TBI_ANAR); > anar |= (NGE_TBIANAR_HDX | NGE_TBIANAR_FDX); > @@ -1693,8 +1698,7 @@ nge_ifmedia_tbi_upd(struct ifnet *ifp) > txcfg = CSR_READ_4(sc, NGE_TX_CFG); > rxcfg = CSR_READ_4(sc, NGE_RX_CFG); > > - if ((sc->nge_ifmedia.ifm_cur->ifm_media & IFM_GMASK) > - == IFM_FDX) { > + if ((media & IFM_GMASK) == IFM_FDX) { > txcfg |= NGE_TXCFG_IGN_HBEAT|NGE_TXCFG_IGN_CARR; > rxcfg |= NGE_RXCFG_RX_FDX; > } else { > @@ -1719,11 +1723,14 @@ void > nge_ifmedia_tbi_sts(struct ifnet *ifp, struct ifmediareq *ifmr) > { > struct nge_softc *sc = ifp->if_softc; > + uint64_t media; > u_int32_t bmcr; > > bmcr = CSR_READ_4(sc, NGE_TBI_BMCR); > > - if (IFM_SUBTYPE(sc->nge_ifmedia.ifm_cur->ifm_media) == IFM_AUTO) { > + ifmedia_current(&sc->nge_ifmedia, &media, NULL); > + > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > u_int32_t bmsr = CSR_READ_4(sc, NGE_TBI_BMSR); > DPRINTFN(2, ("%s: nge_ifmedia_tbi_sts bmsr=%#x, bmcr=%#x\n", > sc->sc_dv.dv_xname, bmsr, bmcr)); > @@ -1744,7 +1751,7 @@ nge_ifmedia_tbi_sts(struct ifnet *ifp, s > if (bmcr & NGE_TBIBMCR_LOOPBACK) > ifmr->ifm_active |= IFM_LOOP; > > - if (IFM_SUBTYPE(sc->nge_ifmedia.ifm_cur->ifm_media) == IFM_AUTO) { > + if (IFM_SUBTYPE(media) == IFM_AUTO) { > u_int32_t anlpar = CSR_READ_4(sc, NGE_TBI_ANLPAR); > DPRINTFN(2, ("%s: nge_ifmedia_tbi_sts anlpar=%#x\n", > sc->sc_dv.dv_xname, anlpar)); > @@ -1757,7 +1764,7 @@ nge_ifmedia_tbi_sts(struct ifnet *ifp, s > } else > ifmr->ifm_active |= IFM_FDX; > > - } else if ((sc->nge_ifmedia.ifm_cur->ifm_media & IFM_GMASK) == IFM_FDX) > + } else if ((media & IFM_GMASK) == IFM_FDX) > ifmr->ifm_active |= IFM_FDX; > else > ifmr->ifm_active |= IFM_HDX; > Index: dev/pci/if_pcn.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_pcn.c,v > retrieving revision 1.48 > diff -u -p -r1.48 if_pcn.c > --- dev/pci/if_pcn.c 10 Jul 2022 21:13:41 -0000 1.48 > +++ dev/pci/if_pcn.c 14 Jul 2022 22:30:51 -0000 > @@ -1861,8 +1861,12 @@ int > pcn_79c970_mediachange(struct ifnet *ifp) > { > struct pcn_softc *sc = ifp->if_softc; > + uint64_t media; > + u_int data; > uint32_t reg; > > + ifmedia_current(&sc->sc_mii.mii_media, &media, &data); > + > if (IFM_SUBTYPE(sc->sc_mii.mii_media.ifm_media) == IFM_AUTO) { > /* > * CSR15:PORTSEL doesn't matter. Just set BCR2:ASEL. > @@ -1880,7 +1884,7 @@ pcn_79c970_mediachange(struct ifnet *ifp > > reg = pcn_csr_read(sc, LE_CSR15); > reg = (reg & ~LE_C15_PORTSEL(PORTSEL_MASK)) | > - LE_C15_PORTSEL(sc->sc_mii.mii_media.ifm_cur->ifm_data); > + LE_C15_PORTSEL(data); > pcn_csr_write(sc, LE_CSR15, reg); > } > > Index: dev/pci/if_rge.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_rge.c,v > retrieving revision 1.19 > diff -u -p -r1.19 if_rge.c > --- dev/pci/if_rge.c 21 Apr 2022 05:08:39 -0000 1.19 > +++ dev/pci/if_rge.c 14 Jul 2022 22:30:51 -0000 > @@ -303,7 +303,7 @@ rge_attach(struct device *parent, struct > rge_add_media_types(sc); > ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL); > ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO); > - sc->sc_media.ifm_media = sc->sc_media.ifm_cur->ifm_media; > + ifmedia_current(&sc->sc_media, &sc->sc_media.ifm_media, NULL); > > if_attach(ifp); > ether_ifattach(ifp); > Index: dev/pci/if_tl.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_tl.c,v > retrieving revision 1.76 > diff -u -p -r1.76 if_tl.c > --- dev/pci/if_tl.c 11 Mar 2022 18:00:50 -0000 1.76 > +++ dev/pci/if_tl.c 14 Jul 2022 22:41:35 -0000 > @@ -1988,7 +1988,6 @@ tl_attach(struct device *parent, struct > mii_attach(self, &sc->sc_mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, > 0); > if (LIST_FIRST(&sc->sc_mii.mii_phys) == NULL) { > - struct ifmedia *ifm; > sc->tl_bitrate = 1; > ifmedia_init(&sc->ifmedia, 0, tl_ifmedia_upd, tl_ifmedia_sts); > ifmedia_add(&sc->ifmedia, IFM_ETHER|IFM_10_T, 0, NULL); > @@ -1998,8 +1997,7 @@ tl_attach(struct device *parent, struct > ifmedia_set(&sc->ifmedia, IFM_ETHER|IFM_10_T); > /* Reset again, this time setting bitrate mode. */ > tl_softreset(sc, 1); > - ifm = &sc->ifmedia; > - ifm->ifm_media = ifm->ifm_cur->ifm_media; > + ifmedia_current(&sc->ifmedia, &sc->ifmedia.ifm_media, NULL); > tl_ifmedia_upd(ifp); > } else > ifmedia_set(&sc->sc_mii.mii_media, IFM_ETHER|IFM_AUTO); > Index: dev/pci/if_txp.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_txp.c,v > retrieving revision 1.129 > diff -u -p -r1.129 if_txp.c > --- dev/pci/if_txp.c 11 Mar 2022 18:00:50 -0000 1.129 > +++ dev/pci/if_txp.c 14 Jul 2022 22:30:51 -0000 > @@ -1661,7 +1661,6 @@ void > txp_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) > { > struct txp_softc *sc = ifp->if_softc; > - struct ifmedia *ifm = &sc->sc_ifmedia; > u_int16_t bmsr, bmcr, anar, anlpar; > > ifmr->ifm_status = IFM_AVALID; > @@ -1718,7 +1717,8 @@ txp_ifmedia_sts(struct ifnet *ifp, struc > else > ifmr->ifm_active |= IFM_NONE; > } else > - ifmr->ifm_active = ifm->ifm_cur->ifm_media; > + ifmedia_current(&sc->sc_ifmedia, &ifmr->ifm_active, NULL); > + > return; > > bail: > Index: dev/pci/if_vge.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_vge.c,v > retrieving revision 1.76 > diff -u -p -r1.76 if_vge.c > --- dev/pci/if_vge.c 11 Mar 2022 18:00:50 -0000 1.76 > +++ dev/pci/if_vge.c 14 Jul 2022 22:30:51 -0000 > @@ -1674,11 +1674,10 @@ void > vge_miibus_statchg(struct device *dev) > { > struct vge_softc *sc = (struct vge_softc *)dev; > - struct mii_data *mii; > - struct ifmedia_entry *ife; > + struct mii_data *mii = &sc->sc_mii; > + uint64_t media; > > - mii = &sc->sc_mii; > - ife = mii->mii_media.ifm_cur; > + ifmedia_current(&mii->mii_media, &media, NULL); > > /* > * If the user manually selects a media mode, we need to turn > @@ -1691,7 +1690,7 @@ vge_miibus_statchg(struct device *dev) > * the FDX bit cleared. > */ > > - switch (IFM_SUBTYPE(ife->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_AUTO: > CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE); > CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE); > @@ -1703,7 +1702,7 @@ vge_miibus_statchg(struct device *dev) > case IFM_100_TX: > case IFM_10_T: > CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_MACFORCE); > - if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { > + if ((media & IFM_GMASK) == IFM_FDX) { > CSR_SETBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE); > } else { > CSR_CLRBIT_1(sc, VGE_DIAGCTL, VGE_DIAGCTL_FDXFORCE); > @@ -1711,7 +1710,7 @@ vge_miibus_statchg(struct device *dev) > break; > default: > printf("%s: unknown media type: %llx\n", > - sc->vge_dev.dv_xname, IFM_SUBTYPE(ife->ifm_media)); > + sc->vge_dev.dv_xname, IFM_SUBTYPE(media)); > break; > } > > Index: dev/sbus/be.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/sbus/be.c,v > retrieving revision 1.44 > diff -u -p -r1.44 be.c > --- dev/sbus/be.c 13 Mar 2022 13:34:54 -0000 1.44 > +++ dev/sbus/be.c 15 Jul 2022 08:13:09 -0000 > @@ -1321,13 +1321,15 @@ be_mii_statchg(struct device *self) > struct be_softc *sc = (struct be_softc *)self; > bus_space_tag_t t = sc->sc_bustag; > bus_space_handle_t br = sc->sc_br; > - u_int64_t instance; > + u_int64_t media; > u_int32_t v; > > - instance = IFM_INST(sc->sc_mii.mii_media.ifm_cur->ifm_media); > + ifmedia_current(&sc->sc_mii.mii_media, &media, NULL); > #ifdef DIAGNOSTIC > - if (instance > 1) > - panic("be_mii_statchg: instance %lld out of range", instance); > + if (IFM_INST(media) > 1) { > + panic("%s: instance %lld out of range", > + __func__, IFM_INST(media)); > + } > #endif > > /* Update duplex mode in TX configuration */ > @@ -1339,7 +1341,7 @@ be_mii_statchg(struct device *self) > bus_space_write_4(t, br, BE_BRI_TXCFG, v); > > /* Change to appropriate gate in transceiver PAL */ > - be_pal_gate(sc, sc->sc_phys[instance]); > + be_pal_gate(sc, sc->sc_phys[IFM_INST(media)]); > } > > /* > @@ -1379,16 +1381,18 @@ be_ifmedia_upd(struct ifnet *ifp) > int > be_intphy_service(struct be_softc *sc, struct mii_data *mii, int cmd) > { > - struct ifmedia_entry *ife = mii->mii_media.ifm_cur; > + uint64_t media; > int bmcr, bmsr; > int error; > > + ifmedia_current(&mii->mii_media, &media, NULL); > + > switch (cmd) { > case MII_POLLSTAT: > /* > * If we're not polling our PHY instance, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii_inst) > + if (IFM_INST(media) != sc->sc_mii_inst) > return (0); > > break; > @@ -1399,7 +1403,7 @@ be_intphy_service(struct be_softc *sc, s > * If the media indicates a different PHY instance, > * isolate ourselves. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii_inst) { > + if (IFM_INST(media) != sc->sc_mii_inst) { > bmcr = be_mii_readreg((void *)sc, > BE_PHY_INTERNAL, MII_BMCR); > be_mii_writereg((void *)sc, > @@ -1418,11 +1422,11 @@ be_intphy_service(struct be_softc *sc, s > /* > * Select the new mode and take out of isolation > */ > - if (IFM_SUBTYPE(ife->ifm_media) == IFM_100_TX) > + if (IFM_SUBTYPE(media) == IFM_100_TX) > bmcr |= BMCR_S100; > - else if (IFM_SUBTYPE(ife->ifm_media) == IFM_10_T) > + else if (IFM_SUBTYPE(media) == IFM_10_T) > bmcr &= ~BMCR_S100; > - else if (IFM_SUBTYPE(ife->ifm_media) == IFM_AUTO) { > + else if (IFM_SUBTYPE(media) == IFM_AUTO) { > if ((sc->sc_mii_flags & MIIF_HAVELINK) != 0) { > bmcr &= ~BMCR_S100; > bmcr |= sc->sc_intphy_curspeed; > @@ -1433,7 +1437,7 @@ be_intphy_service(struct be_softc *sc, s > } > } > > - if ((IFM_OPTIONS(ife->ifm_media) & IFM_FDX) != 0) > + if ((IFM_OPTIONS(media) & IFM_FDX) != 0) > bmcr |= BMCR_FDX; > else > bmcr &= ~BMCR_FDX; > @@ -1445,11 +1449,11 @@ be_intphy_service(struct be_softc *sc, s > /* > * If we're not currently selected, just return. > */ > - if (IFM_INST(ife->ifm_media) != sc->sc_mii_inst) > + if (IFM_INST(media) != sc->sc_mii_inst) > return (0); > > /* Only used for automatic media selection */ > - if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) > + if (IFM_SUBTYPE(media) != IFM_AUTO) > return (0); > > /* Is the interface even up? */ > Index: dev/sbus/if_le_ledma.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/sbus/if_le_ledma.c,v > retrieving revision 1.20 > diff -u -p -r1.20 if_le_ledma.c > --- dev/sbus/if_le_ledma.c 13 Mar 2022 13:34:54 -0000 1.20 > +++ dev/sbus/if_le_ledma.c 14 Jul 2022 20:24:23 -0000 > @@ -249,12 +249,15 @@ le_ledma_hwreset(struct lance_softc *sc) > void > le_ledma_hwinit(struct lance_softc *sc) > { > + uint64_t media; > + > + ifmedia_current(&sc->sc_ifmedia, &media, NULL); > > /* > * Make sure we're using the currently-enabled media type. > * XXX Actually, this is probably unnecessary, now. > */ > - switch (IFM_SUBTYPE(sc->sc_ifmedia.ifm_cur->ifm_media)) { > + switch (IFM_SUBTYPE(media)) { > case IFM_10_T: > le_ledma_setutp(sc); > break; > Index: dev/usb/if_uaq.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/usb/if_uaq.c,v > retrieving revision 1.4 > diff -u -p -r1.4 if_uaq.c > --- dev/usb/if_uaq.c 26 Jun 2022 15:25:03 -0000 1.4 > +++ dev/usb/if_uaq.c 14 Jul 2022 20:25:12 -0000 > @@ -513,7 +513,7 @@ uaq_attach(struct device *parent, struct > uaq_add_media_types(sc); > ifmedia_add(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL); > ifmedia_set(&sc->sc_ifmedia, IFM_ETHER | IFM_AUTO); > - sc->sc_ifmedia.ifm_media = sc->sc_ifmedia.ifm_cur->ifm_media; > + ifmedia_current(&sc->sc_ifmedia, &sc->sc_ifmedia.ifm_media, NULL); > > if_attach(ifp); > ether_ifattach(ifp); > Index: dev/usb/if_ure.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/usb/if_ure.c,v > retrieving revision 1.30 > diff -u -p -r1.30 if_ure.c > --- dev/usb/if_ure.c 2 Apr 2022 15:35:06 -0000 1.30 > +++ dev/usb/if_ure.c 14 Jul 2022 20:25:52 -0000 > @@ -1855,7 +1855,8 @@ ure_attach(struct device *parent, struct > ure_add_media_types(sc); > ifmedia_add(&sc->ure_ifmedia, IFM_ETHER | IFM_AUTO, 0, NULL); > ifmedia_set(&sc->ure_ifmedia, IFM_ETHER | IFM_AUTO); > - sc->ure_ifmedia.ifm_media = sc->ure_ifmedia.ifm_cur->ifm_media; > + ifmedia_current(&sc->ure_ifmedia, &sc->ure_ifmedia.ifm_media, > + NULL); > } else { > rw_init(&sc->ure_mii_lock, "uremii"); > > Index: net/if_media.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_media.c,v > retrieving revision 1.36 > diff -u -p -r1.36 if_media.c > --- net/if_media.c 14 Jul 2022 13:46:25 -0000 1.36 > +++ net/if_media.c 14 Jul 2022 22:30:51 -0000 > @@ -430,6 +430,21 @@ ifmedia_get(struct ifmedia *ifm, uint64_ > return (match); > } > > +void > +ifmedia_current(struct ifmedia *ifm, uint64_t *media, u_int *data) > +{ > + struct ifmedia_entry *ife; > + > + mtx_enter(&ifmedia_mtx); > + ife = ifm->ifm_cur; > + KASSERT(ife != NULL); > + if (media != NULL) > + *media = ife->ifm_media; > + if (data != NULL) > + *data = ife->ifm_data; > + mtx_leave(&ifmedia_mtx); > +} > + > /* > * Delete all media for a given instance. > */ > Index: net/if_media.h > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/net/if_media.h,v > retrieving revision 1.45 > diff -u -p -r1.45 if_media.h > --- net/if_media.h 14 Jul 2022 13:46:25 -0000 1.45 > +++ net/if_media.h 14 Jul 2022 22:30:51 -0000 > @@ -131,6 +131,9 @@ int ifmedia_ioctl(struct ifnet *, struct > /* Locate a media entry */ > int ifmedia_match(struct ifmedia *, uint64_t, uint64_t); > > +/* Get current media and data */ > +void ifmedia_current(struct ifmedia *, uint64_t *, u_int *); > + > /* Delete all media for a given media instance */ > void ifmedia_delete_instance(struct ifmedia *, uint64_t); > > Index: net80211/ieee80211.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/net80211/ieee80211.c,v > retrieving revision 1.88 > diff -u -p -r1.88 ieee80211.c > --- net80211/ieee80211.c 19 Mar 2022 10:25:09 -0000 1.88 > +++ net80211/ieee80211.c 14 Jul 2022 22:38:22 -0000 > @@ -508,16 +508,17 @@ int > ieee80211_media_change(struct ifnet *ifp) > { > struct ieee80211com *ic = (void *)ifp; > - struct ifmedia_entry *ime; > enum ieee80211_opmode newopmode; > enum ieee80211_phymode newphymode; > + uint64_t media; > int i, j, newrate, error = 0; > > - ime = ic->ic_media.ifm_cur; > + ifmedia_current(&ic->ic_media, &media, NULL); > + > /* > * First, identify the phy mode. > */ > - switch (IFM_MODE(ime->ifm_media)) { > + switch (IFM_MODE(media)) { > case IFM_IEEE80211_11A: > newphymode = IEEE80211_MODE_11A; > break; > @@ -550,32 +551,32 @@ ieee80211_media_change(struct ifnet *ifp > * Next, the fixed/variable rate. > */ > i = -1; > - if (IFM_SUBTYPE(ime->ifm_media) >= IFM_IEEE80211_VHT_MCS0 && > - IFM_SUBTYPE(ime->ifm_media) <= IFM_IEEE80211_VHT_MCS9) { > + if (IFM_SUBTYPE(media) >= IFM_IEEE80211_VHT_MCS0 && > + IFM_SUBTYPE(media) <= IFM_IEEE80211_VHT_MCS9) { > if ((ic->ic_modecaps & (1 << IEEE80211_MODE_11AC)) == 0) > return EINVAL; > if (newphymode != IEEE80211_MODE_AUTO && > newphymode != IEEE80211_MODE_11AC) > return EINVAL; > - i = ieee80211_media2mcs(ime->ifm_media); > + i = ieee80211_media2mcs(media); > /* TODO: Obtain VHT MCS information from VHT CAP IE. */ > if (i == -1 /* || !vht_mcs_supported */) > return EINVAL; > - } else if (IFM_SUBTYPE(ime->ifm_media) >= IFM_IEEE80211_HT_MCS0 && > - IFM_SUBTYPE(ime->ifm_media) <= IFM_IEEE80211_HT_MCS76) { > + } else if (IFM_SUBTYPE(media) >= IFM_IEEE80211_HT_MCS0 && > + IFM_SUBTYPE(media) <= IFM_IEEE80211_HT_MCS76) { > if ((ic->ic_modecaps & (1 << IEEE80211_MODE_11N)) == 0) > return EINVAL; > if (newphymode != IEEE80211_MODE_AUTO && > newphymode != IEEE80211_MODE_11N) > return EINVAL; > - i = ieee80211_media2mcs(ime->ifm_media); > + i = ieee80211_media2mcs(media); > if (i == -1 || isclr(ic->ic_sup_mcs, i)) > return EINVAL; > - } else if (IFM_SUBTYPE(ime->ifm_media) != IFM_AUTO) { > + } else if (IFM_SUBTYPE(media) != IFM_AUTO) { > /* > * Convert media subtype to rate. > */ > - newrate = ieee80211_media2rate(ime->ifm_media); > + newrate = ieee80211_media2rate(media); > if (newrate == 0) > return EINVAL; > /* > @@ -608,15 +609,15 @@ ieee80211_media_change(struct ifnet *ifp > * Deduce new operating mode but don't install it just yet. > */ > #ifndef IEEE80211_STA_ONLY > - if (ime->ifm_media & IFM_IEEE80211_ADHOC) > + if (media & IFM_IEEE80211_ADHOC) > newopmode = IEEE80211_M_AHDEMO; > - else if (ime->ifm_media & IFM_IEEE80211_HOSTAP) > + else if (media & IFM_IEEE80211_HOSTAP) > newopmode = IEEE80211_M_HOSTAP; > - else if (ime->ifm_media & IFM_IEEE80211_IBSS) > + else if (media & IFM_IEEE80211_IBSS) > newopmode = IEEE80211_M_IBSS; > else > #endif > - if (ime->ifm_media & IFM_IEEE80211_MONITOR) > + if (media & IFM_IEEE80211_MONITOR) > newopmode = IEEE80211_M_MONITOR; > else > newopmode = IEEE80211_M_STA; > @@ -712,7 +713,7 @@ ieee80211_media_change(struct ifnet *ifp > } > #ifdef notdef > if (error == 0) > - ifp->if_baudrate = ifmedia_baudrate(ime->ifm_media); > + ifp->if_baudrate = ifmedia_baudrate(media); > #endif > return error; > } > @@ -1119,13 +1120,16 @@ enum ieee80211_phymode > ieee80211_next_mode(struct ifnet *ifp) > { > struct ieee80211com *ic = (void *)ifp; > + uint64_t media; > uint16_t mode; > > + ifmedia_current(&ic->ic_media, &media, NULL); > + > /* > * Indicate a wrap-around if we're running in a fixed, user-specified > * phy mode. > */ > - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) != IFM_AUTO) > + if (IFM_MODE(media) != IFM_AUTO) > return (IEEE80211_MODE_AUTO); > > /* > Index: net80211/ieee80211_node.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/net80211/ieee80211_node.c,v > retrieving revision 1.195 > diff -u -p -r1.195 ieee80211_node.c > --- net80211/ieee80211_node.c 20 Mar 2022 07:50:32 -0000 1.195 > +++ net80211/ieee80211_node.c 14 Jul 2022 22:39:11 -0000 > @@ -836,6 +836,7 @@ void > ieee80211_begin_scan(struct ifnet *ifp) > { > struct ieee80211com *ic = (void *)ifp; > + uint64_t media; > > /* > * In all but hostap mode scanning starts off in > @@ -863,11 +864,13 @@ ieee80211_begin_scan(struct ifnet *ifp) > ieee80211_iterate_nodes(ic, ieee80211_node_raise_inact, NULL); > } > > + ifmedia_current(&ic->ic_media, &media, NULL); > + > /* > * Reset the current mode. Setting the current mode will also > * reset scan state. > */ > - if (IFM_MODE(ic->ic_media.ifm_cur->ifm_media) == IFM_AUTO) > + if (IFM_MODE(media) == IFM_AUTO) > ic->ic_curmode = IEEE80211_MODE_AUTO; > ieee80211_setmode(ic, ic->ic_curmode); >