History log of /netbsd-current/sys/dev/ic/i82557.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base
# 1.162 29-Jun-2024 riastradh

if_stats(9): Add ifp argument to if_stat..._ref.

This will enable us to pass the ifp through to a dtrace probe inside.

No functional change intended in this change, but this is an API
change visible to modules so it shouldn't be pulled up.

PR kern/58377


# 1.161 09-Feb-2024 andvar

fix spelling mistakes, mainly in comments and log messages.


Revision tags: netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.160 25-Jun-2022 tsutsui

Pass proper status values to rnd_add_uint32(9) as rnd(9) man page claims.


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.159 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.158 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.157 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.156 30-Oct-2019 msaitoh

branches: 1.156.2;
if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.161 09-Feb-2024 andvar

fix spelling mistakes, mainly in comments and log messages.


Revision tags: netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 thorpej-ifq-base thorpej-altq-separation-base netbsd-10-0-RC1 netbsd-10-base bouyer-sunxi-drm-base
# 1.160 25-Jun-2022 tsutsui

Pass proper status values to rnd_add_uint32(9) as rnd(9) man page claims.


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.159 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.158 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.157 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.156 30-Oct-2019 msaitoh

branches: 1.156.2;
if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.160 25-Jun-2022 tsutsui

Pass proper status values to rnd_add_uint32(9) as rnd(9) man page claims.


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.159 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.158 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.157 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.156 30-Oct-2019 msaitoh

branches: 1.156.2;
if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.159 07-Feb-2020 thorpej

Use callout_setfunc() / callout_schedule().


# 1.158 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.157 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.156 30-Oct-2019 msaitoh

if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.158 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.157 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.156 30-Oct-2019 msaitoh

if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.157 29-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base phil-wifi-20191119
# 1.156 30-Oct-2019 msaitoh

if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.156 30-Oct-2019 msaitoh

if_percpuq(9) automatically increments if_ipackets, so don't add number of
RX frames from device's statistics counter to if_ipackets to avoid double
count.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

branches: 1.154.2;
Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.155 20-Sep-2019 maxv

Fix direction of the loop.

Found by the lgtm bot.


Revision tags: netbsd-9-base
# 1.154 09-Jul-2019 msaitoh

Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.154 09-Jul-2019 msaitoh

Don't automatically set ec_capenable's ETHERCAP_VLAN_HWTAGGING bit in
vlan_config() to make it user-controllable. Instead, set the bit in
xxx_attach().


Revision tags: phil-wifi-20190609
# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 26-Jun-2018 msaitoh

branches: 1.149.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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.153 28-May-2019 msaitoh

Use ETHER_LOCK()/ETHER_UNLOCK() for all ethernet drivers to protect ec_multi*.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.152 23-May-2019 msaitoh

No functional change:
- Simplify MII structure initialization and reference.
- u_int*_t -> uint*_t.
- KNF


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.151 22-Apr-2019 msaitoh

In drivers which use 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 pgoyette-compat-20190127
# 1.150 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.149 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 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base tls-maxphys-base-20171202
# 1.148 26-Sep-2017 knakahara

branches: 1.148.2;
VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

branches: 1.147.6;
Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.148 26-Sep-2017 knakahara

VLAN ID uses pkthdr instead of mtag now. Contributed by s-yamaguchi@IIJ.

I just commit by proxy. Reviewed by joerg@n.o and christos@n.o, thanks.
See http://mail-index.netbsd.org/tech-net/2017/09/26/msg006459.html

XXX need pullup to -8 branch


Revision tags: nick-nhusb-base-20170825 perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 jdolecek-ncq-base pgoyette-localcount-20170320
# 1.147 20-Feb-2017 ozaki-r

Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 15-Dec-2016 ozaki-r

branches: 1.146.2;
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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.147 20-Feb-2017 ozaki-r

Apply deferred if_start to more drivers


Revision tags: nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.146 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.145 10-Jun-2016 ozaki-r

branches: 1.145.2;
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.144 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 nick-nhusb-base-20150606
# 1.143 13-Apr-2015 riastradh

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


Revision tags: 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.


# 1.146 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.145 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.144 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 nick-nhusb-base-20150606
# 1.143 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.142 10-Aug-2014 tls

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


Revision tags: yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 rmind-smpnet-nbase rmind-smpnet-base
# 1.141 12-Sep-2013 martin

