History log of /netbsd-current/sys/dev/pci/if_alc.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.53 17-Sep-2022 thorpej

alc_start(): Remove redundant IFQ_IS_EMPTY(). This very same condition
is checked as soon as we enter the loop.


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
# 1.52 01-Mar-2020 thorpej

Upon further reflection, we actually do need to ensure that the Rx
ring and the Rx Return ring are both in the same 4GB segment.


# 1.51 01-Mar-2020 thorpej

- Use the 64-bit PCI DMA tag if available.
- Add a comment explaining that if we were to use more than one
Rx ring / Rx Return ring, all of the Rx-related control data
would need to be in the same 4G segment.


# 1.50 01-Mar-2020 thorpej

It doesn't make any sense to pass ETHER_ALIGN as the alignment constraint
to bus_dmamem_alloc(). Use PAGE_SIZE instead.


Revision tags: ad-namecache-base3
# 1.49 08-Feb-2020 maxv

constify


# 1.48 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.47 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.46 18-Dec-2019 msaitoh

branches: 1.46.2;
Cast to uint32_t to avoid undefined behavior. Found by kUBSan.


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.52 01-Mar-2020 thorpej

Upon further reflection, we actually do need to ensure that the Rx
ring and the Rx Return ring are both in the same 4GB segment.


# 1.51 01-Mar-2020 thorpej

- Use the 64-bit PCI DMA tag if available.
- Add a comment explaining that if we were to use more than one
Rx ring / Rx Return ring, all of the Rx-related control data
would need to be in the same 4G segment.


# 1.50 01-Mar-2020 thorpej

It doesn't make any sense to pass ETHER_ALIGN as the alignment constraint
to bus_dmamem_alloc(). Use PAGE_SIZE instead.


Revision tags: ad-namecache-base3
# 1.49 08-Feb-2020 maxv

constify


# 1.48 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.47 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.46 18-Dec-2019 msaitoh

branches: 1.46.2;
Cast to uint32_t to avoid undefined behavior. Found by kUBSan.


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.49 08-Feb-2020 maxv

constify


# 1.48 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.47 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.46 18-Dec-2019 msaitoh

Cast to uint32_t to avoid undefined behavior. Found by kUBSan.


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.48 04-Feb-2020 thorpej

Use ifmedia_fini().


# 1.47 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.46 18-Dec-2019 msaitoh

Cast to uint32_t to avoid undefined behavior. Found by kUBSan.


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.47 30-Jan-2020 thorpej

Adopt <net/if_stats.h>.


Revision tags: ad-namecache-base2 ad-namecache-base1 ad-namecache-base
# 1.46 18-Dec-2019 msaitoh

Cast to uint32_t to avoid undefined behavior. Found by kUBSan.


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.46 18-Dec-2019 msaitoh

Cast to uint32_t to avoid undefined behavior. Found by kUBSan.


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.45 01-Dec-2019 msaitoh

Use unsigned to avoid undefined behavoir. Found by kUBSan.


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.44 21-Nov-2019 msaitoh

Fix a bug that IFF_ALLMULTI is almost always set.

OpenBSD's ac_multirangecnt is not NetBSD's ec_multicnt.


Revision tags: phil-wifi-20191119
# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.43 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.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


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

branches: 1.38.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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.42 17-Oct-2019 msaitoh

Add support for Killer E2400 and E2500.


# 1.41 17-Oct-2019 msaitoh

Some alc(4) fixes:

- Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )
- Apply FreeBSD r304574:
> Correct DMA channel number selection on AR816x family of
> controllers. For Gigabit Ethernet version of AR816x, AR813x/AR815x
> except L1D controller, use vendor recommended ASPM parameters.
> While here, increase alc_dma_burst array size. Broken H/W can
> return bogus value in theory.
- Use static.
- Whitespace fix. Remove extra backslash.


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


Revision tags: netbsd-9-base
# 1.38 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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.40 15-Oct-2019 msaitoh

