History log of /openbsd-current/sys/dev/ic/xl.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.139 10-Nov-2023 bluhm

Make ifq and ifiq interface MP safe.

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

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

OK dlg@


Revision tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE
# 1.138 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.137 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.136 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


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

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

ok dlg@ tobhe@


# 1.134 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.133 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.132 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.131 13-Apr-2016 mpi

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.138 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.137 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.136 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


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

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

ok dlg@ tobhe@


# 1.134 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.133 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.132 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.131 13-Apr-2016 mpi

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.137 09-Jan-2022 jsg

spelling
feedback and ok tb@ jmc@ ok ratchov@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.136 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


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

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

ok dlg@ tobhe@


# 1.134 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.133 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.132 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.131 13-Apr-2016 mpi

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.136 12-Dec-2020 jan

Rename the macro MCLGETI to MCLGETL and removes the dead parameter ifp.

OK dlg@, bluhm@
No Opinion mpi@
Not against it claudio@


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

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

ok dlg@ tobhe@


# 1.134 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.133 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.132 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.131 13-Apr-2016 mpi

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.135 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.134 10-Jul-2020 patrick

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

ok dlg@ tobhe@


# 1.133 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.132 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.131 13-Apr-2016 mpi

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


# 1.133 22-Jun-2020 dlg

use ifiq_input and use it's return value to apply backpressure to rxrs.

this is a step toward deprecating softclock based livelock detection.


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.132 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.131 13-Apr-2016 mpi

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.


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

G/C IFQ_SET_READY().


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

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


# 1.128 24-Nov-2015 mpi

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


# 1.127 25-Oct-2015 mpi

arp_ifinit() is no longer needed.


# 1.126 11-Sep-2015 stsp

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

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

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

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


Revision tags: OPENBSD_5_8_BASE
# 1.125 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.124 21-May-2015 mpi

tedu commented out xl_testpacket(), remove one of the IFQ_ENQUEUE()
in the tree.


# 1.123 24-Mar-2015 mpi

Convert to if_input().

Apparently krw@ test diffs faster than I can commit them!


# 1.122 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.121 22-Dec-2014 tedu

unifdef INET


# 1.120 19-Dec-2014 deraadt

another handful of bcopy -> memcpy because there is no overlap


# 1.119 08-Dec-2014 brad

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

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


# 1.118 24-Nov-2014 brad

rxr ioctl handling.


# 1.117 24-Nov-2014 brad

- Check IFF_RUNNING in xl_intr().

From FreeBSD

- Clear IFF_RUNNING at the top of xl_stop() before freeing resources.

Tested with 3c905C.


# 1.116 14-Sep-2014 jsg

remove uneeded proc.h includes
ok mpi@ kspillner@


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

Fewer <netinet/in_systm.h>


# 1.114 08-Jul-2014 dlg

cut things that relied on mclgeti for rx ring accounting/restriction over
to using if_rxr.

cut the reporting systat did over to the rxr ioctl.

tested as much as i can on alpha, amd64, and sparc64.
mpi@ has run it on macppc.
ok mpi@


# 1.113 30-May-2014 chl

Remove dead assignment and newly created unused variable.

Found by LLVM/Clang Static Analyzer.

ok claudio@


Revision tags: OPENBSD_5_5_BASE
# 1.112 28-Dec-2013 deraadt

The few network drivers that called their children's (ie. mii PHY
drivers) activate functions at DVACT_RESUME time do not need to do
so, since their PHYs are repaired by IFF_UP.


# 1.111 06-Dec-2013 deraadt

Add a DVACT_WAKEUP op to the *_activate() API. This is called after the
kernel resumes normal (non-cold, able to run processes, etc) operation.
Previously we were relying on specific DVACT_RESUME op's in drivers
creating callback/threads themselves, but that has become too common,
indicating the need for a built-in mechanism.
ok dlg kettenis, tested by a sufficient amount of people


# 1.110 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.109 14-Mar-2013 brad

Cosmetic tweaking. No functional change.


# 1.108 07-Mar-2013 brad

XL_DMACTL is a 32bit register, use the 32bit write macro.

From FreeBSD

ok chris@


Revision tags: OPENBSD_5_3_BASE
# 1.107 19-Oct-2012 brad

Simplify xl_iff_90x() a bit and only check ac->ac_multicnt since ac_multicnt
is also bumped for multicast ranges.

