History log of /netbsd-current/sys/dev/ic/smc91cxx.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.108 25-Sep-2022 thorpej

Remove unnecessary include of <sys/malloc.h>.


# 1.107 24-May-2022 andvar

fix various typos in comment, documentation and log messages.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.106 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.105 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.104 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.103 06-Dec-2019 maxv

branches: 1.103.2;
localify


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

branches: 1.97.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.107 24-May-2022 andvar

fix various typos in comment, documentation and log messages.


Revision tags: thorpej-i2c-spi-conf2-base thorpej-futex2-base thorpej-cfargs2-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base thorpej-i2c-spi-conf-base thorpej-cfargs-base thorpej-futex-base bouyer-xenpvh-base2 phil-wifi-20200421 bouyer-xenpvh-base1 phil-wifi-20200411 bouyer-xenpvh-base is-mlppp-base phil-wifi-20200406 ad-namecache-base3
# 1.106 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.105 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.104 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.103 06-Dec-2019 maxv

branches: 1.103.2;
localify


Revision tags: netbsd-9-2-RELEASE netbsd-9-1-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

branches: 1.97.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.106 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.105 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.104 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.103 06-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

branches: 1.97.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.105 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.104 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.103 06-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

branches: 1.97.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.104 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.103 06-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

branches: 1.97.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.103 06-Dec-2019 maxv

localify


Revision tags: netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609
# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

branches: 1.97.2;
Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.102 30-May-2019 msaitoh

Simplify MII structure initialization and reference. No functional change.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.101 25-Apr-2019 msaitoh

No functional change:
- Use __arraycount().
- u_int_{8,16,32}_t -> uint_{8,16,32}_t
- KNF.
- Tabify.
- Remove extra space.


# 1.100 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). These drivers don't return ENETRESET in
ifmedia_ioctl(), so no functional change.


Revision tags: isaki-audio2-base
# 1.99 05-Feb-2019 msaitoh

Remove very old IFF_NOTRAILERS flag.


Revision tags: pgoyette-compat-20190127
# 1.98 22-Jan-2019 msaitoh

Change MII PHY read/write API from:

int (*mii_readreg_t)(device_t, int, int);
void (*mii_writereg_t)(device_t, int, int, int);
to:

int (*mii_readreg_t)(device_t, int, int, uint16_t *);
int (*mii_writereg_t)(device_t, int, int, uint16_t);

Now we can test if a read/write operation failed or not by the return value.

In 802.3 spec says that the PHY shall not respond to read/write transaction
to the unimplemented register(22.2.4.3). Detecting timeout can be used to
check whether a register is implemented or not (if the register conforms to
the spec). ukphy(4) can be used this for MII_MMDACR and MII_MMDAADR.

Note that I noticed that the following code do infinite loop in the
read/wirte function. If it accesses unimplemented PHY register, it will hang.
It should be fixed:

arm/at91/at91emac.c
arm/ep93xx/epe.c
arm/omap/omapl1x_emac.c
mips/ralink/ralink_eth.c
arch/powerpc/booke/dev/pq3etsec.c(read)
dev/cadence/if_cemac.c <- hkenken
dev/ic/lan9118.c


Tested with the following device:

axe+ukphy
axe+rgephy
axen+rgephy (tested by Andrius V)
wm+atphy
wm+ukphy
wm+igphy
wm+ihphy
wm+makphy
sk+makphy
sk+brgphy
sk+gentbi
msk+makphy
sip+icsphy
sip+ukphy
re+rgephy
bge+brgphy
bnx+brgphy
gsip+gphyter
rtk+rlphy
fxp+inphy (tested by Andrius V)
tlp+acphy
ex+exphy
epic+qsphy
vge+ciphy (tested by Andrius V)
vr+ukphy (tested by Andrius V)
vte+ukphy (tested by Andrius V)

