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

remove unneeded includes; ok miod@


Revision tags: OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.142 11-Apr-2023 jsg

fix double words in comments
feedback and ok jmc@ miod, ok millert@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.141 15-Aug-2022 jsg

remove tulip_mbuf_compress() unused since if_de.c 1.127
ok miod@


Revision tags: OPENBSD_7_1_BASE
# 1.140 11-Mar-2022 mpi

Constify struct cfattach.


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


# 1.138 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


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 OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.142 11-Apr-2023 jsg

fix double words in comments
feedback and ok jmc@ miod, ok millert@


Revision tags: OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.141 15-Aug-2022 jsg

remove tulip_mbuf_compress() unused since if_de.c 1.127
ok miod@


Revision tags: OPENBSD_7_1_BASE
# 1.140 11-Mar-2022 mpi

Constify struct cfattach.


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


# 1.138 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


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 OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.141 15-Aug-2022 jsg

remove tulip_mbuf_compress() unused since if_de.c 1.127
ok miod@


Revision tags: OPENBSD_7_1_BASE
# 1.140 11-Mar-2022 mpi

Constify struct cfattach.


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


# 1.138 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


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 OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.140 11-Mar-2022 mpi

Constify struct cfattach.


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


# 1.138 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


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 OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


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


# 1.138 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


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 OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


# 1.138 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


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 OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.137 08-Mar-2017 mpi

Do not clear IFF_UP, even in the error path, clearing IFF_RUNNING
is enough.

This flag should only be set by the stack, drivers shouldn't mess
with it.

Discussed with dlg@ and mikeb@, ok mikeb@, stsp@


# 1.136 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.135 13-Apr-2016 mpi

G/C IFQ_SET_READY().


Revision tags: OPENBSD_5_9_BASE
# 1.134 08-Dec-2015 tedu

No trailers has been the default and only option for 20 years, yet some
drivers still set IFF_NOTRAILERS while others do not. Remove all usage of
the flag from the drivers which in ancient times used it (and the modern
drivers which blindly copied it from those drivers of yore).
suggested by guenther. ok mpi


# 1.133 08-Dec-2015 dlg

dont need to repeatedly set if_start to the same function.


# 1.132 25-Nov-2015 mpi

Network drivers should not include <net/route.h> or <net/netisr.h>


# 1.131 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.130 24-Nov-2015 mpi

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


# 1.129 24-Nov-2015 mpi

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


# 1.128 23-Nov-2015 dlg

you cant touch m_pkthdr in between ifq_deq_begin and ifq_deq_commit.

TULIP_SETCTX() does though. this moves that call after ifq_deq_commit.

problem reported (with great detail) and fix tested by ricardo mestre
ok mpi@


# 1.127 20-Nov-2015 dlg

shuffle struct ifqueue so in flight mbufs are protected by a mutex.

the code is refactored so the IFQ macros call newly implemented ifq
functions. the ifq code is split so each discipline (priq and hfsc
in our case) is an opaque set of operations that the common ifq
code can call. the common code does the locking, accounting (ifq_len
manipulation), and freeing of the mbuf if the disciplines enqueue
function rejects it. theyre kind of like bufqs in the block layer
with their fifo and nscan disciplines.

the new api also supports atomic switching of disciplines at runtime.
the hfsc setup in pf_ioctl.c has been tweaked to build a complete
hfsc_if structure which it attaches to the send queue in a single
operation, rather than attaching to the interface up front and
building up a list of queues.

the send queue is now mutexed, which raises the expectation that
packets can be enqueued or purged on one cpu while another cpu is
dequeueing them in a driver for transmission. a lot of drivers use
IFQ_POLL to peek at an mbuf and attempt to fit it on the ring before
committing to it with a later IFQ_DEQUEUE operation. if the mbuf
gets freed in between the POLL and DEQUEUE operations, fireworks
will ensue.

to avoid this, the ifq api introduces ifq_deq_begin, ifq_deq_rollback,
and ifq_deq_commit. ifq_deq_begin allows a driver to take the ifq
mutex and get a reference to the mbuf they wish to try and tx. if
there's space, they can ifq_deq_commit it to remove the mbuf and
release the mutex. if there's no space, ifq_deq_rollback simply
releases the mutex. this api was developed to make updating the
drivers using IFQ_POLL easy, instead of having to do significant
semantic changes to avoid POLL that we cannot test on all the
hardware.