Move PCIe initiaization code from alc_attach() to alc_init_pcie().
No functional change.


# 1.39 15-Oct-2019 msaitoh

Apply FreeBSD r218141:
> alc_rev was used without initialization such that it failed to
> apply AR8152 v1.0 specific initialization code. Fix this bug by
> explicitly reading PCI device revision id via PCI accessor.
>
> Reported by: Gabriel Linder ( linder.gabriel <> gmail dot com )


Revision tags: netbsd-9-base
# 1.38 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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.38 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.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.37 28-May-2019 msaitoh

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


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.36 23-May-2019 msaitoh

Whitespace fix (mainly tabify).


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.35 23-May-2019 msaitoh

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


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.34 01-May-2019 msaitoh

Add ether_ioctl() call for SIOCSIFADDR and SIOCSIFFLAGS to make behavior
the same as before.

XXX need cleanup.


# 1.33 01-May-2019 msaitoh

Fix a wrong and extra ether_ioctl() call in alc_ioctl(). _IOWR types call
broke ifreq by the first ether_ioct() and the second ether_ioctl() caused
unexpected behavior. One of bug example is that SIOCGIFMEDIA always failed.
This bug was added in if_alc.c rev. 1.16.

XXX pullup-8


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.32 22-Apr-2019 msaitoh

This driver uses MII(4) and have hook SIOC[GS]IFMEDIA which just pass to
ifmedia_ioctl(), the hook is not required because ether_ioctl has it
(if_ethersubr.c rev. 1.160). This driver might require some additional fixes
for SIOCSIFMTU and other ioctl()s.


Revision tags: isaki-audio2-base
# 1.31 05-Mar-2019 msaitoh

Centralize ETHER_ALIGN into net/if_ether.h. Note that this commit also changes
if_upgt.c's ETHER_ALIGN from 0 to 2.


Revision tags: pgoyette-compat-20190127
# 1.30 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
# 1.29 09-Dec-2018 jdolecek

use pci_intr_establish_xname() everywhere


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

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

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


Revision tags: pgoyette-compat-0625
# 1.27 25-Jun-2018 msaitoh

Remove duplicated inclusion of net/bpf.h.


# 1.26 01-Jun-2018 maxv

Fix M_PKTHDR use in if_alc, if_age and if_ena.

if_alc and if_age always put in _rxhead a M_PKTHDR-flagged mbuf, so the
flag must always be present. Instead of manually adding the flag, add a
KASSERT to ensure it is already there. If it weren't, there would be
memory corruptions.

Same in if_ena, but this one does not compile so we don't really care.