Not tested (MAC):
arm:at91emac
arm:cemac
arm:epe
arm:geminigmac
arm:enet
arm:cpsw
arm:emac(omac)
arm:emac(sunxi)
arm:npe
evbppc:temac
macppc:bm
macppc:gm
mips:aumac
mips:ae
mips:cnmac
mips:reth
mips:sbmac
playstation2:smap
powerpc:tsec
powerpc:emac(ibm4xx)
sgimips:mec
sparc:be
sf
ne(ax88190, dl10019)
awge
ep
gem
hme
smsh
mtd
sm
age
alc
ale
bce
cas
et
jme
lii
nfe
pcn
ste
stge
tl
xi
aue
mue
smsc
udav
url

Not tested (PHY):
amhphy
bmtphy
dmphy
etphy
glxtphy
ikphy
iophy
lxtphy
nsphyter
pnaphy
rdcphy
sqphy
tlphy
tqphy
urlphy


Revision tags: pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 jdolecek-ncqfixes-base pgoyette-compat-0728 phil-wifi-base
# 1.97 26-Jun-2018 msaitoh

Implement the BPF direction filter (BIOC[GS]DIRECTION). It provides backward
compatibility with BIOC[GS]SEESENT ioctl. The userland interface is the same
as FreeBSD.

This change also fixes a bug that the direction is misunderstand on some
environment by passing the direction to bpf_mtap*() instead of checking
m->m_pkthdr.rcvif.


Revision tags: pgoyette-compat-0625
# 1.96 22-Jun-2018 msaitoh

It's not required to include net/bpfdesc.h. Remove it.


Revision tags: netbsd-8-0-RELEASE netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202 matt-nb8-mediatek-base nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base
# 1.95 23-May-2017 ozaki-r

branches: 1.95.2; 1.95.8;
Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.95 23-May-2017 ozaki-r

Apply deferred if_start to more drivers

And annotate some XXX_start as it runs in softint to clarify that
it doesn't need deferred if_start.


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

branches: 1.93.2;
KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.


# 1.94 15-Dec-2016 ozaki-r

Move bpf_mtap and if_ipackets++ on Rx of each driver to percpuq if_input

The benefits of the change are:
- We can reduce codes
- We can provide the same behavior between drivers
- Where/When if_ipackets is counted up
- Note that some drivers still update packet statistics in their own
way (periodical update)
- Moved bpf_mtap run in softint
- This makes it easy to MP-ify bpf

Proposed on tech-kern and tech-net


Revision tags: nick-nhusb-base-20161204 pgoyette-localcount-20161104 nick-nhusb-base-20161004 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base nick-nhusb-base-20160907
# 1.93 07-Jul-2016 msaitoh

KNF. Remove extra spaces. No functional change.


# 1.92 10-Jun-2016 ozaki-r

Introduce m_set_rcvif and m_reset_rcvif

The API is used to set (or reset) a received interface of a mbuf.
They are counterpart of m_get_rcvif, which will come in another
commit, hide internal of rcvif operation, and reduce the diff of
the upcoming change.

No functional change.


Revision tags: nick-nhusb-base-20160529 nick-nhusb-base-20160422 nick-nhusb-base-20160319
# 1.91 09-Feb-2016 ozaki-r

Introduce softint-based if_input

This change intends to run the whole network stack in softint context
(or normal LWP), not hardware interrupt context. Note that the work is
still incomplete by this change; to that end, we also have to softint-ify
if_link_state_change (and bpf) which can still run in hardware interrupt.

This change softint-ifies at ifp->if_input that is called from
each device driver (and ieee80211_input) to ensure Layer 2 runs
in softint (e.g., ether_input and bridge_input). To this end,
we provide a framework (called percpuq) that utlizes softint(9)
and percpu ifqueues. With this patch, rxintr of most drivers just
queues received packets and schedules a softint, and the softint
dequeues packets and does rest packet processing.

To minimize changes to each driver, percpuq is allocated in struct
ifnet for now and that is initialized by default (in if_attach).
We probably have to move percpuq to softc of each driver, but it's
future work. At this point, only wm(4) has percpuq in its softc
as a reference implementation.

Additional information including performance numbers can be found
in the thread at tech-kern@ and tech-net@:
http://mail-index.netbsd.org/tech-kern/2016/01/14/msg019997.html