the common code has been tested pretty hard, and all the driver
modifications are straightforward except for de(4). if that breaks
it can be dealt with later.

ok mpi@ jmatthew@


# 1.126 04-Nov-2015 dlg

use IFQ_IS_EMPTY to see if if_snd is empty, not IF_IS_EMPTY


# 1.125 04-Nov-2015 dlg

replace the ifqueues used for tulip_txq and _rxq with mbuf_lists.


# 1.124 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


Revision tags: OPENBSD_5_8_BASE
# 1.123 26-Jun-2015 kettenis

There is no excuse for using dma_alloc(9) when a bus_dma_tag_t is available.

deraadt@ thinks this isn't worth it, but reyk@ and mlarkin@ tested it anyway


# 1.122 25-Jun-2015 deraadt

Ensure the setup block is DMA reachable.
tested by reyk, mlarkin, others


# 1.121 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.120 15-May-2015 mpi

Convert to if_input().

ok dlg@


# 1.119 01-Apr-2015 mpi

Remove annoying comment mentionning ether_output().


# 1.118 14-Mar-2015 jsg

Remove some includes include-what-you-use claims don't
have any direct symbols used. Tested for indirect use by compiling
amd64/i386/sparc64 kernels.

ok tedu@ deraadt@


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

unifdef INET


# 1.116 08-Sep-2014 jsg

remove uneeded route.h includes
ok miod@ mpi@


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

Fewer <netinet/in_systm.h>


# 1.114 22-Apr-2014 mpi

Remove some altq tentacles.

ok pelikan@, henning@


# 1.113 19-Apr-2014 henning

another questionable "optimization": de used tulip_ifstart_one instead
of tulip_ifstart if the sendqueue was empty, but only if altq wasn't
compiled in (i. e., that's a _compile time_ decision and not based on
wether altq was actually used).
just use tulip_ifstart all the time, as before in our regular kernels.
kill tulip_ifstart_one completely.
makes sense to sthen


Revision tags: OPENBSD_5_5_BASE
# 1.112 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.111 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.110 04-Jun-2013 miod

Prevent panic'ing on alpha after ifconfig'ing up an unplugged de interface,
by making tulip_txput() aware of whether or not the mbuf it is processing
is in if_snq or not, rather than abusing the TULIP_TXPROBE_ACTIVE flag.

Found the hard way by kurt@, tested on AlphaServer 1000A, I've been sleeping
on this diff for about 3 years.


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE OPENBSD_5_3_BASE
# 1.109 07-Jul-2011 henning

use IF_LEN/IFQ_LEN to access and ifqueue's length field. ryan ok
with this nothing in the tree fiddles if ifqueue internals any more, of
course except if.c and if.h (and some altq)


# 1.108 06-Jul-2011 henning

cosnistently use IFQ_SET_MAXLEN, surfaced in a discussion with + ok bluhm


# 1.107 03-Apr-2011 jasper

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

ok claudio@


Revision tags: OPENBSD_4_9_BASE
# 1.106 20-Sep-2010 deraadt

Stop doing shutdown hooks in network drivers where possible. We already
take all interfaces down, via their xxstop routines. Claudio and I have
verified that none of the shutdown hooks do much extra beyond what xxstop
was already doing; it is largely a pile of junk.
ok claudio, some early comments by sthen; also read by matthew, jsg


Revision tags: OPENBSD_4_8_BASE
# 1.105 08-Apr-2010 tedu

these files don't need to include proc.h anymore. ok oga for agp


Revision tags: OPENBSD_4_7_BASE
# 1.104 02-Oct-2009 deraadt

remove trash left in debug changes; lindroos@nls.fi


# 1.103 13-Aug-2009 jasper

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

ok dlg@


Revision tags: OPENBSD_4_6_BASE
# 1.102 19-Jun-2009 naddy

Tidy up allocation of transmit DMA maps and generalize it to also
tidy up allocation of receive DMA maps. Previously the driver was
using DMA maps off the free list without fully allocating them, in
order to save two or three lines releasing them on error paths.
This was causing it to reuse a map already in use when under load.
From NetBSD.

Revert a workaround against a NULL pointer dereference on alpha
when invoking bus_dmaamp_sync.

All submitted by Brad.


Revision tags: OPENBSD_4_5_BASE
# 1.101 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.100 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@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.99 04-Mar-2008 miod

Add a workaround against a NULL pointer dereference on alpha when
invoking bus_dmaamp_sync, until the cause of the problem is found.
ok deraadt@


