History log of /openbsd-current/sys/dev/pci/if_wb.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.77 24-May-2024 jsg

remove unneeded includes; ok miod@


# 1.76 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_7_5_BASE
# 1.75 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.74 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.73 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_8_BASE
# 1.72 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.71 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


# 1.76 13-May-2024 jsg

remove prototypes with no matching function
ok mpi@


Revision tags: OPENBSD_7_5_BASE
# 1.75 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.74 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.73 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_8_BASE
# 1.72 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.71 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


# 1.75 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

Rename ifq_set_maxlen() to ifq_init_maxlen(). This function neither
uses WRITE_ONCE() nor a mutex and is called before the ifq mutex
is initialized. The new name expresses that it should be used only
during interface attach when there is no concurrency.

Protect ifq_len(), ifq_empty(), ifiq_len(), and ifiq_empty() with
READ_ONCE(). They can be used without lock as they only read a
single integer.

OK dlg@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.74 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.73 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_8_BASE
# 1.72 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.71 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


# 1.74 11-Mar-2022 mpi

Constify struct cfattach.


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.73 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_8_BASE
# 1.72 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.71 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


# 1.73 05-Mar-2021 jsg

ansi


Revision tags: OPENBSD_6_8_BASE
# 1.72 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.71 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


# 1.72 10-Jul-2020 patrick

Change users of IFQ_SET_MAXLEN() and IFQ_IS_EMPTY() to use the "new" API.

ok dlg@ tobhe@


# 1.71 10-Jul-2020 patrick

Change users of IFQ_DEQUEUE(), IFQ_ENQUEUE() and IFQ_LEN() to use the
"new" API.

ok dlg@ tobhe@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


Revision tags: OPENBSD_6_5_BASE
# 1.70 01-Apr-2019 naddy

repair "} if" from an ancient merge error; ok deraadt@ kn@


Revision tags: OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver


Revision tags: OPENBSD_6_2_BASE
# 1.69 13-Jul-2017 naddy

kill a prototype for a nonexisting function; ok mpi@


Revision tags: OPENBSD_6_1_BASE
# 1.68 22-Jan-2017 dlg

move counting if_opackets next to counting if_obytes in if_enqueue.

this means packets are consistently counted in one place, unlike the
many and various ways that drivers thought they should do it.

ok mpi@ deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.67 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.66 25-Nov-2015 dlg

replace IFF_OACTIVE manipulation with mpsafe operations.

there are two things shared between the network stack and drivers
in the send path: the send queue and the IFF_OACTIVE flag. the send
queue is now protected by a mutex. this diff makes the oactive
functionality mpsafe too.

IFF_OACTIVE is part of if_flags. there are two problems with that.
firstly, if_flags is a short and we dont have any MI atomic operations
to manipulate a short. secondly, while we could make the IFF_OACTIVE
operates mpsafe, all changes to other flags would have to be made
safe at the same time, otherwise a read-modify-write cycle on their
updates could clobber the oactive change.

instead, this moves the oactive mark into struct ifqueue and provides
an API for changing it. there's ifq_set_oactive, ifq_clr_oactive,
and ifq_is_oactive. these are modelled on ifsq_set_oactive,
ifsq_clr_oactive, and ifsq_is_oactive in dragonflybsd.

this diff includes changes to all the drivers manipulating IFF_OACTIVE
to now use the ifsq_{set,clr_is}_oactive API too.

ok kettenis@ mpi@ jmatthew@ deraadt@


# 1.65 24-Nov-2015 mpi

You only need <net/if_dl.h> if you're using LLADDR() or a sockaddr_dl.


# 1.64 24-Nov-2015 mpi

The only network driver needing <net/if_types.h> is upl(4) for IFT_OTHER.


# 1.63 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.62 11-Sep-2015 stsp

Make room for media types of the future. Extend the ifmedia word to 64 bits.
This changes numbers of the SIOCSIFMEDIA and SIOCGIFMEDIA ioctls and
grows struct ifmediareq.