Acknowledgment: riastradh@ greatly helped this work.
Thank you very much!


Revision tags: nick-nhusb-base-20151226 nick-nhusb-base-20150921
# 1.90 30-Aug-2015 dholland

Even if the "card went away", don't return from smc91cxx_init without
restoring interrupts. From maxv's brainy list.


Revision tags: nick-nhusb-base-20150606
# 1.89 13-Apr-2015 riastradh

Convert sys/dev to use <sys/rndsource.h>.


Revision tags: netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 nick-nhusb-base-20150406 nick-nhusb-base netbsd-7-base tls-maxphys-base
# 1.88 10-Aug-2014 tls

branches: 1.88.4;
Merge tls-earlyentropy branch into HEAD.


Revision tags: tls-earlyentropy-base
# 1.87 10-Jul-2014 christos

add missing fallthrough


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.86 08-Sep-2013 chs

branches: 1.86.2;
revert making smc91cxx_idstrs static, it's referenced from
sys/dev/isa/if_sm_isa.c


# 1.85 07-Sep-2013 chs

apply changes from Robert Sprowson in PR 47765 and PR 47788:
- make sure we wait long enough after resetting the chip.
- add the necessary delay after changing the FIFO pointer.
- add a missing interrupt ACK.
- fix padding of short and odd-length packets.

and a few more changes from me:
- do 2-byte writes in most places even if SMC91CXX_NO_BYTE_WRITE
is not defined. the only ones still conditionalized are
writing to the interrupt ack/mask registers.
- the only big-endian front-end of this driver (on mac68k) uses
a bus_space that does all the byte-swapping in that layer,
so remove the explicit byte-swapping in the MI part.

tested on mac68k.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.84 11-Jun-2013 msaitoh

branches: 1.84.2;
In interrupt function, use mii_pollstat() instead of mii_tick() to update
PHY status.


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.83 27-Oct-2012 chs

split device_t/softc for all remaining drivers.
replace "struct device *" with "device_t".
use device_xname(), device_unit(), etc.


# 1.82 22-Jul-2012 matt

branches: 1.82.2;
Fix mii_statchg to take a 'struct ifnet *' instead of device_t. This fixes
problem with a common MDIO bus used for multiple interfaces.
Some drivers converted to CFATTACL_DECL_NEW.


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-base2 netbsd-6-base
# 1.81 12-Feb-2012 matt

Change old-style function defintions to C89 prototypes.

Approved by releng.


# 1.80 02-Feb-2012 tls

Entropy-pool implementation move and cleanup.

1) Move core entropy-pool code and source/sink/sample management code
to sys/kern from sys/dev.

2) Remove use of NRND as test for presence of entropy-pool code throughout
source tree.

3) Remove use of RND_ENABLED in device drivers as microoptimization to
avoid expensive operations on disabled entropy sources; make the
rnd_add calls do this directly so all callers benefit.

4) Fix bug in recent rnd_add_data()/rnd_add_uint32() changes that might
have lead to slight entropy overestimation for some sources.

5) Add new source types for environmental sensors, power sensors, VM
system events, and skew between clocks, with a sample implementation
for each.

ok releng to go in before the branch due to the difficulty of later
pullup (widespread #ifdef removal and moved files). Tested with release
builds on amd64 and evbarm and live testing on amd64.


Revision tags: jmcneill-usbmp-pre-base2 jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base rmind-uvmplock-nbase cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231 rmind-uvmplock-base
# 1.79 13-Nov-2010 uebayasi

branches: 1.79.8; 1.79.12;
Don't pull in the whole uvm(9) API to access only PAGE_SIZE and
some other constants. These are provided by sys/param.h now.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.78 05-Apr-2010 joerg

Push the bpf_ops usage back into bpf.h. Push the common ifp->if_bpf
check into the inline functions as well the fourth argument for
bpf_attach.


Revision tags: yamt-nfs-mp-base9 uebayasi-xip-base
# 1.77 19-Jan-2010 pooka

branches: 1.77.2; 1.77.4;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.


Revision tags: matt-premerge-20091211
# 1.76 06-Dec-2009 dyoung

Simplify device-activation hooks.


Revision tags: yamt-nfs-mp-base8 yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 jym-xensuspend-nbase jym-xensuspend-base
# 1.75 12-May-2009 cegger

struct device * -> device_t, no functional changes intended.


# 1.74 11-May-2009 cegger

use device_xname()


Revision tags: yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 nick-hppapmap-base
# 1.73 14-Mar-2009 dsl

ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.


# 1.72 14-Mar-2009 dsl

Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)