# 1.98 19-Sep-2007 brad

Remove unused tulip_21041_media_noprobe() function and tulip_21041np_boardsw
struct.

ok dlg@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.97 14-Feb-2007 jsg

Consistently spell FALLTHROUGH to appease lint.
ok kettenis@ cloder@ tom@ henning@


Revision tags: OPENBSD_4_0_BASE
# 1.96 08-Jul-2006 brad

print the chipset revision too.


# 1.95 08-Jul-2006 brad

shorten dmesg entry from two lines to one.


# 1.94 08-Jul-2006 brad

tulip_pci_(probe/attach) -> tulip_(probe/attach)


# 1.93 08-Jul-2006 brad

remove splnet from attach routine.


# 1.92 01-Jun-2006 brad

de-static and formatting.


# 1.91 28-May-2006 jason

unknown ioctl is ENOTTY not EINVAL


# 1.90 09-May-2006 brad

fix non-ALTQ case.


# 1.89 06-May-2006 brad

restore ALTQ support which was lost with rev 1.87


# 1.88 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.87 07-Nov-2005 brad

branches: 1.87.2;
add bus_dma support.

From NetBSD

tested on i386/alpha.

ok martin@ krw@


# 1.86 01-Oct-2005 martin

oops, the include was just doing fine there


# 1.85 01-Oct-2005 martin

fix some comments and put if_devar.h include where it belongs


# 1.84 25-Sep-2005 brad

shuffle some stuff around


# 1.83 25-Sep-2005 brad

remove TULIP_PCI_ATTACH_ARGS and TULIP_SHUTDOWN_ARGS


# 1.82 25-Sep-2005 brad

remove more indirection through typedef's and macros


# 1.81 25-Sep-2005 brad

- delint: zero sized array initalisation is a gccism
- move timeout_set() from tulip_attach() to tulip_pci_attach()
- free -> freedescs in tulip_txput()
- remove duplicate flag setting in tulip_2114x_media_preset()
TULIP_MEDIA_10BASET_FD switch case
- some cleaning

reduces the delta from the NetBSD driver


# 1.80 08-Sep-2005 brad

add missing TULIP_STS_LINKFAIL flag in tulip_21041_media_probe().

From NetBSD rev 1.67 and verified to still be there in -current.


# 1.79 08-Sep-2005 brad

make de(4) use ether_input_mbuf()

From thorpej NetBSD

ok krw@ martin@


# 1.78 07-Sep-2005 brad

do not try to restore the spl level two times in a row.

ok martin@


# 1.77 06-Sep-2005 brad

- fix up the ioctl handler and make it use ether_ioctl() too
- remove more unused code
- remove some of the macros to make this more readable

ok krw@


# 1.76 06-Sep-2005 brad

another round of removing ifdef crud from this driver.

ok krw@ martin@


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

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


# 1.74 16-Jul-2005 brad

remove __BROKEN_INDIRECT_CONFIG cruft


# 1.73 26-Jun-2005 brad

remove one more piece of the media detection from SRM code.


# 1.72 20-Jun-2005 martin

Remove media detection from the SRM on alpha. Initially a good idea, it
breaks some onboard de(4)'s. The conventional way of getting media settings
is just fine on alpha, so let's just use this. Shrinks de(4) a bit on alpha.

While there de-inline tulip_21140_mediainit().

ok brad@


# 1.71 08-Jun-2005 henning

remove netns crud.
some drivers actually had hooks for SIOCSIFADDR, most just useless includes
"looks good" deraadt miod brad


# 1.70 25-May-2005 martin

- identify Compex NICs (untested)
- wrap more functions in TULIP_PERF* macros

ok brad@

from NetBSD


# 1.69 25-May-2005 martin

in tulip_reset() remove a useless printf and check flags before resetting


# 1.68 23-May-2005 martin

- remomve unneeded tulip_reset() and always include intr.h
- make it possible to get media information from the SRM on alpha

ok brad@


# 1.67 22-May-2005 martin

ALTQ cleanout

ok brad@


# 1.66 23-Apr-2005 martin

make sure bus mastering is enabled

ok brad@

from NetBSD


# 1.65 16-Apr-2005 deraadt

remove lots of crud from this driver, makes it fit on the alpha media


# 1.64 29-Mar-2005 martin

pull over some minor fixes from NetBSD:

