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

remove unneeded includes; ok miod@


Revision tags: OPENBSD_7_5_BASE
# 1.70 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.69 11-Mar-2022 mpi

Constify struct cfattach.


# 1.68 22-Feb-2022 guenther

Delete unnecessary #includes of <sys/domain.h> and/or <sys/protosw.h>

net/if_pppx.c pointed out by jsg@
ok gnezdo@ deraadt@ jsg@ mpi@ millert@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.67 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.66 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_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.65 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.64 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.63 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.62 24-Nov-2015 mpi

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


# 1.61 24-Nov-2015 mpi

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


# 1.60 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.59 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.58 15-May-2015 mpi

Convert to if_input().

ok dlg@


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

unifdef INET


# 1.56 08-Dec-2014 brad

Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant
calls to foo_stop() and foo_reset() before foo_init().

Tested with DP83815, 3c905C, 8139 and ST201.
Mostly from FreeBSD.


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.54 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_4_BASE
# 1.53 14-Mar-2013 brad

- Remove return at the end of void functions
- Move the PCI devices table up to the top


# 1.52 09-Mar-2013 brad

Rewrite the receive filter handling code and cleanup the ioctl bits.

ok sthen@


Revision tags: OPENBSD_5_3_BASE
# 1.51 16-Jan-2013 brad

Some corrections for D-Link device names.

ok jsing@


# 1.50 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.49 23-Nov-2012 gsoares

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

OK reyk@ sthen@


# 1.48 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.47 22-Jun-2011 tedu

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


# 1.46 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_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 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.41 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.40 17-Jul-2007 krw

Add missing '};' to end struct declaration. Compiles again.


# 1.39 17-Jul-2007 jasper

ident/ansify/de-register


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.38 08-Jul-2006 brad

uncomment call to ste_miibus_statchg in ste_stats_update.


# 1.37 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.36 02-Apr-2006 brad

add another PCI id to the ste(4) driver.

From the Sundance Linux driver.


# 1.35 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@


Revision tags: OPENBSD_3_9_BASE
# 1.34 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.33 10-Sep-2005 brad

- a few fixes from the FreeBSD driver
- make use of pci_mapreg_map()
- ensure driver cleans after itself if ste_attach() fails


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

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


# 1.31 02-Jul-2005 brad

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


# 1.30 21-Apr-2005 fgsch