Revision tags: nick-hppapmap-base2 haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.71 07-Nov-2008 dyoung

branches: 1.71.4;
*** Summary ***

When a link-layer address changes (e.g., ifconfig ex0 link
02:de:ad:be:ef:02 active), send a gratuitous ARP and/or a Neighbor
Advertisement to update the network-/link-layer address bindings
on our LAN peers.

Refuse a change of ethernet address to the address 00:00:00:00:00:00
or to any multicast/broadcast address. (Thanks matt@.)

Reorder ifnet ioctl operations so that driver ioctls may inherit
the functions of their "class"---ether_ioctl(), fddi_ioctl(), et
cetera---and the class ioctls may inherit from the generic ioctl,
ifioctl_common(), but both driver- and class-ioctls may override
the generic behavior. Make network drivers share more code.

Distinguish a "factory" link-layer address from others for the
purposes of both protecting that address from deletion and computing
EUI64.

Return consistent, appropriate error codes from network drivers.

Improve readability. KNF.

*** Details ***

In if_attach(), always initialize the interface ioctl routine,
ifnet->if_ioctl, if the driver has not already initialized it.
Delete if_ioctl == NULL tests everywhere else, because it cannot
happen.

In the ioctl routines of network interfaces, inherit common ioctl
behaviors by calling either ifioctl_common() or whichever ioctl
routine is appropriate for the class of interface---e.g., ether_ioctl()
for ethernets.

Stop (ab)using SIOCSIFADDR and start to use SIOCINITIFADDR. In
the user->kernel interface, SIOCSIFADDR's argument was an ifreq,
but on the protocol->ifnet interface, SIOCSIFADDR's argument was
an ifaddr. That was confusing, and it would work against me as I
make it possible for a network interface to overload most ioctls.
On the protocol->ifnet interface, replace SIOCSIFADDR with
SIOCINITIFADDR. In ifioctl(), return EPERM if userland tries to
invoke SIOCINITIFADDR.

In ifioctl(), give the interface the first shot at handling most
interface ioctls, and give the protocol the second shot, instead
of the other way around. Finally, let compatibility code (COMPAT_OSOCK)
take a shot.

Pull device initialization out of switch statements under
SIOCINITIFADDR. For example, pull ..._init() out of any switch
statement that looks like this:

switch (...->sa_family) {
case ...:
..._init();
...
break;
...
default:
..._init();
...
break;
}

Rewrite many if-else clauses that handle all permutations of IFF_UP
and IFF_RUNNING to use a switch statement,

switch (x & (IFF_UP|IFF_RUNNING)) {
case 0:
...
break;
case IFF_RUNNING:
...
break;
case IFF_UP:
...
break;
case IFF_UP|IFF_RUNNING:
...
break;
}

unifdef lots of code containing #ifdef FreeBSD, #ifdef NetBSD, and
#ifdef SIOCSIFMTU, especially in fwip(4) and in ndis(4).

In ipw(4), remove an if_set_sadl() call that is out of place.

In nfe(4), reuse the jumbo MTU logic in ether_ioctl().

Let ethernets register a callback for setting h/w state such as
promiscuous mode and the multicast filter in accord with a change
in the if_flags: ether_set_ifflags_cb() registers a callback that
returns ENETRESET if the caller should reset the ethernet by calling
if_init(), 0 on success, != 0 on failure. Pull common code from
ex(4), gem(4), nfe(4), sip(4), tlp(4), vge(4) into ether_ioctl(),
and register if_flags callbacks for those drivers.

Return ENOTTY instead of EINVAL for inappropriate ioctls. In
zyd(4), use ENXIO instead of ENOTTY to indicate that the device is
not any longer attached.