- use ETHER_ADDR_LEN where apropriate
- consistency fixes in mem-io vs io-io logic
- fixes for 21143 in full-duplex mode
- minor nits here and there

ok brad@


Revision tags: OPENBSD_3_7_BASE
# 1.63 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.62 08-Nov-2004 deraadt

put more debug stuff inside #ifdef, to make the driver a wee bit smaller
for the alpha


# 1.61 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.60 31-May-2004 mcbride

Replace tulip_crc32 with ether_crc32_le.


# 1.59 12-May-2004 tedu

network drivers don't need to include bpfdesc.h
ok krw@ canacar@


Revision tags: OPENBSD_3_4_BASE OPENBSD_3_5_BASE
# 1.58 06-Aug-2003 millert

Remove some double semicolons (hmm, do two semis equal a maxi?).
I've skipped the GNU stuff for now. From Patrick Latifi.


Revision tags: UBC_SYNC_A
# 1.57 06-Apr-2003 ho

strcat/strcpy/sprintf cleanup. krw@, anil@ ok. art@ tested sparc64.


Revision tags: OPENBSD_3_2_BASE OPENBSD_3_3_BASE UBC_SYNC_B
# 1.56 30-Jun-2002 art

The #@$% message about the #$%@ cable down is going to drive me @#%$ insane.
I'm not using this built-in tulip because it sucks and I want it to SHUT UP!


# 1.55 02-Jun-2002 deraadt

withough -> without


Revision tags: OPENBSD_3_1_BASE
# 1.54 01-Apr-2002 nate

Don't have dc and de return the same match value in any case.
Comment the reasoning for the various return values in dc_pci_match.
dc is preferred over de on all archs except for alpha where de is used.
The main reason dc is not preferred on alpha is that it doesn't fit
on the floppy, so RAMDISK and GENERIC would have different drivers for
the same device which is rather confusing.


# 1.53 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


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

branches: 1.52.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.51 21-Sep-2001 miod

Correct some pryntf() usage: get the correct number of arguments in the
correct order.


# 1.50 11-Sep-2001 miod

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


# 1.49 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.48 12-Aug-2001 mickey

absolutely no need to include vm_parm.h after vm.h


# 1.47 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.46 12-Jun-2001 niklas

Make pci_mapreg_map take an extra argument where we can
put a size limitation of the PCI region to map. That makes the PERC 3/Di
raid controller usable, as it publishes too much PCI memory for us to map
in the kernel virtual memory. As we only access the first 256 byte it is
of no use to map 128MB of kvm.


# 1.45 05-May-2001 art

Get rid of CLSIZE and all related stuff.
CLSIZE -> 1
CLBYTES -> PAGE_SIZE
OLOFSET -> PAGE_MASK
etc.
At the same time some archs needed some cleaning in vmparam.h so that
goes in at the same time.


Revision tags: OPENBSD_2_9_BASE
# 1.44 03-Feb-2001 mickey

new timeout, space control


Revision tags: OPENBSD_2_7_BASE OPENBSD_2_8_BASE
# 1.43 27-Apr-2000 chris

Previous commit contained things that I want to keep local for now


# 1.42 27-Apr-2000 chris

Remove MTU cruft


Revision tags: OPENBSD_2_6_BASE SMP_BASE kame_19991208
# 1.41 18-Jul-1999 csapuntz

branches: 1.41.4;


Added pci_mapreg* interface from NetBSD.
Added PCI 2.2 stuff from NetBSD
Modified if_de to use mapreg interface


Revision tags: OPENBSD_2_5_BASE
# 1.40 26-Feb-1999 jason

compensate for the fact that the check for ownership of a unicast packet
has moved to ether_input()


# 1.39 04-Feb-1999 deraadt

correct attach printing for 4-port cards


# 1.38 11-Jan-1999 jason

remove pnic stuff


# 1.37 02-Dec-1998 deraadt

cogent-compatible adapters appearing in an adaptec ethernet block range


# 1.36 28-Oct-1998 csapuntz

Partial merge from netBSD 102498. Seems to fix autonegotation difficulties
on Bay Networks FA310TX card.


Revision tags: OPENBSD_2_4_BASE
# 1.35 08-Oct-1998 jason

Support for the Lite-On PNIC found on Netgear FA310TX rev D1 and
several other boards.


# 1.34 09-Sep-1998 rahnds

Dont swab the data twice, only when assiging to the structure.
This only affect big endian machines (powerpc).


# 1.33 28-Aug-1998 rahnds