ok mikeb@


# 1.106 13-Oct-2012 deraadt

Move WOL activation to DVACT_POWERDOWN (instead of doing it twice, at
DVACT_QUIESCE and DVACT_SUSPEND time).
Tested by stsp.


Revision tags: OPENBSD_5_2_BASE
# 1.105 24-Feb-2012 guenther

Correct the spelling of "transferred" and "transferring"

from Tobias Ulmer (tobiasu at tmux.org); ok jmc@, krw@


Revision tags: OPENBSD_5_0_BASE OPENBSD_5_1_BASE
# 1.104 14-Jul-2011 stsp

We must not call xl_wol_power() from xl_stop(). If we do the device
can be set into D3 sleep state at the wrong time. Fixes lock-up issues
reported by Thomas Gerlach.
Also, the interface needs to be running for WOL to work, so set it up
from within xl_wol() if it's not running yet.
"you don't need an ok for this" deraadt


# 1.103 08-Jul-2011 stsp

Fix WoL support in xl(4). Now works with my hardware (3Com 3c905C).
ok deraadt


# 1.102 21-Jun-2011 tedu

remove some unnecessary casts. ok blambert deraadt kettenis matthew


# 1.101 17-Apr-2011 stsp

Add wol support to xl(4). Not really tested, but hopefully someone will
test it now that it's in-tree. ok deraadt ("It causes no harm")


# 1.100 05-Apr-2011 henning

mechanic rename M_{TCP|UDP}V4_CSUM_OUT -> M_{TCP|UDP}_CSUM_OUT
ok claudio krw


Revision tags: OPENBSD_4_9_BASE
# 1.99 22-Sep-2010 claudio

Call bus_dmamap_sync() of a dma descriptor before checking the ownership
of the descriptor. Diff created and tested by Loganaden Velvindron.
Looks good dlg@ and myself


# 1.98 21-Sep-2010 claudio

mclgeti() support for xl(4). All done by Loganaden Velvindron.
Tested by various people on tech@. OK dlg@, deraadt@ and myself


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


# 1.96 07-Sep-2010 deraadt

remove the powerhook code. All architectures now use the ca_activate tree
traversal code to suspend/resume
ok oga kettenis blambert


# 1.95 06-Sep-2010 deraadt

initialize rv to 0 in the activate function


# 1.94 31-Aug-2010 deraadt

Add DVACT_QUIECE support. This is called before splhigh() and before
DVACT_SUSPEND, therefore DVACT_QUIECE can do standard sleeping operations
to get ready.
Discussed quite a while back with kettenis and jakemsr, oga suddenly needed
it as well and wrote half of it, so it was time to finish it.
proofread by miod.


# 1.93 31-Aug-2010 deraadt

activate function should return result of config_activate_children


# 1.92 27-Aug-2010 deraadt

Move the xl_pci_activate function into xl_activate so that it is in the
sub-driver, and then xl_powerhook can simply be a wrapper around it
ok kettenis; discussion about nested structure aliasing with miod


# 1.91 12-Aug-2010 kettenis

Reset the chip upon suspend, to make sure it stops DMA. Reset it again upon
resume to make sure the chip is initialized the same way as upon attach.
Fixes memory corruption after resume on the Dell Inspirion 4150.

ok deraadt@


Revision tags: OPENBSD_4_8_BASE
# 1.90 06-Aug-2010 deraadt

ca_activate function for suspend/resume
tested by mlarkin


# 1.89 19-May-2010 oga

BUS_DMA_ZERO instead of alloc, map, bzero.

ok krw@


Revision tags: OPENBSD_4_7_BASE
# 1.88 22-Dec-2009 naddy

rewrite promiscuous mode and multicast handling; from Brad


# 1.87 15-Oct-2009 deraadt

Add detach support to a few more drivers, and in others do the neccessary
operations in the detach function in the right order. Also ensure that the
interrupt handlers not trust registers that go away.
read over very carefully by dms, tested by me


Revision tags: OPENBSD_4_6_BASE
# 1.86 02-Jun-2009 deraadt

The xl_detach() function is now used by pci code, so it must be in the
shared code in case either cardbus or pci varients are not configured.


Revision tags: OPENBSD_4_5_BASE
# 1.85 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.84 19-Nov-2008 brad