Old ifconfig and dhclient binaries can still assign addresses, however
the 'media' subcommand stops working. Recompiling ifconfig and dhclient
with new headers before a reboot should not be necessary unless in very
special circumstances where non-default media settings must be used to
get link and console access is not available.

There may be some MD fallout but that will be cleared up later.

ok deraadt miod
with help and suggestions from several sharks attending l2k15


Revision tags: OPENBSD_5_8_BASE
# 1.61 24-Jun-2015 mpi

Increment if_ipackets in if_input().

Note that pseudo-drivers not using if_input() are not affected by this
conversion.

ok mikeb@, kettenis@, claudio@, dlg@


# 1.60 13-Apr-2015 mpi

Now that if_input() set the receiving interface pointer on mbufs for us
there's no need to do it in m_devget(9).

Stop passing an ``ifp'' will help for upcoming interface pointer -> index
conversion.

While here remove unused ``ifp'' argument from m_clget(9) and kill two
birds^W layer violations in one commit.

ok henning@


# 1.59 08-Apr-2015 mpi

Convert to if_input().

ok dlg@


Revision tags: OPENBSD_5_7_BASE
# 1.58 22-Dec-2014 tedu

unifdef INET


# 1.57 03-Dec-2014 brad

wb_init() calls wb_stop() and wb_reset() so remove some redundant calls
to those functions before wb_init() within wb_watchdog() / wb_intr() and
wb_rxeof().


Revision tags: OPENBSD_5_6_BASE
# 1.56 22-Jul-2014 mpi

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.55 26-Nov-2013 mpi

Instead of comparing the lower and higher addresses of all the multicast
entries to decide if the IFF_ALLMULTI flag should be set, check if there
is at least one real range between them.

This should not change the behavior of any driver but if you encounter
any problem, feel free to revert the offending chunk and ping me about
it.

ok naddy@, dlg@


# 1.54 01-Oct-2013 sf

Use %z* for size_t

while there, fix a few %d into %u


# 1.53 21-Aug-2013 dlg

get rid of the copy argument in m_devget that let you provide an
alternative to bcopy since noone uses it.

while there use memcpy instead of bcopy because we know the memory cannot
overlap.

ok henning@ matthew@ mikeb@ deraadt@


# 1.52 07-Aug-2013 bluhm

Most network drivers include netinet/in_var.h, but apparently they
don't have to. Just remove these include lines.
Compiled on amd64 i386 sparc64; OK henning@ mikeb@


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.51 29-Nov-2012 brad

Remove setting an initial assumed baudrate upon driver attach which is not
necessarily correct, there might not even be a link when attaching.

ok mikeb@ reyk@


# 1.50 23-Nov-2012 gsoares

set ifp->if_baudrate with IF_Gbps() / IF_Mbps().

OK reyk@ sthen@


# 1.49 18-Oct-2012 deraadt

Convert a number of old private copies of code which predates
pci_set_powerstate() to using it instead. Many of these chunks of code had
bugs in them, especially missing delay() calls. Some of them were doing
things our PCI subsystem is now responsible for handling. If you have
any of the affected devices, please keep an eye out for regressions.
ok kettenis


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.48 22-Jun-2011 tedu

kill a few more casts that aren't helpful. ok krw miod


# 1.47 03-Apr-2011 jasper

use nitems(); no binary change for drivers that are compiled on amd64.

ok claudio@


Revision tags: OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.46 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.45 13-Aug-2009 jasper

- consistify cfdriver for the ethernet drivers (0 -> NULL)

ok dlg@


# 1.44 10-Aug-2009 deraadt

A few more simple cases of shutdown hooks which only call xxstop, when
we now know the interface has already been stopped


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.43 28-Nov-2008 brad

Eliminate the redundant bits of code for MTU and multicast handling
from the individual drivers now that ether_ioctl() handles this.

Shrinks the i386 kernels by..
RAMDISK - 2176 bytes
RAMDISKB - 1504 bytes
RAMDISKC - 736 bytes