Changes to make if_de driver work on big endian machines with a 21040 based
card. Tested on i386 and alpha. Could use some cleanup to swab constants
instead of variables, so that the compiler can do the work, not the processor.


# 1.32 07-Aug-1998 pefo

com.c needs to know about mem mapped ports in ppc systems.

ncr.c and if_de.c needs some hooks for systems with ncr and dec
ether chips on the motherboard that runs on odd clocks and doesn't
support a srom. srom is emulated in machine dependent code.

big endian support for ncr and dec ether finished. the 21040
have some more coding requirements if it is to run BE since
it does not have the descriptor endian swap configuration bit.


# 1.31 28-May-1998 deraadt

do not panic


# 1.30 22-May-1998 deraadt

EM100FX


Revision tags: OPENBSD_2_3_BASE
# 1.29 22-Feb-1998 niklas

GCC 2.8 -Wall


# 1.28 07-Jan-1998 deraadt

now this is really pretty


# 1.27 05-Jan-1998 deraadt

new style pci attach printing


# 1.26 16-Nov-1997 millert

compile on alpha, needs testing


# 1.25 13-Nov-1997 rees

merge netbsd 1.56.2.1 for de500B (and other 21143) support


Revision tags: OPENBSD_2_2_BASE
# 1.24 20-Oct-1997 pefo

Few minor changes to make if_de work big endian on 21140


# 1.23 29-Jul-1997 downsj

Support BSD/OS 2.1, add OpenBSD tags.


# 1.22 28-Jul-1997 deraadt

pretty


# 1.21 24-Jun-1997 csapuntz

Force driver into store-forward mode on cards that support it. This increases
reliability (less underflows) at the expense of speed.


# 1.20 20-Jun-1997 grr

Comment out some superfluous const declarations that cause cast warnings
with gcc/alpha. We have bcopy(const void *...) so casting a const foo *bar
as in bcopy((caddr_t) bar,...) for bcopy seems to be fairly pointless in
the first place, but there are too many of these to hack out at the moment.


# 1.19 18-Jun-1997 dm

csapuntz@lcs.mit.edu: Port of NetBSD tulip driver. Works with new (21140-AC-based) SMC Etherpower cards.


Revision tags: OPENBSD_2_1_BASE
# 1.18 10-Apr-1997 pefo

These two was not ready for commit yet. Backed out.


# 1.17 10-Apr-1997 pefo

Add Matrox Mystique


# 1.16 19-Dec-1996 mickey

do SIOCGIFADDR in ether_ioctl


# 1.15 28-Nov-1996 niklas

Adaption to new bus.h from NetBSD. Various driver has been updated to
NetBSD 961107 state. Other has not, partly because sometimes the bus.h
changes was coupled with other changes.


# 1.14 12-Nov-1996 niklas

s/bus.h/bus.old.h/ to make the transit to the bus_space bus.h an easy road
possibly taken in small steps


Revision tags: OPENBSD_2_0_BASE
# 1.13 23-Aug-1996 niklas

__OpenBSD__ messup fixed


# 1.12 21-Aug-1996 deraadt

check for __OpenBSD__, prep for tossing __NetBSD__?


# 1.11 10-Jun-1996 deraadt

sync to 0607


# 1.10 26-May-1996 deraadt

sync 0521


# 1.9 10-May-1996 deraadt

if_name/if_unit -> if_xname/if_softc


# 1.8 07-May-1996 deraadt

sync with 0504 -- prototypes and bus.h


# 1.7 05-May-1996 mickey

add general ether_ioctl call in net/if_ethersubr.c,
NS,IPX,X.25 special processing is now handled in there.
reflect this amazing addition in all the ether ifaces.
ppl, pls check the stuff.


# 1.6 21-Apr-1996 deraadt

partial sync with netbsd 960418, more to come


# 1.5 18-Apr-1996 niklas

NetBSD 960317 merge


# 1.4 05-Mar-1996 dm

sc_dev -> tulip_dev


# 1.3 20-Feb-1996 tholo

Pass device name to interrupt establish routines so it can be recorded in
the device interrupt chain structures (isa, pci)

Move interrupt chain structure definition to <machine/psl.h> so vmstat can
get at it (i386)

Remove hack to count interrupts the old way (i386)


# 1.2 27-Dec-1995 deraadt

from netbsd; merge latest Thomas version with our minimal changes


# 1.1 18-Oct-1995 deraadt

branches: 1.1.1;
Initial revision