Add to if_set_sadl() a boolean 'factory' argument that indicates
whether a link-layer address was assigned by the factory or some
other source. In a comment, recommend using the factory address
for generating an EUI64, and update in6_get_hw_ifid() to prefer a
factory address to any other link-layer address.

Add a routing message, RTM_LLINFO_UPD, that tells protocols to
update the binding of network-layer addresses to link-layer addresses.
Implement this message in IPv4 and IPv6 by sending a gratuitous
ARP or a neighbor advertisement, respectively. Generate RTM_LLINFO_UPD
messages on a change of an interface's link-layer address.

In ether_ioctl(), do not let SIOCALIFADDR set a link-layer address
that is broadcast/multicast or equal to 00:00:00:00:00:00.

Make ether_ioctl() call ifioctl_common() to handle ioctls that it
does not understand.

In gif(4), initialize if_softc and use it, instead of assuming that
the gif_softc and ifp overlap.

Let ifioctl_common() handle SIOCGIFADDR.

Sprinkle rtcache_invariants(), which checks on DIAGNOSTIC kernels
that certain invariants on a struct route are satisfied.

In agr(4), rewrite agr_ioctl_filter() to be a bit more explicit
about the ioctls that we do not allow on an agr(4) member interface.

bzero -> memset. Delete unnecessary casts to void *. Use
sockaddr_in_init() and sockaddr_in6_init(). Compare pointers with
NULL instead of "testing truth". Replace some instances of (type
*)0 with NULL. Change some K&R prototypes to ANSI C, and join
lines.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.70 03-Sep-2008 rjs

branches: 1.70.2;
Make it work again for platforms that can do single byte operations.

Fix to PR kern/38757.


Revision tags: wrstuden-revivesa-base-1 simonb-wapbl-nbase yamt-pf42-base4 simonb-wapbl-base yamt-pf42-base3 wrstuden-revivesa-base
# 1.69 25-May-2008 chs

