Subject: Changes to if_media for sysinst on NetBSD/sparc 1.4
To: None <pk@netbsd.org, thorpej@netbsd.org>
From: David Brownlee <abs@anim.dreamworks.com>
List: port-sparc
Date: 04/29/1999 10:12:58
I have sysinst working on sparc, bar 'media selection' on an ss2.
sysinst tries 'ifconfig le0 ... media 10base5', which fails.
10base5 is the only supported media, so from a user perspective
this _should_ work, albeit being a NOP.
I'd like to get a fix under the wire for 1.4 - help needed.
Some options at the end - my preferred option would be b) or c).
Details: (what I believe is happening)
Lance init call ifmedia_set() which sets sc->sc_media->ifm_cur to
the appropriate ifmedia_entry *, but leaves sc->sc_media.ifm_media
(the user selected media word) at 0.
'ifconfig le0 media 10base5' calls SIOCSIFMEDIA ioctl() which
passes the media word to ifmedia_ioctl(), which makes the
following check to see if it needs to take action:
if ((IFM_SUBTYPE(newmedia) != IFM_AUTO) &&
(newmedia == ifm->ifm_media) &&
(match == ifm->ifm_cur))
return 0;
The first and third checks are OK, but the second check fails because
newmedia==0x25, while ifm->ifm_media is still 0 from the init routine.
ifmedia_ioctl() then calls ifm->ifm_change (lance_mediachange())
which performs:
if (sc->sc_mediachange)
return ((*sc->sc_mediachange)(sc));
return (EINVAL);
Since sc->sc_mediachange is not set by leattach_sbus() in if_le.c,
we fail with EINVAL and sysinst chokes.
Some options:
a) Implement sc->sc_mediachange in if_le.c which does nothing but
return success. Easy, but duplicated code in all single media
drivers, and feels wrong.
b) Change the check in ifmedia_ioctl() from
(newmedia == ifm->ifm_media)
to
(ifm->ifm_media == 0 || newmedia == ifm->ifm_media)
This fixes my case, but would change the behaviour for drivers
that support multiple media, when the first SIOCSIFMEDIA ioctl()
re-selects the default media (ifm->ifm_change would not be called).
c) Same as b), except only affect drives with only one media type:
(newmedia == ifm->ifm_media || (ifm->ifm_media == 0 &&
LIST_NEXT(ifm->ifm_list.lh_first,ifm_list)==0)) &&
Only affects single media drivers, and a media change on a single
media driver _should_ be a NOP. I can't find a cleaner way to
check for a single media driver in ifmedia_ioctl().
d) Modify sysinst to not set media if only one media supported
David/absolute
"You think you're God's gift to the opposite sex"
"Maybe... if you believe in a malevolent God."