Make sure to check that the TX queue is empty before clearing the
watchdog timer.

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.83 19-Nov-2008 brad

Do not reset TX threshold value whenever xl_init() is called. Instead
the initial threshould is initialized at device attach. Later the
threshold could be increased if encountering a TX underrun error and
the new threshold should be used in xl_init().

From FreeBSD

Tested on quite a few 3c905/B/C/575 adapters.


# 1.82 02-Oct-2008 brad

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

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

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

ok jsing@


# 1.81 18-Sep-2008 naddy

Introduce the infrastructure required to support hardware VLAN tag
stripping: Add a field to the mbuf pkthdr to hold the tag and an
mbuf flag that tells if the tag is valid. Inspired by FreeBSD.

Struct packing suggested by kettenis@. csum_flags is now 16 bits.
Adapt to this in the drivers.

ok reyk@, henning@


# 1.80 10-Sep-2008 blambert

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

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

ok art@, krw@


Revision tags: OPENBSD_4_4_BASE
# 1.79 11-May-2008 brad

Fix a typo with the media duplex flag being used for AUI connections
so that the status routine will properly display half duplex instead
of full.

ok henning@ krw@


Revision tags: OPENBSD_4_2_BASE OPENBSD_4_3_BASE
# 1.78 19-May-2007 kettenis

My 3c905C needs a brief pause after�reset for PIO too, at least on hppa.

tested by thib@, ok deraadt@


# 1.77 05-May-2007 deraadt

move xl_detach() -- which is only used by cardbus -- to the cardbus code.
ok jsg


Revision tags: OPENBSD_4_0_BASE OPENBSD_4_1_BASE
# 1.76 10-Aug-2006 brad

- ANSI functions
- de-register
- remove return at the end of void functions
- some cosmetic tweaking


# 1.75 10-Aug-2006 brad

- move the promiscuous mode handling code to xl_setpromisc() and simplify
the ioctl handler.
- eliminate re-initialization's when adding IP addresses.


# 1.74 27-May-2006 brad

garbage collect vlan.h


# 1.73 22-May-2006 krw

Attach routines can fail before calling *hook_establish(), and they
often rely on the detach routine for cleanup. So be consistant and
careful by checking for a NULL hook before calling *hook_disestablish
in detach routines.

ok mickey@ brad@ dlg@


# 1.72 25-Mar-2006 djm

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


# 1.71 04-Mar-2006 brad

remove extraneous brackets.

From Mike Pechkin <mpech at mail dot ru>


Revision tags: OPENBSD_3_9_BASE
# 1.70 20-Jan-2006 brad

- xl_encap(): free the mbuf chain and return if bus_dmamap_load_mbuf()
returns an error other than EFBIG.
- xl_encap(): remove a redundant check already done in xl_start_90xB().
- merge xl_encap_90xB() into xl_encap().


# 1.69 11-Jan-2006 brad

only set Ok flag for RX checksums.


# 1.68 11-Jan-2006 brad

remove a printf here.


# 1.67 11-Jan-2006 brad

In the case that we've used up all 63 fragments then try to allocate an mbuf
cluster and copy the mbuf chain. The codepath for older xl's already dealt
with this condition.


# 1.66 07-Nov-2005 brad

splimp -> splnet


Revision tags: OPENBSD_3_8_BASE
# 1.65 02-Jul-2005 brad

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


# 1.64 25-Apr-2005 brad

csum -> csum_flags

ok krw@ canacar@


# 1.63 23-Apr-2005 brad

style


Revision tags: OPENBSD_3_7_BASE
# 1.62 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.61 01-Nov-2004 brad

back out previous commit.


# 1.60 31-Oct-2004 brad

don't swap zeros


# 1.59 23-Oct-2004 brad

add missing braces, noticed by mcbride@


# 1.58 23-Oct-2004 brad

re-add old xl_encap_90xB() for 905B/C cards. removed in rev 1.52.

fixes reported mbuf leaks as well as transmit side breakage on macppc,
PR 3892.

ok mcbride@


# 1.57 02-Oct-2004 brad

remove if NVLAN here too


# 1.56 28-Sep-2004 brad

remove if NVLAN around IFCAP_VLAN_MTU


# 1.55 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.54 04-Jun-2004 brad

branches: 1.54.2;
fix conversion to ether_crc32_be(). problem noticed by naddy@

ok mcbride@