Tested by naddy@/okan@/sthen@/brad@/todd@/jmc@ and lots of users.
Build tested on almost all archs by todd@/brad@

ok naddy@


# 1.42 25-Nov-2008 claudio

Switch wb(4) from the insane ext buffer usage to a very simple m_devget()
call to copy the packet from the RX DMA ring to build a mbuf (it almost
already did that but way more complex).
OK brad@ dlg@ thib@
Tested by Tero Koskinen tero.koskinen (at) iki (dot) fi on a wb(4)


# 1.41 14-Oct-2008 naddy

Change m_devget()'s outdated and unused "offset" argument: It is
now the offset into the first mbuf of the target chain before copying
the source data over. From FreeBSD.

Convert drivers' use of m_devget(). Mostly from thib@.

Update mbuf(9) man page.

ok claudio@, thib@


# 1.40 02-Oct-2008 brad

First step towards cleaning up the Ethernet driver ioctl handling.
Move calling ether_ioctl() from the top of the ioctl function, which
at the moment does absolutely nothing, to the default switch case.
Thus allowing drivers to define their own ioctl handlers and then
falling back on ether_ioctl(). The only functional change this results
in at the moment is having all Ethernet drivers returning the proper
errno of ENOTTY instead of EINVAL/ENXIO when encountering unknown
ioctl's.

Shrinks the i386 kernels by..
RAMDISK - 1024 bytes
RAMDISKB - 1120 bytes
RAMDISKC - 832 bytes

Tested by martin@/jsing@/todd@/brad@
Build tested on almost all archs by todd@/brad@

ok jsing@


# 1.39 10-Sep-2008 blambert

Convert timeout_add() calls using multiples of hz to timeout_add_sec()

Really just the low-hanging fruit of (hopefully) forthcoming timeout
conversions.

ok art@, krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.38 26-May-2007 krw

More comment typos from Diego Casati. Including winners like funtion, allmost,
oustside, seqencer, toghether, nessissary, etc.


# 1.37 25-May-2007 krw

"interupt" -> "interrupt" in various comments. Mostly from Diego Casati.


Revision tags: OPENBSD_4_1_BASE
# 1.36 25-Oct-2006 brad

replace a few more instances of hand rolled code with the
LIST_FOREACH macro.


Revision tags: OPENBSD_4_0_BASE
# 1.35 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.34 25-Mar-2006 djm

allow bpf(4) to ignore packets based on their direction (inbound or
outbound), using a new BIOCSDIRFILT ioctl;
guidance, feedback and ok canacar@


# 1.33 20-Mar-2006 brad

de-register.


Revision tags: OPENBSD_3_9_BASE
# 1.32 23-Nov-2005 mickey

assume vtophys(vaddr_t) just what all the other archs expect; no functional change


# 1.31 07-Nov-2005 brad

- splimp -> splnet
- remove spl's from attach
- removing redundant checks before pci_mapreg_map()
- fix dmesg printing
- de-allocate resources on failure to attach
- remove unused VLAN input code from vge(4)


# 1.30 11-Sep-2005 mickey

do not inline pci_mapreg_map() anymore as it is olrite now; brad@ ok


Revision tags: OPENBSD_3_8_BASE
# 1.29 09-Aug-2005 mickey

do not set PCI_COMMAND_MASTER_ENABLE explicitly as it's already set in pcisubmatch(); kettenis@ testing; brad@ ok


# 1.28 02-Jul-2005 brad

clear IFF_RUNNING & IFF_OACTIVE in foo_stop() before de-allocating resources.


Revision tags: OPENBSD_3_7_BASE
# 1.27 15-Jan-2005 brad

make sure interface is in RUNNING state before touching the multicast filters

From NetBSD

NetBSD PR 27678 for details

ok mcbride@


# 1.26 11-Dec-2004 brad

rev 1.51

When reading PHY regs over the i2c bus, the turnaround ACK bit
is read one clock edge too late. This bit is driven low by
slave (as any other input data bits from slave) when the clock
is LOW. The current code did read the bit after the clock was
driven high again.