branches: 1.141.2;
Remove unused variable


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.140 22-Jul-2012 matt

branches: 1.140.2; 1.140.4;
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.139 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
# 1.138 02-Sep-2011 msaitoh

branches: 1.138.2; 1.138.6;
Add support for some fxp devices from FreeBSD and OpenBSD.
{Free,Open}BSD say that we have to do some work to make fxp
stable.


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.137 30-Mar-2011 jakllsch

IFF_PROMISC implys IFF_ALLMULTI.
Should fix PR#43186.


Revision tags: bouyer-quota2-nbase bouyer-quota2-base jruoho-x86intr-base matt-mips64-premerge-20101231
# 1.136 13-Nov-2010 uebayasi

branches: 1.136.2;
Include sys/proc.h for tsleep, wakeup.


Revision tags: uebayasi-xip-base4 uebayasi-xip-base3 yamt-nfs-mp-base11 uebayasi-xip-base2 yamt-nfs-mp-base10 uebayasi-xip-base1
# 1.135 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.


# 1.134 22-Mar-2010 dyoung

Check whether the fxp(4) actually attached before calling fxp_stop().


# 1.133 22-Mar-2010 dyoung

In fxp_detach(), fxp_stop(), first. fxp_stop() stops the callout.
Destroy the callout in fxp_detach().


Revision tags: yamt-nfs-mp-base9
# 1.132 25-Feb-2010 dyoung

branches: 1.132.2;
Make fxp at cardbus detach during shutdown.

Stop calling (*cardbus_ctrl) to enable bus mastering, I/O and memory
spaces on the CardBus bridge. cbb(4) always enables that stuff,
anyway. In the process, avoid remembering what BAR we mapped by
writing CARDBUS_{IO,MEM}_ENABLE to sc_cben or sc_cbenable, and
record the BAR in use sc_bar, instead.

Replace more CARDBUS_ constants with PCI_ constants.

Compile-tested, only.


Revision tags: uebayasi-xip-base
# 1.131 19-Jan-2010 pooka

branches: 1.131.2;
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 yamt-nfs-mp-base8 jym-xensuspend-nbase
# 1.130 15-Sep-2009 dyoung

Simplify activation routines: don't call mii_activate(), it's a
no-op. Don't block interrupts, if_deactivate() does it.
Compile-tested, only.


Revision tags: yamt-nfs-mp-base7 jymxensuspend-base yamt-nfs-mp-base6 yamt-nfs-mp-base5 yamt-nfs-mp-base4 yamt-nfs-mp-base3 nick-hppapmap-base4 nick-hppapmap-base3 jym-xensuspend-base nick-hppapmap-base
# 1.129 16-Mar-2009 tsutsui