# 1.53 01-Jun-2004 mickey

dv_xname is not the same as dv_unit (for hell knows what reason)


# 1.52 30-May-2004 brad

a bit of syncing with the FreeBSD driver, namely...

- disable TX hardware checksumming since its buggy and slow

- re-enable the hardware multicast filter setup on 3c905B/C's

- enable reception of VLAN sized frames on 3c90x's (pre B/C)

- remove all DELAY(1) calls around MII operations in the xl driver.
according to the MII specification, the delay produced by our
reads alone are sufficient for correct operation.

this reduces the time mii_tick takes from 10ms to ~1ms here. that's
still a lot, but much better than before

- report media status for bitrate PHYs

- change the method used to detect older boomerang chips

- fix an issue with reading PHY regs over the i2c bus

- fix mbuf leaks in an error (rare) code path

- reuse the TX descriptor if xl_encap() failed instead of just picking the next one

- fix bug with 3c90xB cards and newer. We weren't trying to
copy the mbuf chain into an mbuf cluster when there is
more than 63 mbufs in the chain. we were trying with older
cards though

- add some magic bits necessary to turn the transmitter on for some
(newer) 556B chips

local change...

- use ether_crc32_be() instead of hand-rolled xl_calchash()

tested on i386/3c900 by beck@, sparc64/3c905C by me, i386/3c905C by sturm@, naddy@ and a few others
ok deraadt@


Revision tags: OPENBSD_3_5_BASE
# 1.51 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.50 29-Jun-2003 jason

remove usage of xl_unit


Revision tags: OPENBSD_3_3_BASE UBC_SYNC_A
# 1.49 24-Mar-2003 jason

splimp() around xl_reset() during autoconf. something in xl_reset() wants
to generate an interrupt before the rings are setup correctly on some
variants; ok deraadt.


# 1.48 05-Jan-2003 deraadt

spelling


# 1.47 02-Dec-2002 jason

- Remove a few magic constants
- set baudrate for the non-mii modes


# 1.46 25-Nov-2002 brad

remove printf's in xl_setmode().
--
deraadt@ ok


# 1.45 17-Nov-2002 jason

Make sure never to put a loaded dmamap in the spare. 3c90x should work
on big endian now...


# 1.44 17-Nov-2002 jason

this driver has never been in sys/pci (in OpenBSD at least) and supports
cardbus and pci interfaces; pointed out by brad.


# 1.43 17-Nov-2002 jason

Fix another case (tx this time) where buffers were not unloaded (nor sync'd). (bad bad aaron): 90xB works on sparc64, 90x is probably still broken.


# 1.42 17-Nov-2002 jason

- lightly season with htole32 and friends... enough to get rx working
on sparc64
- also fix a bug when dmamap's were never freed on the rx side (bad aaron),
and avoid a sync if we run out of buffers.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.41 22-Aug-2002 jason

simplify multicast setup on the 3c905 (pre-B/C, etc)


# 1.40 09-Jul-2002 aaron

Don't write 32 bits to a 16-bit register.


# 1.39 15-Jun-2002 aaron

Check the correct variable when freeing the RX/TX lists.


# 1.38 15-Jun-2002 aaron

bus_dma'ify. Tested on 3c900(pci), 3c905b(pci), and 3c575c(cardbus). Thanks
to todd@ and camiel@ for trying it, too.


# 1.37 09-Jun-2002 todd

a step towards consistancy; in general:
'struct arpcom foo' -> 'struct arpcom sc_arpcom'
ok itojun@


# 1.36 08-Jun-2002 aaron

Add hardware TCP/IP checksum offloading support for receive and transmit for
the 3c905b; deraadt@ ok.


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

First round of __P removal in sys


# 1.34 15-Feb-2002 nordin

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


# 1.33 25-Jan-2002 nordin

Disestablish *powerhook* on detach. jason@ ok


Revision tags: UBC_BASE
# 1.32 15-Dec-2001 nordin

branches: 1.32.2;
Disestablish the powerhook on detach. ok jason@


# 1.31 06-Nov-2001 miod

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.30 19-Aug-2001 jason

Don't reset rx/tx without turning them back on after suspend (Beck is now
able to do "Real Work" after a suspend)


# 1.29 19-Aug-2001 jason

Add a powerhook for bringing the 556 out of sleepy mode after suspend.
(This isn't perfect... it still requires an down up transition, but Bob is
kicking me off his laptop so he can do "Real Work").