From FreeBSD


# 1.25 28-Sep-2004 brad

Use ETHER_MAX_DIX_LEN/ETHER_MIN_LEN


# 1.24 23-Sep-2004 brad

don't need to set ifp->if_mtu or ifp->if_output in each driver,
{ether,atm,fddi}_ifattach already does this.

ok mcbride@ markus@ henning@


Revision tags: OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 06-Jun-2004 mcbride

Multicast cleanups
- make multicast ranges work
- replace handrolled crc code with ether_crc32_{be,le}()
- add missing calls to ether_{add,del}multi()

ok deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.22 19-Aug-2003 mpech

missing break.

jason@ ok


Revision tags: UBC_SYNC_A
# 1.21 26-Apr-2003 jmc

managment -> management;

ok mickey@


Revision tags: OPENBSD_3_3_BASE
# 1.20 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.19 19-Nov-2002 jason

Add a simplistic table driven lookup routine and use it where appropriate.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.18 05-Jul-2002 aaron

Typo; stobe -> strobe


Revision tags: OPENBSD_3_1_BASE
# 1.17 14-Mar-2002 millert

First round of __P removal in sys


# 1.16 15-Feb-2002 nordin

Don't cast nonexistent return value from splx to (void). ok art@


Revision tags: UBC_BASE
# 1.15 06-Nov-2001 miod

branches: 1.15.2;
Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.14 11-Sep-2001 miod

Don't include <vm/vm_kern.h> if you don't need foo_map.


# 1.13 25-Aug-2001 art

Change pci_intr_map to take pci_attach_args as an argument.
All callers actually took all arguments to pci_intr_map from pci_attach_args
structs, so this simplifies code.
This also allows more complicated interrupt assignment schemes like the one
on sparc64.

This makes sparc64 pci interrupts work.

Inspired by the same change in NetBSD.


# 1.12 12-Aug-2001 mickey

remove redundant vm includes


# 1.11 27-Jun-2001 kjc

ALTQ'ify network drivers.
- use the new queue macros.
- use IFQ_POLL() to peek at the next packet.
- use IFQ_IS_EMPTY() for empty check.
- drivers should always check if (m == NULL) after IFQ_DEQUEUE(),
since it could return NULL even when IFQ_IS_EMPTY() is FALSE
under rate-limiting.
- drivers are supposed to call if_start from tx complete interrupts
(in order to trigger the next dequeue under rate-limiting).


# 1.10 24-Jun-2001 fgsch

more ether_input_mbuf() conversion.


# 1.9 17-May-2001 provos

convert mbuf and cluster allocation to pool, mostly from NetBSD
okay art@ miod@


Revision tags: OPENBSD_2_9_BASE
# 1.8 20-Feb-2001 mickey

for ethernet ifaces attach bpf from ether_ifattach; jason@, aaron@, itojun@ ok


# 1.7 03-Feb-2001 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.6 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


Revision tags: OPENBSD_2_7_BASE
# 1.5 15-Feb-2000 jason

make sure to call ether_{add,del}multi() as appropriate in xxx_ioctl()


Revision tags: SMP_BASE kame_19991208
# 1.4 19-Nov-1999 jason

branches: 1.4.2;
use bus_dma*
merge with freebsd:
use dev/mii layer
do a more full reset in wb_reset()


Revision tags: OPENBSD_2_6_BASE
# 1.3 27-Sep-1999 jason

reindent after removing statics
remove %d/wb_unit in favor of %s/sc_dev.dv_xname
From aaron@:
uncomment and use splimp() (and fix case where splx would be missed)
correct check for mem mapped mode


# 1.2 03-Sep-1999 jason

o make this look more like an OpenBSD driver (removed static's)
o partial merge with freebsd, alpha support (currently untested)


Revision tags: OPENBSD_2_5_BASE
# 1.1 11-Mar-1999 jason

Winbond W89C840F ethernet driver