branches: 1.69.4;
include uvm/uvm_extern.h for trunc_page() on sparc
(where the page size isn't a compile-time constant).


Revision tags: hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2
# 1.68 29-Apr-2008 nakayama

branches: 1.68.2;
Make it compile again on big endian, and restore CVS keyword.


# 1.67 28-Apr-2008 matt

More forgotten changes from matt-armv6.


# 1.66 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-nfs-mp-base yamt-pf42-base
# 1.65 08-Apr-2008 cegger

branches: 1.65.2; 1.65.4;
use aprint_*_dev and device_xname


Revision tags: ad-socklock-base1 yamt-lazymbuf-base15 yamt-lazymbuf-base14 keiichi-mipv6-nbase nick-net80211-sync-base keiichi-mipv6-base bouyer-xeni386-nbase bouyer-xeni386-base matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.64 19-Jan-2008 dyoung

branches: 1.64.6;
Make many ethernet drivers share the common code for MII media
handling, ether_mediastatus() and ether_mediachange(). Check for
a non-ENXIO error return from mii_mediachg(). (ENXIO indicates
that a PHY is suspended.)

This patch shrinks the source code size by 979 lines. There was
a 5100-byte savings on the NetBSD/i386 kernel configuration, ALL.

I have made a few miscellaneous changes, too:

gem(4): use LIST_EMPTY(), LIST_FOREACH().
mtd(4): handle media ioctls, for a change!
axe(4): do not track link status in sc->axe_link any longer
nfe(4), aue(4), axe(4), udav(4), url(4): do not reset all PHYs
on a change of media

Except for the change to mtd(4), no functional changes are intended.

XXX This patch affects more architectures than I can feasibly
XXX compile and run. I have compiled macppc, sparc64, i386. I
XXX have run the patches on i386 boxen with bnx(4) and sip(4).
XXX Compiling and running on evbmips (MERAKI, ADM5120) is in
XXX progress.


Revision tags: bouyer-xeni386-merge1 vmlocking2-base3 yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2 yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base matt-armv6-base jmcneill-pm-base reinoud-bufcleanup-base
# 1.63 19-Oct-2007 ad

branches: 1.63.2; 1.63.8;
machine/{bus,cpu,intr}.h -> sys/{bus,cpu,intr}.h


Revision tags: nick-csl-alignment-base5 yamt-x86pmap-base4 yamt-x86pmap-base3 yamt-x86pmap-base2 yamt-x86pmap-base vmlocking-base
# 1.62 01-Sep-2007 dyoung

branches: 1.62.4;
Change a bazillion occurrences of code resembling this,

error = (cmd == SIOCADDMULTI) ?
ether_addmulti(ifr, &sc->sc_ec) :
ether_delmulti(ifr, &sc->sc_ec);

if (error == ENETRESET) {

to this,

if ((error = ether_ioctl(ifp, cmd, data)) == ENETRESET) {

which does the same thing.

(A bazillion is a very large number. This seems to make the i386
ALL kernel smaller by 3kB to 4kB.)

Use ifreq_getaddr() twice in es(4).

Whitespace nits.


# 1.61 27-Aug-2007 dyoung

branches: 1.61.2;
Constify: use CLLADDR() instead of LLADDR() wherever possible.


# 1.60 14-Aug-2007 kiyohara

Must call callout_init().


Revision tags: matt-mips64-base nick-csl-alignment-base yamt-idlelwp-base8 thorpej-atomic-base mjf-ufs-trans-base
# 1.59 04-Mar-2007 christos

branches: 1.59.2; 1.59.10; 1.59.14;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 matt-nb4-arm-base netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.58 16-Nov-2006 christos

branches: 1.58.4; 1.58.10;
__unused removal on arguments; approved by core.


Revision tags: yamt-splraiseipl-base2
# 1.57 12-Oct-2006 christos

- sprinkle __unused on function decls.
- fix a couple of unused bugs
- no more -Wno-unused for i386


Revision tags: yamt-splraiseipl-base yamt-pdpolicy-base9 rpaulo-netinet-merge-pcb-base
# 1.56 07-Sep-2006 dogcow

branches: 1.56.2; 1.56.4;
remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.


Revision tags: abandoned-netbsd-4-base yamt-pdpolicy-base8 yamt-pdpolicy-base7 yamt-pdpolicy-base6 chap-midi-nbase gdamore-uart-base yamt-pdpolicy-base5 chap-midi-base yamt-pdpolicy-base4 yamt-pdpolicy-base3 peter-altq-base yamt-pdpolicy-base2 elad-kernelauth-base yamt-pdpolicy-base yamt-uio_vmspace-base5 simonb-timecounters-base
# 1.55 20-Feb-2006 thorpej

branches: 1.55.2;
Use device_is_active() rather than testing dv_flags for DVF_ACTIVE
directly.


# 1.54 24-Dec-2005 perry

branches: 1.54.2; 1.54.4; 1.54.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.53 11-Dec-2005 christos

merge ktrace-lwp.


Revision tags: yamt-readahead-base3 yamt-readahead-base2 yamt-readahead-pervnode yamt-readahead-perfile yamt-readahead-base yamt-vop-base3 yamt-vop-base2 thorpej-vnode-attr-base yamt-vop-base ktrace-lwp-base
# 1.52 06-Jun-2005 pooka

branches: 1.52.2;
Instead of writing the packet length in two 8bit pieces, use one
16bit write. At least in certain environments this has the effect
of the latter 8bit write of the length to be not interpreted as
the first 16 bits of the packet contents and hence the interface
working.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 yamt-km-base4 yamt-km-base3 netbsd-3-base kent-audio2-base
# 1.51 27-Feb-2005 perry

nuke trailing whitespace


Revision tags: yamt-km-base2
# 1.50 04-Feb-2005 perry

de-__P


Revision tags: yamt-km-base kent-audio1-beforemerge kent-audio1-base
# 1.49 30-Oct-2004 thorpej

branches: 1.49.4; 1.49.6;
When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.48 09-Aug-2004 mycroft

Don't loop forever if a card went away.


# 1.47 08-Aug-2004 mycroft

Look in the correct register for the BSR detection value.
Also, do this early, before writing any registers.


Revision tags: netbsd-2-0-3-RELEASE netbsd-2-0-2-RELEASE netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.46 02-Nov-2003 wiz

branches: 1.46.4;
Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.45 29-Apr-2003 scw

branches: 1.45.2;
Add support for the SMC91C111 chip, with its internal PHY.


Revision tags: nathanw_sa_before_merge fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base nathanw_sa_base kqueue-aftermerge kqueue-beforemerge
# 1.44 22-Oct-2002 fair

Change the "dontcare bits" argument to ifmedia_init() to IFM_IMASK
so that it is possible select PHY instances other than the first
one (instance zero), if there is more than one PHY attached.


Revision tags: kqueue-base
# 1.43 28-Sep-2002 scw

Add smc91cxx_copy_tx_frame(), based on the version in cs89x0.c, to deal
with misaligned mbufs.


# 1.42 24-Sep-2002 bsh

make this compile again on ports that don't have bus space stream methods.


# 1.41 04-Sep-2002 scw

Add a flag, SMC_FLAGS_32BIT_READ, which is settable by the bus-specific
back-end to indicate that the device always sees reads as 32-bit
transactions, even if the host does 8 or 16-bit reads.

This is necessary for the SH-5 "Cayman" on-board ethernet. The SMsC part
is behind an FPGA which maps all cpu reads to 32-bits transactions.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base gehenna-devsw-base
# 1.40 03-May-2002 thorpej

Handle platforms that don't provide stream methods.
From Hiroyuki Bessho, PR 16617.


# 1.39 27-Mar-2002 chs

91C96 has the same chip ID as 91C94, list both in attach output. PR 11413.


Revision tags: eeh-devprop-base
# 1.38 20-Mar-2002 thorpej

When getting the packet off the interface, make sure the payload is
aligned after the Ethernet header.

kern/15982, Hiroyuki Bessho <bsh@grotto.jp>


Revision tags: newlock-base ifpoll-base
# 1.37 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3
# 1.36 02-Oct-2001 pooka

fix system freeze in situation where you pop a pcmcia card out of the
slot while it is in operation

ok'd by thorpej


Revision tags: thorpej-devvp-base2 post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.35 20-Aug-2001 thorpej

branches: 1.35.2;
Oops, the "auto" capability was getting masked off by mistake.
Fixes a panic reported by Chuck Silvers.


# 1.34 07-Jul-2001 thorpej

branches: 1.34.2;
bcopy -> memcpy, strcpy


# 1.33 14-Jun-2001 itojun

change the meaning of ifnet.if_lastchange to meet RFC1573 ifLastChange.
follows BSD/OS practice and ucd-snmp code (FreeBSD does it for specific
interfaces only).

was: if_lastchange get updated on every packet transmission/receipt.
now: if_lastchange get updated when IFF_UP is changed.


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.32 14-Dec-2000 thorpej

branches: 1.32.2;
ALTQ'ify.


# 1.31 15-Nov-2000 thorpej

Move bpfattach()/bpfdetach() calls into ether_ifattach()/ether_ifdetach().


# 1.30 01-Oct-2000 thorpej

Move the check for "promisc + unicast + not for us" into ether_input(),
and change Ethernet drivers to always pass all received frames to
ether_input() (with a few exceptions, which are documented in the
code).


# 1.29 06-Aug-2000 briggs

Label the buffer size as such on probe. 128 KB makes sense, but 4608 does not.


# 1.28 31-Jul-2000 briggs

Use bus_space_read/write_multi_stream_2 for FIFO instead of bsr/w_multi_2.


# 1.27 31-Jul-2000 briggs

Make sure that we do not call bus_space_*_multi_* with zero count.


# 1.26 30-Jul-2000 briggs

Add MII support to smc91cxx driver. This is supported for the 91c100
and 91c100FD (FEAST) controllers. Existing controllers should continue
to work as they have. Added the card's memory to the probe message.


Revision tags: netbsd-1-5-base
# 1.25 29-May-2000 jhawk

branches: 1.25.2;
For all network drivers that call ether_ifattach(), and also
have _detach() functions:
Ensure that softc keeps state about whether the attach succeeded,
and make the detach function return immediately if the attach did
not complete.


Revision tags: minoura-xpg4dl-base chs-ubc2-newbase
# 1.24 04-Feb-2000 enami

branches: 1.24.2;
- Call if_deactivate instead of smc91cxx_disable when deactivating.
- Fix typo in comment.


# 1.23 03-Feb-2000 itojun

fix promisc mode for smc91cxx again.


# 1.22 02-Feb-2000 itojun

if_detach for sm/pcmcia.
with addition of resource allocation flags in softc (to DTRT on detach).


# 1.21 17-Jan-2000 itojun

in promisc mode, don't inject outgoing packet to bpf twice.
this is because the card gets the outgoing packet from itself in promisc mode
(not really IFF_SIMPLEX).


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base fvdl-softdep-base
# 1.20 28-Sep-1999 thorpej

branches: 1.20.2;
Make sure the Revision register contains the correct magic number.

From Chuck Cranor.


# 1.19 12-Sep-1999 itojun

drop wrongly looped back multicast packet before we put it into BPF.


# 1.18 10-Sep-1999 itojun

Make sure to behave as IFF_SIMPLEX in all cases.
Drop multicast/broadcast packet looped back from myself.

This is to cope with SMC91C92 (Megahertz XJ10BT), which
loops back multicast packet to itself on promiscuous mode.
(should be ensured by chipset configuration)

Reviewed by: thorpej


Revision tags: chs-ubc2-base
# 1.17 18-May-1999 thorpej

Rework layer 2 protocol input routines. Instead of calling e.g. ether_input()
directly, call the function pointer (*if_input)(ifp, m). The input routine
expects the packet header to be at the head of the packet, and will adjust
as necessary. Privatize the layer 2 input and output routines, allowing
*_ifattach() to set them up as appropriate.


Revision tags: netbsd-1-4-PATCH001 kame_14_19990705 kame_14_19990628 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 25-Mar-1999 thorpej

branches: 1.16.2; 1.16.4; 1.16.6;
Use ETHER_*_LEN constants from <net/if_ether.h> instead of defining them
ourselves.


# 1.15 28-Feb-1999 explorer

Update to slightly altered rnd_attach_source() api


# 1.14 17-Feb-1999 thorpej

Avoid initializing the interface in the SIOCSIFFLAGS if ! UP and ! RUNNING.


Revision tags: kenh-if-detach-base
# 1.13 18-Nov-1998 thorpej

branches: 1.13.2;
Now that the *_activate() functions don't do things which are attachment
specific, move them into the chipset drivers.


# 1.12 17-Nov-1998 thorpej

Expose the "enable" and "disable" functions so that the front-ends can
access them.


Revision tags: chs-ubc-base
# 1.11 08-Aug-1998 mycroft

Use splnet, not splimp.


Revision tags: eeh-paddr_t-base
# 1.10 05-Jul-1998 jonathan

defopt NS, NSIP.


# 1.9 05-Jul-1998 jonathan

defopt LLC


# 1.8 05-Jul-1998 jonathan

defopt CCITT.


# 1.7 05-Jul-1998 jonathan

defopt INET, NETATALK.


# 1.6 12-Jan-1998 thorpej

Adjust for config changes.


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.5 15-Oct-1997 explorer

Add and/or update rnd_*() hooks


Revision tags: marc-pcmcia-base
# 1.4 14-Oct-1997 thorpej

Pull down from marc-pcmcia branch:

Add support for power management.


# 1.3 09-Oct-1997 jtc

Fix tipo inherited from old version of TNF copyright template.


Revision tags: thorpej-signal-base
# 1.2 02-Sep-1997 thorpej

Pull the SMC91Cxx single-chip Ethernet driver core down from the marc-pcmcia
branch. It is also needed by and ISA front-end.


# 1.1 11-Aug-1997 thorpej

branches: 1.1.2;
file smc91cxx.c was initially added on branch marc-pcmcia.