# 1.28 12-Aug-2001 mickey

remove some of the redundant vm includes


# 1.27 03-Aug-2001 chris

This driver allows vlan sized frames on 905B, set IFCAP_VLAN_MTU on that chip


# 1.26 02-Jul-2001 jason

these don't depend on pci register defs


# 1.25 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.24 23-Jun-2001 fgsch

ether_input_mbuf().


Revision tags: OPENBSD_2_9_BASE
# 1.23 08-Apr-2001 aaron

branches: 1.23.4;
Don't print anything for transmission error 90, since the driver always
recovers from the situation, and there's not much point in knowing about it.


# 1.22 25-Mar-2001 csapuntz

Missing splx(). Thanks to Dawson and team for finding this


# 1.21 20-Feb-2001 mickey

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


# 1.20 02-Feb-2001 aaron

No need for xl(4) to report tx underruns, they are much too common, and the
driver adjusts itself to compensate anyway; jason@ ok.


# 1.19 12-Jan-2001 todd

add SIOCSIFMTU; angelos@ coached


# 1.18 09-Nov-2000 mickey

new timeouts


Revision tags: OPENBSD_2_8_BASE
# 1.17 19-Oct-2000 jason

if vlans are in use, then set the 3c905b to accept frames of size 1518.


# 1.16 16-Oct-2000 aaron

Use mii_attach() directly instead of mii_phy_probe().


# 1.15 15-Oct-2000 aaron

Do not pass uninitialized ifmedia structures to ifmedia_add(). Fixes PR1426.
Thanks to reinhard@ for testing.


# 1.14 14-Oct-2000 aaron

There's a Type III 3c656C card, too.


# 1.13 13-Oct-2000 aaron

Do reset properly on MiniPCI adapters.


# 1.12 07-Oct-2000 aaron

Correct interrupt ack'ing for CardBus and MiniPCI. I hope this fixes 3c556.


# 1.11 30-Sep-2000 aaron

Whoops, forgot to list the 3c555 device ID under media selection parts.


# 1.10 29-Sep-2000 aaron

- Add support for 3Com 3C555 MiniPCI.
- Clean up configuration flags mess. The MiniPCI adapters share some properties
with the CardBus adapters.


# 1.9 16-Sep-2000 aaron

- No need to do bpfdetach(), that's done in if_detach().
- No need to keep around NetBSD NRND cruft.
- Indentation fixes.


# 1.8 16-Sep-2000 aaron

Note support for the new 3Com 3C3FE575CT LAN CardBus Type III PC Card. No
actual code changes here, just a comment added to the list of supported
cards, since the 3C3 has the same product ID as the 3CC (according to
dahinds@users.sourceforge.net).


# 1.7 16-Sep-2000 aaron

Add support for 3C556[B] MiniPCI Ethernet adapters, found on some laptops
(i.e., HP OmniBooks). I have sent these changes to a tester but I haven't
heard back yet. Assume for now the changes are OK since all of the other
variants I have still work.


# 1.6 05-Sep-2000 aaron

Support detach of xl(4) devices, mainly to allow the ejection and insertion of
3Com575-based CardBus PC Cards; from nate@


# 1.5 01-Jul-2000 aaron

- Make the 3CCFE575BT work.
- Add support for the 3CCFEM656C.
- Lots of code cleanup.


# 1.4 29-Jun-2000 jason

after computing the hash value, inform the card [delete-o from when this
was imported]. Also, backout previous.


# 1.3 22-Jun-2000 itojun

xl_setmulti_hash() does not work right. tested at usenix2000 term room.
affects 905B only.


Revision tags: OPENBSD_2_7_BASE
# 1.2 18-Apr-2000 aaron

branches: 1.2.2;
Set MII parameters for the other 3Com CardBus cards, not just 'C' revision.


# 1.1 08-Apr-2000 aaron

Initial check-in for support of 32-bit CardBus PC Cards; from NetBSD. On many
machines, this code needs the new PCIBIOS* options enabled in the kernel config
file to work, but your mileage may vary. Included is a working 3c575 driver for
3Com 10/100 CardBus PC Card NICs (tested only with the 'C' revision). The 3c575
is the pccard version of the PCI EtherLink XL cards, and thus the xl driver has
been split into /sys/dev/ic.