Also, use m_remove_pkthdr to remove the flag, instead of doing it
manually. This ensures the tags get freed (even though these drivers
don't seem to be using mtags).


Revision tags: 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.25 26-Sep-2017 knakahara

branches: 1.25.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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

branches: 1.24.8;
Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.25 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 nick-nhusb-base-20170204 bouyer-socketcan-base pgoyette-localcount-20170107
# 1.24 21-Dec-2016 maya

Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 10-Jun-2016 ozaki-r

branches: 1.21.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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto


# 1.24 21-Dec-2016 maya

Less magic. 0x00000c00 is equal to PCIE_LCAP_ASPM.


# 1.23 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


# 1.22 08-Dec-2016 ozaki-r

Apply deferred if_start framework

if_schedule_deferred_start checks if the if_snd queue contains packets,
so drivers don't need to check it by themselves.


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.21 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.20 17-Feb-2016 christos

PR/50818: David Binderman: Delete dead code (copied from if_et.c)


# 1.19 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!


# 1.18 26-Jan-2016 christos

PR/50694: David Binderman: Fix wrong pasto constant.


Revision tags: nick-nhusb-base-20151226
# 1.17 24-Nov-2015 leot

Add NetBSD RCS Id.


# 1.16 24-Nov-2015 christos

kern/50456: Freddy DISSAUX: Fix packets lost with tcpdump.


Revision tags: nick-nhusb-base-20150921
# 1.15 08-Sep-2015 leot

Add some missing fixes to alc(4) to sync with the latest FreeBSD and OpenBSD
alc(4)s.

Fix a long standing bug in MAC statistics register access. One
additional register was erroneously added in the MAC register set
such that 7 TX statistics counters were wrong. (from OpenBSD, if_alc.c 1.29)

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.
(from OpenBSD, if_alc.c 1.22)

Add some missing bus_dmamap_sync()'s and sync the others with
the FreeBSD code. (from OpenBSD, if_alc.c 1.21)

Help with the watchdog timeouts seen when unplugging the cable from
the alc(4) NIC while running or the NIC not working if the cable is
not plugged in upon boot up. (from OpenBSD, if_alc.c 1.16)

ok mrg@


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

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


Revision tags: nick-nhusb-base-20150406
# 1.13 19-Jan-2015 christos

CID 1245802: Result always 0.


# 1.12 18-Jan-2015 christos

PR/49584: Leonardo Taccari: alc(4): add support for AR816x/AR817x chipsets


Revision tags: nick-nhusb-base netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 rmind-smpnet-nbase rmind-smpnet-base tls-maxphys-base
# 1.11 29-Mar-2014 christos

branches: 1.11.4; 1.11.6;
make pci_intr_string and eisa_intr_string take a buffer and a length
instead of relying in local static storage.


Revision tags: riastradh-drm2-base3
# 1.10 21-Feb-2014 christos

PR/48606: Lloyd Parkes: Drivers not using ifp->if_input but using ether_input
directly.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base
# 1.9 21-Apr-2013 msaitoh

branches: 1.9.4;
Delete "PCI_" from PCIX and PICE capability registers.


# 1.8 30-Mar-2013 christos

remove trailing whitespace


Revision tags: agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7
# 1.7 09-Dec-2012 mrg

avoid illegal sleeps in the softint routine.
XXX could probably do better by creating a watchdog thread.


Revision tags: yamt-pagecache-base6
# 1.6 22-Jul-2012 matt

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


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 jmcneill-usbmp-base10 yamt-pagecache-base5 jmcneill-usbmp-base9 yamt-pagecache-base4 jmcneill-usbmp-base8 jmcneill-usbmp-base7 jmcneill-usbmp-base6 jmcneill-usbmp-base5 jmcneill-usbmp-base4 jmcneill-usbmp-base3 jmcneill-usbmp-pre-base2 jmcneill-usbmp-base2 netbsd-6-base jmcneill-usbmp-base jmcneill-audiomp3-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.5 29-Aug-2011 jmcneill

branches: 1.5.2; 1.5.8;
have pci register itself as a module, and make PCI driver modules depend on it


# 1.4 23-Jun-2011 matt

When printing the interrupt string, be like the other driver and do
"alc0: interrupting at msi 1" instead of "alc: msi 1".


Revision tags: rmind-uvmplock-nbase cherry-xenmp-base rmind-uvmplock-base
# 1.3 08-Apr-2011 sborrill

branches: 1.3.4;
PR kern/38871

Fix LAN on bge(4), alc(4). Flag VLAN capability in ec_capenable as used by network
card drivers.


Revision tags: bouyer-quota2-nbase
# 1.2 23-Feb-2011 jmcneill

branches: 1.2.2; 1.2.4;
catch up with FreeBSD driver, adds support for AR815x chips


# 1.1 23-Feb-2011 jmcneill

add network driver for Atheros AR813x/AR815x ethernet controllers, based
on a patch from fire crow on tech-net with additional bpf & detach fixes,
module support, and a match for 8152 v2.0 devices.

alc0 at pci3 dev 0 function 0: Attansic/Atheros L1C/L2C Ethernet
alc0: ioapic0 pin 17
alc0: Ethernet address 00:26:6c:9e:d4:c1
ukphy0 at alc0 phy 0: L2 10/100 PHY (OUI 0x00c82e, model 0x0002), rev. 5
ukphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, 1000baseT-FDX, auto