o if the mac address cannot be read, just fail and disestablish the
irq (for shared irq's) on failure. (should other drivers do the same?)
o if it's a rev 0x12 card, only use the first phy as it reports a
non-existent one as well (From FreeBSD).
o remove splimp/splx from ste_attach().
o some cleanup.

thanks to matt at mattroberts dot org and paolo at actcom dot net dot il
for testing; commit deraadt@.


# 1.29 08-Apr-2005 beck

remove dmesg spewage when link changes, ok deraadt, brad, canacar


Revision tags: OPENBSD_3_7_BASE
# 1.28 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.27 21-Nov-2004 brad

- Use ETHER_MAX_DIX_LEN.
- Accept VLAN sized frames. based on diff from canacar@


# 1.26 30-Oct-2004 canacar

vaddr_t casts for vtophys, works on amd64, enabled in GENERIC
patch submitted and tested by Steffen Sch�tz, schuetz.steffen at melle de
ok tedu@


# 1.25 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
# 1.24 22-Aug-2004 canacar

Do check for STATS_OFLOW in interrupt handler. The overflow interrupt is
already disabled and the status update function fails to clear the overflow,
causing high interrupt load. Reported and tested by Arvid Gr�tting.
ok deraadt@


# 1.23 09-Aug-2004 canacar

update ste(4) with stability and performance fixes from
FreeBSD if_ste.c revisions 1.28, 1.29, 1.38, 1.43, 1.63, 1.68, 1.70
ok henning@


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.22 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@


# 1.21 09-Apr-2004 henning

do not whine if we cannot get mbufs. the countless printfd makes the machine
crawl under mbuf starvation, making the situationmuch worse, and don't make
sense in the first place.
ok tdeval@ millert@ beck@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.20 29-Jun-2003 avsm

lose ste_unit; jason@ ok


# 1.19 29-Jun-2003 avsm

another bad format string; %s->%d
ok tedu@


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.18 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.17 19-Nov-2002 jason

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


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 14-Mar-2002 millert

First round of __P removal in sys


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 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.13 12-Aug-2001 mickey

remove redundant vm includes


# 1.12 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.11 25-Jun-2001 fgsch

trivial ether_input_mbuf() conversion.


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

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


# 1.9 03-Feb-2001 mickey

new timeouts


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

Use mii_attach() directly instead of mii_phy_probe().


# 1.7 27-Jun-2000 aaron

Make this driver work. When I ported it from FreeBSD, somehow a line got left
out. :-( It was never noticed until now since I didn't have an actual D-Link
550TX card to test with. Thanks to Gardner Cohen for sending me one of these.


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

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


Revision tags: SMP_BASE kame_19991208
# 1.5 08-Dec-1999 aaron

branches: 1.5.2;
Remove unused #define cruft.


# 1.4 08-Dec-1999 aaron

Whoops; forgot to bump FreeBSD version numbers.


# 1.3 08-Dec-1999 aaron

Sync with FreeBSD:
- Use TX descriptor polling, similar to the xl driver, to reduce TX overhead.
- As in if_sf, reset PHY when switching modes.
- Remove unused code that was #ifdef foo'd out.


# 1.2 07-Dec-1999 jason

remove freebsd bridging stuff, and let ALL packets go to ether_input()


# 1.1 07-Dec-1999 aaron

Driver for Sundance ST201 Ethernet; from FreeBSD.


# 1.70 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.69 11-Mar-2022 mpi

Constify struct cfattach.


# 1.68 22-Feb-2022 guenther

Delete unnecessary #includes of <sys/domain.h> and/or <sys/protosw.h>

net/if_pppx.c pointed out by jsg@
ok gnezdo@ deraadt@ jsg@ mpi@ millert@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.67 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.66 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_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.65 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.64 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.63 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.62 24-Nov-2015 mpi

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


# 1.61 24-Nov-2015 mpi

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


# 1.60 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.59 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.58 15-May-2015 mpi

Convert to if_input().

ok dlg@


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

unifdef INET


# 1.56 08-Dec-2014 brad

Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant
calls to foo_stop() and foo_reset() before foo_init().

Tested with DP83815, 3c905C, 8139 and ST201.
Mostly from FreeBSD.


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.54 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_4_BASE
# 1.53 14-Mar-2013 brad

- Remove return at the end of void functions
- Move the PCI devices table up to the top


# 1.52 09-Mar-2013 brad

Rewrite the receive filter handling code and cleanup the ioctl bits.

ok sthen@


Revision tags: OPENBSD_5_3_BASE
# 1.51 16-Jan-2013 brad

Some corrections for D-Link device names.

ok jsing@


# 1.50 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.49 23-Nov-2012 gsoares

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

OK reyk@ sthen@


# 1.48 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.47 22-Jun-2011 tedu

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


# 1.46 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_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 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.41 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.40 17-Jul-2007 krw

Add missing '};' to end struct declaration. Compiles again.


# 1.39 17-Jul-2007 jasper

ident/ansify/de-register


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.38 08-Jul-2006 brad

uncomment call to ste_miibus_statchg in ste_stats_update.


# 1.37 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.36 02-Apr-2006 brad

add another PCI id to the ste(4) driver.

From the Sundance Linux driver.


# 1.35 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@


Revision tags: OPENBSD_3_9_BASE
# 1.34 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.33 10-Sep-2005 brad

- a few fixes from the FreeBSD driver
- make use of pci_mapreg_map()
- ensure driver cleans after itself if ste_attach() fails


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

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


# 1.31 02-Jul-2005 brad

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


# 1.30 21-Apr-2005 fgsch

o if the mac address cannot be read, just fail and disestablish the
irq (for shared irq's) on failure. (should other drivers do the same?)
o if it's a rev 0x12 card, only use the first phy as it reports a
non-existent one as well (From FreeBSD).
o remove splimp/splx from ste_attach().
o some cleanup.

thanks to matt at mattroberts dot org and paolo at actcom dot net dot il
for testing; commit deraadt@.


# 1.29 08-Apr-2005 beck

remove dmesg spewage when link changes, ok deraadt, brad, canacar


Revision tags: OPENBSD_3_7_BASE
# 1.28 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.27 21-Nov-2004 brad

- Use ETHER_MAX_DIX_LEN.
- Accept VLAN sized frames. based on diff from canacar@


# 1.26 30-Oct-2004 canacar

vaddr_t casts for vtophys, works on amd64, enabled in GENERIC
patch submitted and tested by Steffen Sch�tz, schuetz.steffen at melle de
ok tedu@


# 1.25 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
# 1.24 22-Aug-2004 canacar

Do check for STATS_OFLOW in interrupt handler. The overflow interrupt is
already disabled and the status update function fails to clear the overflow,
causing high interrupt load. Reported and tested by Arvid Gr�tting.
ok deraadt@


# 1.23 09-Aug-2004 canacar

update ste(4) with stability and performance fixes from
FreeBSD if_ste.c revisions 1.28, 1.29, 1.38, 1.43, 1.63, 1.68, 1.70
ok henning@


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.22 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@


# 1.21 09-Apr-2004 henning

do not whine if we cannot get mbufs. the countless printfd makes the machine
crawl under mbuf starvation, making the situationmuch worse, and don't make
sense in the first place.
ok tdeval@ millert@ beck@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.20 29-Jun-2003 avsm

lose ste_unit; jason@ ok


# 1.19 29-Jun-2003 avsm

another bad format string; %s->%d
ok tedu@


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.18 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.17 19-Nov-2002 jason

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


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 14-Mar-2002 millert

First round of __P removal in sys


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 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.13 12-Aug-2001 mickey

remove redundant vm includes


# 1.12 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.11 25-Jun-2001 fgsch

trivial ether_input_mbuf() conversion.


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

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


# 1.9 03-Feb-2001 mickey

new timeouts


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

Use mii_attach() directly instead of mii_phy_probe().


# 1.7 27-Jun-2000 aaron

Make this driver work. When I ported it from FreeBSD, somehow a line got left
out. :-( It was never noticed until now since I didn't have an actual D-Link
550TX card to test with. Thanks to Gardner Cohen for sending me one of these.


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

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


Revision tags: SMP_BASE kame_19991208
# 1.5 08-Dec-1999 aaron

branches: 1.5.2;
Remove unused #define cruft.


# 1.4 08-Dec-1999 aaron

Whoops; forgot to bump FreeBSD version numbers.


# 1.3 08-Dec-1999 aaron

Sync with FreeBSD:
- Use TX descriptor polling, similar to the xl driver, to reduce TX overhead.
- As in if_sf, reset PHY when switching modes.
- Remove unused code that was #ifdef foo'd out.


# 1.2 07-Dec-1999 jason

remove freebsd bridging stuff, and let ALL packets go to ether_input()


# 1.1 07-Dec-1999 aaron

Driver for Sundance ST201 Ethernet; from FreeBSD.


# 1.69 11-Mar-2022 mpi

Constify struct cfattach.


# 1.68 22-Feb-2022 guenther

Delete unnecessary #includes of <sys/domain.h> and/or <sys/protosw.h>

net/if_pppx.c pointed out by jsg@
ok gnezdo@ deraadt@ jsg@ mpi@ millert@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.67 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.66 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_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.65 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.64 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.63 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.62 24-Nov-2015 mpi

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


# 1.61 24-Nov-2015 mpi

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


# 1.60 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.59 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.58 15-May-2015 mpi

Convert to if_input().

ok dlg@


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

unifdef INET


# 1.56 08-Dec-2014 brad

Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant
calls to foo_stop() and foo_reset() before foo_init().

Tested with DP83815, 3c905C, 8139 and ST201.
Mostly from FreeBSD.


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.54 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_4_BASE
# 1.53 14-Mar-2013 brad

- Remove return at the end of void functions
- Move the PCI devices table up to the top


# 1.52 09-Mar-2013 brad

Rewrite the receive filter handling code and cleanup the ioctl bits.

ok sthen@


Revision tags: OPENBSD_5_3_BASE
# 1.51 16-Jan-2013 brad

Some corrections for D-Link device names.

ok jsing@


# 1.50 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.49 23-Nov-2012 gsoares

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

OK reyk@ sthen@


# 1.48 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.47 22-Jun-2011 tedu

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


# 1.46 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_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 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.41 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.40 17-Jul-2007 krw

Add missing '};' to end struct declaration. Compiles again.


# 1.39 17-Jul-2007 jasper

ident/ansify/de-register


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.38 08-Jul-2006 brad

uncomment call to ste_miibus_statchg in ste_stats_update.


# 1.37 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.36 02-Apr-2006 brad

add another PCI id to the ste(4) driver.

From the Sundance Linux driver.


# 1.35 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@


Revision tags: OPENBSD_3_9_BASE
# 1.34 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.33 10-Sep-2005 brad

- a few fixes from the FreeBSD driver
- make use of pci_mapreg_map()
- ensure driver cleans after itself if ste_attach() fails


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

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


# 1.31 02-Jul-2005 brad

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


# 1.30 21-Apr-2005 fgsch

o if the mac address cannot be read, just fail and disestablish the
irq (for shared irq's) on failure. (should other drivers do the same?)
o if it's a rev 0x12 card, only use the first phy as it reports a
non-existent one as well (From FreeBSD).
o remove splimp/splx from ste_attach().
o some cleanup.

thanks to matt at mattroberts dot org and paolo at actcom dot net dot il
for testing; commit deraadt@.


# 1.29 08-Apr-2005 beck

remove dmesg spewage when link changes, ok deraadt, brad, canacar


Revision tags: OPENBSD_3_7_BASE
# 1.28 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.27 21-Nov-2004 brad

- Use ETHER_MAX_DIX_LEN.
- Accept VLAN sized frames. based on diff from canacar@


# 1.26 30-Oct-2004 canacar

vaddr_t casts for vtophys, works on amd64, enabled in GENERIC
patch submitted and tested by Steffen Sch�tz, schuetz.steffen at melle de
ok tedu@


# 1.25 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
# 1.24 22-Aug-2004 canacar

Do check for STATS_OFLOW in interrupt handler. The overflow interrupt is
already disabled and the status update function fails to clear the overflow,
causing high interrupt load. Reported and tested by Arvid Gr�tting.
ok deraadt@


# 1.23 09-Aug-2004 canacar

update ste(4) with stability and performance fixes from
FreeBSD if_ste.c revisions 1.28, 1.29, 1.38, 1.43, 1.63, 1.68, 1.70
ok henning@


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.22 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@


# 1.21 09-Apr-2004 henning

do not whine if we cannot get mbufs. the countless printfd makes the machine
crawl under mbuf starvation, making the situationmuch worse, and don't make
sense in the first place.
ok tdeval@ millert@ beck@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.20 29-Jun-2003 avsm

lose ste_unit; jason@ ok


# 1.19 29-Jun-2003 avsm

another bad format string; %s->%d
ok tedu@


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.18 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.17 19-Nov-2002 jason

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


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 14-Mar-2002 millert

First round of __P removal in sys


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 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.13 12-Aug-2001 mickey

remove redundant vm includes


# 1.12 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.11 25-Jun-2001 fgsch

trivial ether_input_mbuf() conversion.


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

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


# 1.9 03-Feb-2001 mickey

new timeouts


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

Use mii_attach() directly instead of mii_phy_probe().


# 1.7 27-Jun-2000 aaron

Make this driver work. When I ported it from FreeBSD, somehow a line got left
out. :-( It was never noticed until now since I didn't have an actual D-Link
550TX card to test with. Thanks to Gardner Cohen for sending me one of these.


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

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


Revision tags: SMP_BASE kame_19991208
# 1.5 08-Dec-1999 aaron

branches: 1.5.2;
Remove unused #define cruft.


# 1.4 08-Dec-1999 aaron

Whoops; forgot to bump FreeBSD version numbers.


# 1.3 08-Dec-1999 aaron

Sync with FreeBSD:
- Use TX descriptor polling, similar to the xl driver, to reduce TX overhead.
- As in if_sf, reset PHY when switching modes.
- Remove unused code that was #ifdef foo'd out.


# 1.2 07-Dec-1999 jason

remove freebsd bridging stuff, and let ALL packets go to ether_input()


# 1.1 07-Dec-1999 aaron

Driver for Sundance ST201 Ethernet; from FreeBSD.


# 1.68 22-Feb-2022 guenther

Delete unnecessary #includes of <sys/domain.h> and/or <sys/protosw.h>

net/if_pppx.c pointed out by jsg@
ok gnezdo@ deraadt@ jsg@ mpi@ millert@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.67 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.66 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_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.65 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.64 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.63 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.62 24-Nov-2015 mpi

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


# 1.61 24-Nov-2015 mpi

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


# 1.60 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.59 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.58 15-May-2015 mpi

Convert to if_input().

ok dlg@


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

unifdef INET


# 1.56 08-Dec-2014 brad

Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant
calls to foo_stop() and foo_reset() before foo_init().

Tested with DP83815, 3c905C, 8139 and ST201.
Mostly from FreeBSD.


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.54 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_4_BASE
# 1.53 14-Mar-2013 brad

- Remove return at the end of void functions
- Move the PCI devices table up to the top


# 1.52 09-Mar-2013 brad

Rewrite the receive filter handling code and cleanup the ioctl bits.

ok sthen@


Revision tags: OPENBSD_5_3_BASE
# 1.51 16-Jan-2013 brad

Some corrections for D-Link device names.

ok jsing@


# 1.50 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.49 23-Nov-2012 gsoares

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

OK reyk@ sthen@


# 1.48 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.47 22-Jun-2011 tedu

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


# 1.46 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_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 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.41 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.40 17-Jul-2007 krw

Add missing '};' to end struct declaration. Compiles again.


# 1.39 17-Jul-2007 jasper

ident/ansify/de-register


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.38 08-Jul-2006 brad

uncomment call to ste_miibus_statchg in ste_stats_update.


# 1.37 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.36 02-Apr-2006 brad

add another PCI id to the ste(4) driver.

From the Sundance Linux driver.


# 1.35 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@


Revision tags: OPENBSD_3_9_BASE
# 1.34 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.33 10-Sep-2005 brad

- a few fixes from the FreeBSD driver
- make use of pci_mapreg_map()
- ensure driver cleans after itself if ste_attach() fails


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

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


# 1.31 02-Jul-2005 brad

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


# 1.30 21-Apr-2005 fgsch

o if the mac address cannot be read, just fail and disestablish the
irq (for shared irq's) on failure. (should other drivers do the same?)
o if it's a rev 0x12 card, only use the first phy as it reports a
non-existent one as well (From FreeBSD).
o remove splimp/splx from ste_attach().
o some cleanup.

thanks to matt at mattroberts dot org and paolo at actcom dot net dot il
for testing; commit deraadt@.


# 1.29 08-Apr-2005 beck

remove dmesg spewage when link changes, ok deraadt, brad, canacar


Revision tags: OPENBSD_3_7_BASE
# 1.28 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.27 21-Nov-2004 brad

- Use ETHER_MAX_DIX_LEN.
- Accept VLAN sized frames. based on diff from canacar@


# 1.26 30-Oct-2004 canacar

vaddr_t casts for vtophys, works on amd64, enabled in GENERIC
patch submitted and tested by Steffen Sch�tz, schuetz.steffen at melle de
ok tedu@


# 1.25 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
# 1.24 22-Aug-2004 canacar

Do check for STATS_OFLOW in interrupt handler. The overflow interrupt is
already disabled and the status update function fails to clear the overflow,
causing high interrupt load. Reported and tested by Arvid Gr�tting.
ok deraadt@


# 1.23 09-Aug-2004 canacar

update ste(4) with stability and performance fixes from
FreeBSD if_ste.c revisions 1.28, 1.29, 1.38, 1.43, 1.63, 1.68, 1.70
ok henning@


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.22 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@


# 1.21 09-Apr-2004 henning

do not whine if we cannot get mbufs. the countless printfd makes the machine
crawl under mbuf starvation, making the situationmuch worse, and don't make
sense in the first place.
ok tdeval@ millert@ beck@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.20 29-Jun-2003 avsm

lose ste_unit; jason@ ok


# 1.19 29-Jun-2003 avsm

another bad format string; %s->%d
ok tedu@


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.18 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.17 19-Nov-2002 jason

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


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 14-Mar-2002 millert

First round of __P removal in sys


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 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.13 12-Aug-2001 mickey

remove redundant vm includes


# 1.12 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.11 25-Jun-2001 fgsch

trivial ether_input_mbuf() conversion.


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

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


# 1.9 03-Feb-2001 mickey

new timeouts


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

Use mii_attach() directly instead of mii_phy_probe().


# 1.7 27-Jun-2000 aaron

Make this driver work. When I ported it from FreeBSD, somehow a line got left
out. :-( It was never noticed until now since I didn't have an actual D-Link
550TX card to test with. Thanks to Gardner Cohen for sending me one of these.


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

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


Revision tags: SMP_BASE kame_19991208
# 1.5 08-Dec-1999 aaron

branches: 1.5.2;
Remove unused #define cruft.


# 1.4 08-Dec-1999 aaron

Whoops; forgot to bump FreeBSD version numbers.


# 1.3 08-Dec-1999 aaron

Sync with FreeBSD:
- Use TX descriptor polling, similar to the xl driver, to reduce TX overhead.
- As in if_sf, reset PHY when switching modes.
- Remove unused code that was #ifdef foo'd out.


# 1.2 07-Dec-1999 jason

remove freebsd bridging stuff, and let ALL packets go to ether_input()


# 1.1 07-Dec-1999 aaron

Driver for Sundance ST201 Ethernet; from FreeBSD.


# 1.67 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.66 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_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.65 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.64 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.63 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.62 24-Nov-2015 mpi

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


# 1.61 24-Nov-2015 mpi

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


# 1.60 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.59 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.58 15-May-2015 mpi

Convert to if_input().

ok dlg@


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

unifdef INET


# 1.56 08-Dec-2014 brad

Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant
calls to foo_stop() and foo_reset() before foo_init().

Tested with DP83815, 3c905C, 8139 and ST201.
Mostly from FreeBSD.


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.54 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_4_BASE
# 1.53 14-Mar-2013 brad

- Remove return at the end of void functions
- Move the PCI devices table up to the top


# 1.52 09-Mar-2013 brad

Rewrite the receive filter handling code and cleanup the ioctl bits.

ok sthen@


Revision tags: OPENBSD_5_3_BASE
# 1.51 16-Jan-2013 brad

Some corrections for D-Link device names.

ok jsing@


# 1.50 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.49 23-Nov-2012 gsoares

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

OK reyk@ sthen@


# 1.48 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.47 22-Jun-2011 tedu

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


# 1.46 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_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 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.41 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.40 17-Jul-2007 krw

Add missing '};' to end struct declaration. Compiles again.


# 1.39 17-Jul-2007 jasper

ident/ansify/de-register


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.38 08-Jul-2006 brad

uncomment call to ste_miibus_statchg in ste_stats_update.


# 1.37 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.36 02-Apr-2006 brad

add another PCI id to the ste(4) driver.

From the Sundance Linux driver.


# 1.35 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@


Revision tags: OPENBSD_3_9_BASE
# 1.34 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.33 10-Sep-2005 brad

- a few fixes from the FreeBSD driver
- make use of pci_mapreg_map()
- ensure driver cleans after itself if ste_attach() fails


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

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


# 1.31 02-Jul-2005 brad

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


# 1.30 21-Apr-2005 fgsch

o if the mac address cannot be read, just fail and disestablish the
irq (for shared irq's) on failure. (should other drivers do the same?)
o if it's a rev 0x12 card, only use the first phy as it reports a
non-existent one as well (From FreeBSD).
o remove splimp/splx from ste_attach().
o some cleanup.

thanks to matt at mattroberts dot org and paolo at actcom dot net dot il
for testing; commit deraadt@.


# 1.29 08-Apr-2005 beck

remove dmesg spewage when link changes, ok deraadt, brad, canacar


Revision tags: OPENBSD_3_7_BASE
# 1.28 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.27 21-Nov-2004 brad

- Use ETHER_MAX_DIX_LEN.
- Accept VLAN sized frames. based on diff from canacar@


# 1.26 30-Oct-2004 canacar

vaddr_t casts for vtophys, works on amd64, enabled in GENERIC
patch submitted and tested by Steffen Sch�tz, schuetz.steffen at melle de
ok tedu@


# 1.25 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
# 1.24 22-Aug-2004 canacar

Do check for STATS_OFLOW in interrupt handler. The overflow interrupt is
already disabled and the status update function fails to clear the overflow,
causing high interrupt load. Reported and tested by Arvid Gr�tting.
ok deraadt@


# 1.23 09-Aug-2004 canacar

update ste(4) with stability and performance fixes from
FreeBSD if_ste.c revisions 1.28, 1.29, 1.38, 1.43, 1.63, 1.68, 1.70
ok henning@


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.22 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@


# 1.21 09-Apr-2004 henning

do not whine if we cannot get mbufs. the countless printfd makes the machine
crawl under mbuf starvation, making the situationmuch worse, and don't make
sense in the first place.
ok tdeval@ millert@ beck@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.20 29-Jun-2003 avsm

lose ste_unit; jason@ ok


# 1.19 29-Jun-2003 avsm

another bad format string; %s->%d
ok tedu@


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.18 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.17 19-Nov-2002 jason

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


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 14-Mar-2002 millert

First round of __P removal in sys


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 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.13 12-Aug-2001 mickey

remove redundant vm includes


# 1.12 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.11 25-Jun-2001 fgsch

trivial ether_input_mbuf() conversion.


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

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


# 1.9 03-Feb-2001 mickey

new timeouts


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

Use mii_attach() directly instead of mii_phy_probe().


# 1.7 27-Jun-2000 aaron

Make this driver work. When I ported it from FreeBSD, somehow a line got left
out. :-( It was never noticed until now since I didn't have an actual D-Link
550TX card to test with. Thanks to Gardner Cohen for sending me one of these.


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

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


Revision tags: SMP_BASE kame_19991208
# 1.5 08-Dec-1999 aaron

branches: 1.5.2;
Remove unused #define cruft.


# 1.4 08-Dec-1999 aaron

Whoops; forgot to bump FreeBSD version numbers.


# 1.3 08-Dec-1999 aaron

Sync with FreeBSD:
- Use TX descriptor polling, similar to the xl driver, to reduce TX overhead.
- As in if_sf, reset PHY when switching modes.
- Remove unused code that was #ifdef foo'd out.


# 1.2 07-Dec-1999 jason

remove freebsd bridging stuff, and let ALL packets go to ether_input()


# 1.1 07-Dec-1999 aaron

Driver for Sundance ST201 Ethernet; from FreeBSD.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.65 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.64 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.63 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.62 24-Nov-2015 mpi

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


# 1.61 24-Nov-2015 mpi

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


# 1.60 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.59 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.58 15-May-2015 mpi

Convert to if_input().

ok dlg@


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

unifdef INET


# 1.56 08-Dec-2014 brad

Have foo_init() call foo_reset() to reset the chip to a known state
as is the case for a lot of the other drivers. Remove some redundant
calls to foo_stop() and foo_reset() before foo_init().

Tested with DP83815, 3c905C, 8139 and ST201.
Mostly from FreeBSD.


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

Fewer <netinet/in_systm.h>


Revision tags: OPENBSD_5_5_BASE
# 1.54 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_4_BASE
# 1.53 14-Mar-2013 brad

- Remove return at the end of void functions
- Move the PCI devices table up to the top


# 1.52 09-Mar-2013 brad

Rewrite the receive filter handling code and cleanup the ioctl bits.

ok sthen@


Revision tags: OPENBSD_5_3_BASE
# 1.51 16-Jan-2013 brad

Some corrections for D-Link device names.

ok jsing@


# 1.50 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.49 23-Nov-2012 gsoares

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

OK reyk@ sthen@


# 1.48 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.47 22-Jun-2011 tedu

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


# 1.46 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_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 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.41 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.40 17-Jul-2007 krw

Add missing '};' to end struct declaration. Compiles again.


# 1.39 17-Jul-2007 jasper

ident/ansify/de-register


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.38 08-Jul-2006 brad

uncomment call to ste_miibus_statchg in ste_stats_update.


# 1.37 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.36 02-Apr-2006 brad

add another PCI id to the ste(4) driver.

From the Sundance Linux driver.


# 1.35 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@


Revision tags: OPENBSD_3_9_BASE
# 1.34 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.33 10-Sep-2005 brad

- a few fixes from the FreeBSD driver
- make use of pci_mapreg_map()
- ensure driver cleans after itself if ste_attach() fails


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

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


# 1.31 02-Jul-2005 brad

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


# 1.30 21-Apr-2005 fgsch

o if the mac address cannot be read, just fail and disestablish the
irq (for shared irq's) on failure. (should other drivers do the same?)
o if it's a rev 0x12 card, only use the first phy as it reports a
non-existent one as well (From FreeBSD).
o remove splimp/splx from ste_attach().
o some cleanup.

thanks to matt at mattroberts dot org and paolo at actcom dot net dot il
for testing; commit deraadt@.


# 1.29 08-Apr-2005 beck

remove dmesg spewage when link changes, ok deraadt, brad, canacar


Revision tags: OPENBSD_3_7_BASE
# 1.28 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.27 21-Nov-2004 brad

- Use ETHER_MAX_DIX_LEN.
- Accept VLAN sized frames. based on diff from canacar@


# 1.26 30-Oct-2004 canacar

vaddr_t casts for vtophys, works on amd64, enabled in GENERIC
patch submitted and tested by Steffen Sch�tz, schuetz.steffen at melle de
ok tedu@


# 1.25 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
# 1.24 22-Aug-2004 canacar

Do check for STATS_OFLOW in interrupt handler. The overflow interrupt is
already disabled and the status update function fails to clear the overflow,
causing high interrupt load. Reported and tested by Arvid Gr�tting.
ok deraadt@


# 1.23 09-Aug-2004 canacar

update ste(4) with stability and performance fixes from
FreeBSD if_ste.c revisions 1.28, 1.29, 1.38, 1.43, 1.63, 1.68, 1.70
ok henning@


Revision tags: SMP_SYNC_A SMP_SYNC_B
# 1.22 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@


# 1.21 09-Apr-2004 henning

do not whine if we cannot get mbufs. the countless printfd makes the machine
crawl under mbuf starvation, making the situationmuch worse, and don't make
sense in the first place.
ok tdeval@ millert@ beck@ deraadt@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.20 29-Jun-2003 avsm

lose ste_unit; jason@ ok


# 1.19 29-Jun-2003 avsm

another bad format string; %s->%d
ok tedu@


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.18 15-Jan-2003 art

Get rid of the remaining vm_offset_t in pci drivers.


# 1.17 19-Nov-2002 jason

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


Revision tags: OPENBSD_3_1_BASE OPENBSD_3_2_BASE UBC_SYNC_B
# 1.16 14-Mar-2002 millert

First round of __P removal in sys


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 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.13 12-Aug-2001 mickey

remove redundant vm includes


# 1.12 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.11 25-Jun-2001 fgsch

trivial ether_input_mbuf() conversion.


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

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


# 1.9 03-Feb-2001 mickey

new timeouts


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

Use mii_attach() directly instead of mii_phy_probe().


# 1.7 27-Jun-2000 aaron

Make this driver work. When I ported it from FreeBSD, somehow a line got left
out. :-( It was never noticed until now since I didn't have an actual D-Link
550TX card to test with. Thanks to Gardner Cohen for sending me one of these.


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

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


Revision tags: SMP_BASE kame_19991208
# 1.5 08-Dec-1999 aaron

branches: 1.5.2;
Remove unused #define cruft.


# 1.4 08-Dec-1999 aaron

Whoops; forgot to bump FreeBSD version numbers.


# 1.3 08-Dec-1999 aaron

Sync with FreeBSD:
- Use TX descriptor polling, similar to the xl driver, to reduce TX overhead.
- As in if_sf, reset PHY when switching modes.
- Remove unused code that was #ifdef foo'd out.


# 1.2 07-Dec-1999 jason

remove freebsd bridging stuff, and let ALL packets go to ether_input()


# 1.1 07-Dec-1999 aaron

Driver for Sundance ST201 Ethernet; from FreeBSD.