Pull a fix from hme.c rev 1.73 (to #if 0'ed out part):
> Fix a bug in calculation of checksum deduction:
> - To get 16 bit one's complement value from uint32_t variable,
> higher 16 bits should be ignored.
> - RFC 1624 describes methods to recalculate checksum field in headers,
> i.e. one's complement of one's complement sum that could be 0x0000,
> but we don't have to use the strategy to deduct one's complement sum
> itself which won't be zero but should be 0xffff.


# 1.128 15-Mar-2009 tsutsui

Tweak comments and conditionals about EXT_RFA and IPCB.


# 1.127 11-Mar-2009 tsutsui

u_intNN_t -> uintNN_t


# 1.126 09-Mar-2009 tsutsui

Computed checksum value by the FXPF_82559_RXCSUM feature includes data
in IP headers, so we have to deduct not only IP option headers but all
IP headers. But in TCP/UDP layer we can assume the IP header is valid
and a sum of the IP header part should be 0xffff, so we don't have to
bother to deduct it from the computed checksum.


# 1.125 07-Mar-2009 tsutsui

Add TCPv4/UDPv4 RX hardware checksum support for i82559 and later chips
which don't have EXT_RFA and IPCB support. From hme(4) driver and
FreeBSD's fxp(4). Tested on i82559.

XXX: Probably we should have a common function to parse RX packet headers
XXX: to handle a raw checksum value and share it among hme(4) and gem(4) etc.


# 1.124 04-Mar-2009 tsutsui

Use FXPF_EXT_RFA flag instead of FXPF_EXT_TXCB to see IPCB capability
because EXT_RFA for RX cksum is always available with IPCB for TX cksum
but i82558 and i82559 have only EXT_TXCB without IPCB.

Tested on the following fxp cards:
fxp0 at pci0 dev 14 function 0: Intel i82557 Ethernet, rev 2
fxp0 at pci0 dev 14 function 0: i82559 Ethernet, rev 8
fxp0 at pci0 dev 14 function 0: i82550 Ethernet, rev 12


Revision tags: nick-hppapmap-base2
# 1.123 20-Feb-2009 mrg

- remove FXPF_IPCB flag. it should always/only be used with the code
conditional on FXPF_EXT_TXCB, so, replace all uses with that
- for the pci frontend, reestablish some flags lost the the prior
changes and simplify one of the cases

this fixes PR 40677 and may fix PR 40431.


# 1.122 18-Jan-2009 mrg

branches: 1.122.2;
The PCI revision numbers are unique to a PCI vendor/product
ID pair. Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips. So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known. (Note: sc_rev should be removed. The
microcode patch stuff is also busted and needs to be fixed.) Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.


Revision tags: haad-dm-base2 haad-nbase2 ad-audiomp2-base haad-dm-base mjf-devfs2-base
# 1.121 05-Dec-2008 tsutsui

Wrap long lines.


# 1.120 04-Dec-2008 tsutsui

Don't pass uint8_t values to le16toh() in fxp_rx_hwcksum().
fxp(4)'s RX hwcksum results weren't used at all on big endian machines.

Checked by i82550 and vmstat -ev on macppc GENERIC kernel with
options INET_CSUM_COUNTERS,TCP_CSUM_COUNTERS,UDP_CSUM_COUNTERS.


# 1.119 04-Dec-2008 tsutsui

Add a missed htole32() on the previous ip4csum-tx bug workaround.


# 1.118 04-Dec-2008 tsutsui

Sort Tx/Rx macro in previous.


# 1.117 03-Dec-2008 tsutsui

Add a workaround for hardware ip4csum-tx bug and enable it.
Confirmed on i82550 rev 12 and UDP fragment packets by ttcp(1).


# 1.116 03-Dec-2008 tsutsui

Call BUS_DMASYNC_PREREAD more strictly on polling DMA descriptors.


Revision tags: netbsd-5-base matt-mips64-base2 haad-dm-base1 wrstuden-revivesa-base-4 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.115 31-Jul-2008 ws

branches: 1.115.2; 1.115.4;
Calling fxp_init within the interrupt handler results in
a hang (continuous assertion of FXP_SCB_STATACK_RNR).
Instead do it in the ioctl routine after receiving a
signal from the interrupt handler.


Revision tags: simonb-wapbl-nbase simonb-wapbl-base
# 1.114 09-Jul-2008 joerg

- device/softc split for fxp(4)


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 yamt-nfs-mp-base2 wrstuden-revivesa-base
# 1.113 28-Apr-2008 martin

branches: 1.113.2; 1.113.4; 1.113.6;
Remove clause 3 and 4 from TNF licenses


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

branches: 1.112.2; 1.112.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 matt-armv6-nbase mjf-devfs-base hpcarm-cleanup-base
# 1.111 07-Feb-2008 dyoung

branches: 1.111.6;
Start patching up the kernel so that a network driver always has
the opportunity to handle an ioctl before generic ifioctl handling
occurs. This will ease extending the kernel and sharing of code
between drivers.

First steps: Make the signature of ifioctl_common() match struct
ifinet->if_ioctl. Convert SIOCSIFCAP and SIOCSIFMTU to the new
ifioctl() regime, throughout the kernel.


Revision tags: bouyer-xeni386-nbase bouyer-xeni386-base
# 1.110 19-Jan-2008 dyoung

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: matt-armv6-base
# 1.109 29-Dec-2007 tsutsui

Fix typo in comments.


Revision tags: vmlocking2-base3
# 1.108 17-Dec-2007 tsutsui

Fix from YAMAGUCHI Takahiro in PR kern/30023:
Pass correct EEPROM address in fxp_write_eeprom().


# 1.107 13-Dec-2007 degroote

Remove the shutdown hook (pmf takes care about it already), as suggested by joerg@


Revision tags: yamt-kmem-base3 cube-autoconf-base yamt-kmem-base2
# 1.106 10-Dec-2007 degroote

branches: 1.106.2;
Register fxp @ pci to the pmf framework
Kill reference to old powerhook framework.


Revision tags: yamt-kmem-base vmlocking2-base2 reinoud-bufcleanup-nbase jmcneill-pm-base
# 1.105 08-Dec-2007 tsutsui

branches: 1.105.2;
Pull several fixes from OpenBSD's fxp.c:

Rev 1.41:
> use a nop with I bit set at the end of the tx chain. This avoids a race
> between status update and clearing the suspend bit on machines which can't
> write data smaller than 32bits at a time.
This should fix PR port-alpha/30560.

Rev 1.50:
> Fix nasty bug where driver would not correctly catch and handle an rnr
> condition when it was due to the the recieve buffers being exhausted with
> no packet transmits during that time. Symptom was that the fxp would
> simply stop interrupting for the next 15 seconds until the watchdog kicked
> in and reset the chip due to 15 seconds of inactivity, making the fxp very
> poorly behaved when hammered on hard.

Rev 1.61:
> Defer reinitialisation of the RU until after the interrupt handler has had
> a chance to process all pending packets, otherwise the chip may overwrite
> their mbuf clusters after we have freed them.
>
> Eliminates a race that can cause random pool corruption when reconfiguring
> an interface under heavy network load.

And one more change for RX sanity:
- put RU into suspend when the last RFA is processed.

These RNR/RU changes may fix pool corruption problems on fxp.

Tested on AlphaPC164 and i386 with i82559 and i82550.


Revision tags: vmlocking2-base1 jmcneill-base bouyer-xenamd64-base2 vmlocking-nbase bouyer-xenamd64-base reinoud-bufcleanup-base
# 1.104 19-Oct-2007 ad

branches: 1.104.2; 1.104.4;
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.103 26-Aug-2007 dyoung

branches: 1.103.2; 1.103.6;
Constify: LLADDR -> CLLADDR. I'm aiming here to make it easier to
identify sockaddr_dl abuse that remains in the kernel, especially
the potential for overwriting memory past the end of a sockaddr_dl
with, e.g., memcpy(LLADDR(), ...).


Revision tags: matt-mips64-base nick-csl-alignment-base mjf-ufs-trans-base
# 1.102 09-Jul-2007 ad

branches: 1.102.2; 1.102.6;
Merge some of the less invasive changes from the vmlocking branch:

- kthread, callout, devsw API changes
- select()/poll() improvements
- miscellaneous MT safety improvements


Revision tags: yamt-idlelwp-base8 thorpej-atomic-base
# 1.101 04-Mar-2007 christos

branches: 1.101.2; 1.101.4; 1.101.6;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.


Revision tags: 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 ad-audiomp-base post-newlock2-merge newlock2-nbase yamt-splraiseipl-base5 yamt-splraiseipl-base4 yamt-splraiseipl-base3 newlock2-base netbsd-4-base
# 1.100 16-Nov-2006 christos

branches: 1.100.2; 1.100.4; 1.100.8; 1.100.12;
__unused removal on arguments; approved by core.


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

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


# 1.98 24-Sep-2006 jmcneill

Add "name" parameter to powerhook_establish, to aid debugging. No objections
on tech-kern@


Revision tags: abandoned-netbsd-4-base yamt-splraiseipl-base yamt-pdpolicy-base9 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 rpaulo-netinet-merge-pcb-base
# 1.97 20-Feb-2006 thorpej

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


# 1.96 24-Dec-2005 perry

branches: 1.96.2; 1.96.4; 1.96.6;
Remove leading __ from __(const|inline|signed|volatile) -- it is obsolete.


# 1.95 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.94 15-Oct-2005 jdolecek

use VLAN_OUTPUT_TAG()


# 1.93 12-Oct-2005 abs

Make receiver lock-up workaround conditional on setting link1, as we have
too many false positives - should address PR/30505


# 1.92 12-Aug-2005 junyoung

Make microcode loading work on big endian machines.
Reported and patch supplied by yongari@freebsd a long time ago.


# 1.91 29-May-2005 christos

branches: 1.91.2;
- sprinkle const.
- avoid variable shadowing.


# 1.90 02-May-2005 yamt

split IFCAP_CSUM_xxx to IFCAP_CSUM_xxx_Rx and IFCAP_CSUM_xxx_Tx.


Revision tags: yamt-km-base4 yamt-km-base3 netbsd-3-base yamt-km-base2 yamt-km-base kent-audio2-base kent-audio1-beforemerge kent-audio1-base
# 1.89 23-Nov-2004 thorpej

branches: 1.89.10;
Use log() instead of printf().


# 1.88 30-Oct-2004 thorpej

When adding/deleting multicast addresses, only whack the address
filter if the interface is marked RUNNING.

Fixes kern/27678.


# 1.87 20-Sep-2004 simonb

Fix a typo in a comment.


# 1.86 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Add PAUSE-related event counters.
* Return flow control bits in fxp_mii_mediastatus().


# 1.85 16-May-2004 thorpej

Patch from HITOSHI Osada:
* Newer chips do not need the receiver lock-up workaround; detect when it
is required.


# 1.84 28-Apr-2004 briggs

When we are recovering from a resource exhaustion on receive, make sure
that the RU is stopped before issuing an RU_START.
Fix suggested by Takahiro Kambe in PR kern/10622.


# 1.83 28-Apr-2004 briggs

Back out revision 1.82. It seems to cause a number of device timeouts
on x86 boxes. There must be a better way to deal with this that works
well for everyone. In the meantime, back out to the version that works
for more people.


# 1.82 31-Mar-2004 briggs

Be more careful about issuing CU_RESUME in fxp_start()--only doing
it if we think it's probably necessary. Then do it again in the
tx interrupt handler, if we again think it's necessary. This
reduces the number of commands we issue the chip. Prior to this
change, the i82550 (running without extended feature set, so like
a '559) would sometimes fail in fxp_scb_wait() prior to issuing
another CU_RESUME, resulting in
fxp0: WARNING: SCB timed out!
messages on the console, often followed by device timeouts.


Revision tags: netbsd-2-0-base
# 1.81 19-Feb-2004 yamt

branches: 1.81.2;
support h/w assisted vlan tag insertion.


# 1.80 19-Feb-2004 yamt

support h/w assisted vlan tag removal.


# 1.79 09-Feb-2004 hpeyerl

On some 'fast' i386 motherboards, the timing between consecutive reads
and writes of the EEPROM are too fast so invalid data is returned. So we
increase the DELAY()s. The right thing would be to check a ready bit
on the E^2 if such a thing exists. (checked by potr)


# 1.78 06-Dec-2003 yamt

- disable ipv4 checksum offloading as it seems to have a problem.
- add comments to describe it.


# 1.77 02-Nov-2003 wiz

Fix some typos. From Tom Cosgrove via jmc@openbsd.


# 1.76 01-Aug-2003 scw

In fxp_intr(), bail early without touching any registers if sc_enabled is
zero, otherwise we could cause PCI master aborts if the card is in D3 power
state and we happen to share a PCI interrupt line with some other device.


# 1.75 26-May-2003 yamt

branches: 1.75.2;
ip/tcp/udp checksum offloading support for i82550.
largely from FreeBSD.


# 1.74 25-May-2003 yamt

check and MCLAIM correct mbuf in fxp_copy_small path.


# 1.73 26-Feb-2003 matt

Add MBUFTRACE kernel option.
Do a little mbuf rework while here. Change all uses of MGET*(*, M_WAIT, *)
to m_get*(M_WAIT, *). These are not performance critical and making them
call m_get saves considerable space. Add m_clget analogue of MCLGET and
make corresponding change for M_WAIT uses.
Modify netinet, gem, fxp, tulip, nfs to support MBUFTRACE.
Begin to change netstat to use sysctl.


# 1.72 04-Feb-2003 thorpej

Use bus_dmamap_load_mbuf() in fxp_add_rfabuf().


# 1.71 31-Jan-2003 thorpej

Use aprint_*().


Revision tags: nathanw_sa_before_merge nathanw_sa_base
# 1.70 06-Jan-2003 wiz

synchronous, not syncronous.


Revision tags: fvdl_fs64_base gmcgarry_ctxsw_base gmcgarry_ucred_base
# 1.69 15-Nov-2002 enami

Cosmetic changes.


# 1.68 07-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


Revision tags: kqueue-aftermerge kqueue-beforemerge
# 1.67 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: gehenna-devsw-base kqueue-base
# 1.66 06-Jun-2002 he

Add newlines to the WARNING messages printed for the dynamic standby bug.


Revision tags: netbsd-1-6-base
# 1.65 20-May-2002 mycroft

branches: 1.65.2;
The FIX_RESUME_BUG hack does not work, so remove it.
Also, attempt to clarify the message slightly when updating the EEPROM.


# 1.64 05-Apr-2002 thorpej

branches: 1.64.2;
Add support for the "CPUSaver" receive interrupt mitigating microcode
on the following PRO/100 chips:

* i82558 step A4
* i82558 step B0
* i82559 step A0
* i82559S step A
* i82550
* i82550 step C

The interrupt delay is configurable on all microcodable chips. The
maximum "bundle" size (packet count) is configurable on all but the
i82558.

The microcode is enabled by setting IFF_LINK0 on the interface.

Derived from code in FreeBSD.


# 1.63 04-Apr-2002 thorpej

Address Intel 82801BA/82801BAM Specification Update, Errata #30:

The ICH on-board Ethernet and some i82559 chips have a bug which
will cause a PCI protocol violation if the chip receives a CU_RESUME
command as it is entering the IDLE state by deasserting #CLKRUN.
(This is the so-called "resume bug" that we previously had an incomplete
work-around for on ICH chipsets.)

The work-around is to disable Dynamic Standby Mode, such that the
chip will never deasert #CLKRUN. Dynamic Standby Mode is disabled
by clearing a bit in the EEPROM and updating the EEPROM (and EEPROM
checksum).

Unfortunately, the chip will only consult the EEPROM setting after
a PCI bus reset, so a system reboot is required once the EEPROM
has been updated (the EEPROM update only needs to happen once,
and the driver usses a warning instructing the user to reboot the
system once the work-around has been applied).

Issue pointed out by David Brownlee, and code more-or-less lifted
from FreeBSD.


# 1.62 04-Apr-2002 thorpej

Move the code which shifts bits into the EEPROM into its own function.


Revision tags: eeh-devprop-base newlock-base ifpoll-base
# 1.61 13-Nov-2001 lukem

add/cleanup RCSID


Revision tags: thorpej-mips-cache-base thorpej-devvp-base3 thorpej-devvp-base2
# 1.60 16-Sep-2001 wiz

Spell 'occurred' with two 'r's.


Revision tags: post-chs-ubcperf pre-chs-ubcperf thorpej-devvp-base
# 1.59 06-Aug-2001 enami

branches: 1.59.2;
Advertize pause capability (802.3x flow control) to peer.


# 1.58 19-Jul-2001 thorpej

Use BUS_DMA_READ and BUS_DMA_WRITE in some obvious places.


# 1.57 07-Jul-2001 thorpej

branches: 1.57.2;
bzero -> memset


# 1.56 07-Jul-2001 thorpej

bcopy -> strcpy


# 1.55 15-Jun-2001 thorpej

Split the Tx and Rx interrupt routines into separate functions,
and add some (optional) event counters.


# 1.54 12-Jun-2001 thorpej

Don't need INET or NS includes here.


# 1.53 02-Jun-2001 thorpej

Define some extra configuration block bits used on the i82550 (a.k.a.
PRO 100/S), including the extended RFA format. Don't hard-code the
RFA size to allow us to use the extended format in the future.


# 1.52 22-May-2001 thorpej

Some changes from the new FreeBSD `fxp' driver:
- Add some additional config block bits for the i82558/i82559.
- Change the config block template to only fill in the must-be-one
reserved bits, leave fxp_init() to fill in all the important things.
- On the i82558/i82559, we can use "Receive Long Frames" rather than
"Save Bad Frames" to support the VLAN MTU.
- Use 802.3x flow control on the i82558/i82559. This is all handled
transparently by the hardware. When in promiscuous mode, allow
wire-watchers to see the flow control frames.
- Use the Extended TxCB format on the i82558/i82559. This places two
Transmit Buffer Descriptors directly in the TxCB, which should cover
the vast majority of packets transmitted. This saves PCI transactions
that would otherwise be required to fetch the TBD list.

With the tansmit queue length changes from yesterday, this gets us up to
11.5MB/s TCP transmit speed, out of an absolute maximum of 12MB/s possible
on a 100Mb/s link.


# 1.51 22-May-2001 thorpej

A little slight cleanup.


# 1.50 21-May-2001 thorpej

Re-arrange the transmit control data somewhat so that we can
use the extended TxCB format (that change will happen later).


# 1.49 21-May-2001 thorpej

Sigh, typo in last.


# 1.48 21-May-2001 thorpej

Fix non-fatal typo -- CB_NOP -> CU_NOP in the ICH work-around (they
have the same value).


# 1.47 21-May-2001 thorpej

The 82801BA built-in Ethernet has a bug which requires us to
issue a NOP before a CU_RESUME when in 10baseT mode. Handle
this.


# 1.46 21-May-2001 thorpej

ANSI'ify.


# 1.45 16-May-2001 lukem

delint: remove volatile from fxp_mdi_read() decl


Revision tags: thorpej_scsipi_beforemerge thorpej_scsipi_nbase thorpej_scsipi_base
# 1.44 19-Dec-2000 thorpej

branches: 1.44.2;
Fix a problem with the ALTQ changes that can cause bogus memory
refernces. Problem reported by Luke Mewburn.


# 1.43 14-Dec-2000 thorpej

ALTQ'ify.


# 1.42 26-Nov-2000 takemura

Add new powerhook argument values, PWR_SOFTSUSPEND, PWR_SOFTSTANDBY and
PWR_SOFTRESUME. Apm calls powerhook with the values in normal interrupt
priority level while others are protected with splhigh().


# 1.41 15-Nov-2000 thorpej

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


# 1.40 11-Oct-2000 thorpej

Use ether_ioctl().


# 1.39 03-Oct-2000 thorpej

Support ETHERCAP_VLAN_MTU by doing extra error checking upon packet
reception and saving other "bad frames" (i.e. ones that are larger
than the standard Ethernet frame length) if we have VLANs configured
on the interface.


# 1.38 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.37 28-Sep-2000 tsutsui

6 -> ETHER_ADDR_LEN


# 1.36 29-Jun-2000 thorpej

Since the RFA is allocated in a normal mbuf, as opposed to DMA-safe
memory that is explicitly mapped in a DMA-coherent manner, we must
make sure to PREREAD sync the RFA after noticing a clear "complete"
bit. Without this, the clear bit will linger in the cache, and the
CPU will not notice when the chip updates the bit via DMA later.

From Izumi Tsutsui on port-arm32@netbsd.org.


# 1.35 28-Jun-2000 mrg

remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>


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

branches: 1.34.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
# 1.33 27-May-2000 tsutsui

branches: 1.33.2;
Increase delay on EEPROM access.
CATS sometimes cannot read MAC address correctly.


# 1.32 26-May-2000 tsutsui

Call bus_dmamap_sync() properly before/after reading fcd_stats
in fxp_control_data.


# 1.31 24-May-2000 soren

Make two previous changes more correct, as shown by Izumi Tsutsui.


# 1.30 24-May-2000 soren

The EEPROM is little-endian.


# 1.29 24-May-2000 soren

Fix DMA status reading on big-endian systems. From Sanjay Lal on port-macppc.


# 1.28 24-May-2000 soren

And a newline after error string.


# 1.27 19-May-2000 jhawk

Calibrate the timeouts from rev 1.26 by using DELAY(1) so their
values are less machine-dependant. Fixes port-i386/10141, where
spurrious timeouts were being seen.
Also note the line numbers of the timeouts so it can be determined
which is being seen (via __LINE__).


# 1.26 12-May-2000 jhawk

Catch some potentially infinite loops in while() loops if the chip happens
to "go insane" and never complete some operations (dmasync, etc.).


# 1.25 30-Mar-2000 simonb

Delete redundant decls of fxp_enable(), fxp_disable() - they're in
i82557var.h.


# 1.24 23-Mar-2000 thorpej

New callout mechanism with two major improvements over the old
timeout()/untimeout() API:
- Clients supply callout handle storage, thus eliminating problems of
resource allocation.
- Insertion and removal of callouts is constant time, important as
this facility is used quite a lot in the kernel.

The old timeout()/untimeout() API has been removed from the kernel.


# 1.23 20-Mar-2000 thorpej

Get rid of the powerhook when we detach.


# 1.22 06-Mar-2000 thorpej

No longer necessary to futz with ifp->if_baudrate here.


# 1.21 28-Feb-2000 joda

(fxp_init): don't clear the FXPF_MII flag as this results in a panic
when detaching


Revision tags: chs-ubc2-newbase
# 1.20 12-Feb-2000 enami

Add activate routine and check device active flag also in one second
tick handler.


# 1.19 12-Feb-2000 enami

Cosmetic changes.


# 1.18 09-Feb-2000 joda

add detach code


# 1.17 02-Feb-2000 thorpej

Don't dry to diving MIIF_NOISOLATE in the PHY drivers. Instead, pass
flags down from the parent to child vi mii_attach().


# 1.16 02-Feb-2000 thorpej

Bring some order to the chaos which was the MII code function naming
"conventions".


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.15 12-Dec-1999 thorpej

Take a stab at making this work on big-endian systems.


# 1.14 04-Dec-1999 sommerfeld

change comment to mention that this driver also handles the '558 and '559


# 1.13 19-Nov-1999 joda

try to do a better job of figuring out the EEPROM size; the old code
didn't work on (some?) 557-based cards


Revision tags: fvdl-softdep-base
# 1.12 12-Nov-1999 thorpej

Call mii_down() as appropriate.


# 1.11 04-Nov-1999 thorpej

Adapt to mii_phy_probe() change.


Revision tags: comdex-fall-1999-base
# 1.10 30-Oct-1999 sommerfeld

Add enable/disable support and EEPROM size selection, prerequisites
for getting the cardbus fxp attachment to work.

Tested on the built-in 82559 in a VAIO Z505S.

From Johan Danielsson / PR8631; changed slightly to KNF.


# 1.9 28-Oct-1999 sommerfeld

Fix suspend/resume-related problems observed on fxp0 on Sony Z505S:

Symptoms: system would crash with "data modified on free list" pool
panic from the mbuf cluster pool shortly after a resume. The cluster
in question contained a valid 82557 receive descriptor and an IP
packet. Happened sporadically in normal use. Easiest way for me to
reproduce it was to run tcpdump and a flood ping and do a
suspend/resume cycle or two.

Changes:
- in interrupt handler, if the interface isn't in IFF_RUNNING state,
just ack interrupts and return; don't try to receive packets, queue
new descriptors, etc., etc.,
- add power control hook to take interface down on suspend,
and restart it (if it was up) on resume.
- tweaks to fxp_stop and fxp_shutdown to avoid recursive panics due
to the (now fixed) bug.


# 1.8 05-Aug-1999 thorpej

branches: 1.8.2; 1.8.4; 1.8.6;
Since we have to go through fxp_init() to properly handle IFF_ALLMULTI
anyway, take advantage of this and greatly simplify the programming
of the multicast filter. This solves the last reported "device timeout"
problem with this driver.


# 1.7 04-Aug-1999 thorpej

Almost completely rewrite the receive logic, making it as close as possible
to the EPIC/100 driver's (adjusting for the fact that Intel Ethernet chips
are from Pluto):
* Don't allocate receive buffers until the interface is actually brought
up, and release all of them if the interface is taken down.
* Add a knob (defaults to off) which will copy an incoming packet to
a single header mbuf if it is small enough to fit in one, rather than
burning an entire cluster on it. Note that this change will be mostly
moot if/when sbcompress() is changed to handle compressing clusters.

Simplify some of the receive list logic:
* Rather than using a homegrown queue and additional software RX descriptors,
use an ifqueue to queue receive buffers, and M_{GET,SET}CTX() to hook DMA
maps and receive buffers together.

Clean up a bit:
* Macroize a bunch of things to make the code a bit easier to follow.


# 1.6 04-Aug-1999 thorpej

Only tick the MII if we are using it.


# 1.5 04-Aug-1999 thorpej

Be a little less selective in the transmit interrupt path.


# 1.4 03-Aug-1999 thorpej

Use the Interrupt bit in the command block to generate interrupts, rather
than interrupting after every Command Unit Not Active event.


# 1.3 03-Aug-1999 thorpej

Don't bother with interrupt-driven multicast setup.


# 1.2 03-Aug-1999 thorpej

Completely rewrite the transmit logic, making it look more like the
EPIC/100 driver's. Also, fix the "all multicast" logic. Also do some
general cleanup.


Revision tags: chs-ubc2-base
# 1.1 20-Jun-1999 thorpej

branches: 1.1.2;
Bus-independent back-end driver for Intel i82557 fast Ethernet chips.